@zip.js/zip.js 2.6.11 → 2.6.14

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 (72) hide show
  1. package/cli-deno/mc-zip.js +1 -1
  2. package/dist/zip-fs-full.js +26 -17
  3. package/dist/zip-fs-full.min.js +1 -1
  4. package/dist/zip-fs.js +26 -17
  5. package/dist/zip-fs.min.js +1 -1
  6. package/dist/zip-full.js +25 -16
  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 +25 -16
  12. package/dist/zip.min.js +1 -1
  13. package/index.d.ts +3 -2
  14. package/lib/core/io.js +11 -10
  15. package/lib/core/util/cp437-decode.js +12 -5
  16. package/lib/core/zip-fs-core.js +1 -1
  17. package/lib/core/zip-reader.js +2 -1
  18. package/package.json +16 -7
  19. package/tests/all/loader.html +2 -4
  20. package/tests/all/test-abort-signal-read.js +0 -1
  21. package/tests/all/test-abort-signal-write.js +0 -1
  22. package/tests/all/test-array.js +3 -1
  23. package/tests/all/test-base64.js +3 -1
  24. package/tests/all/test-blob.js +5 -1
  25. package/tests/all/test-codecs-interoperability.js +3 -1
  26. package/tests/all/test-crc.js +7 -12
  27. package/tests/all/test-crypto.js +3 -1
  28. package/tests/all/test-custom-io.js +3 -1
  29. package/tests/all/test-data-descriptor-signature.js +7 -1
  30. package/tests/all/test-data-descriptor.js +7 -1
  31. package/tests/all/test-duplicated-filename.js +1 -1
  32. package/tests/all/test-empty.js +3 -1
  33. package/tests/all/test-extended-timestamp.js +3 -1
  34. package/tests/all/test-extra-field.js +3 -2
  35. package/tests/all/test-fflate-no-worker.js +3 -1
  36. package/tests/all/test-fflate.js +3 -1
  37. package/tests/all/test-fs-base64.js +3 -1
  38. package/tests/all/test-fs-export-options.js +3 -1
  39. package/tests/all/test-fs-http-import.js +3 -1
  40. package/tests/all/test-fs-http-reader.js +3 -1
  41. package/tests/all/test-fs-replace.js +3 -1
  42. package/tests/all/test-fs-streams.js +3 -1
  43. package/tests/all/test-fs-text.js +3 -1
  44. package/tests/all/test-fs-unzip-store.js +3 -1
  45. package/tests/all/test-fs.js +3 -1
  46. package/tests/all/test-http-crypto.js +3 -2
  47. package/tests/all/test-http-range.js +3 -2
  48. package/tests/all/test-http-zip64.js +3 -2
  49. package/tests/all/test-invalid-crc.js +3 -1
  50. package/tests/all/test-no-worker.js +3 -1
  51. package/tests/all/test-pako-no-worker.js +3 -1
  52. package/tests/all/test-pako.js +3 -1
  53. package/tests/all/test-parallel-reads.js +3 -1
  54. package/tests/all/test-parallel-writes-auto-buffered.js +3 -1
  55. package/tests/all/test-parallel-writes-ordered.js +4 -2
  56. package/tests/all/test-parallel-writes.js +3 -1
  57. package/tests/all/test-readable-stream.js +8 -12
  58. package/tests/all/test-readable-zip-stream.js +3 -2
  59. package/tests/all/test-safe-closing.js +3 -1
  60. package/tests/all/test-store.js +9 -1
  61. package/tests/all/test-sw-worker.js +0 -1
  62. package/tests/all/test-sw.js +0 -1
  63. package/tests/all/test-worker-timeout.js +7 -12
  64. package/tests/all/test-wrapped.js +4 -2
  65. package/tests/all/test-writable-stream.js +23 -25
  66. package/tests/all/test-zip64-auto.js +3 -1
  67. package/tests/all/test-zip64-crypto.js +3 -1
  68. package/tests/all/test-zip64.js +3 -1
  69. package/tests/all/test-zipcrypto.js +3 -1
  70. package/tests/node-runner.js +17 -9
  71. package/build.sh +0 -3
  72. package/tests/run-tests.sh +0 -3
