@zip.js/zip.js 2.11.3 → 2.11.4

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.
@@ -217,6 +217,8 @@
217
217
  const ERR_INVALID_FUNCTION_OPTION = "Invalid option (must be a function)";
218
218
  const ERR_INVALID_SIGNAL = "Invalid signal (must be an AbortSignal instance)";
219
219
  const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
220
+ const ERR_ABORTED = "The operation was aborted";
221
+ const ABORT_ERROR_NAME = "AbortError";
220
222
 
221
223
  function checkFunctionOption(value) {
222
224
  if (value && typeof value != FUNCTION_TYPE) {
@@ -232,6 +234,12 @@
232
234
  return signal || UNDEFINED_VALUE;
233
235
  }
234
236
 
237
+ function throwIfAborted(signal) {
238
+ if (signal && signal.aborted) {
239
+ throw signal.reason === UNDEFINED_VALUE ? new DOMException(ERR_ABORTED, ABORT_ERROR_NAME) : signal.reason;
240
+ }
241
+ }
242
+
235
243
  function checkPasswordOption(password, rawPassword) {
236
244
  if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
237
245
  throw new Error(ERR_INVALID_PASSWORD_TYPE);
@@ -3756,11 +3764,13 @@
3756
3764
  const reader = this;
3757
3765
  const { sourceBlob, size } = reader;
3758
3766
  const { offset = 0, size: readSize = size - offset } = options || {};
3759
- if (!offset && readSize >= size) {
3760
- return toCompatibleReadable(sourceBlob.stream());
3761
- }
3762
- if (blobSliceReliable) {
3763
- return toCompatibleReadable(sourceBlob.slice(offset, offset + readSize).stream());
3767
+ if (typeof sourceBlob.stream == FUNCTION_TYPE) {
3768
+ if (!offset && readSize >= size) {
3769
+ return toCompatibleReadable(sourceBlob.stream());
3770
+ }
3771
+ if (blobSliceReliable) {
3772
+ return toCompatibleReadable(sourceBlob.slice(offset, offset + readSize).stream());
3773
+ }
3764
3774
  }
3765
3775
  return super.createReadable(options);
3766
3776
  }
@@ -5176,27 +5186,28 @@
5176
5186
  const { done, value } = await gen.next();
5177
5187
  if (done)
5178
5188
  return controller.close();
5179
- const chunk = {
5180
- ...value,
5181
- readable: (function () {
5182
- const { readable, writable } = new TransformStream();
5183
- if (value.getData) {
5184
- getData();
5185
- return readable;
5186
- }
5189
+ const entryReadable = (function () {
5190
+ const { readable, writable } = new TransformStream();
5191
+ if (value.getData) {
5192
+ getData();
5193
+ return readable;
5194
+ }
5187
5195
 
5188
- async function getData() {
5196
+ async function getData() {
5197
+ try {
5198
+ await value.getData(writable);
5199
+ } catch (error) {
5189
5200
  try {
5190
- await value.getData(writable);
5191
- } catch (error) {
5192
- try {
5193
- await writable.abort(error);
5194
- } catch {
5195
- // ignored
5196
- }
5201
+ await writable.abort(error);
5202
+ } catch {
5203
+ // ignored
5197
5204
  }
5198
5205
  }
5199
- })()
5206
+ }
5207
+ })();
5208
+ const chunk = {
5209
+ ...value,
5210
+ readable: entryReadable
5200
5211
  };
5201
5212
  delete chunk.getData;
5202
5213
  controller.enqueue(chunk);
@@ -5342,6 +5353,7 @@
5342
5353
  const size = compressedSize;
5343
5354
  const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
5344
5355
  const signal = checkSignalOption(getOptionValue$1(zipEntry, options, OPTION_SIGNAL));
5356
+ throwIfAborted(signal);
5345
5357
  const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
5346
5358
  let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
5347
5359
  const checkOverlappingEntryOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY_ONLY);
@@ -6872,6 +6884,7 @@
6872
6884
  const createTempStream = getFunctionOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
6873
6885
  const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, true);
6874
6886
  const signal = checkSignalOption(getOptionValue(zipWriter, options, OPTION_SIGNAL));
6887
+ throwIfAborted(signal);
6875
6888
  const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
6876
6889
  const compressionMethod = getOptionValue(zipWriter, options, PROPERTY_NAME_COMPRESSION_METHOD);
6877
6890
  const registeredCodec = passThrough || compressionMethod === UNDEFINED_VALUE ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
@@ -8539,7 +8552,7 @@
8539
8552
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8540
8553
  */
8541
8554
 
8542
- const VERSION = "2.11.3";
8555
+ const VERSION = "2.11.4";
8543
8556
 
8544
8557
  /*
8545
8558
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.