@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.
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zip-js/zip-js",
3
- "version": "2.11.3",
3
+ "version": "2.11.4",
4
4
  "exports": {
5
5
  ".": "./index.js",
6
6
  "./external": "./lib/zip-fs-external.js",
@@ -208,6 +208,8 @@ const STRICTNESS_TOLERANT = "tolerant";
208
208
  const ERR_INVALID_FUNCTION_OPTION = "Invalid option (must be a function)";
209
209
  const ERR_INVALID_SIGNAL = "Invalid signal (must be an AbortSignal instance)";
210
210
  const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
211
+ const ERR_ABORTED = "The operation was aborted";
212
+ const ABORT_ERROR_NAME = "AbortError";
211
213
 
212
214
  function checkFunctionOption(value) {
213
215
  if (value && typeof value != FUNCTION_TYPE) {
@@ -223,6 +225,12 @@ function checkSignalOption(signal) {
223
225
  return signal || UNDEFINED_VALUE;
224
226
  }
225
227
 
228
+ function throwIfAborted(signal) {
229
+ if (signal && signal.aborted) {
230
+ throw signal.reason === UNDEFINED_VALUE ? new DOMException(ERR_ABORTED, ABORT_ERROR_NAME) : signal.reason;
231
+ }
232
+ }
233
+
226
234
  function checkPasswordOption(password, rawPassword) {
227
235
  if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
228
236
  throw new Error(ERR_INVALID_PASSWORD_TYPE);
@@ -3785,11 +3793,13 @@ class BlobReader extends Reader {
3785
3793
  const reader = this;
3786
3794
  const { sourceBlob, size } = reader;
3787
3795
  const { offset = 0, size: readSize = size - offset } = options || {};
3788
- if (!offset && readSize >= size) {
3789
- return toCompatibleReadable(sourceBlob.stream());
3790
- }
3791
- if (blobSliceReliable) {
3792
- return toCompatibleReadable(sourceBlob.slice(offset, offset + readSize).stream());
3796
+ if (typeof sourceBlob.stream == FUNCTION_TYPE) {
3797
+ if (!offset && readSize >= size) {
3798
+ return toCompatibleReadable(sourceBlob.stream());
3799
+ }
3800
+ if (blobSliceReliable) {
3801
+ return toCompatibleReadable(sourceBlob.slice(offset, offset + readSize).stream());
3802
+ }
3793
3803
  }
3794
3804
  return super.createReadable(options);
3795
3805
  }
@@ -5205,27 +5215,28 @@ class ZipReaderStream {
5205
5215
  const { done, value } = await gen.next();
5206
5216
  if (done)
5207
5217
  return controller.close();
5208
- const chunk = {
5209
- ...value,
5210
- readable: (function () {
5211
- const { readable, writable } = new TransformStream();
5212
- if (value.getData) {
5213
- getData();
5214
- return readable;
5215
- }
5218
+ const entryReadable = (function () {
5219
+ const { readable, writable } = new TransformStream();
5220
+ if (value.getData) {
5221
+ getData();
5222
+ return readable;
5223
+ }
5216
5224
 
5217
- async function getData() {
5225
+ async function getData() {
5226
+ try {
5227
+ await value.getData(writable);
5228
+ } catch (error) {
5218
5229
  try {
5219
- await value.getData(writable);
5220
- } catch (error) {
5221
- try {
5222
- await writable.abort(error);
5223
- } catch {
5224
- // ignored
5225
- }
5230
+ await writable.abort(error);
5231
+ } catch {
5232
+ // ignored
5226
5233
  }
5227
5234
  }
5228
- })()
5235
+ }
5236
+ })();
5237
+ const chunk = {
5238
+ ...value,
5239
+ readable: entryReadable
5229
5240
  };
5230
5241
  delete chunk.getData;
5231
5242
  controller.enqueue(chunk);
@@ -5371,6 +5382,7 @@ class ZipEntry {
5371
5382
  const size = compressedSize;
5372
5383
  const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
5373
5384
  const signal = checkSignalOption(getOptionValue$1(zipEntry, options, OPTION_SIGNAL));
5385
+ throwIfAborted(signal);
5374
5386
  const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
5375
5387
  let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
5376
5388
  const checkOverlappingEntryOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY_ONLY);
@@ -6901,6 +6913,7 @@ function resolveMetadata(zipWriter, name, options) {
6901
6913
  const createTempStream = getFunctionOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
6902
6914
  const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, true);
6903
6915
  const signal = checkSignalOption(getOptionValue(zipWriter, options, OPTION_SIGNAL));
6916
+ throwIfAborted(signal);
6904
6917
  const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
6905
6918
  const compressionMethod = getOptionValue(zipWriter, options, PROPERTY_NAME_COMPRESSION_METHOD);
6906
6919
  const registeredCodec = passThrough || compressionMethod === UNDEFINED_VALUE ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
@@ -8568,7 +8581,7 @@ function formatSupported(StreamClass, format) {
8568
8581
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8569
8582
  */
8570
8583
 
8571
- const VERSION = "2.11.3";
8584
+ const VERSION = "2.11.4";
8572
8585
 
8573
8586
  /*
8574
8587
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.