@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.
- package/README.md +16 -17
- package/dist/z-worker-fflate.js +1 -1
- package/dist/z-worker-pako.js +1 -1
- package/dist/z-worker.js +1 -1
- package/dist/zip-fs-full.js +3698 -3693
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +89 -73
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +3675 -3670
- package/dist/zip-full.min.js +1 -1
- package/dist/zip-no-worker-deflate.min.js +1 -1
- package/dist/zip-no-worker-inflate.min.js +1 -1
- package/dist/zip-no-worker.min.js +1 -1
- package/dist/zip.js +89 -73
- package/dist/zip.min.js +1 -1
- package/index.d.ts +11 -11
- package/index.js +2 -2
- package/lib/core/codec-interface.js +36 -19
- package/lib/core/codec-pool-worker.js +2 -2
- package/lib/core/codec-pool.js +2 -2
- package/lib/core/streams/aes-crypto-stream.js +1 -1
- package/lib/core/streams/codec-stream.js +3 -1
- package/lib/core/streams/codecs/crc32.js +3 -1
- package/lib/core/streams/codecs/deflate.js +1792 -1796
- package/lib/core/streams/codecs/inflate.js +1828 -1831
- package/lib/core/streams/crc32-stream.js +7 -7
- package/lib/core/streams/zip-crypto-stream.js +1 -1
- package/lib/core/streams/zip-entry-stream.js +2 -2
- package/lib/core/util/cp437-decode.js +6 -2
- package/lib/core/util/decode-text.js +4 -2
- package/lib/core/util/encode-text.js +3 -1
- package/lib/core/util/stream-codec-shim.js +6 -2
- package/lib/core/zip-entry.js +6 -2
- package/lib/core/zip-reader.js +17 -5
- package/lib/core/zip-writer.js +27 -10
- package/lib/z-worker-bootstrap-fflate.js +1 -1
- package/lib/z-worker-bootstrap-pako.js +1 -1
- package/lib/z-worker-inline-template.js +9 -7
- package/lib/z-worker-inline.js +1 -1
- package/lib/z-worker.js +2 -2
- package/lib/zip-fflate-shim.js +1 -1
- package/lib/zip-fs.js +2 -2
- package/lib/zip-full-fflate.js +2 -2
- package/lib/zip-full.js +4 -4
- package/lib/zip-no-worker-deflate.js +1 -1
- package/lib/zip-no-worker-inflate.js +1 -1
- package/lib/zip-no-worker.js +2 -2
- package/lib/zip.js +2 -2
- package/package.json +1 -1
- package/tests/all/test-streams.js +29 -0
- package/tests/tests-data.js +1 -0
- 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(
|
|
64
|
+
constructor(CodecConstructor, readable, writable, options, config) {
|
|
65
65
|
const { codecType } = options;
|
|
66
|
+
let StreamConstructor;
|
|
66
67
|
if (codecType.startsWith(CODEC_DEFLATE)) {
|
|
67
|
-
|
|
68
|
+
StreamConstructor = DeflateStream;
|
|
68
69
|
} else if (codecType.startsWith(CODEC_INFLATE)) {
|
|
69
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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,
|
|
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
|
|
96
|
+
return useWebWorkers && workersSupported ? createWebWorkerInterface(workerData, config) : createWorkerInterface(workerData, config);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
package/lib/core/codec-pool.js
CHANGED
|
@@ -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.
|
|
60
|
-
workerOptions.scripts = workerOptions.
|
|
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) {
|