@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/dist/zip-fs-core.js
CHANGED
|
@@ -489,6 +489,39 @@
|
|
|
489
489
|
return new DataView(array.buffer, array.byteOffset, array.byteLength);
|
|
490
490
|
}
|
|
491
491
|
|
|
492
|
+
/*
|
|
493
|
+
Copyright (c) 2026 Gildas Lormeau. All rights reserved.
|
|
494
|
+
|
|
495
|
+
Redistribution and use in source and binary forms, with or without
|
|
496
|
+
modification, are permitted provided that the following conditions are met:
|
|
497
|
+
|
|
498
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
499
|
+
this list of conditions and the following disclaimer.
|
|
500
|
+
|
|
501
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
502
|
+
notice, this list of conditions and the following disclaimer in
|
|
503
|
+
the documentation and/or other materials provided with the distribution.
|
|
504
|
+
|
|
505
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
506
|
+
derived from this software without specific prior written permission.
|
|
507
|
+
|
|
508
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
509
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
510
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
511
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
512
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
513
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
514
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
515
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
516
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
517
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
518
|
+
*/
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
function isErrorObject(error) {
|
|
522
|
+
return Boolean(error) && typeof error == "object";
|
|
523
|
+
}
|
|
524
|
+
|
|
492
525
|
/*
|
|
493
526
|
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
494
527
|
|
|
@@ -2756,7 +2789,9 @@
|
|
|
2756
2789
|
|
|
2757
2790
|
class CodecWorker {
|
|
2758
2791
|
|
|
2759
|
-
constructor(workerData, { readable, writable },
|
|
2792
|
+
constructor(workerData, { readable, writable }, workerOptions, onTaskFinished) {
|
|
2793
|
+
const { options, config, streamOptions, useWebWorkers, transferStreams, workerURI } = workerOptions;
|
|
2794
|
+
let { createWorker } = workerOptions;
|
|
2760
2795
|
const { signal } = streamOptions;
|
|
2761
2796
|
if (createWorkerFailed) {
|
|
2762
2797
|
createWorker = UNDEFINED_VALUE;
|
|
@@ -2769,6 +2804,7 @@
|
|
|
2769
2804
|
.pipeThrough(new ProgressWatcherStream(streamOptions), { signal }),
|
|
2770
2805
|
writable,
|
|
2771
2806
|
options: Object.assign({}, options),
|
|
2807
|
+
workerOptions,
|
|
2772
2808
|
workerURI,
|
|
2773
2809
|
createWorker,
|
|
2774
2810
|
transferStreams,
|
|
@@ -2850,7 +2886,7 @@
|
|
|
2850
2886
|
};
|
|
2851
2887
|
}
|
|
2852
2888
|
|
|
2853
|
-
async function runWorker$1({ options, readable, writable, onTaskFinished }, config) {
|
|
2889
|
+
async function runWorker$1({ options, readable, writable, onTaskFinished, workerOptions }, config) {
|
|
2854
2890
|
let codecStream, chunkStream;
|
|
2855
2891
|
try {
|
|
2856
2892
|
if (options.compressed && !options.format) {
|
|
@@ -2891,7 +2927,15 @@
|
|
|
2891
2927
|
};
|
|
2892
2928
|
} catch (error) {
|
|
2893
2929
|
if (codecStream) {
|
|
2894
|
-
|
|
2930
|
+
const outputSize = chunkStream ? chunkStream.outputSize : 0;
|
|
2931
|
+
workerOptions.outputSize = outputSize;
|
|
2932
|
+
if (isErrorObject(error)) {
|
|
2933
|
+
try {
|
|
2934
|
+
error.outputSize = outputSize;
|
|
2935
|
+
} catch {
|
|
2936
|
+
// ignored
|
|
2937
|
+
}
|
|
2938
|
+
}
|
|
2895
2939
|
}
|
|
2896
2940
|
throw error;
|
|
2897
2941
|
} finally {
|
|
@@ -3001,8 +3045,14 @@
|
|
|
3001
3045
|
const result = new Promise((resolve, reject) => {
|
|
3002
3046
|
resolveResult = resolve;
|
|
3003
3047
|
rejectResult = error => {
|
|
3004
|
-
|
|
3005
|
-
|
|
3048
|
+
const { outputSize, workerOptions } = workerData;
|
|
3049
|
+
workerOptions.outputSize = outputSize;
|
|
3050
|
+
if (isErrorObject(error) && error.outputSize === UNDEFINED_VALUE) {
|
|
3051
|
+
try {
|
|
3052
|
+
error.outputSize = outputSize;
|
|
3053
|
+
} catch {
|
|
3054
|
+
// ignored
|
|
3055
|
+
}
|
|
3006
3056
|
}
|
|
3007
3057
|
reject(error);
|
|
3008
3058
|
};
|
|
@@ -3271,21 +3321,15 @@
|
|
|
3271
3321
|
}
|
|
3272
3322
|
|
|
3273
3323
|
async function onMessage({ data }, workerData) {
|
|
3274
|
-
const { type, value, messageId, result, error } = data;
|
|
3324
|
+
const { type, value, messageId, result, error, errorValue } = data;
|
|
3275
3325
|
const { reader, writer, resolveResult, rejectResult, onTaskFinished, generation } = workerData;
|
|
3276
3326
|
const stale = () => workerData.generation != generation;
|
|
3277
3327
|
try {
|
|
3278
3328
|
if (error) {
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
Object.assign(responseError, { stack, code, name, outputSize });
|
|
3282
|
-
if (cause) {
|
|
3283
|
-
responseError.cause = Object.assign(new Error(cause.message), { name: cause.name });
|
|
3284
|
-
}
|
|
3285
|
-
if (codecImportFailed) {
|
|
3286
|
-
responseError.codecImportFailed = true;
|
|
3329
|
+
if (error.outputSize !== UNDEFINED_VALUE) {
|
|
3330
|
+
workerData.outputSize = error.outputSize;
|
|
3287
3331
|
}
|
|
3288
|
-
|
|
3332
|
+
fail(getResponseError(error, errorValue));
|
|
3289
3333
|
} else {
|
|
3290
3334
|
if (type == MESSAGE_PULL) {
|
|
3291
3335
|
const { value, done } = await reader.read();
|
|
@@ -3303,32 +3347,73 @@
|
|
|
3303
3347
|
}
|
|
3304
3348
|
}
|
|
3305
3349
|
if (type == MESSAGE_CLOSE) {
|
|
3306
|
-
|
|
3350
|
+
succeed(result);
|
|
3307
3351
|
}
|
|
3308
3352
|
}
|
|
3309
3353
|
} catch (error) {
|
|
3310
3354
|
if (!stale()) {
|
|
3311
3355
|
terminateWorker$1(workerData);
|
|
3312
|
-
|
|
3356
|
+
fail(error);
|
|
3313
3357
|
}
|
|
3314
3358
|
}
|
|
3315
3359
|
|
|
3316
|
-
function
|
|
3317
|
-
if (stale()) {
|
|
3318
|
-
return;
|
|
3319
|
-
}
|
|
3320
|
-
if (error) {
|
|
3360
|
+
function fail(error) {
|
|
3361
|
+
if (!stale()) {
|
|
3321
3362
|
rejectResult(error);
|
|
3322
|
-
|
|
3363
|
+
releaseWriter();
|
|
3364
|
+
if (!(isErrorObject(error) && error.codecImportFailed)) {
|
|
3365
|
+
onTaskFinished();
|
|
3366
|
+
}
|
|
3367
|
+
}
|
|
3368
|
+
}
|
|
3369
|
+
|
|
3370
|
+
function succeed(result) {
|
|
3371
|
+
if (!stale()) {
|
|
3323
3372
|
resolveResult(result);
|
|
3373
|
+
releaseWriter();
|
|
3374
|
+
onTaskFinished();
|
|
3324
3375
|
}
|
|
3376
|
+
}
|
|
3377
|
+
|
|
3378
|
+
function releaseWriter() {
|
|
3325
3379
|
if (writer) {
|
|
3326
3380
|
writer.releaseLock();
|
|
3327
3381
|
}
|
|
3328
|
-
|
|
3329
|
-
|
|
3382
|
+
}
|
|
3383
|
+
}
|
|
3384
|
+
|
|
3385
|
+
function getResponseError(errorData, errorValue) {
|
|
3386
|
+
const { message, stack, code, name, outputSize, cause, codecImportFailed } = errorData;
|
|
3387
|
+
let responseError;
|
|
3388
|
+
if (errorValue) {
|
|
3389
|
+
responseError = errorValue.value;
|
|
3390
|
+
} else {
|
|
3391
|
+
responseError = Object.assign(new Error(message), { stack, code, name });
|
|
3392
|
+
if (cause) {
|
|
3393
|
+
responseError.cause = Object.assign(new Error(cause.message), { name: cause.name });
|
|
3330
3394
|
}
|
|
3331
3395
|
}
|
|
3396
|
+
if (isErrorObject(responseError)) {
|
|
3397
|
+
try {
|
|
3398
|
+
if (outputSize !== UNDEFINED_VALUE) {
|
|
3399
|
+
responseError.outputSize = outputSize;
|
|
3400
|
+
}
|
|
3401
|
+
if (codecImportFailed) {
|
|
3402
|
+
responseError.codecImportFailed = true;
|
|
3403
|
+
}
|
|
3404
|
+
if (errorValue) {
|
|
3405
|
+
if (responseError.name !== name) {
|
|
3406
|
+
responseError.name = name;
|
|
3407
|
+
}
|
|
3408
|
+
if (responseError.code !== code) {
|
|
3409
|
+
responseError.code = code;
|
|
3410
|
+
}
|
|
3411
|
+
}
|
|
3412
|
+
} catch {
|
|
3413
|
+
// ignored
|
|
3414
|
+
}
|
|
3415
|
+
}
|
|
3416
|
+
return responseError;
|
|
3332
3417
|
}
|
|
3333
3418
|
|
|
3334
3419
|
/*
|
|
@@ -5610,7 +5695,7 @@
|
|
|
5610
5695
|
readRanges
|
|
5611
5696
|
});
|
|
5612
5697
|
}
|
|
5613
|
-
let writable, abortError;
|
|
5698
|
+
let writable, abortError, aborted;
|
|
5614
5699
|
try {
|
|
5615
5700
|
if (!checkOverlappingEntryOnly) {
|
|
5616
5701
|
if (checkPasswordOnly) {
|
|
@@ -5626,18 +5711,22 @@
|
|
|
5626
5711
|
writer.size += writtenSize;
|
|
5627
5712
|
}
|
|
5628
5713
|
} catch (error) {
|
|
5629
|
-
|
|
5714
|
+
const { outputSize: failedOutputSize } = workerOptions;
|
|
5715
|
+
if (failedOutputSize !== UNDEFINED_VALUE) {
|
|
5716
|
+
writer.size += failedOutputSize;
|
|
5717
|
+
} else if (isErrorObject(error) && error.outputSize !== UNDEFINED_VALUE) {
|
|
5630
5718
|
writer.size += error.outputSize;
|
|
5631
5719
|
}
|
|
5632
|
-
if (!checkPasswordOnly || error.message != ERR_ABORT_CHECK_PASSWORD) {
|
|
5720
|
+
if (!checkPasswordOnly || !isErrorObject(error) || error.message != ERR_ABORT_CHECK_PASSWORD) {
|
|
5633
5721
|
abortError = error;
|
|
5722
|
+
aborted = true;
|
|
5634
5723
|
throw error;
|
|
5635
5724
|
}
|
|
5636
5725
|
} finally {
|
|
5637
5726
|
const preventClose = !ownsWritable(writer) && getOptionValue$1(zipEntry, options, OPTION_PREVENT_CLOSE);
|
|
5638
5727
|
if (!preventClose && writable && !writable.locked) {
|
|
5639
5728
|
const writableWriter = writable.getWriter();
|
|
5640
|
-
if (
|
|
5729
|
+
if (aborted) {
|
|
5641
5730
|
try {
|
|
5642
5731
|
await writableWriter.abort(abortError);
|
|
5643
5732
|
} catch {
|
|
@@ -6697,7 +6786,7 @@
|
|
|
6697
6786
|
await Promise.allSettled(Array.from(pendingAddFileCalls));
|
|
6698
6787
|
}
|
|
6699
6788
|
await Promise.allSettled(zipWriter.pendingErrors.map(watcher => watcher.recorded));
|
|
6700
|
-
const unobservedWatchers = zipWriter.pendingErrors.filter(watcher => watcher.
|
|
6789
|
+
const unobservedWatchers = zipWriter.pendingErrors.filter(watcher => watcher.failed && !watcher.observed);
|
|
6701
6790
|
if (unobservedWatchers.length) {
|
|
6702
6791
|
const unobservedErrors = unobservedWatchers.map(watcher => watcher.error);
|
|
6703
6792
|
unobservedWatchers.forEach(watcher => watcher.observed = true);
|
|
@@ -6806,7 +6895,8 @@
|
|
|
6806
6895
|
const watchedPromise = new WatchedPromise((resolve, reject) => Promise.prototype.then.call(promise, resolve, reject));
|
|
6807
6896
|
const watcher = {};
|
|
6808
6897
|
watchedPromise.watcher = watcher;
|
|
6809
|
-
watcher.recorded = Promise.prototype.then.call(watchedPromise, UNDEFINED_VALUE,
|
|
6898
|
+
watcher.recorded = Promise.prototype.then.call(watchedPromise, UNDEFINED_VALUE,
|
|
6899
|
+
error => Object.assign(watcher, { failed: true, error }));
|
|
6810
6900
|
zipWriter.pendingErrors.push(watcher);
|
|
6811
6901
|
return watchedPromise;
|
|
6812
6902
|
}
|
|
@@ -7820,7 +7910,10 @@
|
|
|
7820
7910
|
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
7821
7911
|
}
|
|
7822
7912
|
} catch (error) {
|
|
7823
|
-
|
|
7913
|
+
const { outputSize: failedOutputSize } = workerOptions;
|
|
7914
|
+
if (failedOutputSize !== UNDEFINED_VALUE) {
|
|
7915
|
+
writer.size += failedOutputSize;
|
|
7916
|
+
} else if (isErrorObject(error) && error.outputSize !== UNDEFINED_VALUE) {
|
|
7824
7917
|
writer.size += error.outputSize;
|
|
7825
7918
|
}
|
|
7826
7919
|
throw error;
|
|
@@ -8985,7 +9078,7 @@
|
|
|
8985
9078
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8986
9079
|
*/
|
|
8987
9080
|
|
|
8988
|
-
const VERSION = "2.
|
|
9081
|
+
const VERSION = "2.13.0";
|
|
8989
9082
|
|
|
8990
9083
|
/*
|
|
8991
9084
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -9610,7 +9703,7 @@
|
|
|
9610
9703
|
}));
|
|
9611
9704
|
return true;
|
|
9612
9705
|
} catch (error) {
|
|
9613
|
-
if (error.message == ERR_INVALID_PASSWORD) {
|
|
9706
|
+
if (isErrorObject(error) && error.message == ERR_INVALID_PASSWORD) {
|
|
9614
9707
|
return false;
|
|
9615
9708
|
} else {
|
|
9616
9709
|
throw error;
|