@zip.js/zip.js 2.12.0 → 2.13.0
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 +126 -33
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +126 -33
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +127 -34
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +127 -34
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +127 -34
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +129 -36
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +128 -35
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +128 -35
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +128 -35
- package/dist/zip-native.min.js +1 -1
- package/dist/zip-web-worker-native.js +1 -1
- package/dist/zip-web-worker.js +1 -1
- package/dist/zip.js +127 -34
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +129 -36
- package/index-native.min.js +1 -1
- package/index.cjs +128 -35
- package/index.d.cts +13 -7
- package/index.d.ts +13 -7
- package/index.min.js +1 -1
- package/lib/core/codec-worker-web.js +64 -22
- package/lib/core/codec-worker.js +15 -3
- package/lib/core/util/error.js +35 -0
- package/lib/core/version.js +1 -1
- package/lib/core/web-worker-base.js +43 -7
- package/lib/core/web-worker-inline-native.js +1 -1
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/core/zip-fs.js +2 -1
- package/lib/core/zip-reader.js +9 -4
- package/lib/core/zip-writer.js +8 -3
- package/package.json +1 -1
- package/worker-message-property-names.js +1 -1
package/deno.json
CHANGED
|
@@ -516,6 +516,39 @@ function getDataView(array) {
|
|
|
516
516
|
return new DataView(array.buffer, array.byteOffset, array.byteLength);
|
|
517
517
|
}
|
|
518
518
|
|
|
519
|
+
/*
|
|
520
|
+
Copyright (c) 2026 Gildas Lormeau. All rights reserved.
|
|
521
|
+
|
|
522
|
+
Redistribution and use in source and binary forms, with or without
|
|
523
|
+
modification, are permitted provided that the following conditions are met:
|
|
524
|
+
|
|
525
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
526
|
+
this list of conditions and the following disclaimer.
|
|
527
|
+
|
|
528
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
529
|
+
notice, this list of conditions and the following disclaimer in
|
|
530
|
+
the documentation and/or other materials provided with the distribution.
|
|
531
|
+
|
|
532
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
533
|
+
derived from this software without specific prior written permission.
|
|
534
|
+
|
|
535
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
536
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
537
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
538
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
539
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
540
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
541
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
542
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
543
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
544
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
545
|
+
*/
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
function isErrorObject(error) {
|
|
549
|
+
return Boolean(error) && typeof error == "object";
|
|
550
|
+
}
|
|
551
|
+
|
|
519
552
|
/*
|
|
520
553
|
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
521
554
|
|
|
@@ -2787,7 +2820,9 @@ function disableWebWorker(workerData) {
|
|
|
2787
2820
|
|
|
2788
2821
|
class CodecWorker {
|
|
2789
2822
|
|
|
2790
|
-
constructor(workerData, { readable, writable },
|
|
2823
|
+
constructor(workerData, { readable, writable }, workerOptions, onTaskFinished) {
|
|
2824
|
+
const { options, config, streamOptions, useWebWorkers, transferStreams, workerURI } = workerOptions;
|
|
2825
|
+
let { createWorker } = workerOptions;
|
|
2791
2826
|
const { signal } = streamOptions;
|
|
2792
2827
|
if (createWorkerFailed) {
|
|
2793
2828
|
createWorker = UNDEFINED_VALUE;
|
|
@@ -2800,6 +2835,7 @@ class CodecWorker {
|
|
|
2800
2835
|
.pipeThrough(new ProgressWatcherStream(streamOptions), { signal }),
|
|
2801
2836
|
writable,
|
|
2802
2837
|
options: Object.assign({}, options),
|
|
2838
|
+
workerOptions,
|
|
2803
2839
|
workerURI,
|
|
2804
2840
|
createWorker,
|
|
2805
2841
|
transferStreams,
|
|
@@ -2881,7 +2917,7 @@ function createWorkerInterface(workerData, config) {
|
|
|
2881
2917
|
};
|
|
2882
2918
|
}
|
|
2883
2919
|
|
|
2884
|
-
async function runWorker$1({ options, readable, writable, onTaskFinished }, config) {
|
|
2920
|
+
async function runWorker$1({ options, readable, writable, onTaskFinished, workerOptions }, config) {
|
|
2885
2921
|
let codecStream, chunkStream;
|
|
2886
2922
|
try {
|
|
2887
2923
|
if (options.compressed && !options.format) {
|
|
@@ -2922,7 +2958,15 @@ async function runWorker$1({ options, readable, writable, onTaskFinished }, conf
|
|
|
2922
2958
|
};
|
|
2923
2959
|
} catch (error) {
|
|
2924
2960
|
if (codecStream) {
|
|
2925
|
-
|
|
2961
|
+
const outputSize = chunkStream ? chunkStream.outputSize : 0;
|
|
2962
|
+
workerOptions.outputSize = outputSize;
|
|
2963
|
+
if (isErrorObject(error)) {
|
|
2964
|
+
try {
|
|
2965
|
+
error.outputSize = outputSize;
|
|
2966
|
+
} catch {
|
|
2967
|
+
// ignored
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2926
2970
|
}
|
|
2927
2971
|
throw error;
|
|
2928
2972
|
} finally {
|
|
@@ -3032,8 +3076,14 @@ async function runWebWorker(workerData, config) {
|
|
|
3032
3076
|
const result = new Promise((resolve, reject) => {
|
|
3033
3077
|
resolveResult = resolve;
|
|
3034
3078
|
rejectResult = error => {
|
|
3035
|
-
|
|
3036
|
-
|
|
3079
|
+
const { outputSize, workerOptions } = workerData;
|
|
3080
|
+
workerOptions.outputSize = outputSize;
|
|
3081
|
+
if (isErrorObject(error) && error.outputSize === UNDEFINED_VALUE) {
|
|
3082
|
+
try {
|
|
3083
|
+
error.outputSize = outputSize;
|
|
3084
|
+
} catch {
|
|
3085
|
+
// ignored
|
|
3086
|
+
}
|
|
3037
3087
|
}
|
|
3038
3088
|
reject(error);
|
|
3039
3089
|
};
|
|
@@ -3302,21 +3352,15 @@ function sendMessage(message, { worker, writer, transferStreams, workerAlive })
|
|
|
3302
3352
|
}
|
|
3303
3353
|
|
|
3304
3354
|
async function onMessage({ data }, workerData) {
|
|
3305
|
-
const { type, value, messageId, result, error } = data;
|
|
3355
|
+
const { type, value, messageId, result, error, errorValue } = data;
|
|
3306
3356
|
const { reader, writer, resolveResult, rejectResult, onTaskFinished, generation } = workerData;
|
|
3307
3357
|
const stale = () => workerData.generation != generation;
|
|
3308
3358
|
try {
|
|
3309
3359
|
if (error) {
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
Object.assign(responseError, { stack, code, name, outputSize });
|
|
3313
|
-
if (cause) {
|
|
3314
|
-
responseError.cause = Object.assign(new Error(cause.message), { name: cause.name });
|
|
3315
|
-
}
|
|
3316
|
-
if (codecImportFailed) {
|
|
3317
|
-
responseError.codecImportFailed = true;
|
|
3360
|
+
if (error.outputSize !== UNDEFINED_VALUE) {
|
|
3361
|
+
workerData.outputSize = error.outputSize;
|
|
3318
3362
|
}
|
|
3319
|
-
|
|
3363
|
+
fail(getResponseError(error, errorValue));
|
|
3320
3364
|
} else {
|
|
3321
3365
|
if (type == MESSAGE_PULL) {
|
|
3322
3366
|
const { value, done } = await reader.read();
|
|
@@ -3334,32 +3378,73 @@ async function onMessage({ data }, workerData) {
|
|
|
3334
3378
|
}
|
|
3335
3379
|
}
|
|
3336
3380
|
if (type == MESSAGE_CLOSE) {
|
|
3337
|
-
|
|
3381
|
+
succeed(result);
|
|
3338
3382
|
}
|
|
3339
3383
|
}
|
|
3340
3384
|
} catch (error) {
|
|
3341
3385
|
if (!stale()) {
|
|
3342
3386
|
terminateWorker$1(workerData);
|
|
3343
|
-
|
|
3387
|
+
fail(error);
|
|
3344
3388
|
}
|
|
3345
3389
|
}
|
|
3346
3390
|
|
|
3347
|
-
function
|
|
3348
|
-
if (stale()) {
|
|
3349
|
-
return;
|
|
3350
|
-
}
|
|
3351
|
-
if (error) {
|
|
3391
|
+
function fail(error) {
|
|
3392
|
+
if (!stale()) {
|
|
3352
3393
|
rejectResult(error);
|
|
3353
|
-
|
|
3394
|
+
releaseWriter();
|
|
3395
|
+
if (!(isErrorObject(error) && error.codecImportFailed)) {
|
|
3396
|
+
onTaskFinished();
|
|
3397
|
+
}
|
|
3398
|
+
}
|
|
3399
|
+
}
|
|
3400
|
+
|
|
3401
|
+
function succeed(result) {
|
|
3402
|
+
if (!stale()) {
|
|
3354
3403
|
resolveResult(result);
|
|
3404
|
+
releaseWriter();
|
|
3405
|
+
onTaskFinished();
|
|
3355
3406
|
}
|
|
3407
|
+
}
|
|
3408
|
+
|
|
3409
|
+
function releaseWriter() {
|
|
3356
3410
|
if (writer) {
|
|
3357
3411
|
writer.releaseLock();
|
|
3358
3412
|
}
|
|
3359
|
-
|
|
3360
|
-
|
|
3413
|
+
}
|
|
3414
|
+
}
|
|
3415
|
+
|
|
3416
|
+
function getResponseError(errorData, errorValue) {
|
|
3417
|
+
const { message, stack, code, name, outputSize, cause, codecImportFailed } = errorData;
|
|
3418
|
+
let responseError;
|
|
3419
|
+
if (errorValue) {
|
|
3420
|
+
responseError = errorValue.value;
|
|
3421
|
+
} else {
|
|
3422
|
+
responseError = Object.assign(new Error(message), { stack, code, name });
|
|
3423
|
+
if (cause) {
|
|
3424
|
+
responseError.cause = Object.assign(new Error(cause.message), { name: cause.name });
|
|
3425
|
+
}
|
|
3426
|
+
}
|
|
3427
|
+
if (isErrorObject(responseError)) {
|
|
3428
|
+
try {
|
|
3429
|
+
if (outputSize !== UNDEFINED_VALUE) {
|
|
3430
|
+
responseError.outputSize = outputSize;
|
|
3431
|
+
}
|
|
3432
|
+
if (codecImportFailed) {
|
|
3433
|
+
responseError.codecImportFailed = true;
|
|
3434
|
+
}
|
|
3435
|
+
if (errorValue) {
|
|
3436
|
+
if (responseError.name !== name) {
|
|
3437
|
+
responseError.name = name;
|
|
3438
|
+
}
|
|
3439
|
+
if (responseError.code !== code) {
|
|
3440
|
+
responseError.code = code;
|
|
3441
|
+
}
|
|
3442
|
+
}
|
|
3443
|
+
} catch {
|
|
3444
|
+
// ignored
|
|
3361
3445
|
}
|
|
3362
3446
|
}
|
|
3447
|
+
return responseError;
|
|
3363
3448
|
}
|
|
3364
3449
|
|
|
3365
3450
|
/*
|
|
@@ -5621,7 +5706,7 @@ class ZipEntry {
|
|
|
5621
5706
|
readRanges
|
|
5622
5707
|
});
|
|
5623
5708
|
}
|
|
5624
|
-
let writable, abortError;
|
|
5709
|
+
let writable, abortError, aborted;
|
|
5625
5710
|
try {
|
|
5626
5711
|
if (!checkOverlappingEntryOnly) {
|
|
5627
5712
|
if (checkPasswordOnly) {
|
|
@@ -5637,18 +5722,22 @@ class ZipEntry {
|
|
|
5637
5722
|
writer.size += writtenSize;
|
|
5638
5723
|
}
|
|
5639
5724
|
} catch (error) {
|
|
5640
|
-
|
|
5725
|
+
const { outputSize: failedOutputSize } = workerOptions;
|
|
5726
|
+
if (failedOutputSize !== UNDEFINED_VALUE) {
|
|
5727
|
+
writer.size += failedOutputSize;
|
|
5728
|
+
} else if (isErrorObject(error) && error.outputSize !== UNDEFINED_VALUE) {
|
|
5641
5729
|
writer.size += error.outputSize;
|
|
5642
5730
|
}
|
|
5643
|
-
if (!checkPasswordOnly || error.message != ERR_ABORT_CHECK_PASSWORD) {
|
|
5731
|
+
if (!checkPasswordOnly || !isErrorObject(error) || error.message != ERR_ABORT_CHECK_PASSWORD) {
|
|
5644
5732
|
abortError = error;
|
|
5733
|
+
aborted = true;
|
|
5645
5734
|
throw error;
|
|
5646
5735
|
}
|
|
5647
5736
|
} finally {
|
|
5648
5737
|
const preventClose = !ownsWritable(writer) && getOptionValue$1(zipEntry, options, OPTION_PREVENT_CLOSE);
|
|
5649
5738
|
if (!preventClose && writable && !writable.locked) {
|
|
5650
5739
|
const writableWriter = writable.getWriter();
|
|
5651
|
-
if (
|
|
5740
|
+
if (aborted) {
|
|
5652
5741
|
try {
|
|
5653
5742
|
await writableWriter.abort(abortError);
|
|
5654
5743
|
} catch {
|
|
@@ -6708,7 +6797,7 @@ class ZipWriter {
|
|
|
6708
6797
|
await Promise.allSettled(Array.from(pendingAddFileCalls));
|
|
6709
6798
|
}
|
|
6710
6799
|
await Promise.allSettled(zipWriter.pendingErrors.map(watcher => watcher.recorded));
|
|
6711
|
-
const unobservedWatchers = zipWriter.pendingErrors.filter(watcher => watcher.
|
|
6800
|
+
const unobservedWatchers = zipWriter.pendingErrors.filter(watcher => watcher.failed && !watcher.observed);
|
|
6712
6801
|
if (unobservedWatchers.length) {
|
|
6713
6802
|
const unobservedErrors = unobservedWatchers.map(watcher => watcher.error);
|
|
6714
6803
|
unobservedWatchers.forEach(watcher => watcher.observed = true);
|
|
@@ -6817,7 +6906,8 @@ function watchPromiseError(zipWriter, promise) {
|
|
|
6817
6906
|
const watchedPromise = new WatchedPromise((resolve, reject) => Promise.prototype.then.call(promise, resolve, reject));
|
|
6818
6907
|
const watcher = {};
|
|
6819
6908
|
watchedPromise.watcher = watcher;
|
|
6820
|
-
watcher.recorded = Promise.prototype.then.call(watchedPromise, UNDEFINED_VALUE,
|
|
6909
|
+
watcher.recorded = Promise.prototype.then.call(watchedPromise, UNDEFINED_VALUE,
|
|
6910
|
+
error => Object.assign(watcher, { failed: true, error }));
|
|
6821
6911
|
zipWriter.pendingErrors.push(watcher);
|
|
6822
6912
|
return watchedPromise;
|
|
6823
6913
|
}
|
|
@@ -7733,7 +7823,10 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7733
7823
|
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
7734
7824
|
}
|
|
7735
7825
|
} catch (error) {
|
|
7736
|
-
|
|
7826
|
+
const { outputSize: failedOutputSize } = workerOptions;
|
|
7827
|
+
if (failedOutputSize !== UNDEFINED_VALUE) {
|
|
7828
|
+
writer.size += failedOutputSize;
|
|
7829
|
+
} else if (isErrorObject(error) && error.outputSize !== UNDEFINED_VALUE) {
|
|
7737
7830
|
writer.size += error.outputSize;
|
|
7738
7831
|
}
|
|
7739
7832
|
throw error;
|
|
@@ -8898,7 +8991,7 @@ function formatSupported(StreamClass, format) {
|
|
|
8898
8991
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8899
8992
|
*/
|
|
8900
8993
|
|
|
8901
|
-
const VERSION = "2.
|
|
8994
|
+
const VERSION = "2.13.0";
|
|
8902
8995
|
|
|
8903
8996
|
/*
|
|
8904
8997
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|