@zip.js/zip.js 2.13.0 → 2.13.1
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/deno.json +1 -1
- package/dist/zip-core-external.js +36 -12
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +36 -12
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +36 -12
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +36 -12
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +36 -12
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +36 -12
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +36 -12
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +36 -12
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +36 -12
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +36 -12
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +36 -12
- package/index-native.min.js +1 -1
- package/index.cjs +36 -12
- package/index.d.cts +6 -0
- package/index.d.ts +6 -0
- package/index.min.js +1 -1
- package/lib/core/codec-worker-web.js +35 -11
- package/lib/core/version.js +1 -1
- package/package.json +1 -1
|
@@ -125,7 +125,7 @@ async function runWebWorker(workerData, config) {
|
|
|
125
125
|
rejectResult = error => {
|
|
126
126
|
const { outputSize, workerOptions } = workerData;
|
|
127
127
|
workerOptions.outputSize = outputSize;
|
|
128
|
-
if (isErrorObject(error)
|
|
128
|
+
if (isErrorObject(error)) {
|
|
129
129
|
try {
|
|
130
130
|
error.outputSize = outputSize;
|
|
131
131
|
} catch {
|
|
@@ -139,12 +139,14 @@ async function runWebWorker(workerData, config) {
|
|
|
139
139
|
reader: null,
|
|
140
140
|
writer: null,
|
|
141
141
|
outputSize: 0,
|
|
142
|
+
destinationFailed: false,
|
|
143
|
+
destinationError: null,
|
|
142
144
|
resolveResult,
|
|
143
145
|
rejectResult,
|
|
144
146
|
result
|
|
145
147
|
});
|
|
146
148
|
const { readable, options } = workerData;
|
|
147
|
-
const { writable, closed, abortPipe } = watchClosedStream(workerData.writable);
|
|
149
|
+
const { writable, closed, abortPipe } = watchClosedStream(workerData.writable, workerData);
|
|
148
150
|
let streamsTransferred;
|
|
149
151
|
try {
|
|
150
152
|
streamsTransferred = sendMessage({
|
|
@@ -187,7 +189,18 @@ async function runWebWorker(workerData, config) {
|
|
|
187
189
|
} catch {
|
|
188
190
|
// ignored
|
|
189
191
|
}
|
|
190
|
-
|
|
192
|
+
const { outputSize, workerOptions, destinationFailed, destinationError } = workerData;
|
|
193
|
+
workerOptions.outputSize = outputSize;
|
|
194
|
+
const workerFailed = isErrorObject(error) && (error.codecImportFailed || error.workerStartupFailed);
|
|
195
|
+
const reportedError = destinationFailed && !workerFailed ? destinationError : error;
|
|
196
|
+
if (isErrorObject(reportedError)) {
|
|
197
|
+
try {
|
|
198
|
+
reportedError.outputSize = outputSize;
|
|
199
|
+
} catch {
|
|
200
|
+
// ignored
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
throw reportedError;
|
|
191
204
|
}
|
|
192
205
|
|
|
193
206
|
async function closeWritable() {
|
|
@@ -201,12 +214,27 @@ async function runWebWorker(workerData, config) {
|
|
|
201
214
|
}
|
|
202
215
|
}
|
|
203
216
|
|
|
204
|
-
function watchClosedStream(writableSource) {
|
|
217
|
+
function watchClosedStream(writableSource, workerData) {
|
|
205
218
|
const abortController = new AbortController();
|
|
206
|
-
|
|
219
|
+
let aborting;
|
|
220
|
+
const { writable, readable } = new TransformStream({
|
|
221
|
+
transform(chunk, controller) {
|
|
222
|
+
workerData.outputSize += chunk.length;
|
|
223
|
+
controller.enqueue(chunk);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
207
226
|
const closed = readable.pipeTo(writableSource, { preventClose: true, preventAbort: true, signal: abortController.signal });
|
|
208
|
-
closed.catch(
|
|
209
|
-
|
|
227
|
+
closed.catch(error => {
|
|
228
|
+
if (!aborting) {
|
|
229
|
+
Object.assign(workerData, { destinationFailed: true, destinationError: error });
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
return {
|
|
233
|
+
writable, closed, abortPipe: () => {
|
|
234
|
+
aborting = true;
|
|
235
|
+
abortController.abort();
|
|
236
|
+
}
|
|
237
|
+
};
|
|
210
238
|
}
|
|
211
239
|
|
|
212
240
|
function releaseWorkerStreams(workerData) {
|
|
@@ -404,9 +432,6 @@ async function onMessage({ data }, workerData) {
|
|
|
404
432
|
const stale = () => workerData.generation != generation;
|
|
405
433
|
try {
|
|
406
434
|
if (error) {
|
|
407
|
-
if (error.outputSize !== UNDEFINED_VALUE) {
|
|
408
|
-
workerData.outputSize = error.outputSize;
|
|
409
|
-
}
|
|
410
435
|
fail(getResponseError(error, errorValue));
|
|
411
436
|
} else {
|
|
412
437
|
if (type == MESSAGE_PULL) {
|
|
@@ -419,7 +444,6 @@ async function onMessage({ data }, workerData) {
|
|
|
419
444
|
const chunk = new Uint8Array(value);
|
|
420
445
|
await writer.ready;
|
|
421
446
|
await writer.write(chunk);
|
|
422
|
-
workerData.outputSize += chunk.length;
|
|
423
447
|
if (!stale()) {
|
|
424
448
|
sendMessage({ type: MESSAGE_ACK_DATA, messageId }, workerData);
|
|
425
449
|
}
|
package/lib/core/version.js
CHANGED
package/package.json
CHANGED