@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/dist/zip-fs.js CHANGED
@@ -3053,7 +3053,7 @@
3053
3053
  rejectResult = error => {
3054
3054
  const { outputSize, workerOptions } = workerData;
3055
3055
  workerOptions.outputSize = outputSize;
3056
- if (isErrorObject(error) && error.outputSize === UNDEFINED_VALUE) {
3056
+ if (isErrorObject(error)) {
3057
3057
  try {
3058
3058
  error.outputSize = outputSize;
3059
3059
  } catch {
@@ -3067,12 +3067,14 @@
3067
3067
  reader: null,
3068
3068
  writer: null,
3069
3069
  outputSize: 0,
3070
+ destinationFailed: false,
3071
+ destinationError: null,
3070
3072
  resolveResult,
3071
3073
  rejectResult,
3072
3074
  result
3073
3075
  });
3074
3076
  const { readable, options } = workerData;
3075
- const { writable, closed, abortPipe } = watchClosedStream(workerData.writable);
3077
+ const { writable, closed, abortPipe } = watchClosedStream(workerData.writable, workerData);
3076
3078
  let streamsTransferred;
3077
3079
  try {
3078
3080
  streamsTransferred = sendMessage({
@@ -3115,7 +3117,18 @@
3115
3117
  } catch {
3116
3118
  // ignored
3117
3119
  }
3118
- throw error;
3120
+ const { outputSize, workerOptions, destinationFailed, destinationError } = workerData;
3121
+ workerOptions.outputSize = outputSize;
3122
+ const workerFailed = isErrorObject(error) && (error.codecImportFailed || error.workerStartupFailed);
3123
+ const reportedError = destinationFailed && !workerFailed ? destinationError : error;
3124
+ if (isErrorObject(reportedError)) {
3125
+ try {
3126
+ reportedError.outputSize = outputSize;
3127
+ } catch {
3128
+ // ignored
3129
+ }
3130
+ }
3131
+ throw reportedError;
3119
3132
  }
3120
3133
 
3121
3134
  async function closeWritable() {
@@ -3129,12 +3142,27 @@
3129
3142
  }
3130
3143
  }
3131
3144
 
3132
- function watchClosedStream(writableSource) {
3145
+ function watchClosedStream(writableSource, workerData) {
3133
3146
  const abortController = new AbortController();
3134
- const { writable, readable } = new TransformStream();
3147
+ let aborting;
3148
+ const { writable, readable } = new TransformStream({
3149
+ transform(chunk, controller) {
3150
+ workerData.outputSize += chunk.length;
3151
+ controller.enqueue(chunk);
3152
+ }
3153
+ });
3135
3154
  const closed = readable.pipeTo(writableSource, { preventClose: true, preventAbort: true, signal: abortController.signal });
3136
- closed.catch(() => { });
3137
- return { writable, closed, abortPipe: () => abortController.abort() };
3155
+ closed.catch(error => {
3156
+ if (!aborting) {
3157
+ Object.assign(workerData, { destinationFailed: true, destinationError: error });
3158
+ }
3159
+ });
3160
+ return {
3161
+ writable, closed, abortPipe: () => {
3162
+ aborting = true;
3163
+ abortController.abort();
3164
+ }
3165
+ };
3138
3166
  }
3139
3167
 
3140
3168
  function releaseWorkerStreams(workerData) {
@@ -3332,9 +3360,6 @@
3332
3360
  const stale = () => workerData.generation != generation;
3333
3361
  try {
3334
3362
  if (error) {
3335
- if (error.outputSize !== UNDEFINED_VALUE) {
3336
- workerData.outputSize = error.outputSize;
3337
- }
3338
3363
  fail(getResponseError(error, errorValue));
3339
3364
  } else {
3340
3365
  if (type == MESSAGE_PULL) {
@@ -3347,7 +3372,6 @@
3347
3372
  const chunk = new Uint8Array(value);
3348
3373
  await writer.ready;
3349
3374
  await writer.write(chunk);
3350
- workerData.outputSize += chunk.length;
3351
3375
  if (!stale()) {
3352
3376
  sendMessage({ type: MESSAGE_ACK_DATA, messageId }, workerData);
3353
3377
  }
@@ -9084,7 +9108,7 @@
9084
9108
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9085
9109
  */
9086
9110
 
9087
- const VERSION = "2.13.0";
9111
+ const VERSION = "2.13.1";
9088
9112
 
9089
9113
  /*
9090
9114
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.