@helloao/cli 0.0.10 → 0.0.11

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 (81) hide show
  1. package/dist/cjs/cli.cjs +9936 -8987
  2. package/dist/cjs/index.cjs +16452 -0
  3. package/dist/esm/index.js +8102 -0
  4. package/dist/esm/index.js.map +7 -0
  5. package/dist/types/actions.d.ts +10 -0
  6. package/dist/types/db.d.ts +2 -1
  7. package/dist/types/files.d.ts +2 -2
  8. package/dist/types/s3.d.ts +1 -1
  9. package/dist/types/uploads.d.ts +4 -0
  10. package/migrations/20241204173229_add_license_notes/migration.sql +5 -0
  11. package/migrations/20241204182154_add_book_intro_summaries/migration.sql +2 -0
  12. package/migrations/20241218211246_add_profiles/migration.sql +12 -0
  13. package/migrations/20241218211453_add_profile_references/migration.sql +6 -0
  14. package/node_modules/@zip.js/zip.js/.github/workflows/publish.yml +17 -0
  15. package/node_modules/@zip.js/zip.js/deno.json +10 -1
  16. package/node_modules/@zip.js/zip.js/dist/z-worker-fflate.js +1 -1
  17. package/node_modules/@zip.js/zip.js/dist/z-worker-pako.js +1 -1
  18. package/node_modules/@zip.js/zip.js/dist/z-worker.js +1 -1
  19. package/node_modules/@zip.js/zip.js/dist/zip-fs-full.js +274 -133
  20. package/node_modules/@zip.js/zip.js/dist/zip-fs-full.min.js +1 -1
  21. package/node_modules/@zip.js/zip.js/dist/zip-fs.js +274 -125
  22. package/node_modules/@zip.js/zip.js/dist/zip-fs.min.js +1 -1
  23. package/node_modules/@zip.js/zip.js/dist/zip-full.js +233 -122
  24. package/node_modules/@zip.js/zip.js/dist/zip-full.min.js +1 -1
  25. package/node_modules/@zip.js/zip.js/dist/zip-no-worker-deflate.min.js +1 -1
  26. package/node_modules/@zip.js/zip.js/dist/zip-no-worker-inflate.min.js +1 -1
  27. package/node_modules/@zip.js/zip.js/dist/zip-no-worker.min.js +1 -1
  28. package/node_modules/@zip.js/zip.js/dist/zip.js +233 -114
  29. package/node_modules/@zip.js/zip.js/dist/zip.min.js +1 -1
  30. package/node_modules/@zip.js/zip.js/eslint.config.mjs +49 -0
  31. package/node_modules/@zip.js/zip.js/index-fflate.js +2 -1
  32. package/node_modules/@zip.js/zip.js/index.cjs +274 -133
  33. package/node_modules/@zip.js/zip.js/index.d.ts +254 -34
  34. package/node_modules/@zip.js/zip.js/index.js +3 -1
  35. package/node_modules/@zip.js/zip.js/index.min.js +1 -1
  36. package/node_modules/@zip.js/zip.js/lib/core/codec-pool.js +3 -1
  37. package/node_modules/@zip.js/zip.js/lib/core/codec-worker.js +11 -8
  38. package/node_modules/@zip.js/zip.js/lib/core/configuration.js +2 -1
  39. package/node_modules/@zip.js/zip.js/lib/core/constants.js +8 -0
  40. package/node_modules/@zip.js/zip.js/lib/core/io.js +10 -3
  41. package/node_modules/@zip.js/zip.js/lib/core/streams/aes-crypto-stream.js +4 -3
  42. package/node_modules/@zip.js/zip.js/lib/core/streams/codecs/deflate.js +0 -4
  43. package/node_modules/@zip.js/zip.js/lib/core/streams/codecs/inflate.js +0 -4
  44. package/node_modules/@zip.js/zip.js/lib/core/streams/crc32-stream.js +1 -0
  45. package/node_modules/@zip.js/zip.js/lib/core/streams/zip-entry-stream.js +4 -2
  46. package/node_modules/@zip.js/zip.js/lib/core/util/mime-type.js +0 -2
  47. package/node_modules/@zip.js/zip.js/lib/core/util/stream-codec-shim.js +4 -4
  48. package/node_modules/@zip.js/zip.js/lib/core/z-worker-core.js +4 -2
  49. package/node_modules/@zip.js/zip.js/lib/core/zip-entry.js +17 -5
  50. package/node_modules/@zip.js/zip.js/lib/core/zip-fs-core.js +41 -11
  51. package/node_modules/@zip.js/zip.js/lib/core/zip-reader.js +45 -23
  52. package/node_modules/@zip.js/zip.js/lib/core/zip-writer.js +147 -66
  53. package/node_modules/@zip.js/zip.js/lib/z-worker-inline-template.js +1 -1
  54. package/node_modules/@zip.js/zip.js/lib/z-worker-inline.js +1 -1
  55. package/node_modules/@zip.js/zip.js/lib/zip-data-uri.js +4 -1
  56. package/node_modules/@zip.js/zip.js/lib/zip-fs.js +2 -1
  57. package/node_modules/@zip.js/zip.js/lib/zip-full-fflate.js +2 -1
  58. package/node_modules/@zip.js/zip.js/lib/zip-full.js +2 -1
  59. package/node_modules/@zip.js/zip.js/lib/zip.js +2 -1
  60. package/node_modules/@zip.js/zip.js/package.json +121 -78
  61. package/package.json +14 -6
  62. package/prisma-gen/client.d.ts +1 -0
  63. package/prisma-gen/client.js +4 -0
  64. package/prisma-gen/default.d.ts +1 -1
  65. package/prisma-gen/edge.d.ts +1 -1
  66. package/prisma-gen/edge.js +30 -9
  67. package/prisma-gen/index-browser.js +25 -4
  68. package/prisma-gen/index.d.ts +3530 -1572
  69. package/prisma-gen/index.js +30 -9
  70. package/prisma-gen/runtime/edge-esm.js +21 -18
  71. package/prisma-gen/runtime/edge.js +21 -18
  72. package/prisma-gen/runtime/index-browser.d.ts +1 -1
  73. package/prisma-gen/runtime/index-browser.js +1 -1
  74. package/prisma-gen/runtime/library.d.ts +306 -71
  75. package/prisma-gen/runtime/library.js +70 -67
  76. package/prisma-gen/runtime/react-native.js +80 -0
  77. package/prisma-gen/runtime/wasm.js +22 -19
  78. package/prisma-gen/wasm.d.ts +1 -1
  79. package/prisma-gen/wasm.js +25 -4
  80. package/schema.prisma +27 -0
  81. package/node_modules/@zip.js/.ignored_zip.js +0 -0
