@zip.js/zip.js 2.7.56 → 2.7.58

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.
@@ -0,0 +1,17 @@
1
+ # .github/workflows/publish.yml
2
+
3
+ name: Publish
4
+
5
+ on:
6
+ release:
7
+ types: [published]
8
+
9
+ jobs:
10
+ publish:
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ contents: read
14
+ id-token: write
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - run: npx jsr publish
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zip-js/zip-js",
3
- "version": "2.7.56",
3
+ "version": "2.7.58",
4
4
  "exports": {
5
5
  ".": "./index.js",
6
6
  "./data-uri": "./lib/zip-data-uri.js"
@@ -4284,6 +4284,7 @@
4284
4284
  const FILE_ATTR_MSDOS_DIR_MASK = 0x10;
4285
4285
  const FILE_ATTR_UNIX_DIR_MASK = 0x4000;
4286
4286
  const FILE_ATTR_UNIX_EXECUTABLE_MASK = 0o111;
4287
+ const FILE_ATTR_UNIX_DEFAULT_MASK = 0o644;
4287
4288
 
4288
4289
  const VERSION_DEFLATE = 0x14;
4289
4290
  const VERSION_ZIP64 = 0x2D;
@@ -8405,6 +8406,7 @@
8405
8406
  const ERR_HTTP_STATUS = "HTTP error ";
8406
8407
  const ERR_HTTP_RANGE = "HTTP Range not supported";
8407
8408
  const ERR_ITERATOR_COMPLETED_TOO_SOON = "Writer iterator completed too soon";
8409
+ const ERR_WRITER_NOT_INITIALIZED = "Writer not initialized";
8408
8410
 
8409
8411
  const CONTENT_TYPE_TEXT_PLAIN = "text/plain";
8410
8412
  const HTTP_HEADER_CONTENT_LENGTH = "Content-Length";
@@ -8442,8 +8444,10 @@
8442
8444
  async pull(controller) {
8443
8445
  const { offset = 0, size, diskNumberStart } = readable;
8444
8446
  const { chunkOffset } = this;
8445
- controller.enqueue(await readUint8Array(reader, offset + chunkOffset, Math.min(chunkSize, size - chunkOffset), diskNumberStart));
8446
- if (chunkOffset + chunkSize > size) {
8447
+ const dataSize = size === UNDEFINED_VALUE ? chunkSize : Math.min(chunkSize, size - chunkOffset);
8448
+ const data = await readUint8Array(reader, offset + chunkOffset, dataSize, diskNumberStart);
8449
+ controller.enqueue(data);
8450
+ if ((chunkOffset + chunkSize > size) || (size === UNDEFINED_VALUE && !data.length && dataSize)) {
8447
8451
  controller.close();
8448
8452
  } else {
8449
8453
  this.chunkOffset += chunkSize;
@@ -8461,6 +8465,9 @@
8461
8465
  const writer = this;
8462
8466
  const writable = new WritableStream({
8463
8467
  write(chunk) {
8468
+ if (!writer.initialized) {
8469
+ throw new Error(ERR_WRITER_NOT_INITIALIZED);
8470
+ }
8464
8471
  return writer.writeUint8Array(chunk);
8465
8472
  }
8466
8473
  });
@@ -9223,12 +9230,14 @@
9223
9230
  const PROPERTY_NAME_VERSION = "version";
9224
9231
  const PROPERTY_NAME_VERSION_MADE_BY = "versionMadeBy";
9225
9232
  const PROPERTY_NAME_ZIPCRYPTO = "zipCrypto";
9233
+ const PROPERTY_NAME_DIRECTORY = "directory";
9234
+ const PROPERTY_NAME_EXECUTABLE = "executable";
9226
9235
 
9227
9236
  const PROPERTY_NAMES = [
9228
9237
  PROPERTY_NAME_FILENAME, PROPERTY_NAME_RAW_FILENAME, PROPERTY_NAME_COMPPRESSED_SIZE, PROPERTY_NAME_UNCOMPPRESSED_SIZE,
9229
9238
  PROPERTY_NAME_LAST_MODIFICATION_DATE, PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE, PROPERTY_NAME_COMMENT, PROPERTY_NAME_RAW_COMMENT,
9230
9239
  PROPERTY_NAME_LAST_ACCESS_DATE, PROPERTY_NAME_CREATION_DATE, PROPERTY_NAME_OFFSET, PROPERTY_NAME_DISK_NUMBER_START,
9231
- 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"];
9240
+ 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"];
9232
9241
 
9233
9242
  class Entry {
9234
9243
 
@@ -10073,10 +10082,37 @@
10073
10082
 
10074
10083
  async function addFile(zipWriter, name, reader, options) {
10075
10084
  name = name.trim();
10076
- if (options.directory && (!name.endsWith(DIRECTORY_SIGNATURE))) {
10077
- name += DIRECTORY_SIGNATURE;
10078
- } else {
10079
- options.directory = name.endsWith(DIRECTORY_SIGNATURE);
10085
+ const msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
10086
+ const versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? 20 : 768);
10087
+ const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
10088
+ if (versionMadeBy > MAX_16_BITS) {
10089
+ throw new Error(ERR_INVALID_VERSION);
10090
+ }
10091
+ let externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, 0);
10092
+ if (externalFileAttributes === 0) {
10093
+ externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE, 0);
10094
+ }
10095
+ if (!options.directory && name.endsWith(DIRECTORY_SIGNATURE)) {
10096
+ options.directory = true;
10097
+ }
10098
+ const directory = getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY);
10099
+ if (directory) {
10100
+ if (!name.endsWith(DIRECTORY_SIGNATURE)) {
10101
+ name += DIRECTORY_SIGNATURE;
10102
+ }
10103
+ if (externalFileAttributes === 0) {
10104
+ if (msDosCompatible) {
10105
+ externalFileAttributes = FILE_ATTR_MSDOS_DIR_MASK;
10106
+ } else {
10107
+ externalFileAttributes = FILE_ATTR_UNIX_DIR_MASK << 16;
10108
+ }
10109
+ }
10110
+ } else if (!msDosCompatible && externalFileAttributes === 0) {
10111
+ if (executable) {
10112
+ externalFileAttributes = (FILE_ATTR_UNIX_EXECUTABLE_MASK | FILE_ATTR_UNIX_DEFAULT_MASK) << 16;
10113
+ } else {
10114
+ externalFileAttributes = FILE_ATTR_UNIX_DEFAULT_MASK << 16;
10115
+ }
10080
10116
  }
10081
10117
  const encode = getOptionValue(zipWriter, options, "encodeText", encodeText);
10082
10118
  let rawFilename = encode(name);
@@ -10098,22 +10134,13 @@
10098
10134
  if (version > MAX_16_BITS) {
10099
10135
  throw new Error(ERR_INVALID_VERSION);
10100
10136
  }
10101
- const versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, 20);
10102
- if (versionMadeBy > MAX_16_BITS) {
10103
- throw new Error(ERR_INVALID_VERSION);
10104
- }
10105
10137
  const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
10106
10138
  const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
10107
10139
  const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
10108
- const msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE, true);
10109
10140
  let internalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, 0);
10110
10141
  if (internalFileAttributes === 0) {
10111
10142
  internalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, 0);
10112
10143
  }
