@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/dist/zip-legacy.js
CHANGED
|
@@ -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 (
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
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
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
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
|
-
|
|
5196
|
+
async function getData() {
|
|
5197
|
+
try {
|
|
5198
|
+
await value.getData(writable);
|
|
5199
|
+
} catch (error) {
|
|
5189
5200
|
try {
|
|
5190
|
-
await
|
|
5191
|
-
} catch
|
|
5192
|
-
|
|
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.
|
|
8555
|
+
const VERSION = "2.11.4";
|
|
8543
8556
|
|
|
8544
8557
|
/*
|
|
8545
8558
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|