@@ -36,7 +36,7 @@ async function displayUsage() {
36
36
  await stdout.write(" --data-descriptor-signature add data descriptor signatures (default: false)\n");
37
37
  await stdout.write(" --keep-order keep entries order (default: true)\n");
38
38
  await stdout.write(" --zip64 use Zip64 format (default: false)\n");
39
- await stdout.write(" --prevent-parent-directories remove occurences of \"../\" in filenames\n");
39
+ await stdout.write(" --prevent-parent-directories remove occurences of \"../\" in filenames (default: true)\n");
40
40
  await stdout.write("\n");
41
41
  Deno.exit(-1);
42
42
  }
@@ -7951,18 +7951,19 @@
7951
7951
 
7952
7952
  class Uint8ArrayWriter extends Writer {
7953
7953
 
7954
- constructor() {
7955
- super();
7956
- this.array = new Uint8Array();
7954
+ init(initSize = 0) {
7955
+ this.array = new Uint8Array(initSize);
7957
7956
  }
7958
7957
 
7959
7958
  writeUint8Array(array) {
7960
- super.writeUint8Array(array);
7961
7959
  const writer = this;
7962
- const previousArray = writer.array;
7963
- writer.array = new Uint8Array(previousArray.length + array.length);
7964
- writer.array.set(previousArray);
7965
- writer.array.set(array, previousArray.length);
7960
+ if (writer.size + array.length > writer.array.length) {
7961
+ const previousArray = writer.array;
7962
+ writer.array = new Uint8Array(previousArray.length + array.length);
7963
+ writer.array.set(previousArray);
7964
+ }
7965
+ writer.array.set(array, writer.size);
7966
+ super.writeUint8Array(array);
7966
7967
  }
7967
7968
 
7968
7969
  getData() {
@@ -7976,9 +7977,9 @@
7976
7977
  return protocol == "http:" || protocol == "https:";
7977
7978
  }
7978
7979
 
7979
- async function initStream(stream) {
7980
+ async function initStream(stream, initSize) {
7980
7981
  if (stream.init && !stream.initialized) {
7981
- await stream.init();
7982
+ await stream.init(initSize);
7982
7983
  }
7983
7984
  }
7984
7985
 
@@ -8080,14 +8081,21 @@
8080
8081
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8081
8082
  */
8082
8083
 
8084
+ /* global TextDecoder */
8085
+
8083
8086
  const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
8087
+ const VALID_CP437 = CP437.length == 256;
8084
8088
 
8085
- var decodeCP437 = stringValue => {
8086
- let result = "";
8087
- for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
8088
- result += CP437[stringValue[indexCharacter]];
8089
+ var decodeCP437 = (stringValue) => {
8090
+ if (VALID_CP437) {
8091
+ let result = "";
8092
+ for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
8093
+ result += CP437[stringValue[indexCharacter]];
8094
+ }
8095
+ return result;
8096
+ } else {
8097
+ return new TextDecoder().decode(stringValue);
8089
8098
  }
8090
- return result;
8091
8099
  };
8092
8100
 
8093
8101
  /*
@@ -8390,6 +8398,7 @@
8390
8398
  bitFlag,
8391
8399
  signature,
8392
8400
  rawLastModDate,
8401
+ uncompressedSize,
8393
8402
  compressedSize
8394
8403
  } = zipEntry;
8395
8404
  const localDirectory = zipEntry.localDirectory = {};
@@ -8430,7 +8439,7 @@
8430
8439
  readable.size = size;
8431
8440
  const { writable } = writer;
8432
8441
  const signal = getOptionValue$1(zipEntry, options, "signal");
8433
- await initStream(writer);
8442
+ await initStream(writer, uncompressedSize);
8434
8443
  const { onstart, onprogress, onend } = options;
8435
8444
  const workerOptions = {
8436
8445
  options: {
@@ -9579,7 +9588,7 @@
9579
9588
  return zipEntry.data;
9580
9589
  } else {
9581
9590
  const reader = zipEntry.reader = new zipEntry.Reader(zipEntry.data, options);
9582
- await Promise.all([initStream(reader), initStream(writer)]);
9591
+ await Promise.all([initStream(reader), initStream(writer, zipEntry.data.uncompressedSize)]);
9583
9592
  zipEntry.uncompressedSize = reader.size;
9584
9593
  const readable = reader.readable;
9585
9594
  readable.size = () => reader.size;