10113
- let externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, 0);
10114
- if (externalFileAttributes === 0) {
10115
- externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE, 0);
10116
- }
10117
10144
  const passThrough = getOptionValue(zipWriter, options, "passThrough");
10118
10145
  let password, rawPassword;
10119
10146
  if (!passThrough) {
@@ -10436,6 +10463,7 @@
10436
10463
  zipCrypto,
10437
10464
  dataDescriptor,
10438
10465
  directory,
10466
+ executable,
10439
10467
  versionMadeBy,
10440
10468
  rawComment,
10441
10469
  rawExtraField,
@@ -10457,6 +10485,7 @@
10457
10485
  versionMadeBy,
10458
10486
  zip64,
10459
10487
  directory: Boolean(directory),
10488
+ executable: Boolean(executable),
10460
10489
  filenameUTF8: true,
10461
10490
  rawFilename,
10462
10491
  commentUTF8: true,
@@ -10917,13 +10946,11 @@
10917
10946
  rawComment,
10918
10947
  versionMadeBy,
10919
10948
  headerArray,
10920
- directory,
10921
10949
  zip64,
10922
10950
  zip64UncompressedSize,
10923
10951
  zip64CompressedSize,
10924
10952
  zip64DiskNumberStart,
10925
10953
  zip64Offset,
10926
- msDosCompatible,
10927
10954
  internalFileAttributes,
10928
10955
  externalFileAttributes,
10929
10956
  diskNumberStart,
@@ -10947,8 +10974,6 @@
10947
10974
  setUint16(directoryView, offset + 36, internalFileAttributes);
10948
10975
  if (externalFileAttributes) {
10949
10976
  setUint32(directoryView, offset + 38, externalFileAttributes);
10950
- } else if (directory && msDosCompatible) {
10951
- setUint8(directoryView, offset + 38, FILE_ATTR_MSDOS_DIR_MASK);
10952
10977
  }
10953
10978
  setUint32(directoryView, offset + 42, zip64 && zip64Offset ? MAX_32_BITS : fileEntryOffset);
10954
10979
  arraySet(directoryArray, rawFilename, offset + 46);
@@ -12032,6 +12057,7 @@
12032
12057
  exports.ERR_UNSUPPORTED_COMPRESSION = ERR_UNSUPPORTED_COMPRESSION;
12033
12058
  exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
12034
12059
  exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
12060
+ exports.ERR_WRITER_NOT_INITIALIZED = ERR_WRITER_NOT_INITIALIZED;
12035
12061
  exports.HttpRangeReader = HttpRangeReader;
12036
12062
  exports.HttpReader = HttpReader;
12037
12063
  exports.Reader = Reader;