@zip.js/zip.js 2.5.14 → 2.5.15
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/cli-deno/mc-zip.js +21 -19
- package/dist/zip-fs-full.js +2 -1
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +2 -1
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +2 -1
- 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 +2 -1
- package/dist/zip.min.js +1 -1
- package/lib/core/codec-pool-worker.js +2 -1
- package/package.json +1 -1
package/cli-deno/mc-zip.js
CHANGED
|
@@ -7,7 +7,7 @@ import { fromFileUrl, normalize as normalizePath, resolve as resolvePath, extnam
|
|
|
7
7
|
import { configure, ZipWriter, ReadableStreamReader, WritableStreamWriter, terminateWorkers } from "../index.js";
|
|
8
8
|
|
|
9
9
|
const args = parseArgs(Deno.args);
|
|
10
|
-
const stdout =
|
|
10
|
+
const stdout = getTextWriter(Deno.stdout);
|
|
11
11
|
main();
|
|
12
12
|
|
|
13
13
|
async function main() {
|
|
@@ -57,32 +57,28 @@ async function runCommand(zipfile, list, options) {
|
|
|
57
57
|
list = await Promise.all(list.map(getFileInfo));
|
|
58
58
|
list = await Promise.all(list.map(file => addDirectories(file)));
|
|
59
59
|
list = list.flat();
|
|
60
|
+
zipfile = await Deno.open(zipfile, { create: true, write: true });
|
|
60
61
|
configure(options);
|
|
61
|
-
const
|
|
62
|
-
const zipWriter = new ZipWriter(new WritableStreamWriter(targetFile.writable), options);
|
|
62
|
+
const zipWriter = new ZipWriter(new WritableStreamWriter(zipfile.writable), options);
|
|
63
63
|
try {
|
|
64
|
-
await Promise.all(list.map(
|
|
65
|
-
try {
|
|
66
|
-
const readable = await getReadable(file);
|
|
67
|
-
if (readable) {
|
|
68
|
-
await zipWriter.add(file.name, new ReadableStreamReader(readable), {
|
|
69
|
-
onstart: () => stdout.write(" adding: " + file.name + "\n")
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
} catch (error) {
|
|
73
|
-
await stdout.write(" error: " + error.message + ", file: " + file.url + "\n");
|
|
74
|
-
}
|
|
75
|
-
}));
|
|
64
|
+
await Promise.all(list.map(file => addFile(zipWriter, file)));
|
|
76
65
|
await zipWriter.close();
|
|
77
66
|
} finally {
|
|
78
67
|
terminateWorkers();
|
|
79
68
|
}
|
|
80
69
|
}
|
|
81
70
|
|
|
82
|
-
function
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
71
|
+
async function addFile(zipWriter, file) {
|
|
72
|
+
try {
|
|
73
|
+
const readable = await getReadable(file);
|
|
74
|
+
if (readable) {
|
|
75
|
+
await zipWriter.add(file.name, new ReadableStreamReader(readable), {
|
|
76
|
+
onstart: () => stdout.write(" adding: " + file.name + "\n")
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
} catch (error) {
|
|
80
|
+
await stdout.write(" error: " + error.message + ", file: " + file.url + "\n");
|
|
81
|
+
}
|
|
86
82
|
}
|
|
87
83
|
|
|
88
84
|
async function getFileInfo(file) {
|
|
@@ -140,6 +136,12 @@ function isRemote(path) {
|
|
|
140
136
|
return path.startsWith("http:") || path.startsWith("https:");
|
|
141
137
|
}
|
|
142
138
|
|
|
139
|
+
function getTextWriter(stdout) {
|
|
140
|
+
const textEncoderStream = new TextEncoderStream();
|
|
141
|
+
textEncoderStream.readable.pipeTo(stdout.writable);
|
|
142
|
+
return textEncoderStream.writable.getWriter();
|
|
143
|
+
}
|
|
144
|
+
|
|
143
145
|
function trimSlashes(url) {
|
|
144
146
|
const match = url.match(/^(?:\/|\\)?(.*?)(?:\/|\\)?$/);
|
|
145
147
|
if (match) {
|
package/dist/zip-fs-full.js
CHANGED
|
@@ -7172,6 +7172,7 @@
|
|
|
7172
7172
|
workerData.worker.addEventListener(MESSAGE_EVENT_TYPE, onMessage, false);
|
|
7173
7173
|
workerData.interface = {
|
|
7174
7174
|
abort() {
|
|
7175
|
+
workerData.interface.aborted = true;
|
|
7175
7176
|
sendMessage({ type: MESSAGE_ABORT });
|
|
7176
7177
|
workerData.writer.releaseLock();
|
|
7177
7178
|
workerData.onTaskFinished();
|
|
@@ -7254,7 +7255,7 @@
|
|
|
7254
7255
|
}
|
|
7255
7256
|
|
|
7256
7257
|
function close(error, result) {
|
|
7257
|
-
if (error) {
|
|
7258
|
+
if (error && !workerData.interface.aborted) {
|
|
7258
7259
|
rejectResult(error);
|
|
7259
7260
|
} else {
|
|
7260
7261
|
resolveResult(result);
|