@@ -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,9 @@ import {
57
57
  BITFLAG_DATA_DESCRIPTOR,
58
58
  BITFLAG_LANG_ENCODING_FLAG,
59
59
  FILE_ATTR_MSDOS_DIR_MASK,
60
+ FILE_ATTR_UNIX_TYPE_MASK,
61
+ FILE_ATTR_UNIX_TYPE_DIR,
62
+ FILE_ATTR_UNIX_EXECUTABLE_MASK,
60
63
  DIRECTORY_SIGNATURE,
61
64
  UNDEFINED_VALUE
62
65
  } from "./constants.js";
@@ -250,14 +253,20 @@ class ZipReader {
250
253
  const extraFieldOffset = filenameOffset + fileEntry.filenameLength;
251
254
  const commentOffset = extraFieldOffset + fileEntry.extraFieldLength;
252
255
  const versionMadeBy = getUint16(directoryView, offset + 4);
253
- const msDosCompatible = (versionMadeBy & 0) == 0;
256
+ const msDosCompatible = versionMadeBy >> 8 == 0;
257
+ const unixCompatible = versionMadeBy >> 8 == 3;
254
258
  const rawFilename = directoryArray.subarray(filenameOffset, extraFieldOffset);
255
259
  const commentLength = getUint16(directoryView, offset + 32);
256
260
  const endOffset = commentOffset + commentLength;
257
261
  const rawComment = directoryArray.subarray(commentOffset, endOffset);
258
262
  const filenameUTF8 = languageEncodingFlag;
259
263
  const commentUTF8 = languageEncodingFlag;
260
- const directory = msDosCompatible && ((getUint8(directoryView, offset + 38) & FILE_ATTR_MSDOS_DIR_MASK) == FILE_ATTR_MSDOS_DIR_MASK);
264
+ const externalFileAttributes = getUint32(directoryView, offset + 38);
265
+ const directory =
266
+ (msDosCompatible && ((getUint8(directoryView, offset + 38) & FILE_ATTR_MSDOS_DIR_MASK) == FILE_ATTR_MSDOS_DIR_MASK)) ||
267
+ (unixCompatible && (((externalFileAttributes >> 16) & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR)) ||
268
+ (rawFilename.length && rawFilename[rawFilename.length - 1] == DIRECTORY_SIGNATURE.charCodeAt(0));
269
+ const executable = (unixCompatible && (((externalFileAttributes >> 16) & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0));
261
270
  const offsetFileEntry = getUint32(directoryView, offset + 42) + prependedDataLength;
262
271
  Object.assign(fileEntry, {
263
272
  versionMadeBy,
@@ -268,13 +277,16 @@ class ZipReader {
268
277
  directory,
269
278
  offset: offsetFileEntry,
270
279
  diskNumberStart: getUint16(directoryView, offset + 34),
271
- internalFileAttribute: getUint16(directoryView, offset + 36),
272
- externalFileAttribute: getUint32(directoryView, offset + 38),
280
+ internalFileAttributes: getUint16(directoryView, offset + 36),
281
+ externalFileAttributes,
273
282
  rawFilename,
274
283
  filenameUTF8,
275
284
  commentUTF8,
276
- rawExtraField: directoryArray.subarray(extraFieldOffset, commentOffset)
285
+ rawExtraField: directoryArray.subarray(extraFieldOffset, commentOffset),
286
+ executable
277
287
  });
288
+ fileEntry.internalFileAttribute = fileEntry.internalFileAttributes;
289
+ fileEntry.externalFileAttribute = fileEntry.externalFileAttributes;
278
290
  const decode = getOptionValue(zipReader, options, "decodeText") || decodeText;
279
291
  const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
280
292
  const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
@@ -293,7 +305,8 @@ class ZipReader {
293
305
  directory: directory || filename.endsWith(DIRECTORY_SIGNATURE)
294
306
  });
295
307
  startOffset = Math.max(offsetFileEntry, startOffset);
296
- await readCommonFooter(fileEntry, fileEntry, directoryView, offset + 6);
308
+ readCommonFooter(fileEntry, fileEntry, directoryView, offset + 6);
309
+ fileEntry.zipCrypto = fileEntry.encrypted && !fileEntry.extraFieldAES;
297
310
  const entry = new Entry(fileEntry);
298
311
  entry.getData = (writer, options) => fileEntry.getData(writer, entry, options);
299
312
  offset = endOffset;
@@ -301,7 +314,8 @@ class ZipReader {
301
314
  if (onprogress) {
302
315
  try {
303
316
  await onprogress(indexFile + 1, filesLength, new Entry(fileEntry));
304
- } catch (_error) {
317
+ // eslint-disable-next-line no-unused-vars
318
+ } catch (_) {
305
319
  // ignored
306
320
  }
307
321
  }
@@ -406,6 +420,7 @@ class ZipEntry {
406
420
  const dataView = getDataView(dataArray);
407
421
  let password = getOptionValue(zipEntry, options, "password");
408
422
  let rawPassword = getOptionValue(zipEntry, options, "rawPassword");
423
+ const passThrough = getOptionValue(zipEntry, options, "passThrough");
409
424
  password = password && password.length && password;
410
425
  rawPassword = rawPassword && rawPassword.length && rawPassword;
411
426
  if (extraFieldAES) {
@@ -413,7 +428,7 @@ class ZipEntry {
413
428
  throw new Error(ERR_UNSUPPORTED_COMPRESSION);
414
429
  }
415
430
  }
416
- if (compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE) {
431
+ if ((compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE) && !passThrough) {
417
432
  throw new Error(ERR_UNSUPPORTED_COMPRESSION);
418
433
  }
419
434
  if (getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
@@ -423,13 +438,16 @@ class ZipEntry {
423
438
  localDirectory.rawExtraField = localDirectory.extraFieldLength ?
424
439
  await readUint8Array(reader, offset + 30 + localDirectory.filenameLength, localDirectory.extraFieldLength, diskNumberStart) :
425
440
  new Uint8Array();
426
- await readCommonFooter(zipEntry, localDirectory, dataView, 4, true);
441
+ readCommonFooter(zipEntry, localDirectory, dataView, 4, true);
427
442
  Object.assign(fileEntry, {
428
443
  lastAccessDate: localDirectory.lastAccessDate,
429
444
  creationDate: localDirectory.creationDate
430
445
  });
431
- const encrypted = zipEntry.encrypted && localDirectory.encrypted;
446
+ const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
432
447
  const zipCrypto = encrypted && !extraFieldAES;
448
+ if (!passThrough) {
449
+ fileEntry.zipCrypto = zipCrypto;
450
+ }
433
451
  if (encrypted) {
434
452
  if (!zipCrypto && extraFieldAES.strength === UNDEFINED_VALUE) {
435
453
  throw new Error(ERR_UNSUPPORTED_ENCRYPTION);
@@ -451,7 +469,7 @@ class ZipEntry {
451
469
  writer = new WritableStream();
452
470
  }
453
471
  writer = initWriter(writer);
454
- await initStream(writer, uncompressedSize);
472
+ await initStream(writer, passThrough ? compressedSize : uncompressedSize);
455
473
  const { writable } = writer;
456
474
  const { onstart, onprogress, onend } = options;
457
475
  const workerOptions = {
@@ -461,11 +479,11 @@ class ZipEntry {
461
479
  rawPassword,
462
480
  zipCrypto,
463
481
  encryptionStrength: extraFieldAES && extraFieldAES.strength,
464
- signed: getOptionValue(zipEntry, options, "checkSignature"),
482
+ signed: getOptionValue(zipEntry, options, "checkSignature") && !passThrough,
465
483
  passwordVerification: zipCrypto && (bitFlag.dataDescriptor ? ((rawLastModDate >>> 8) & 0xFF) : ((signature >>> 24) & 0xFF)),
466
484
  signature,
467
- compressed: compressionMethod != 0,
468
- encrypted,
485
+ compressed: compressionMethod != 0 && !passThrough,
486
+ encrypted: zipEntry.encrypted && !passThrough,
469
487
  useWebWorkers: getOptionValue(zipEntry, options, "useWebWorkers"),
470
488
  useCompressionStream: getOptionValue(zipEntry, options, "useCompressionStream"),
471
489
  transferStreams: getOptionValue(zipEntry, options, "transferStreams"),
@@ -511,7 +529,7 @@ function readCommonHeader(directory, dataView, offset) {
511
529
  });
512
530
  }
513
531
 
514
- async function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory) {
532
+ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory) {
515
533
  const { rawExtraField } = directory;
516
534
  const extraField = directory.extraField = new Map();
517
535
  const rawExtraFieldView = getDataView(new Uint8Array(rawExtraField));
@@ -526,7 +544,8 @@ async function readCommonFooter(fileEntry, directory, dataView, offset, localDir
526
544
  });
527
545
  offsetExtraField += 4 + size;
528
546
  }
529
- } catch (_error) {
547
+ // eslint-disable-next-line no-unused-vars
548
+ } catch (_) {
530
549
  // ignored
531
550
  }
532
551
  const compressionMethod = getUint16(dataView, offset + 4);
@@ -542,12 +561,12 @@ async function readCommonFooter(fileEntry, directory, dataView, offset, localDir
542
561
  }
543
562
  const extraFieldUnicodePath = extraField.get(EXTRAFIELD_TYPE_UNICODE_PATH);
544
563
  if (extraFieldUnicodePath) {
545
- await readExtraFieldUnicode(extraFieldUnicodePath, PROPERTY_NAME_FILENAME, PROPERTY_NAME_RAW_FILENAME, directory, fileEntry);
564
+ readExtraFieldUnicode(extraFieldUnicodePath, PROPERTY_NAME_FILENAME, PROPERTY_NAME_RAW_FILENAME, directory, fileEntry);
546
565
  directory.extraFieldUnicodePath = extraFieldUnicodePath;
547
566
  }
548
567
  const extraFieldUnicodeComment = extraField.get(EXTRAFIELD_TYPE_UNICODE_COMMENT);
549
568
  if (extraFieldUnicodeComment) {
550
- await readExtraFieldUnicode(extraFieldUnicodeComment, PROPERTY_NAME_COMMENT, PROPERTY_NAME_RAW_COMMENT, directory, fileEntry);
569
+ readExtraFieldUnicode(extraFieldUnicodeComment, PROPERTY_NAME_COMMENT, PROPERTY_NAME_RAW_COMMENT, directory, fileEntry);
551
570
  directory.extraFieldUnicodeComment = extraFieldUnicodeComment;
552
571
  }
553
572
  const extraFieldAES = extraField.get(EXTRAFIELD_TYPE_AES);
@@ -589,7 +608,7 @@ function readExtraFieldZip64(extraFieldZip64, directory) {
589
608
  }
590
609
  }
591
610
 
592
- async function readExtraFieldUnicode(extraFieldUnicode, propertyName, rawPropertyName, directory, fileEntry) {
611
+ function readExtraFieldUnicode(extraFieldUnicode, propertyName, rawPropertyName, directory, fileEntry) {
593
612
  const extraFieldView = getDataView(extraFieldUnicode.data);
594
613
  const crc32 = new Crc32();
595
614
  crc32.append(fileEntry[rawPropertyName]);
@@ -633,7 +652,8 @@ function readExtraFieldNTFS(extraFieldNTFS, directory) {
633
652
  }
634
653
  offsetExtraField += 4 + attributeSize;
635
654
  }
636
- } catch (_error) {
655
+ // eslint-disable-next-line no-unused-vars
656
+ } catch (_) {
637
657
  // ignored
638
658
  }
639
659
  try {
@@ -654,7 +674,8 @@ function readExtraFieldNTFS(extraFieldNTFS, directory) {
654
674
  Object.assign(extraFieldNTFS, extraFieldData);
655
675
  Object.assign(directory, extraFieldData);
656
676
  }
657
- } catch (_error) {
677
+ // eslint-disable-next-line no-unused-vars
678
+ } catch (_) {
658
679
  // ignored
659
680
  }
660
681
  }
@@ -723,7 +744,8 @@ function getDate(timeRaw) {
723
744
  const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & 0x0000ffff;
724
745
  try {
725
746
  return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
726
- } catch (_error) {
747
+ // eslint-disable-next-line no-unused-vars
748
+ } catch (_) {
727
749
  // ignored
728
750
  }
729
751
  }
@@ -26,7 +26,7 @@
26
26
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
27
  */
28
28
 
29
- /* global BigInt, TransformStream, Response */
29
+ /* global TransformStream, Response */
30
30
  // deno-lint-ignore-file no-this-alias
31
31
 
32
32
  import {
@@ -56,6 +56,9 @@ import {
56
56
  BITFLAG_DATA_DESCRIPTOR,
57
57
  BITFLAG_LANG_ENCODING_FLAG,
58
58
  FILE_ATTR_MSDOS_DIR_MASK,
59
+ FILE_ATTR_UNIX_TYPE_DIR,
60
+ FILE_ATTR_UNIX_EXECUTABLE_MASK,
61
+ FILE_ATTR_UNIX_DEFAULT_MASK,
59
62
  VERSION_DEFLATE,
60
63
  VERSION_ZIP64,
61
64
  VERSION_AES,
@@ -84,8 +87,16 @@ import {
84
87
  PROPERTY_NAME_CREATION_DATE,
85
88
  PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE,
86
89
  PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE,
90
+ PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES,
91
+ PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES,
87
92
  PROPERTY_NAME_MS_DOS_COMPATIBLE,
88
93
  PROPERTY_NAME_ZIP64,
94
+ PROPERTY_NAME_ENCRYPTED,
95
+ PROPERTY_NAME_VERSION,
96
+ PROPERTY_NAME_VERSION_MADE_BY,
97
+ PROPERTY_NAME_ZIPCRYPTO,
98
+ PROPERTY_NAME_DIRECTORY,
99
+ PROPERTY_NAME_EXECUTABLE,
89
100
  Entry
90
101
  } from "./zip-entry.js";
91
102
 
@@ -98,6 +109,7 @@ const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
98
109
  const ERR_INVALID_EXTRAFIELD_TYPE = "Extra field type exceeds 65535";
99
110
  const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
100
111
  const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (make sure 'keepOrder' is set to 'true')";
112
+ const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
101
113
 
102
114
  const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
103
115
 
@@ -118,7 +130,7 @@ class ZipWriter {
118
130
  config: getConfiguration(),
119
131
  files: new Map(),
120
132
  filenames: new Set(),
121
- offset: writer.writable.size,
133
+ offset: options.offset === UNDEFINED_VALUE ? writer.writable.size : options.offset,
122
134
  pendingEntriesSize: 0,
123
135
  pendingAddFileCalls: new Set(),
124
136
  bufferedWrites: 0
@@ -214,15 +226,42 @@ export {
214
226
  ERR_INVALID_EXTRAFIELD_TYPE,
215
227
  ERR_INVALID_EXTRAFIELD_DATA,
216
228
  ERR_INVALID_ENCRYPTION_STRENGTH,
217
- ERR_UNSUPPORTED_FORMAT
229
+ ERR_UNSUPPORTED_FORMAT,
230
+ ERR_UNDEFINED_UNCOMPRESSED_SIZE
218
231
  };
219
232
 
220
233
  async function addFile(zipWriter, name, reader, options) {
221
234
  name = name.trim();
222
- if (options.directory && (!name.endsWith(DIRECTORY_SIGNATURE))) {
223
- name += DIRECTORY_SIGNATURE;
224
- } else {
225
- options.directory = name.endsWith(DIRECTORY_SIGNATURE);
235
+ const msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
236
+ const versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? 20 : 768);
237
+ const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
238
+ if (versionMadeBy > MAX_16_BITS) {
239
+ throw new Error(ERR_INVALID_VERSION);
240
+ }
241
+ let externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, 0);
242
+ if (externalFileAttributes === 0) {
243
+ externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE, 0);
244
+ }
245
+ if (!options.directory && name.endsWith(DIRECTORY_SIGNATURE)) {
246
+ options.directory = true;
247
+ }
248
+ const directory = getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY);
249
+ if (directory) {
250
+ if (!name.endsWith(DIRECTORY_SIGNATURE)) {
251
+ name += DIRECTORY_SIGNATURE;
252
+ }
253
+ if (externalFileAttributes === 0) {
254
+ externalFileAttributes = FILE_ATTR_MSDOS_DIR_MASK;
255
+ if (!msDosCompatible) {
256
+ externalFileAttributes |= (FILE_ATTR_UNIX_TYPE_DIR | FILE_ATTR_UNIX_EXECUTABLE_MASK | FILE_ATTR_UNIX_DEFAULT_MASK) << 16;
257
+ }
258
+ }
259
+ } else if (!msDosCompatible && externalFileAttributes === 0) {
260
+ if (executable) {
261
+ externalFileAttributes = (FILE_ATTR_UNIX_EXECUTABLE_MASK | FILE_ATTR_UNIX_DEFAULT_MASK) << 16;
262
+ } else {
263
+ externalFileAttributes = FILE_ATTR_UNIX_DEFAULT_MASK << 16;
264
+ }
226
265
  }
227
266
  const encode = getOptionValue(zipWriter, options, "encodeText", encodeText);
228
267
  let rawFilename = encode(name);
@@ -240,24 +279,25 @@ async function addFile(zipWriter, name, reader, options) {
240
279
  if (getLength(rawComment) > MAX_16_BITS) {
241
280
  throw new Error(ERR_INVALID_ENTRY_COMMENT);
242
281
  }
243
- const version = getOptionValue(zipWriter, options, "version", VERSION_DEFLATE);
282
+ const version = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION, VERSION_DEFLATE);
244
283
  if (version > MAX_16_BITS) {
245
284
  throw new Error(ERR_INVALID_VERSION);
246
285
  }
247
- const versionMadeBy = getOptionValue(zipWriter, options, "versionMadeBy", 20);
248
- if (versionMadeBy > MAX_16_BITS) {
249
- throw new Error(ERR_INVALID_VERSION);
250
- }
251
286
  const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
252
287
  const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
253
288
  const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
254
- const msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE, true);
255
- const internalFileAttribute = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, 0);
256
- const externalFileAttribute = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE, 0);
257
- const password = getOptionValue(zipWriter, options, "password");
258
- const rawPassword = getOptionValue(zipWriter, options, "rawPassword");
289
+ let internalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, 0);
290
+ if (internalFileAttributes === 0) {
291
+ internalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, 0);
292
+ }
293
+ const passThrough = getOptionValue(zipWriter, options, "passThrough");
294
+ let password, rawPassword;
295
+ if (!passThrough) {
296
+ password = getOptionValue(zipWriter, options, "password");
297
+ rawPassword = getOptionValue(zipWriter, options, "rawPassword");
298
+ }
259
299
  const encryptionStrength = getOptionValue(zipWriter, options, "encryptionStrength", 3);
260
- const zipCrypto = getOptionValue(zipWriter, options, "zipCrypto");
300
+ const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
261
301
  const extendedTimestamp = getOptionValue(zipWriter, options, "extendedTimestamp", true);
262
302
  const keepOrder = getOptionValue(zipWriter, options, "keepOrder", true);
263
303
  const level = getOptionValue(zipWriter, options, "level");
@@ -265,10 +305,12 @@ async function addFile(zipWriter, name, reader, options) {
265
305
  const bufferedWrite = getOptionValue(zipWriter, options, "bufferedWrite");
266
306
  const dataDescriptorSignature = getOptionValue(zipWriter, options, "dataDescriptorSignature", false);
267
307
  const signal = getOptionValue(zipWriter, options, "signal");
308
+ const useUnicodeFileNames = getOptionValue(zipWriter, options, "useUnicodeFileNames", true);
268
309
  const useCompressionStream = getOptionValue(zipWriter, options, "useCompressionStream");
310
+ const compressionMethod = getOptionValue(zipWriter, options, "compressionMethod");
269
311
  let dataDescriptor = getOptionValue(zipWriter, options, "dataDescriptor", true);
270
312
  let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
271
- if (password !== UNDEFINED_VALUE && encryptionStrength !== UNDEFINED_VALUE && (encryptionStrength < 1 || encryptionStrength > 3)) {
313
+ if (!zipCrypto && (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) && !(encryptionStrength >= 1 && encryptionStrength <= 3)) {
272
314
  throw new Error(ERR_INVALID_ENCRYPTION_STRENGTH);
273
315
  }
274
316
  let rawExtraField = new Uint8Array();
@@ -294,18 +336,28 @@ async function addFile(zipWriter, name, reader, options) {
294
336
  let maximumCompressedSize = 0;
295
337
  let maximumEntrySize = 0;
296
338
  let uncompressedSize = 0;
339
+ if (passThrough) {
340
+ ({ uncompressedSize } = options);
341
+ if (uncompressedSize === UNDEFINED_VALUE) {
342
+ throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
343
+ }
344
+ }
297
345
  const zip64Enabled = zip64 === true;
298
346
  if (reader) {
299
347
  reader = initReader(reader);
300
348
  await initStream(reader);
301
- if (reader.size === UNDEFINED_VALUE) {
302
- dataDescriptor = true;
303
- if (zip64 || zip64 === UNDEFINED_VALUE) {
304
- zip64 = true;
305
- uncompressedSize = maximumCompressedSize = MAX_32_BITS + 1;
349
+ if (!passThrough) {
350
+ if (reader.size === UNDEFINED_VALUE) {
351
+ dataDescriptor = true;
352
+ if (zip64 || zip64 === UNDEFINED_VALUE) {
353
+ zip64 = true;
354
+ uncompressedSize = maximumCompressedSize = MAX_32_BITS + 1;
355
+ }
356
+ } else {
357
+ uncompressedSize = reader.size;
358
+ maximumCompressedSize = getMaximumCompressedSize(uncompressedSize);
306
359
  }
307
360
  } else {
308
- uncompressedSize = reader.size;
309
361
  maximumCompressedSize = getMaximumCompressedSize(uncompressedSize);
310
362
  }
311
363
  }
@@ -323,6 +375,8 @@ async function addFile(zipWriter, name, reader, options) {
323
375
  }
324
376
  }
325
377
  zip64 = zip64 || false;
378
+ const encrypted = getOptionValue(zipWriter, options, PROPERTY_NAME_ENCRYPTED);
379
+ const { signature } = options;
326
380
  options = Object.assign({}, options, {
327
381
  rawFilename,
328
382
  rawComment,
@@ -346,13 +400,20 @@ async function addFile(zipWriter, name, reader, options) {
346
400
  zipCrypto,
347
401
  bufferedWrite,
348
402
  keepOrder,
403
+ useUnicodeFileNames,
349
404
  dataDescriptor,
350
405
  dataDescriptorSignature,
351
406
  signal,
352
407
  msDosCompatible,
353
- internalFileAttribute,
354
- externalFileAttribute,
355
- useCompressionStream
408
+ internalFileAttribute: internalFileAttributes,
409
+ internalFileAttributes,
410
+ externalFileAttribute: externalFileAttributes,
411
+ externalFileAttributes,
412
+ useCompressionStream,
413
+ passThrough,
414
+ encrypted: Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted),
415
+ signature,
416
+ compressionMethod
356
417
  });
357
418
  const headerInfo = getHeaderInfo(options);
358
419
  const dataDescriptorInfo = getDataDescriptorInfo(options);
@@ -468,7 +529,8 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
468
529
  if (error) {
469
530
  try {
470
531
  error.corruptedEntry = true;
471
- } catch (_error) {
532
+ // eslint-disable-next-line no-unused-vars
533
+ } catch (_) {
472
534
  // ignored
473
535
  }
474
536
  }
@@ -550,6 +612,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
550
612
  zipCrypto,
551
613
  dataDescriptor,
552
614
  directory,
615
+ executable,
553
616
  versionMadeBy,
554
617
  rawComment,
555
618
  rawExtraField,
@@ -561,15 +624,17 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
561
624
  encryptionStrength,
562
625
  extendedTimestamp,
563
626
  msDosCompatible,
564
- internalFileAttribute,
565
- externalFileAttribute,
566
- useCompressionStream
627
+ internalFileAttributes,
628
+ externalFileAttributes,
629
+ useCompressionStream,
630
+ passThrough
567
631
  } = options;
568
632
  const fileEntry = {
569
633
  lock,
570
634
  versionMadeBy,
571
635
  zip64,
572
636
  directory: Boolean(directory),
637
+ executable: Boolean(executable),
573
638
  filenameUTF8: true,
574
639
  rawFilename,
575
640
  commentUTF8: true,
@@ -580,13 +645,18 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
580
645
  rawExtraField,
581
646
  extendedTimestamp,
582
647
  msDosCompatible,
583
- internalFileAttribute,
584
- externalFileAttribute,
648
+ internalFileAttributes,
649
+ externalFileAttributes,
585
650
  diskNumberStart
586
651
  };
652
+ let {
653
+ signature,
654
+ uncompressedSize
655
+ } = options;
587
656
  let compressedSize = 0;
588
- let uncompressedSize = 0;
589
- let signature;
657
+ if (!passThrough) {
658
+ uncompressedSize = 0;
659
+ }
590
660
  const { writable } = writer;
591
661
  if (reader) {
592
662
  reader.chunkSize = getChunkSize(config);
@@ -602,9 +672,9 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
602
672
  encryptionStrength,
603
673
  zipCrypto: encrypted && zipCrypto,
604
674
  passwordVerification: encrypted && zipCrypto && (rawLastModDate >> 8) & 0xFF,
605
- signed: true,
606
- compressed,
607
- encrypted,
675
+ signed: !passThrough,
676
+ compressed: compressed && !passThrough,
677
+ encrypted: encrypted && !passThrough,
608
678
  useWebWorkers,
609
679
  useCompressionStream,
610
680
  transferStreams: false
@@ -613,9 +683,11 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
613
683
  streamOptions: { signal, size, onstart, onprogress, onend }
614
684
  };
615
685
  const result = await runWorker({ readable, writable }, workerOptions);
616
- uncompressedSize = result.inputSize;
617
686
  compressedSize = result.outputSize;
618
- signature = result.signature;
687
+ if (!passThrough) {
688
+ uncompressedSize = result.inputSize;
689
+ signature = result.signature;
690
+ }
619
691
  writable.size += uncompressedSize;
620
692
  } else {
621
693
  await writeData(writable, localHeaderArray);
@@ -658,6 +730,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
658
730
  creationDate,
659
731
  lastAccessDate,
660
732
  encrypted,
733
+ zipCrypto,
661
734
  size: metadataSize + compressedSize,
662
735
  compressionMethod,
663
736
  version,
@@ -679,20 +752,19 @@ function getHeaderInfo(options) {
679
752
  lastModDate,
680
753
  lastAccessDate,
681
754
  creationDate,
682
- rawPassword,
683
- password,
684
755
  level,
685
756
  zip64,
686
757
  zipCrypto,
758
+ useUnicodeFileNames,
687
759
  dataDescriptor,
688
760
  directory,
689
761
  rawExtraField,
690
762
  encryptionStrength,
691
- extendedTimestamp
763
+ extendedTimestamp,
764
+ encrypted
692
765
  } = options;
693
- const compressed = level !== 0 && !directory;
694
- const encrypted = Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword)));
695
- let version = options.version;
766
+ let { version, compressionMethod } = options;
767
+ const compressed = !directory && (level > 0 || (level === UNDEFINED_VALUE && compressionMethod !== 0));
696
768
  let rawExtraFieldAES;
697
769
  if (encrypted && !zipCrypto) {
698
770
  rawExtraFieldAES = new Uint8Array(getLength(EXTRAFIELD_DATA_AES) + 2);
@@ -734,19 +806,33 @@ function getHeaderInfo(options) {
734
806
  setBigUint64(extraFieldNTFSView, 12, lastModTimeNTFS);
735
807
  setBigUint64(extraFieldNTFSView, 20, getTimeNTFS(lastAccessDate) || lastModTimeNTFS);
736
808
  setBigUint64(extraFieldNTFSView, 28, getTimeNTFS(creationDate) || lastModTimeNTFS);
737
- } catch (_error) {
809
+ // eslint-disable-next-line no-unused-vars
810
+ } catch (_) {
738
811
  rawExtraFieldNTFS = new Uint8Array();
739
812
  }
740
813
  } else {
741
814
  rawExtraFieldNTFS = rawExtraFieldExtendedTimestamp = new Uint8Array();
742
815
  }
743
- let bitFlag = BITFLAG_LANG_ENCODING_FLAG;
816
+ let bitFlag = 0;
817
+ if (useUnicodeFileNames) {
818
+ bitFlag = bitFlag | BITFLAG_LANG_ENCODING_FLAG;
819
+ }
744
820
  if (dataDescriptor) {
745
821
  bitFlag = bitFlag | BITFLAG_DATA_DESCRIPTOR;
746
822
  }
747
- let compressionMethod = COMPRESSION_METHOD_STORE;
748
- if (compressed) {
749
- compressionMethod = COMPRESSION_METHOD_DEFLATE;
823
+ if (compressionMethod === UNDEFINED_VALUE) {
824
+ compressionMethod = compressed ? COMPRESSION_METHOD_DEFLATE : COMPRESSION_METHOD_STORE;
825
+ }
826
+ if (compressionMethod == COMPRESSION_METHOD_DEFLATE) {
827
+ if (level >= 1 && level < 3) {
828
+ bitFlag = bitFlag | 0b110;
829
+ }
830
+ if (level >= 3 && level < 5) {
831
+ bitFlag = bitFlag | 0b01;
832
+ }
833
+ if (level === 9) {
834
+ bitFlag = bitFlag | 0b10;
835
+ }
750
836
  }
751
837
  if (zip64) {
752
838
  version = version > VERSION_ZIP64 ? version : VERSION_ZIP64;
@@ -755,10 +841,8 @@ function getHeaderInfo(options) {
755
841
  bitFlag = bitFlag | BITFLAG_ENCRYPTED;
756
842
  if (!zipCrypto) {
757
843
  version = version > VERSION_AES ? version : VERSION_AES;
844
+ rawExtraFieldAES[9] = compressionMethod;
758
845
  compressionMethod = COMPRESSION_METHOD_AES;
759
- if (compressed) {
760
- rawExtraFieldAES[9] = COMPRESSION_METHOD_DEFLATE;
761
- }
762
846
  }
763
847
  }
764
848
  const headerArray = new Uint8Array(26);
@@ -1011,15 +1095,13 @@ async function closeFile(zipWriter, comment, options) {
1011
1095
  rawComment,
1012
1096
  versionMadeBy,
1013
1097
  headerArray,
1014
- directory,
1015
1098
  zip64,
1016
1099
  zip64UncompressedSize,
1017
1100
  zip64CompressedSize,
1018
1101
  zip64DiskNumberStart,
1019
1102
  zip64Offset,
1020
- msDosCompatible,
1021
- internalFileAttribute,
1022
- externalFileAttribute,
1103
+ internalFileAttributes,
1104
+ externalFileAttributes,
1023
1105
  diskNumberStart,
1024
1106
  uncompressedSize,
1025
1107
  compressedSize
@@ -1038,11 +1120,9 @@ async function closeFile(zipWriter, comment, options) {
1038
1120
  setUint16(directoryView, offset + 30, extraFieldLength);
1039
1121
  setUint16(directoryView, offset + 32, getLength(rawComment));
1040
1122
  setUint16(directoryView, offset + 34, zip64 && zip64DiskNumberStart ? MAX_16_BITS : diskNumberStart);
1041
- setUint16(directoryView, offset + 36, internalFileAttribute);
1042
- if (externalFileAttribute) {
1043
- setUint32(directoryView, offset + 38, externalFileAttribute);
1044
- } else if (directory && msDosCompatible) {
1045
- setUint8(directoryView, offset + 38, FILE_ATTR_MSDOS_DIR_MASK);
1123
+ setUint16(directoryView, offset + 36, internalFileAttributes);
1124
+ if (externalFileAttributes) {
1125
+ setUint32(directoryView, offset + 38, externalFileAttributes);
1046
1126
  }
1047
1127
  setUint32(directoryView, offset + 42, zip64 && zip64Offset ? MAX_32_BITS : fileEntryOffset);
1048
1128
  arraySet(directoryArray, rawFilename, offset + 46);
@@ -1062,7 +1142,8 @@ async function closeFile(zipWriter, comment, options) {
1062
1142
  if (options.onprogress) {
1063
1143
  try {
1064
1144
  await options.onprogress(indexFileEntry + 1, files.size, new Entry(fileEntry));
1065
- } catch (_error) {
1145
+ // eslint-disable-next-line no-unused-vars
1146
+ } catch (_) {
1066
1147
  // ignored
1067
1148
  }
1068
1149
  }
@@ -1073,7 +1154,7 @@ async function closeFile(zipWriter, comment, options) {
1073
1154
  if (availableSize < END_OF_CENTRAL_DIR_LENGTH) {
1074
1155
  lastDiskNumber++;
1075
1156
  }
1076
- let zip64 = getOptionValue(zipWriter, options, "zip64");
1157
+ let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
1077
1158
  if (directoryOffset > MAX_32_BITS || directoryDataLength > MAX_32_BITS || filesLength > MAX_16_BITS || lastDiskNumber > MAX_16_BITS) {
1078
1159
  if (zip64 === false) {
1079
1160
  throw new Error(ERR_UNSUPPORTED_FORMAT);
@@ -35,7 +35,7 @@ export {
35
35
  function configureWebWorker(configure, options = {}) {
36
36
  // eslint-disable-next-line quotes
37
37
  const code = `__workerCode__`;
38
- const uri = options.useDataURI ?
38
+ const uri = () => options.useDataURI ?
39
39
  `data:text/javascript,${encodeURIComponent(code)}` :
40
40
  URL.createObjectURL(new Blob([code], { type: "text/javascript" }));
41
41
  configure({ workerScripts: { inflate: [uri], deflate: [uri] } });