@zip.js/zip.js 2.7.43 → 2.7.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/deno.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@zip-js/zip-js",
3
- "version": "2.7.43",
3
+ "version": "2.7.45",
4
4
  "exports": "./index.js"
5
5
  }
@@ -6,6 +6,7 @@
6
6
 
7
7
  const { Array, Object, String, Number, BigInt, Math, Date, Map, Set, Response, URL, Error, Uint8Array, Uint16Array, Uint32Array, DataView, Blob, Promise, TextEncoder, TextDecoder, document, crypto, btoa, TransformStream, ReadableStream, WritableStream, CompressionStream, DecompressionStream, navigator, Worker } = typeof globalThis !== 'undefined' ? globalThis : this || self;
8
8
 
9
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
9
10
  /*
10
11
  Copyright (c) 2022 Gildas Lormeau. All rights reserved.
11
12
 
@@ -1046,7 +1047,7 @@
1046
1047
  bi_windup(); // align on byte boundary
1047
1048
  last_eob_len = 8; // enough lookahead for inflate
1048
1049
 
1049
- if (header) {
1050
+ {
1050
1051
  put_short(len);
1051
1052
  put_short(~len);
1052
1053
  }
@@ -1061,7 +1062,7 @@
1061
1062
  eof // true if this is the last block for a file
1062
1063
  ) {
1063
1064
  send_bits((STORED_BLOCK << 1) + (eof ? 1 : 0), 3); // send block type
1064
- copy_block(buf, stored_len, true); // with header
1065
+ copy_block(buf, stored_len); // with header
1065
1066
  }
1066
1067
 
1067
1068
  // Determine the best encoding for the current block: dynamic trees, static
@@ -4331,6 +4332,7 @@
4331
4332
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4332
4333
  */
4333
4334
 
