@zip.js/zip.js 2.6.24 → 2.6.26

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 (52) hide show
  1. package/README.md +16 -17
  2. package/dist/z-worker-fflate.js +1 -1
  3. package/dist/z-worker-pako.js +1 -1
  4. package/dist/z-worker.js +1 -1
  5. package/dist/zip-fs-full.js +3698 -3693
  6. package/dist/zip-fs-full.min.js +1 -1
  7. package/dist/zip-fs.js +89 -73
  8. package/dist/zip-fs.min.js +1 -1
  9. package/dist/zip-full.js +3675 -3670
  10. package/dist/zip-full.min.js +1 -1
  11. package/dist/zip-no-worker-deflate.min.js +1 -1
  12. package/dist/zip-no-worker-inflate.min.js +1 -1
  13. package/dist/zip-no-worker.min.js +1 -1
  14. package/dist/zip.js +89 -73
  15. package/dist/zip.min.js +1 -1
  16. package/index.d.ts +11 -11
  17. package/index.js +2 -2
  18. package/lib/core/codec-interface.js +36 -19
  19. package/lib/core/codec-pool-worker.js +2 -2
  20. package/lib/core/codec-pool.js +2 -2
  21. package/lib/core/streams/aes-crypto-stream.js +1 -1
  22. package/lib/core/streams/codec-stream.js +3 -1
  23. package/lib/core/streams/codecs/crc32.js +3 -1
  24. package/lib/core/streams/codecs/deflate.js +1792 -1796
  25. package/lib/core/streams/codecs/inflate.js +1828 -1831
  26. package/lib/core/streams/crc32-stream.js +7 -7
  27. package/lib/core/streams/zip-crypto-stream.js +1 -1
  28. package/lib/core/streams/zip-entry-stream.js +2 -2
  29. package/lib/core/util/cp437-decode.js +6 -2
  30. package/lib/core/util/decode-text.js +4 -2
  31. package/lib/core/util/encode-text.js +3 -1
  32. package/lib/core/util/stream-codec-shim.js +6 -2
  33. package/lib/core/zip-entry.js +6 -2
  34. package/lib/core/zip-reader.js +17 -5
  35. package/lib/core/zip-writer.js +27 -10
  36. package/lib/z-worker-bootstrap-fflate.js +1 -1
  37. package/lib/z-worker-bootstrap-pako.js +1 -1
  38. package/lib/z-worker-inline-template.js +9 -7
  39. package/lib/z-worker-inline.js +1 -1
  40. package/lib/z-worker.js +2 -2
  41. package/lib/zip-fflate-shim.js +1 -1
  42. package/lib/zip-fs.js +2 -2
  43. package/lib/zip-full-fflate.js +2 -2
  44. package/lib/zip-full.js +4 -4
  45. package/lib/zip-no-worker-deflate.js +1 -1
  46. package/lib/zip-no-worker-inflate.js +1 -1
  47. package/lib/zip-no-worker.js +2 -2
  48. package/lib/zip.js +2 -2
  49. package/package.json +1 -1
  50. package/tests/all/test-streams.js +29 -0
  51. package/tests/tests-data.js +1 -0
  52. package/lib/z-worker-inline-template-base64.js +0 -36
