@zip.js/zip.js 2.11.0 → 2.11.2
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/BENCHMARKS.md +127 -60
- package/deno.json +1 -1
- package/dist/zip-core-external.js +22 -19
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +12 -6
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +22 -19
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +12 -6
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +22 -19
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +12 -6
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +25 -22
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +12 -6
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-module.wasm +0 -0
- package/dist/zip-native.js +12 -6
- package/dist/zip-native.min.js +1 -1
- package/dist/zip-web-worker.js +1 -1
- package/dist/zip.js +25 -22
- package/dist/zip.min.js +1 -1
- package/eslint.config.mjs +1 -1
- package/index-native.cjs +12 -6
- package/index-native.min.js +1 -1
- package/index.cjs +25 -22
- package/index.d.cts +3 -4
- package/index.d.ts +3 -4
- package/index.min.js +1 -1
- package/lib/core/io.js +2 -3
- package/lib/core/streams/zlib-wasm/zlib-streams.js +10 -13
- package/lib/core/streams/zlib-wasm/zlib-streams.wasm +0 -0
- package/lib/core/version.js +1 -1
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/core/zip-writer.js +13 -2
- package/lib/core/zlib-streams-inline.js +1 -1
- package/package.json +4 -2
package/dist/zip-fs-external.js
CHANGED
|
@@ -3639,11 +3639,10 @@ class Reader extends Stream {
|
|
|
3639
3639
|
const data = await readUint8Array(reader, offset + chunkOffset, dataSize);
|
|
3640
3640
|
if (data.length) {
|
|
3641
3641
|
controller.enqueue(data);
|
|
3642
|
+
chunkOffset += data.length;
|
|
3642
3643
|
}
|
|
3643
|
-
if ((
|
|
3644
|
+
if ((size !== UNDEFINED_VALUE && chunkOffset >= size) || (!data.length && dataSize)) {
|
|
3644
3645
|
controller.close();
|
|
3645
|
-
} else {
|
|
3646
|
-
chunkOffset += chunkSize;
|
|
3647
3646
|
}
|
|
3648
3647
|
}
|
|
3649
3648
|
});
|
|
@@ -6354,6 +6353,7 @@ class ZipWriter {
|
|
|
6354
6353
|
pendingAddFileCalls: new Set(),
|
|
6355
6354
|
pendingErrors: [],
|
|
6356
6355
|
bufferedWrites: 0,
|
|
6356
|
+
directWrites: 0,
|
|
6357
6357
|
lastFileEntry: UNDEFINED_VALUE
|
|
6358
6358
|
});
|
|
6359
6359
|
}
|
|
@@ -7204,6 +7204,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
7204
7204
|
const usdz = zipWriter.options[OPTION_USDZ];
|
|
7205
7205
|
let fileEntry = pendingFileEntry;
|
|
7206
7206
|
let bufferedWrite;
|
|
7207
|
+
let directWrite;
|
|
7207
7208
|
let releaseLockWriter;
|
|
7208
7209
|
let writingBufferedEntryData;
|
|
7209
7210
|
let writingEntryData;
|
|
@@ -7213,7 +7214,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
7213
7214
|
const lockPreviousFileEntry = keepOrder && previousFileEntry ? previousFileEntry.lockFileEntry : UNDEFINED_VALUE;
|
|
7214
7215
|
fileEntries.set(name, fileEntry);
|
|
7215
7216
|
try {
|
|
7216
|
-
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || (!dataDescriptor && !emptyEntry)) {
|
|
7217
|
+
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || zipWriter.directWrites || (!dataDescriptor && !emptyEntry)) {
|
|
7217
7218
|
bufferedWrite = true;
|
|
7218
7219
|
zipWriter.bufferedWrites++;
|
|
7219
7220
|
if (options.createTempStream) {
|
|
@@ -7224,6 +7225,8 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
7224
7225
|
fileWriter.size = 0;
|
|
7225
7226
|
await initStream(writer);
|
|
7226
7227
|
} else {
|
|
7228
|
+
directWrite = true;
|
|
7229
|
+
zipWriter.directWrites++;
|
|
7227
7230
|
fileWriter = writer;
|
|
7228
7231
|
await lockPreviousFileEntry;
|
|
7229
7232
|
await requestLockWriter();
|
|
@@ -7302,6 +7305,9 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
7302
7305
|
if (bufferedWrite) {
|
|
7303
7306
|
zipWriter.bufferedWrites--;
|
|
7304
7307
|
}
|
|
7308
|
+
if (directWrite) {
|
|
7309
|
+
zipWriter.directWrites--;
|
|
7310
|
+
}
|
|
7305
7311
|
if (releaseLockFileEntry) {
|
|
7306
7312
|
releaseLockFileEntry(lockPreviousFileEntry);
|
|
7307
7313
|
}
|
|
@@ -7446,8 +7452,8 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7446
7452
|
}
|
|
7447
7453
|
const { writable } = writer;
|
|
7448
7454
|
if (reader) {
|
|
7449
|
-
const readable = toCompatibleReadable(createReadable(reader));
|
|
7450
7455
|
const size = reader.size;
|
|
7456
|
+
const readable = toCompatibleReadable(createReadable(reader, { size }));
|
|
7451
7457
|
const workerOptions = {
|
|
7452
7458
|
options: {
|
|
7453
7459
|
codecType: CODEC_DEFLATE,
|
|
@@ -8626,7 +8632,7 @@ function formatSupported(StreamClass, format) {
|
|
|
8626
8632
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8627
8633
|
*/
|
|
8628
8634
|
|
|
8629
|
-
const VERSION = "2.11.
|
|
8635
|
+
const VERSION = "2.11.2";
|
|
8630
8636
|
|
|
8631
8637
|
/*
|
|
8632
8638
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -9215,18 +9221,17 @@ function _make(isCompress, type, options = {}) {
|
|
|
9215
9221
|
}
|
|
9216
9222
|
heap.set(buffer.subarray(offset, offset + toRead), this.in);
|
|
9217
9223
|
const result = process(this.streamHandle, this.in, toRead, out, outBufferSize, 0);
|
|
9224
|
+
// checked before the byte count is used, so a status code can never be read as one
|
|
9225
|
+
const code = (result >> 24) & 0xff;
|
|
9226
|
+
const signedCode = (code & 0x80) ? code - 256 : code;
|
|
9227
|
+
if (signedCode < 0) {
|
|
9228
|
+
throw new Error("process error:" + signedCode);
|
|
9229
|
+
}
|
|
9218
9230
|
const prod = result & 0x00ffffff;
|
|
9219
9231
|
if (prod) {
|
|
9220
9232
|
scratch.set(heap.subarray(out, out + prod), 0);
|
|
9221
9233
|
controller.enqueue(scratch.slice(0, prod));
|
|
9222
9234
|
}
|
|
9223
|
-
if (!isCompress) {
|
|
9224
|
-
const code = (result >> 24) & 0xff;
|
|
9225
|
-
const signedCode = (code & 0x80) ? code - 256 : code;
|
|
9226
|
-
if (signedCode < 0) {
|
|
9227
|
-
throw new Error("process error:" + signedCode);
|
|
9228
|
-
}
|
|
9229
|
-
}
|
|
9230
9235
|
const consumed = last_consumed(this.streamHandle);
|
|
9231
9236
|
if (consumed === 0 && prod === 0) {
|
|
9232
9237
|
break;
|
|
@@ -9246,14 +9251,12 @@ function _make(isCompress, type, options = {}) {
|
|
|
9246
9251
|
const scratch = this._scratch;
|
|
9247
9252
|
while (true) {
|
|
9248
9253
|
const result = process(this.streamHandle, 0, 0, out, outBufferSize, 4);
|
|
9249
|
-
const produced = result & 0x00ffffff;
|
|
9250
9254
|
const code = (result >> 24) & 0xff;
|
|
9251
|
-
|
|
9252
|
-
|
|
9253
|
-
|
|
9254
|
-
throw new Error("process error:" + signedCode);
|
|
9255
|
-
}
|
|
9255
|
+
const signedCode = (code & 0x80) ? code - 256 : code;
|
|
9256
|
+
if (signedCode < 0) {
|
|
9257
|
+
throw new Error("process error:" + signedCode);
|
|
9256
9258
|
}
|
|
9259
|
+
const produced = result & 0x00ffffff;
|
|
9257
9260
|
if (produced) {
|
|
9258
9261
|
scratch.set(heap.subarray(out, out + produced), 0);
|
|
9259
9262
|
controller.enqueue(scratch.slice(0, produced));
|