@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.
@@ -3047,7 +3047,7 @@
3047
3047
  rejectResult = error => {
3048
3048
  const { outputSize, workerOptions } = workerData;
3049
3049
  workerOptions.outputSize = outputSize;
3050
- if (isErrorObject(error) && error.outputSize === UNDEFINED_VALUE) {
3050
+ if (isErrorObject(error)) {
3051
3051
  try {
3052
3052
  error.outputSize = outputSize;
3053
3053
  } catch {
@@ -3061,12 +3061,14 @@
3061
3061
  reader: null,
3062
3062
  writer: null,
3063
3063
  outputSize: 0,
3064
+ destinationFailed: false,
3065
+ destinationError: null,
3064
3066
  resolveResult,
3065
3067
  rejectResult,
3066
3068
  result
3067
3069
  });
3068
3070
  const { readable, options } = workerData;
3069
- const { writable, closed, abortPipe } = watchClosedStream(workerData.writable);
3071
+ const { writable, closed, abortPipe } = watchClosedStream(workerData.writable, workerData);
3070
3072
  let streamsTransferred;
3071
3073
  try {
3072
3074
  streamsTransferred = sendMessage({
@@ -3109,7 +3111,18 @@
3109
3111
  } catch {
3110
3112
  // ignored
3111
3113
  }
3112
- throw error;
3114
+ const { outputSize, workerOptions, destinationFailed, destinationError } = workerData;
3115
+ workerOptions.outputSize = outputSize;
3116
+ const workerFailed = isErrorObject(error) && (error.codecImportFailed || error.workerStartupFailed);
3117
+ const reportedError = destinationFailed && !workerFailed ? destinationError : error;
3118
+ if (isErrorObject(reportedError)) {
3119
+ try {
3120
+ reportedError.outputSize = outputSize;
3121
+ } catch {
3122
+ // ignored
3123
+ }
3124
+ }
3125
+ throw reportedError;
3113
3126
  }
3114
3127
 
3115
3128
  async function closeWritable() {
@@ -3123,12 +3136,27 @@
3123
3136
  }
3124
3137
  }
3125
3138
 
3126
- function watchClosedStream(writableSource) {
3139
+ function watchClosedStream(writableSource, workerData) {
3127
3140
  const abortController = new AbortController();
3128
- const { writable, readable } = new TransformStream();
3141
+ let aborting;
3142
+ const { writable, readable } = new TransformStream({
3143
+ transform(chunk, controller) {
3144
+ workerData.outputSize += chunk.length;
3145
+ controller.enqueue(chunk);
3146
+ }
3147
+ });
3129
3148
  const closed = readable.pipeTo(writableSource, { preventClose: true, preventAbort: true, signal: abortController.signal });
3130
- closed.catch(() => { });
3131
- return { writable, closed, abortPipe: () => abortController.abort() };
3149
+ closed.catch(error => {
3150
+ if (!aborting) {
3151
+ Object.assign(workerData, { destinationFailed: true, destinationError: error });
3152
+ }
3153
+ });
3154
+ return {
3155
+ writable, closed, abortPipe: () => {
3156
+ aborting = true;
3157
+ abortController.abort();
3158
+ }
3159
+ };
3132
3160
  }
3133
3161
 
3134
3162
  function releaseWorkerStreams(workerData) {
@@ -3326,9 +3354,6 @@
3326
3354
  const stale = () => workerData.generation != generation;
3327
3355
  try {
3328
3356
  if (error) {
3329
- if (error.outputSize !== UNDEFINED_VALUE) {
3330
- workerData.outputSize = error.outputSize;
3331
- }
3332
3357
  fail(getResponseError(error, errorValue));
3333
3358
  } else {
3334
3359
  if (type == MESSAGE_PULL) {
@@ -3341,7 +3366,6 @@
3341
3366
  const chunk = new Uint8Array(value);
3342
3367
  await writer.ready;
3343
3368
  await writer.write(chunk);
3344
- workerData.outputSize += chunk.length;
3345
3369
  if (!stale()) {
3346
3370
  sendMessage({ type: MESSAGE_ACK_DATA, messageId }, workerData);
3347
3371
  }
@@ -9078,7 +9102,7 @@
9078
9102
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9079
9103
  */
9080
9104
 
9081
- const VERSION = "2.13.0";
9105
+ const VERSION = "2.13.1";
9082
9106
 
9083
9107
  /*
9084
9108
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.