4335
+
4334
4336
  class StreamAdapter {
4335
4337
 
4336
4338
  constructor(Codec) {
@@ -4381,6 +4383,7 @@
4381
4383
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4382
4384
  */
4383
4385
 
4386
+
4384
4387
  const MINIMUM_CHUNK_SIZE = 64;
4385
4388
  let maxWorkers = 2;
4386
4389
  try {
@@ -4495,6 +4498,7 @@
4495
4498
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4496
4499
  */
4497
4500
 
4501
+
4498
4502
  function getMimeType$1() {
4499
4503
  return "application/octet-stream";
4500
4504
  }
@@ -4527,6 +4531,7 @@
4527
4531
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4528
4532
  */
4529
4533
 
4534
+
4530
4535
  const table$1 = {
4531
4536
  "application": {
4532
4537
  "andrew-inset": "ez",
@@ -6218,6 +6223,7 @@
6218
6223
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6219
6224
  */
6220
6225
 
6226
+
6221
6227
  class Crc32Stream extends TransformStream {
6222
6228
 
6223
6229
  constructor() {
@@ -6267,6 +6273,7 @@
6267
6273
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6268
6274
  */
6269
6275
 
6276
+
6270
6277
  function encodeText(value) {
6271
6278
  if (typeof TextEncoder == UNDEFINED_TYPE) {
6272
6279
  value = unescape(encodeURIComponent(value));
@@ -7128,6 +7135,7 @@
7128
7135
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7129
7136
  */
7130
7137
 
7138
+
7131
7139
  const GET_RANDOM_VALUES_SUPPORTED = typeof crypto != UNDEFINED_TYPE && typeof crypto.getRandomValues == FUNCTION_TYPE;
7132
7140
 
7133
7141
  const ERR_INVALID_PASSWORD = "Invalid password";
@@ -7170,6 +7178,7 @@
7170
7178
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7171
7179
  */
7172
7180
 
7181
+
7173
7182
  const BLOCK_LENGTH = 16;
7174
7183
  const RAW_FORMAT = "raw";
7175
7184
  const PBKDF2_ALGORITHM = { name: "PBKDF2" };
@@ -7473,6 +7482,7 @@
7473
7482
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7474
7483
  */
7475
7484
 
7485
+
7476
7486
  const HEADER_LENGTH = 12;
7477
7487
 
7478
7488
  class ZipCryptoDecryptionStream extends TransformStream {
@@ -7620,6 +7630,7 @@
7620
7630
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7621
7631
  */
7622
7632
 
7633
+
7623
7634
  const COMPRESSION_FORMAT = "deflate-raw";
7624
7635
 
7625
7636
  class DeflateStream extends TransformStream {
@@ -7760,6 +7771,7 @@
7760
7771
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7761
7772
  */
7762
7773
 
7774
+
7763
7775
  const MESSAGE_EVENT_TYPE = "message";
7764
7776
  const MESSAGE_START = "start";
7765
7777
  const MESSAGE_PULL = "pull";
@@ -7881,6 +7893,7 @@
7881
7893
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7882
7894
  */
7883
7895
 
7896
+
7884
7897
  // deno-lint-ignore valid-typeof
7885
7898
  let WEB_WORKERS_SUPPORTED = typeof Worker != UNDEFINED_TYPE;
7886
7899
 
@@ -8209,6 +8222,7 @@
8209
8222
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8210
8223
  */
8211
8224
 
8225
+
8212
8226
  let pool = [];
8213
8227
  const pendingRequests = [];
8214
8228
 
@@ -8372,6 +8386,7 @@
8372
8386
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8373
8387
  */
8374
8388
 
8389
+
8375
8390
  const ERR_HTTP_STATUS = "HTTP error ";
8376
8391
  const ERR_HTTP_RANGE = "HTTP Range not supported";
8377
8392
  const ERR_ITERATOR_COMPLETED_TOO_SOON = "Writer iterator completed too soon";
@@ -9132,6 +9147,7 @@
9132
9147
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9133
9148
  */
9134
9149
 
9150
+
9135
9151
  function decodeText(value, encoding) {
9136
9152
  if (encoding && encoding.trim().toLowerCase() == "cp437") {
9137
9153
  return decodeCP437(value);
@@ -9233,6 +9249,7 @@
9233
9249
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9234
9250
  */
9235
9251
 
9252
+
9236
9253
  const ERR_BAD_FORMAT = "File format is not recognized";
9237
9254
  const ERR_EOCDR_NOT_FOUND = "End of central directory not found";
9238
9255
  const ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND = "End of Zip64 central directory locator not found";
@@ -9411,10 +9428,16 @@
9411
9428
  rawExtraField: directoryArray.subarray(extraFieldOffset, commentOffset)
9412
9429
  });
9413
9430
  const decode = getOptionValue$1(zipReader, options, "decodeText") || decodeText;
9414
- const [filename, comment] = await Promise.all([
9415
- decode(rawFilename, filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437),
9416
- decode(rawComment, commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437)
9417
- ]);
9431
+ const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
9432
+ const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
9433
+ let filename = decode(rawFilename, rawFilenameEncoding);
9434
+ if (filename === UNDEFINED_VALUE) {
9435
+ filename = decodeText(rawFilename, rawFilenameEncoding);
9436
+ }
9437
+ let comment = decode(rawComment, rawCommentEncoding);
9438
+ if (comment === UNDEFINED_VALUE) {
9439
+ comment = decodeText(rawComment, rawCommentEncoding);
9440
+ }
9418
9441
  Object.assign(fileEntry, {
9419
9442
  rawComment,
9420
9443
  filename,
@@ -9488,7 +9511,7 @@
9488
9511
  }
9489
9512
  }
9490
9513
 
9491
- class ZipEntry$1 {
9514
+ let ZipEntry$1 = class ZipEntry {
9492
9515
 
9493
9516
  constructor(reader, config, options) {
9494
9517
  Object.assign(this, {
@@ -9602,7 +9625,7 @@
9602
9625
  }
9603
9626
  return checkPasswordOnly ? UNDEFINED_VALUE : writer.getData ? writer.getData() : writable;
9604
9627
  }
9605
- }
9628
+ };
9606
9629
 
9607
9630
  function readCommonHeader(directory, dataView, offset) {
9608
9631
  const rawBitFlag = directory.rawBitFlag = getUint16(dataView, offset + 2);
@@ -9896,6 +9919,7 @@
9896
9919
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9897
9920
  */
9898
9921
 
9922
+
9899
9923
  const ERR_DUPLICATED_NAME = "File already exists";
9900
9924
  const ERR_INVALID_COMMENT = "Zip file comment exceeds 64KB";
9901
9925
  const ERR_INVALID_ENTRY_COMMENT = "File entry comment exceeds 64KB";
@@ -10018,12 +10042,18 @@
10018
10042
  options.directory = name.endsWith(DIRECTORY_SIGNATURE);
10019
10043
  }
10020
10044
  const encode = getOptionValue(zipWriter, options, "encodeText", encodeText);
10021
- const rawFilename = encode(name);
10045
+ let rawFilename = encode(name);
10046
+ if (rawFilename === UNDEFINED_VALUE) {
10047
+ rawFilename = encodeText(name);
10048
+ }
10022
10049
  if (getLength(rawFilename) > MAX_16_BITS) {
10023
10050
  throw new Error(ERR_INVALID_ENTRY_NAME);
10024
10051
  }
10025
10052
  const comment = options.comment || "";
10026
- const rawComment = encode(comment);
10053
+ let rawComment = encode(comment);
10054
+ if (rawComment === UNDEFINED_VALUE) {
10055
+ rawComment = encodeText(comment);
10056
+ }
10027
10057
  if (getLength(rawComment) > MAX_16_BITS) {
10028
10058
  throw new Error(ERR_INVALID_ENTRY_COMMENT);
10029
10059
  }
@@ -10089,7 +10119,7 @@
10089
10119
  dataDescriptor = true;
10090
10120
  if (zip64 || zip64 === UNDEFINED_VALUE) {
10091
10121
  zip64 = true;
10092
- uncompressedSize = maximumCompressedSize = MAX_32_BITS;
10122
+ uncompressedSize = maximumCompressedSize = MAX_32_BITS + 1;
10093
10123
  }
10094
10124
  } else {
10095
10125
  uncompressedSize = reader.size;
@@ -10097,11 +10127,11 @@
10097
10127
  }
10098
10128
  }
10099
10129
  const { diskOffset, diskNumber, maxSize } = zipWriter.writer;
10100
- const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
10101
- const zip64CompressedSize = zip64Enabled || maximumCompressedSize >= MAX_32_BITS;
10102
- const zip64Offset = zip64Enabled || zipWriter.offset + zipWriter.pendingEntriesSize - diskOffset >= MAX_32_BITS;
10130
+ const zip64UncompressedSize = zip64Enabled || uncompressedSize > MAX_32_BITS;
10131
+ const zip64CompressedSize = zip64Enabled || maximumCompressedSize > MAX_32_BITS;
10132
+ const zip64Offset = zip64Enabled || zipWriter.offset + zipWriter.pendingEntriesSize - diskOffset > MAX_32_BITS;
10103
10133
  const supportZip64SplitFile = getOptionValue(zipWriter, options, "supportZip64SplitFile", true);
10104
- const zip64DiskNumberStart = (supportZip64SplitFile && zip64Enabled) || diskNumber + Math.ceil(zipWriter.pendingEntriesSize / maxSize) >= MAX_16_BITS;
10134
+ const zip64DiskNumberStart = (supportZip64SplitFile && zip64Enabled) || diskNumber + Math.ceil(zipWriter.pendingEntriesSize / maxSize) > MAX_16_BITS;
10105
10135
  if (zip64Offset || zip64UncompressedSize || zip64CompressedSize || zip64DiskNumberStart) {
10106
10136
  if (zip64 === false || !keepOrder) {
10107
10137
  throw new Error(ERR_UNSUPPORTED_FORMAT);
@@ -10126,7 +10156,7 @@
10126
10156
  zip64DiskNumberStart,
10127
10157
  password,
10128
10158
  rawPassword,
10129
- level: !useCompressionStream && zipWriter.config.CompressionStream === UNDEFINED_VALUE ? 0 : level,
10159
+ level: !useCompressionStream && (zipWriter.config.CompressionStream === UNDEFINED_VALUE && zipWriter.config.CompressionStreamNative === UNDEFINED_VALUE) ? 0 : level,
10130
10160
  useWebWorkers,
10131
10161
  encryptionStrength,
10132
10162
  extendedTimestamp,
@@ -10244,7 +10274,7 @@
10244
10274
  fileEntry.offset = zipWriter.offset - diskOffset;
10245
10275
  if (fileEntry.zip64) {
10246
10276
  setZip64ExtraInfo(fileEntry, options);
10247
- } else if (fileEntry.offset >= MAX_32_BITS) {
10277
+ } else if (fileEntry.offset > MAX_32_BITS) {
10248
10278
  throw new Error(ERR_UNSUPPORTED_FORMAT);
10249
10279
  }
10250
10280
  zipWriter.offset += fileEntry.size;
@@ -10861,7 +10891,7 @@
10861
10891
  lastDiskNumber++;
10862
10892
  }
10863
10893
  let zip64 = getOptionValue(zipWriter, options, "zip64");
10864
- if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || filesLength >= MAX_16_BITS || lastDiskNumber >= MAX_16_BITS) {
10894
+ if (directoryOffset > MAX_32_BITS || directoryDataLength > MAX_32_BITS || filesLength > MAX_16_BITS || lastDiskNumber > MAX_16_BITS) {
10865
10895
  if (zip64 === false) {
10866
10896
  throw new Error(ERR_UNSUPPORTED_FORMAT);
10867
10897
  } else {
@@ -11000,6 +11030,7 @@
11000
11030
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11001
11031
  */
11002
11032
 
11033
+
11003
11034
  class ZipEntry {
11004
11035
 
11005
11036
  constructor(fs, name, params, parent) {
@@ -11837,9 +11868,10 @@
11837
11868
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11838
11869
  */
11839
11870
 
11871
+
11840
11872
  let baseURL;
11841
11873
  try {
11842
- baseURL = (typeof document === 'undefined' && typeof location === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : typeof document === 'undefined' ? location.href : (document.currentScript && document.currentScript.src || new URL('zip-fs-full.js', document.baseURI).href));
11874
+ baseURL = (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.src || new URL('zip-fs-full.js', document.baseURI).href));
11843
11875
  } catch (_error) {
11844
11876
  // ignored
11845
11877
  }
@@ -11848,6 +11880,7 @@
11848
11880
 
11849
11881
  /// <reference types="./index.d.ts" />
11850
11882
 
11883
+
11851
11884
  configure({ Deflate: ZipDeflate, Inflate: ZipInflate });
11852
11885
 
11853
11886
  exports.BlobReader = BlobReader;
@@ -11899,6 +11932,4 @@
11899
11932
  exports.initShimAsyncCodec = initShimAsyncCodec;
11900
11933
  exports.terminateWorkers = terminateWorkers;
11901
11934
 
11902
- Object.defineProperty(exports, '__esModule', { value: true });
11903
-
11904
11935
  }));