@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/lib/core/zip-reader.js
CHANGED
|
@@ -123,6 +123,7 @@ import { decodeText } from "./util/decode-text.js";
|
|
|
123
123
|
import { getDataView } from "./util/array.js";
|
|
124
124
|
import { addWarning } from "./util/warnings.js";
|
|
125
125
|
import { toCompatibleReadable, streamToBlob } from "./util/compatible-streams.js";
|
|
126
|
+
import { isErrorObject } from "./util/error.js";
|
|
126
127
|
import { Crc32 } from "./streams/codecs/crc32.js";
|
|
127
128
|
import {
|
|
128
129
|
PROPERTY_NAME_RAW_FILENAME,
|
|
@@ -1012,7 +1013,7 @@ class ZipEntry {
|
|
|
1012
1013
|
readRanges
|
|
1013
1014
|
});
|
|
1014
1015
|
}
|
|
1015
|
-
let writable, abortError;
|
|
1016
|
+
let writable, abortError, aborted;
|
|
1016
1017
|
try {
|
|
1017
1018
|
if (!checkOverlappingEntryOnly) {
|
|
1018
1019
|
if (checkPasswordOnly) {
|
|
@@ -1028,18 +1029,22 @@ class ZipEntry {
|
|
|
1028
1029
|
writer.size += writtenSize;
|
|
1029
1030
|
}
|
|
1030
1031
|
} catch (error) {
|
|
1031
|
-
|
|
1032
|
+
const { outputSize: failedOutputSize } = workerOptions;
|
|
1033
|
+
if (failedOutputSize !== UNDEFINED_VALUE) {
|
|
1034
|
+
writer.size += failedOutputSize;
|
|
1035
|
+
} else if (isErrorObject(error) && error.outputSize !== UNDEFINED_VALUE) {
|
|
1032
1036
|
writer.size += error.outputSize;
|
|
1033
1037
|
}
|
|
1034
|
-
if (!checkPasswordOnly || error.message != ERR_ABORT_CHECK_PASSWORD) {
|
|
1038
|
+
if (!checkPasswordOnly || !isErrorObject(error) || error.message != ERR_ABORT_CHECK_PASSWORD) {
|
|
1035
1039
|
abortError = error;
|
|
1040
|
+
aborted = true;
|
|
1036
1041
|
throw error;
|
|
1037
1042
|
}
|
|
1038
1043
|
} finally {
|
|
1039
1044
|
const preventClose = !ownsWritable(writer) && getOptionValue(zipEntry, options, OPTION_PREVENT_CLOSE);
|
|
1040
1045
|
if (!preventClose && writable && !writable.locked) {
|
|
1041
1046
|
const writableWriter = writable.getWriter();
|
|
1042
|
-
if (
|
|
1047
|
+
if (aborted) {
|
|
1043
1048
|
try {
|
|
1044
1049
|
await writableWriter.abort(abortError);
|
|
1045
1050
|
} catch {
|
package/lib/core/zip-writer.js
CHANGED
|
@@ -178,6 +178,7 @@ import { encodeText } from "./util/encode-text.js";
|
|
|
178
178
|
import { concat, getDataView } from "./util/array.js";
|
|
179
179
|
import { addWarning } from "./util/warnings.js";
|
|
180
180
|
import { toCompatibleReadable, streamToBlob } from "./util/compatible-streams.js";
|
|
181
|
+
import { isErrorObject } from "./util/error.js";
|
|
181
182
|
import {
|
|
182
183
|
PROPERTY_NAME_LAST_MODIFICATION_DATE,
|
|
183
184
|
PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE,
|
|
@@ -512,7 +513,7 @@ class ZipWriter {
|
|
|
512
513
|
await Promise.allSettled(Array.from(pendingAddFileCalls));
|
|
513
514
|
}
|
|
514
515
|
await Promise.allSettled(zipWriter.pendingErrors.map(watcher => watcher.recorded));
|
|
515
|
-
const unobservedWatchers = zipWriter.pendingErrors.filter(watcher => watcher.
|
|
516
|
+
const unobservedWatchers = zipWriter.pendingErrors.filter(watcher => watcher.failed && !watcher.observed);
|
|
516
517
|
if (unobservedWatchers.length) {
|
|
517
518
|
const unobservedErrors = unobservedWatchers.map(watcher => watcher.error);
|
|
518
519
|
unobservedWatchers.forEach(watcher => watcher.observed = true);
|
|
@@ -621,7 +622,8 @@ function watchPromiseError(zipWriter, promise) {
|
|
|
621
622
|
const watchedPromise = new WatchedPromise((resolve, reject) => Promise.prototype.then.call(promise, resolve, reject));
|
|
622
623
|
const watcher = {};
|
|
623
624
|
watchedPromise.watcher = watcher;
|
|
624
|
-
watcher.recorded = Promise.prototype.then.call(watchedPromise, UNDEFINED_VALUE,
|
|
625
|
+
watcher.recorded = Promise.prototype.then.call(watchedPromise, UNDEFINED_VALUE,
|
|
626
|
+
error => Object.assign(watcher, { failed: true, error }));
|
|
625
627
|
zipWriter.pendingErrors.push(watcher);
|
|
626
628
|
return watchedPromise;
|
|
627
629
|
}
|
|
@@ -1681,7 +1683,10 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
1681
1683
|
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
1682
1684
|
}
|
|
1683
1685
|
} catch (error) {
|
|
1684
|
-
|
|
1686
|
+
const { outputSize: failedOutputSize } = workerOptions;
|
|
1687
|
+
if (failedOutputSize !== UNDEFINED_VALUE) {
|
|
1688
|
+
writer.size += failedOutputSize;
|
|
1689
|
+
} else if (isErrorObject(error) && error.outputSize !== UNDEFINED_VALUE) {
|
|
1685
1690
|
writer.size += error.outputSize;
|
|
1686
1691
|
}
|
|
1687
1692
|
throw error;
|
package/package.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const WORKER_MESSAGE_PROPERTY_NAMES = ["baseURI", "cause", "checkAuthenticationCode", "checkCrc32", "checkPasswordOnly", "chunkSize", "code", "codecImportFailed", "codecType", "codecURI", "compressed", "compressionMethod", "computeCrc32", "config", "crc32", "deflate64", "done", "encrypted", "encryptionStrength", "error", "format", "inputSize", "level", "message", "messageId", "name", "options", "outputSize", "password", "passwordVerification", "rawBitFlag", "rawPassword", "readable", "result", "stack", "transferStreams", "type", "useCompressionStream", "useWebWorkers", "value", "wasmURI", "workerStartupTimeout", "writable", "zipCrypto"];
|
|
1
|
+
const WORKER_MESSAGE_PROPERTY_NAMES = ["baseURI", "cause", "checkAuthenticationCode", "checkCrc32", "checkPasswordOnly", "chunkSize", "code", "codecImportFailed", "codecType", "codecURI", "compressed", "compressionMethod", "computeCrc32", "config", "crc32", "deflate64", "done", "encrypted", "encryptionStrength", "error", "errorValue", "format", "inputSize", "level", "message", "messageId", "name", "options", "outputSize", "password", "passwordVerification", "rawBitFlag", "rawPassword", "readable", "result", "stack", "transferStreams", "type", "useCompressionStream", "useWebWorkers", "value", "wasmURI", "workerStartupTimeout", "writable", "zipCrypto"];
|
|
2
2
|
|
|
3
3
|
export { WORKER_MESSAGE_PROPERTY_NAMES };
|