@zip.js/zip.js 2.5.24 → 2.6.0
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 +62 -0
- package/cli-deno/mc-zip.js +1 -3
- package/dist/zip-fs-full.js +14 -46
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +14 -46
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +14 -46
- 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 +14 -46
- package/dist/zip.min.js +1 -1
- package/index-fflate.js +1 -5
- package/index.d.ts +2 -14
- package/index.js +1 -5
- package/lib/core/codec-interface.js +1 -3
- package/lib/core/codec-pool.js +4 -15
- package/lib/core/io.js +12 -33
- package/lib/core/zip-fs-core.js +0 -1
- package/lib/core/zip-reader.js +1 -1
- package/lib/zip-fs.js +2 -6
- package/lib/zip-full-fflate.js +2 -6
- package/lib/zip-full.js +2 -6
- package/lib/zip-no-worker-deflate.js +2 -6
- package/lib/zip-no-worker-fflate-deflate.js +2 -6
- package/lib/zip-no-worker-fflate-inflate.js +2 -6
- package/lib/zip-no-worker-fflate.js +2 -6
- package/lib/zip-no-worker-inflate.js +2 -6
- package/lib/zip-no-worker.js +2 -6
- package/lib/zip.js +2 -6
- package/package.json +2 -2
- package/rollup-fflate.config.dev.js +3 -1
- package/rollup-fflate.config.js +3 -1
- package/tests/all/test-abort-signal-read.js +1 -1
- package/tests/all/test-abort-signal-write.js +1 -1
package/lib/core/io.js
CHANGED
|
@@ -26,11 +26,10 @@
|
|
|
26
26
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
-
/* global Blob, atob, btoa, XMLHttpRequest, URL, fetch, ReadableStream, WritableStream */
|
|
29
|
+
/* global Blob, atob, btoa, XMLHttpRequest, URL, fetch, ReadableStream, WritableStream, FileReader */
|
|
30
30
|
|
|
31
31
|
const ERR_HTTP_STATUS = "HTTP error ";
|
|
32
32
|
const ERR_HTTP_RANGE = "HTTP Range not supported";
|
|
33
|
-
const ERR_NOT_SEEKABLE_READER = "Reader is not seekable";
|
|
34
33
|
|
|
35
34
|
const CONTENT_TYPE_TEXT_PLAIN = "text/plain";
|
|
36
35
|
const HTTP_HEADER_CONTENT_LENGTH = "Content-Length";
|
|
@@ -138,7 +137,16 @@ class TextWriter extends Writer {
|
|
|
138
137
|
|
|
139
138
|
getData() {
|
|
140
139
|
const writer = this;
|
|
141
|
-
|
|
140
|
+
if (writer.blob.text && (writer.encoding === undefined || (writer.encoding && writer.encoding.toLowerCase() == "utf-8"))) {
|
|
141
|
+
return writer.blob.text();
|
|
142
|
+
} else {
|
|
143
|
+
const reader = new FileReader();
|
|
144
|
+
return new Promise((resolve, reject) => {
|
|
145
|
+
reader.onload = event => resolve(event.target.result);
|
|
146
|
+
reader.onerror = () => reject(reader.error);
|
|
147
|
+
reader.readAsText(writer.blob, writer.encoding);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
142
150
|
}
|
|
143
151
|
}
|
|
144
152
|
|
|
@@ -258,32 +266,6 @@ function flushArrayBuffers(blobWriter) {
|
|
|
258
266
|
blobWriter.arrayBuffers = [];
|
|
259
267
|
}
|
|
260
268
|
|
|
261
|
-
class ReadableStreamReader extends Stream {
|
|
262
|
-
|
|
263
|
-
constructor(readable) {
|
|
264
|
-
super();
|
|
265
|
-
if (!readable) {
|
|
266
|
-
this.readable = new ReadableStream({});
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
class WritableStreamWriter extends Writer {
|
|
272
|
-
|
|
273
|
-
constructor(writable, { preventClose } = {}) {
|
|
274
|
-
super();
|
|
275
|
-
this.preventClose = preventClose;
|
|
276
|
-
if (!writable) {
|
|
277
|
-
writable = new WritableStream({});
|
|
278
|
-
}
|
|
279
|
-
Object.defineProperty(this, "writable", {
|
|
280
|
-
get() {
|
|
281
|
-
return writable;
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
269
|
class FetchReader extends Reader {
|
|
288
270
|
|
|
289
271
|
constructor(url, options) {
|
|
@@ -550,8 +532,5 @@ export {
|
|
|
550
532
|
Uint8ArrayWriter,
|
|
551
533
|
HttpReader,
|
|
552
534
|
HttpRangeReader,
|
|
553
|
-
|
|
554
|
-
WritableStreamWriter,
|
|
555
|
-
ERR_HTTP_RANGE,
|
|
556
|
-
ERR_NOT_SEEKABLE_READER
|
|
535
|
+
ERR_HTTP_RANGE
|
|
557
536
|
};
|
package/lib/core/zip-fs-core.js
CHANGED
package/lib/core/zip-reader.js
CHANGED
|
@@ -217,7 +217,7 @@ class ZipReader {
|
|
|
217
217
|
const extractPrependedData = getOptionValue(zipReader, options, "extractPrependedData");
|
|
218
218
|
const extractAppendedData = getOptionValue(zipReader, options, "extractAppendedData");
|
|
219
219
|
if (extractPrependedData) {
|
|
220
|
-
zipReader.prependedData = await readUint8Array(reader, 0, startOffset);
|
|
220
|
+
zipReader.prependedData = startOffset > 0 ? await readUint8Array(reader, 0, startOffset) : new Uint8Array();
|
|
221
221
|
}
|
|
222
222
|
zipReader.comment = commentLength ? await readUint8Array(reader, commentOffset + END_OF_CENTRAL_DIR_LENGTH, commentLength) : new Uint8Array();
|
|
223
223
|
if (extractAppendedData) {
|
package/lib/zip-fs.js
CHANGED
|
@@ -30,10 +30,7 @@ import { configure } from "./core/configuration.js";
|
|
|
30
30
|
import configureWebWorker from "./z-worker-inline.js";
|
|
31
31
|
import { getMimeType } from "./core/util/default-mime-type.js";
|
|
32
32
|
import initShimAsyncCodec from "./core/util/stream-codec-shim.js";
|
|
33
|
-
import {
|
|
34
|
-
terminateWorkers,
|
|
35
|
-
ERR_ABORT
|
|
36
|
-
} from "./core/codec-pool.js";
|
|
33
|
+
import { terminateWorkers } from "./core/codec-pool.js";
|
|
37
34
|
|
|
38
35
|
let baseURL;
|
|
39
36
|
try {
|
|
@@ -52,6 +49,5 @@ export {
|
|
|
52
49
|
configure,
|
|
53
50
|
getMimeType,
|
|
54
51
|
initShimAsyncCodec,
|
|
55
|
-
terminateWorkers
|
|
56
|
-
ERR_ABORT
|
|
52
|
+
terminateWorkers
|
|
57
53
|
};
|
package/lib/zip-full-fflate.js
CHANGED
|
@@ -31,10 +31,7 @@ import { configure } from "./core/configuration.js";
|
|
|
31
31
|
import configureWebWorker from "./z-worker-inline.js";
|
|
32
32
|
import { getMimeType } from "./core/util/default-mime-type.js";
|
|
33
33
|
import initShimAsyncCodec from "./core/util/stream-codec-shim.js";
|
|
34
|
-
import {
|
|
35
|
-
terminateWorkers,
|
|
36
|
-
ERR_ABORT
|
|
37
|
-
} from "./core/codec-pool.js";
|
|
34
|
+
import { terminateWorkers } from "./core/codec-pool.js";
|
|
38
35
|
|
|
39
36
|
let baseURL;
|
|
40
37
|
try {
|
|
@@ -52,6 +49,5 @@ export {
|
|
|
52
49
|
configure,
|
|
53
50
|
getMimeType,
|
|
54
51
|
initShimAsyncCodec,
|
|
55
|
-
terminateWorkers
|
|
56
|
-
ERR_ABORT
|
|
52
|
+
terminateWorkers
|
|
57
53
|
};
|
package/lib/zip-full.js
CHANGED
|
@@ -32,10 +32,7 @@ import { configure } from "./core/configuration.js";
|
|
|
32
32
|
import configureWebWorker from "./z-worker-inline.js";
|
|
33
33
|
import { getMimeType } from "./core/util/default-mime-type.js";
|
|
34
34
|
import initShimAsyncCodec from "./core/util/stream-codec-shim.js";
|
|
35
|
-
import {
|
|
36
|
-
terminateWorkers,
|
|
37
|
-
ERR_ABORT
|
|
38
|
-
} from "./core/codec-pool.js";
|
|
35
|
+
import { terminateWorkers } from "./core/codec-pool.js";
|
|
39
36
|
|
|
40
37
|
let baseURL;
|
|
41
38
|
try {
|
|
@@ -53,6 +50,5 @@ export {
|
|
|
53
50
|
configure,
|
|
54
51
|
getMimeType,
|
|
55
52
|
initShimAsyncCodec,
|
|
56
|
-
terminateWorkers
|
|
57
|
-
ERR_ABORT
|
|
53
|
+
terminateWorkers
|
|
58
54
|
};
|
|
@@ -29,10 +29,7 @@
|
|
|
29
29
|
import Deflate from "./core/streams/codecs/deflate.js";
|
|
30
30
|
import { configure } from "./core/configuration.js";
|
|
31
31
|
import { getMimeType } from "./core/util/default-mime-type.js";
|
|
32
|
-
import {
|
|
33
|
-
terminateWorkers,
|
|
34
|
-
ERR_ABORT
|
|
35
|
-
} from "./core/codec-pool.js";
|
|
32
|
+
import { terminateWorkers } from "./core/codec-pool.js";
|
|
36
33
|
|
|
37
34
|
configure({ Deflate });
|
|
38
35
|
|
|
@@ -41,6 +38,5 @@ export * from "./core/zip-writer.js";
|
|
|
41
38
|
export {
|
|
42
39
|
configure,
|
|
43
40
|
getMimeType,
|
|
44
|
-
terminateWorkers
|
|
45
|
-
ERR_ABORT
|
|
41
|
+
terminateWorkers
|
|
46
42
|
};
|
|
@@ -29,10 +29,7 @@
|
|
|
29
29
|
import { Deflate } from "./zip-fflate-shim.js";
|
|
30
30
|
import { configure } from "./core/configuration.js";
|
|
31
31
|
import { getMimeType } from "./core/util/default-mime-type.js";
|
|
32
|
-
import {
|
|
33
|
-
terminateWorkers,
|
|
34
|
-
ERR_ABORT
|
|
35
|
-
} from "./core/codec-pool.js";
|
|
32
|
+
import { terminateWorkers } from "./core/codec-pool.js";
|
|
36
33
|
|
|
37
34
|
configure({ Deflate });
|
|
38
35
|
|
|
@@ -41,6 +38,5 @@ export * from "./core/zip-writer.js";
|
|
|
41
38
|
export {
|
|
42
39
|
configure,
|
|
43
40
|
getMimeType,
|
|
44
|
-
terminateWorkers
|
|
45
|
-
ERR_ABORT
|
|
41
|
+
terminateWorkers
|
|
46
42
|
};
|
|
@@ -29,10 +29,7 @@
|
|
|
29
29
|
import { Inflate } from "./zip-fflate-shim.js";
|
|
30
30
|
import { configure } from "./core/configuration.js";
|
|
31
31
|
import { getMimeType } from "./core/util/default-mime-type.js";
|
|
32
|
-
import {
|
|
33
|
-
terminateWorkers,
|
|
34
|
-
ERR_ABORT
|
|
35
|
-
} from "./core/codec-pool.js";
|
|
32
|
+
import { terminateWorkers } from "./core/codec-pool.js";
|
|
36
33
|
|
|
37
34
|
configure({ Inflate });
|
|
38
35
|
|
|
@@ -41,6 +38,5 @@ export * from "./core/zip-reader.js";
|
|
|
41
38
|
export {
|
|
42
39
|
configure,
|
|
43
40
|
getMimeType,
|
|
44
|
-
terminateWorkers
|
|
45
|
-
ERR_ABORT
|
|
41
|
+
terminateWorkers
|
|
46
42
|
};
|
|
@@ -29,10 +29,7 @@
|
|
|
29
29
|
import { Deflate, Inflate } from "./zip-fflate-shim.js";
|
|
30
30
|
import { configure } from "./core/configuration.js";
|
|
31
31
|
import { getMimeType } from "./core/util/default-mime-type.js";
|
|
32
|
-
import {
|
|
33
|
-
terminateWorkers,
|
|
34
|
-
ERR_ABORT
|
|
35
|
-
} from "./core/codec-pool.js";
|
|
32
|
+
import { terminateWorkers } from "./core/codec-pool.js";
|
|
36
33
|
|
|
37
34
|
configure({ Deflate, Inflate });
|
|
38
35
|
|
|
@@ -42,6 +39,5 @@ export * from "./core/zip-writer.js";
|
|
|
42
39
|
export {
|
|
43
40
|
configure,
|
|
44
41
|
getMimeType,
|
|
45
|
-
terminateWorkers
|
|
46
|
-
ERR_ABORT
|
|
42
|
+
terminateWorkers
|
|
47
43
|
};
|
|
@@ -29,10 +29,7 @@
|
|
|
29
29
|
import Inflate from "./core/streams/codecs/inflate.js";
|
|
30
30
|
import { configure } from "./core/configuration.js";
|
|
31
31
|
import { getMimeType } from "./core/util/default-mime-type.js";
|
|
32
|
-
import {
|
|
33
|
-
terminateWorkers,
|
|
34
|
-
ERR_ABORT
|
|
35
|
-
} from "./core/codec-pool.js";
|
|
32
|
+
import { terminateWorkers } from "./core/codec-pool.js";
|
|
36
33
|
|
|
37
34
|
configure({ Inflate });
|
|
38
35
|
|
|
@@ -41,6 +38,5 @@ export * from "./core/zip-reader.js";
|
|
|
41
38
|
export {
|
|
42
39
|
configure,
|
|
43
40
|
getMimeType,
|
|
44
|
-
terminateWorkers
|
|
45
|
-
ERR_ABORT
|
|
41
|
+
terminateWorkers
|
|
46
42
|
};
|
package/lib/zip-no-worker.js
CHANGED
|
@@ -30,10 +30,7 @@ import Deflate from "./core/streams/codecs/deflate.js";
|
|
|
30
30
|
import Inflate from "./core/streams/codecs/inflate.js";
|
|
31
31
|
import { configure } from "./core/configuration.js";
|
|
32
32
|
import { getMimeType } from "./core/util/default-mime-type.js";
|
|
33
|
-
import {
|
|
34
|
-
terminateWorkers,
|
|
35
|
-
ERR_ABORT
|
|
36
|
-
} from "./core/codec-pool.js";
|
|
33
|
+
import { terminateWorkers } from "./core/codec-pool.js";
|
|
37
34
|
|
|
38
35
|
configure({ Deflate, Inflate });
|
|
39
36
|
|
|
@@ -43,6 +40,5 @@ export * from "./core/zip-writer.js";
|
|
|
43
40
|
export {
|
|
44
41
|
configure,
|
|
45
42
|
getMimeType,
|
|
46
|
-
terminateWorkers
|
|
47
|
-
ERR_ABORT
|
|
43
|
+
terminateWorkers
|
|
48
44
|
};
|
package/lib/zip.js
CHANGED
|
@@ -30,10 +30,7 @@ import { configure } from "./core/configuration.js";
|
|
|
30
30
|
import configureWebWorker from "./z-worker-inline.js";
|
|
31
31
|
import { getMimeType } from "./core/util/default-mime-type.js";
|
|
32
32
|
import initShimAsyncCodec from "./core/util/stream-codec-shim.js";
|
|
33
|
-
import {
|
|
34
|
-
terminateWorkers,
|
|
35
|
-
ERR_ABORT
|
|
36
|
-
} from "./core/codec-pool.js";
|
|
33
|
+
import { terminateWorkers } from "./core/codec-pool.js";
|
|
37
34
|
|
|
38
35
|
let baseURL;
|
|
39
36
|
try {
|
|
@@ -51,6 +48,5 @@ export {
|
|
|
51
48
|
configure,
|
|
52
49
|
getMimeType,
|
|
53
50
|
initShimAsyncCodec,
|
|
54
|
-
terminateWorkers
|
|
55
|
-
ERR_ABORT
|
|
51
|
+
terminateWorkers
|
|
56
52
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "A JavaScript library to zip and unzip files in the browser and Deno",
|
|
4
4
|
"author": "Gildas Lormeau",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.6.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"zip",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
40
40
|
"@rollup/plugin-replace": "^4.0.0",
|
|
41
|
-
"rollup": "^2.
|
|
41
|
+
"rollup": "^2.77.0",
|
|
42
42
|
"rollup-plugin-terser": "^7.0.2"
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// You must install fflate (e.g. npm i fflate) before running this script
|
|
2
|
+
|
|
1
3
|
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
2
4
|
import replace from "@rollup/plugin-replace";
|
|
3
5
|
import fs from "fs";
|
|
@@ -109,7 +111,7 @@ export default [{
|
|
|
109
111
|
}],
|
|
110
112
|
plugins: [nodeResolve()]
|
|
111
113
|
}, {
|
|
112
|
-
input: "lib/z-worker.js",
|
|
114
|
+
input: "lib/z-worker-fflate.js",
|
|
113
115
|
output: [{
|
|
114
116
|
intro: GLOBALS_WORKER,
|
|
115
117
|
file: "dist/z-worker.js",
|
package/rollup-fflate.config.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// You must install fflate (e.g. npm i fflate) before running this script
|
|
2
|
+
|
|
1
3
|
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
2
4
|
import replace from "@rollup/plugin-replace";
|
|
3
5
|
import { terser } from "rollup-plugin-terser";
|
|
@@ -146,7 +148,7 @@ export default [{
|
|
|
146
148
|
}],
|
|
147
149
|
plugins: [nodeResolve()]
|
|
148
150
|
}, {
|
|
149
|
-
input: "lib/z-worker.js",
|
|
151
|
+
input: "lib/z-worker-fflate.js",
|
|
150
152
|
output: [{
|
|
151
153
|
intro: GLOBALS_WORKER,
|
|
152
154
|
file: "dist/z-worker.js",
|