@zip.js/zip.js 2.7.66 → 2.7.68

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.
@@ -29,6 +29,7 @@
29
29
  const MAX_32_BITS = 0xffffffff;
30
30
  const MAX_16_BITS = 0xffff;
31
31
  const COMPRESSION_METHOD_DEFLATE = 0x08;
32
+ const COMPRESSION_METHOD_DEFLATE_64 = 0x09;
32
33
  const COMPRESSION_METHOD_STORE = 0x00;
33
34
  const COMPRESSION_METHOD_AES = 0x63;
34
35
 
@@ -88,6 +89,7 @@ export {
88
89
  MAX_32_BITS,
89
90
  MAX_16_BITS,
90
91
  COMPRESSION_METHOD_DEFLATE,
92
+ COMPRESSION_METHOD_DEFLATE_64,
91
93
  COMPRESSION_METHOD_STORE,
92
94
  COMPRESSION_METHOD_AES,
93
95
  SPLIT_ZIP_FILE_SIGNATURE,
package/lib/core/io.js CHANGED
@@ -378,11 +378,18 @@ async function readUint8ArrayHttpReader(httpReader, index, length, sendRequest,
378
378
  if (eocdCache && index == size - END_OF_CENTRAL_DIR_LENGTH && length == END_OF_CENTRAL_DIR_LENGTH) {
379
379
  return eocdCache;
380
380
  }
381
- const response = await sendRequest(HTTP_METHOD_GET, httpReader, getRangeHeaders(httpReader, index, length));
382
- if (response.status != 206) {
383
- throw new Error(ERR_HTTP_RANGE);
381
+ if (index >= size) {
382
+ return new Uint8Array();
383
+ } else {
384
+ if (index + length > size) {
385
+ length = size - index;
386
+ }
387
+ const response = await sendRequest(HTTP_METHOD_GET, httpReader, getRangeHeaders(httpReader, index, length));
388
+ if (response.status != 206) {
389
+ throw new Error(ERR_HTTP_RANGE);
390
+ }
391
+ return new Uint8Array(await response.arrayBuffer());
384
392
  }
385
- return new Uint8Array(await response.arrayBuffer());
386
393
  } else {
387
394
  const { data } = httpReader;
388
395
  if (!data) {
@@ -26,13 +26,14 @@
26
26
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
27
  */
28
28
 
29
- /* global TransformStream, Response, ReadableStream */
29
+ /* global TransformStream, Response */
30
30
  // deno-lint-ignore-file no-this-alias
31
31
 
32
32
  import {
33
33
  MAX_32_BITS,
34
34
  MAX_16_BITS,
35
35
  COMPRESSION_METHOD_DEFLATE,
36
+ COMPRESSION_METHOD_DEFLATE_64,
36
37
  COMPRESSION_METHOD_STORE,
37
38
  COMPRESSION_METHOD_AES,
38
39
  SPLIT_ZIP_FILE_SIGNATURE,
@@ -152,27 +153,11 @@ class ZipWriter {
152
153
  if (this.filenames.size) {
153
154
  throw new Error(ERR_ZIP_NOT_EMPTY);
154
155
  }
155
- ({ reader } = new GenericReader(reader));
156
- const [zipEntriesReader, zipDataReader] = reader.readable.tee();
157
- const zipReader = new ZipReader(new ReadableStream({
158
- async start(controller) {
159
- const reader = zipEntriesReader.getReader();
160
- await readChunk();
161
-
162
- async function readChunk() {
163
- const { done, value } = await reader.read();
164
- if (done) {
165
- controller.close();
166
- } else {
167
- controller.enqueue(value);
168
- await readChunk();
169
- }
170
- }
171
- }
172
- }));
156
+ reader = new GenericReader(reader);
157
+ const zipReader = new ZipReader(reader.readable);
173
158
  const entries = await zipReader.getEntries();
174
159
  await zipReader.close();
175
- await zipDataReader.pipeTo(this.writer.writable, { preventClose: true, preventAbort: true });
160
+ await reader.readable.pipeTo(this.writer.writable, { preventClose: true, preventAbort: true });
176
161
  this.writer.size = this.offset = reader.size;
177
162
  this.filenames = new Set(entries.map(entry => entry.filename));
178
163
  this.files = new Map(entries.map(entry => {
@@ -212,7 +197,7 @@ class ZipWriter {
212
197
  headerView
213
198
  } = getHeaderArrayData({
214
199
  version,
215
- bitFlag: getBitFlag(level, languageEncodingFlag, dataDescriptor, encrypted),
200
+ bitFlag: getBitFlag(level, languageEncodingFlag, dataDescriptor, encrypted, compressionMethod),
216
201
  compressionMethod,
217
202
  uncompressedSize,
218
203
  compressedSize,
@@ -1014,7 +999,7 @@ function getHeaderInfo(options) {
1014
999
  rawLastModDate
1015
1000
  } = getHeaderArrayData({
1016
1001
  version,
1017
- bitFlag: getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted),
1002
+ bitFlag: getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted, compressionMethod),
1018
1003
  compressionMethod,
1019
1004
  uncompressedSize,
1020
1005
  lastModDate: lastModDate < MIN_DATE ? MIN_DATE : lastModDate > MAX_DATE ? MAX_DATE : lastModDate,
@@ -1502,8 +1487,7 @@ function getHeaderArrayData({
1502
1487
  };
1503
1488
  }
1504
1489
 
1505
-
1506
- function getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted) {
1490
+ function getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted, compressionMethod) {
1507
1491
  let bitFlag = 0;
1508
1492
  if (useUnicodeFileNames) {
1509
1493
  bitFlag = bitFlag | BITFLAG_LANG_ENCODING_FLAG;
@@ -1511,14 +1495,16 @@ function getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted) {
1511
1495
  if (dataDescriptor) {
1512
1496
  bitFlag = bitFlag | BITFLAG_DATA_DESCRIPTOR;
1513
1497
  }
1514
- if (level > 0 && level <= 3) {
1515
- bitFlag = bitFlag | BITFLAG_LEVEL_SUPER_FAST_MASK;
1516
- }
1517
- if (level > 3 && level <= 5) {
1518
- bitFlag = bitFlag | BITFLAG_LEVEL_FAST_MASK;
1519
- }
1520
- if (level == 9) {
1521
- bitFlag = bitFlag | BITFLAG_LEVEL_MAX_MASK;
1498
+ if (compressionMethod == COMPRESSION_METHOD_DEFLATE || compressionMethod == COMPRESSION_METHOD_DEFLATE_64) {
1499
+ if (level >= 0 && level <= 3) {
1500
+ bitFlag = bitFlag | BITFLAG_LEVEL_SUPER_FAST_MASK;
1501
+ }
1502
+ if (level > 3 && level <= 5) {
1503
+ bitFlag = bitFlag | BITFLAG_LEVEL_FAST_MASK;
1504
+ }
1505
+ if (level == 9) {
1506
+ bitFlag = bitFlag | BITFLAG_LEVEL_MAX_MASK;
1507
+ }
1522
1508
  }
1523
1509
  if (encrypted) {
1524
1510
  bitFlag = bitFlag | BITFLAG_ENCRYPTED;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A JavaScript library to zip and unzip files in the browser, Deno and Node.js",
4
4
  "author": "Gildas Lormeau",
5
5
  "license": "BSD-3-Clause",
6
- "version": "2.7.66",
6
+ "version": "2.7.68",
7
7
  "type": "module",
8
8
  "keywords": [
9
9
  "zip",
@@ -124,6 +124,6 @@
124
124
  "http-server": "^14.1.1",
125
125
  "rollup": "^4.45.1",
126
126
  "typedoc": "^0.28.7",
127
- "typedoc-plugin-markdown": "^4.7.0"
127
+ "typedoc-plugin-markdown": "^4.7.1"
128
128
  }
129
129
  }