@@ -61,30 +61,47 @@ export {
61
61
 
62
62
  class Codec {
63
63
 
64
- constructor(codecConstructor, readable, writable, options, config) {
64
+ constructor(CodecConstructor, readable, writable, options, config) {
65
65
  const { codecType } = options;
66
+ let StreamConstructor;
66
67
  if (codecType.startsWith(CODEC_DEFLATE)) {
67
- this.run = () => run(DeflateStream);
68
+ StreamConstructor = DeflateStream;
68
69
  } else if (codecType.startsWith(CODEC_INFLATE)) {
69
- this.run = () => run(InflateStream);
70
+ StreamConstructor = InflateStream;
70
71
  }
72
+ Object.assign(this, {
73
+ StreamConstructor,
74
+ CodecConstructor,
75
+ readable,
76
+ writable,
77
+ options,
78
+ config
79
+ });
80
+ }
71
81
 
72
- async function run(StreamConstructor) {
73
- const stream = new StreamConstructor(codecConstructor, options, config);
74
- let size = 0;
75
- await readable
76
- .pipeThrough(stream)
77
- .pipeThrough(new TransformStream({
78
- transform(chunk, controller) {
79
- if (chunk && chunk.length) {
80
- size += chunk.length;
81
- controller.enqueue(chunk);
82
- }
82
+ async run() {
83
+ const {
84
+ StreamConstructor,
85
+ CodecConstructor,
86
+ readable,
87
+ writable,
88
+ options,
89
+ config
90
+ } = this;
91
+ const stream = new StreamConstructor(CodecConstructor, options, config);
92
+ let size = 0;
93
+ await readable
94
+ .pipeThrough(stream)
95
+ .pipeThrough(new TransformStream({
96
+ transform(chunk, controller) {
97
+ if (chunk && chunk.length) {
98
+ size += chunk.length;
99
+ controller.enqueue(chunk);
83
100
  }
84
- }))
85
- .pipeTo(writable, { preventClose: true, preventAbort: true });
86
- const { signature } = stream;
87
- return { size, signature };
88
- }
101
+ }
102
+ }))
103
+ .pipeTo(writable, { preventClose: true, preventAbort: true });
104
+ const { signature } = stream;
105
+ return { size, signature };
89
106
  }
90
107
  }
@@ -50,7 +50,7 @@ class CodecWorker {
50
50
 
51
51
  constructor(workerData, stream, workerOptions, onTaskFinished) {
52
52
  const { readable, writable } = stream;
53
- const { options, config, streamOptions, webWorker, transferStreams, scripts, codecConstructor } = workerOptions;
53
+ const { options, config, streamOptions, useWebWorkers, transferStreams, scripts, codecConstructor } = workerOptions;
54
54
  Object.assign(workerData, {
55
55
  busy: true,
56
56
  codecConstructor,
@@ -93,7 +93,7 @@ class CodecWorker {
93
93
  if (workersSupported === undefined) {
94
94
  workersSupported = typeof Worker != "undefined";
95
95
  }
96
- return webWorker && workersSupported ? createWebWorkerInterface(workerData, config) : createWorkerInterface(workerData, config);
96
+ return useWebWorkers && workersSupported ? createWebWorkerInterface(workerData, config) : createWorkerInterface(workerData, config);
97
97
  }
98
98
  }
99
99
 
@@ -56,8 +56,8 @@ async function runWorker(stream, workerOptions) {
56
56
  const { workerScripts } = config;
57
57
  workerOptions.transferStreams = transferStreams || transferStreams === undefined;
58
58
  const streamCopy = !compressed && !signed && !encrypted && !workerOptions.transferStreams;
59
- workerOptions.webWorker = !streamCopy && (useWebWorkers || (useWebWorkers === undefined && config.useWebWorkers));
60
- workerOptions.scripts = workerOptions.webWorker && workerScripts ? workerScripts[codecType] : [];
59
+ workerOptions.useWebWorkers = !streamCopy && (useWebWorkers || (useWebWorkers === undefined && config.useWebWorkers));
60
+ workerOptions.scripts = workerOptions.useWebWorkers && workerScripts ? workerScripts[codecType] : [];
61
61
  options.useCompressionStream = useCompressionStream === undefined ? config.useCompressionStream : useCompressionStream;
62
62
  let worker;
63
63
  if (pool.length < config.maxWorkers) {
@@ -29,7 +29,7 @@
29
29
  /* global crypto, TransformStream */
30
30
  // deno-lint-ignore-file no-this-alias
31
31
 
32
- import encodeText from "./../util/encode-text.js";
32
+ import { encodeText } from "./../util/encode-text.js";
33
33
  import {
34
34
  cipher,
35
35
  codec,
@@ -57,4 +57,6 @@ class CodecStream extends TransformStream {
57
57
  }
58
58
  }
59
59
 
60
- export default CodecStream;
60
+ export {
61
+ CodecStream
62
+ };
@@ -58,4 +58,6 @@ class Crc32 {
58
58
  }
59
59
  }
60
60
 
61
- export default Crc32;
61
+ export {
62
+ Crc32
63
+ };