@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 +1 -1
- package/dist/zip-core-external.js +36 -23
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +36 -23
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +36 -25
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +36 -25
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +36 -25
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +36 -25
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +36 -25
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +36 -23
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +36 -23
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +36 -23
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +36 -25
- package/index-native.min.js +1 -1
- package/index.cjs +36 -25
- package/index.d.cts +12 -0
- package/index.d.ts +12 -0
- package/index.min.js +1 -1
- package/lib/core/io.js +7 -5
- package/lib/core/options.js +13 -0
- package/lib/core/version.js +1 -1
- package/lib/core/zip-fs.js +1 -3
- package/lib/core/zip-reader.js +20 -17
- package/lib/core/zip-writer.js +2 -0
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -211,6 +211,8 @@ const STRICTNESS_TOLERANT = "tolerant";
|
|
|
211
211
|
const ERR_INVALID_FUNCTION_OPTION = "Invalid option (must be a function)";
|
|
212
212
|
const ERR_INVALID_SIGNAL = "Invalid signal (must be an AbortSignal instance)";
|
|
213
213
|
const ERR_INVALID_PASSWORD_TYPE = "Invalid password (password must be a string, rawPassword must be a Uint8Array)";
|
|
214
|
+
const ERR_ABORTED = "The operation was aborted";
|
|
215
|
+
const ABORT_ERROR_NAME = "AbortError";
|
|
214
216
|
|
|
215
217
|
function checkFunctionOption(value) {
|
|
216
218
|
if (value && typeof value != FUNCTION_TYPE) {
|
|
@@ -226,6 +228,12 @@ function checkSignalOption(signal) {
|
|
|
226
228
|
return signal || UNDEFINED_VALUE;
|
|
227
229
|
}
|
|
228
230
|
|
|
231
|
+
function throwIfAborted(signal) {
|
|
232
|
+
if (signal && signal.aborted) {
|
|
233
|
+
throw signal.reason === UNDEFINED_VALUE ? new DOMException(ERR_ABORTED, ABORT_ERROR_NAME) : signal.reason;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
229
237
|
function checkPasswordOption(password, rawPassword) {
|
|
230
238
|
if ((password && typeof password != STRING_TYPE) || (rawPassword && !(rawPassword instanceof Uint8Array))) {
|
|
231
239
|
throw new Error(ERR_INVALID_PASSWORD_TYPE);
|
|
@@ -3754,11 +3762,13 @@ class BlobReader extends Reader {
|
|
|
3754
3762
|
const reader = this;
|
|
3755
3763
|
const { sourceBlob, size } = reader;
|
|
3756
3764
|
const { offset = 0, size: readSize = size - offset } = options || {};
|
|
3757
|
-
if (
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3765
|
+
if (typeof sourceBlob.stream == FUNCTION_TYPE) {
|
|
3766
|
+
if (!offset && readSize >= size) {
|
|
3767
|
+
return toCompatibleReadable(sourceBlob.stream());
|
|
3768
|
+
}
|
|
3769
|
+
if (blobSliceReliable) {
|
|
3770
|
+
return toCompatibleReadable(sourceBlob.slice(offset, offset + readSize).stream());
|
|
3771
|
+
}
|
|
3762
3772
|
}
|
|
3763
3773
|
return super.createReadable(options);
|
|
3764
3774
|
}
|
|
@@ -5194,27 +5204,28 @@ class ZipReaderStream {
|
|
|
5194
5204
|
const { done, value } = await gen.next();
|
|
5195
5205
|
if (done)
|
|
5196
5206
|
return controller.close();
|
|
5197
|
-
const
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
return readable;
|
|
5204
|
-
}
|
|
5207
|
+
const entryReadable = (function () {
|
|
5208
|
+
const { readable, writable } = new TransformStream();
|
|
5209
|
+
if (value.getData) {
|
|
5210
|
+
getData();
|
|
5211
|
+
return readable;
|
|
5212
|
+
}
|
|
5205
5213
|
|
|
5206
|
-
|
|
5214
|
+
async function getData() {
|
|
5215
|
+
try {
|
|
5216
|
+
await value.getData(writable);
|
|
5217
|
+
} catch (error) {
|
|
5207
5218
|
try {
|
|
5208
|
-
await
|
|
5209
|
-
} catch
|
|
5210
|
-
|
|
5211
|
-
await writable.abort(error);
|
|
5212
|
-
} catch {
|
|
5213
|
-
// ignored
|
|
5214
|
-
}
|
|
5219
|
+
await writable.abort(error);
|
|
5220
|
+
} catch {
|
|
5221
|
+
// ignored
|
|
5215
5222
|
}
|
|
5216
5223
|
}
|
|
5217
|
-
}
|
|
5224
|
+
}
|
|
5225
|
+
})();
|
|
5226
|
+
const chunk = {
|
|
5227
|
+
...value,
|
|
5228
|
+
readable: entryReadable
|
|
5218
5229
|
};
|
|
5219
5230
|
delete chunk.getData;
|
|
5220
5231
|
controller.enqueue(chunk);
|
|
@@ -5360,6 +5371,7 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5360
5371
|
const size = compressedSize;
|
|
5361
5372
|
const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
|
|
5362
5373
|
const signal = checkSignalOption(getOptionValue$1(zipEntry, options, OPTION_SIGNAL));
|
|
5374
|
+
throwIfAborted(signal);
|
|
5363
5375
|
const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
|
|
5364
5376
|
let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
|
|
5365
5377
|
const checkOverlappingEntryOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY_ONLY);
|
|
@@ -6890,6 +6902,7 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6890
6902
|
const createTempStream = getFunctionOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
|
|
6891
6903
|
const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, true);
|
|
6892
6904
|
const signal = checkSignalOption(getOptionValue(zipWriter, options, OPTION_SIGNAL));
|
|
6905
|
+
throwIfAborted(signal);
|
|
6893
6906
|
const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
|
|
6894
6907
|
const compressionMethod = getOptionValue(zipWriter, options, PROPERTY_NAME_COMPRESSION_METHOD);
|
|
6895
6908
|
const registeredCodec = passThrough || compressionMethod === UNDEFINED_VALUE ? UNDEFINED_VALUE : getRegisteredCodec(compressionMethod);
|
|
@@ -8634,7 +8647,7 @@ function formatSupported(StreamClass, format) {
|
|
|
8634
8647
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8635
8648
|
*/
|
|
8636
8649
|
|
|
8637
|
-
const VERSION = "2.11.
|
|
8650
|
+
const VERSION = "2.11.4";
|
|
8638
8651
|
|
|
8639
8652
|
/*
|
|
8640
8653
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -9535,8 +9548,6 @@ const ERR_INVALID_PASS_THROUGH = "Invalid passThrough option (use readerOptions.
|
|
|
9535
9548
|
const ERR_INVALID_READER_OPTIONS = "Invalid readerOptions (must be an object)";
|
|
9536
9549
|
const ERR_ZIP_CRYPTO_LAST_MOD_DATE = "The last modification date of an entry encrypted with ZipCrypto cannot be changed when passThrough is set";
|
|
9537
9550
|
const ERR_ABORT_EXPORT = "zipjs-abort-export";
|
|
9538
|
-
const ERR_ABORTED = "The operation was aborted";
|
|
9539
|
-
const ABORT_ERROR_NAME = "AbortError";
|
|
9540
9551
|
const INFOZIP_EXTRA_FIELD_TYPE = "infozip";
|
|
9541
9552
|
const INTERPRETED_EXTRA_FIELD_TYPES = new Set([
|
|
9542
9553
|
EXTRAFIELD_TYPE_ZIP64,
|
package/index.d.cts
CHANGED
|
@@ -1344,6 +1344,10 @@ export class ZipReaderStream<T> {
|
|
|
1344
1344
|
|
|
1345
1345
|
/**
|
|
1346
1346
|
* The readable stream.
|
|
1347
|
+
*
|
|
1348
|
+
* @remarks The properties deposited on an entry while its data is read, i.e.
|
|
1349
|
+
* {@link EntryMetaData#warnings} and {@link EntryMetaData#localDirectory}, are shared with the
|
|
1350
|
+
* chunk, so they are readable on it once its `readable` property has been consumed.
|
|
1347
1351
|
*/
|
|
1348
1352
|
readable: ReadableStream<
|
|
1349
1353
|
Omit<Entry, "getData"> & { readable?: ReadableStream<Uint8Array> }
|
|
@@ -1880,6 +1884,10 @@ export interface ZipReaderOptions {
|
|
|
1880
1884
|
rawPassword?: Uint8Array;
|
|
1881
1885
|
/**
|
|
1882
1886
|
* The `AbortSignal` instance used to cancel the decompression.
|
|
1887
|
+
*
|
|
1888
|
+
* A signal already aborted when the operation starts rejects it with {@link ERR_ABORTED} as the
|
|
1889
|
+
* reason of the `AbortError`, or with `signal.reason` when it is set, without relying on the
|
|
1890
|
+
* `signal` option of `pipeTo` that the oldest supported engines ignore.
|
|
1883
1891
|
*/
|
|
1884
1892
|
signal?: AbortSignal;
|
|
1885
1893
|
/**
|
|
@@ -3155,6 +3163,10 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3155
3163
|
encryptionStrength?: 1 | 2 | 3;
|
|
3156
3164
|
/**
|
|
3157
3165
|
* The `AbortSignal` instance used to cancel the compression.
|
|
3166
|
+
*
|
|
3167
|
+
* A signal already aborted when the operation starts rejects it with {@link ERR_ABORTED} as the
|
|
3168
|
+
* reason of the `AbortError`, or with `signal.reason` when it is set, without relying on the
|
|
3169
|
+
* `signal` option of `pipeTo` that the oldest supported engines ignore.
|
|
3158
3170
|
*/
|
|
3159
3171
|
signal?: AbortSignal;
|
|
3160
3172
|
/**
|
package/index.d.ts
CHANGED
|
@@ -1344,6 +1344,10 @@ export class ZipReaderStream<T> {
|
|
|
1344
1344
|
|
|
1345
1345
|
/**
|
|
1346
1346
|
* The readable stream.
|
|
1347
|
+
*
|
|
1348
|
+
* @remarks The properties deposited on an entry while its data is read, i.e.
|
|
1349
|
+
* {@link EntryMetaData#warnings} and {@link EntryMetaData#localDirectory}, are shared with the
|
|
1350
|
+
* chunk, so they are readable on it once its `readable` property has been consumed.
|
|
1347
1351
|
*/
|
|
1348
1352
|
readable: ReadableStream<
|
|
1349
1353
|
Omit<Entry, "getData"> & { readable?: ReadableStream<Uint8Array> }
|
|
@@ -1880,6 +1884,10 @@ export interface ZipReaderOptions {
|
|
|
1880
1884
|
rawPassword?: Uint8Array;
|
|
1881
1885
|
/**
|
|
1882
1886
|
* The `AbortSignal` instance used to cancel the decompression.
|
|
1887
|
+
*
|
|
1888
|
+
* A signal already aborted when the operation starts rejects it with {@link ERR_ABORTED} as the
|
|
1889
|
+
* reason of the `AbortError`, or with `signal.reason` when it is set, without relying on the
|
|
1890
|
+
* `signal` option of `pipeTo` that the oldest supported engines ignore.
|
|
1883
1891
|
*/
|
|
1884
1892
|
signal?: AbortSignal;
|
|
1885
1893
|
/**
|
|
@@ -3155,6 +3163,10 @@ export interface ZipWriterConstructorOptions extends WorkerConfiguration {
|
|
|
3155
3163
|
encryptionStrength?: 1 | 2 | 3;
|
|
3156
3164
|
/**
|
|
3157
3165
|
* The `AbortSignal` instance used to cancel the compression.
|
|
3166
|
+
*
|
|
3167
|
+
* A signal already aborted when the operation starts rejects it with {@link ERR_ABORTED} as the
|
|
3168
|
+
* reason of the `AbortError`, or with `signal.reason` when it is set, without relying on the
|
|
3169
|
+
* `signal` option of `pipeTo` that the oldest supported engines ignore.
|
|
3158
3170
|
*/
|
|
3159
3171
|
signal?: AbortSignal;
|
|
3160
3172
|
/**
|