@zip.js/zip.js 2.6.5 → 2.6.6
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/dist/zip-fs-full.js +77 -53
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +78 -53
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +19 -20
- package/dist/zip-full.min.js +1 -1
- package/dist/zip-no-worker-deflate.min.js +1 -1
- package/dist/zip-no-worker-inflate.min.js +1 -1
- package/dist/zip-no-worker.min.js +1 -1
- package/dist/zip.js +19 -20
- package/dist/zip.min.js +1 -1
- package/index.d.ts +5 -0
- package/lib/core/io.js +7 -0
- package/lib/core/zip-fs-core.js +68 -35
- package/lib/core/zip-reader.js +7 -8
- package/lib/core/zip-writer.js +10 -13
- package/package.json +3 -1
- package/tests/all/test-fs-streams.js +22 -0
- package/tests/tests-data.js +1 -0
package/dist/zip-full.js
CHANGED
|
@@ -6939,6 +6939,12 @@
|
|
|
6939
6939
|
return protocol == "http:" || protocol == "https:";
|
|
6940
6940
|
}
|
|
6941
6941
|
|
|
6942
|
+
async function initStream(stream) {
|
|
6943
|
+
if (stream.init && !stream.initialized) {
|
|
6944
|
+
await stream.init();
|
|
6945
|
+
}
|
|
6946
|
+
}
|
|
6947
|
+
|
|
6942
6948
|
/*
|
|
6943
6949
|
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
6944
6950
|
|
|
@@ -7183,9 +7189,7 @@
|
|
|
7183
7189
|
const zipReader = this;
|
|
7184
7190
|
let { reader } = zipReader;
|
|
7185
7191
|
const { config } = zipReader;
|
|
7186
|
-
|
|
7187
|
-
await reader.init();
|
|
7188
|
-
}
|
|
7192
|
+
await initStream(reader);
|
|
7189
7193
|
if (reader.size === undefined || !reader.readUint8Array) {
|
|
7190
7194
|
const blob = await new Response(reader.readable).blob();
|
|
7191
7195
|
reader = new BlobReader(blob);
|
|
@@ -7251,7 +7255,7 @@
|
|
|
7251
7255
|
throw new Error(ERR_BAD_FORMAT);
|
|
7252
7256
|
}
|
|
7253
7257
|
const filenameEncoding = getOptionValue$1(zipReader, options, "filenameEncoding");
|
|
7254
|
-
const commentEncoding = getOptionValue$1(zipReader, options, "commentEncoding");
|
|
7258
|
+
const commentEncoding = getOptionValue$1(zipReader, options, "commentEncoding");
|
|
7255
7259
|
for (let indexFile = 0; indexFile < filesLength; indexFile++) {
|
|
7256
7260
|
const fileEntry = new ZipEntry(reader, config, zipReader.options);
|
|
7257
7261
|
if (getUint32(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
|
|
@@ -7389,9 +7393,7 @@
|
|
|
7389
7393
|
readable.size = size;
|
|
7390
7394
|
const { writable } = writer;
|
|
7391
7395
|
const signal = getOptionValue$1(zipEntry, options, "signal");
|
|
7392
|
-
|
|
7393
|
-
await writer.init();
|
|
7394
|
-
}
|
|
7396
|
+
await initStream(writer);
|
|
7395
7397
|
const { onstart, onprogress, onend } = options;
|
|
7396
7398
|
const workerOptions = {
|
|
7397
7399
|
options: {
|
|
@@ -7851,9 +7853,7 @@
|
|
|
7851
7853
|
const internalFileAttribute = getOptionValue(zipWriter, options, "internalFileAttribute") || 0;
|
|
7852
7854
|
const externalFileAttribute = getOptionValue(zipWriter, options, "externalFileAttribute") || 0;
|
|
7853
7855
|
if (reader) {
|
|
7854
|
-
|
|
7855
|
-
await reader.init();
|
|
7856
|
-
}
|
|
7856
|
+
await initStream(reader);
|
|
7857
7857
|
if (reader.size === undefined) {
|
|
7858
7858
|
options.dataDescriptor = true;
|
|
7859
7859
|
} else {
|
|
@@ -7950,9 +7950,7 @@
|
|
|
7950
7950
|
bufferedWrite = true;
|
|
7951
7951
|
} else {
|
|
7952
7952
|
zipWriter.lockWriter = Promise.resolve();
|
|
7953
|
-
|
|
7954
|
-
await writer.init();
|
|
7955
|
-
}
|
|
7953
|
+
await initStream(writer);
|
|
7956
7954
|
fileWriter = writer;
|
|
7957
7955
|
}
|
|
7958
7956
|
fileEntry = await createFileEntry(reader, fileEntry, fileWriter.writable, zipWriter.config, options);
|
|
@@ -7978,7 +7976,7 @@
|
|
|
7978
7976
|
setUint32(arrayBufferView, 18, fileEntry.compressedSize);
|
|
7979
7977
|
setUint32(arrayBufferView, 22, fileEntry.uncompressedSize);
|
|
7980
7978
|
}
|
|
7981
|
-
await
|
|
7979
|
+
await writeData(writable, new Uint8Array(arrayBuffer));
|
|
7982
7980
|
blob = blob.slice(headerLength);
|
|
7983
7981
|
}
|
|
7984
7982
|
await blob.stream().pipeTo(writable, { preventClose: true, signal });
|
|
@@ -8174,7 +8172,7 @@
|
|
|
8174
8172
|
let compressedSize = 0;
|
|
8175
8173
|
if (reader) {
|
|
8176
8174
|
reader.chunkSize = getChunkSize(config);
|
|
8177
|
-
await
|
|
8175
|
+
await writeData(writable, localHeaderArray);
|
|
8178
8176
|
fileEntry.dataWritten = pendingFileEntry.dataWritten = true;
|
|
8179
8177
|
const size = () => reader.size;
|
|
8180
8178
|
const readable = reader.readable;
|
|
@@ -8201,7 +8199,7 @@
|
|
|
8201
8199
|
uncompressedSize = fileEntry.uncompressedSize = reader.size = readable.size();
|
|
8202
8200
|
compressedSize = result.size;
|
|
8203
8201
|
} else {
|
|
8204
|
-
await
|
|
8202
|
+
await writeData(writable, localHeaderArray);
|
|
8205
8203
|
fileEntry.dataWritten = pendingFileEntry.dataWritten = true;
|
|
8206
8204
|
}
|
|
8207
8205
|
let dataDescriptorArray = new Uint8Array();
|
|
@@ -8245,7 +8243,7 @@
|
|
|
8245
8243
|
}
|
|
8246
8244
|
}
|
|
8247
8245
|
if (dataDescriptor) {
|
|
8248
|
-
await
|
|
8246
|
+
await writeData(writable, dataDescriptorArray);
|
|
8249
8247
|
}
|
|
8250
8248
|
const length = localHeaderArray.length + compressedSize + dataDescriptorArray.length;
|
|
8251
8249
|
Object.assign(fileEntry, {
|
|
@@ -8377,9 +8375,9 @@
|
|
|
8377
8375
|
}
|
|
8378
8376
|
}
|
|
8379
8377
|
const { writable } = zipWriter.writer;
|
|
8380
|
-
await
|
|
8378
|
+
await writeData(writable, directoryArray);
|
|
8381
8379
|
if (comment && comment.length) {
|
|
8382
|
-
await
|
|
8380
|
+
await writeData(writable, comment);
|
|
8383
8381
|
}
|
|
8384
8382
|
}
|
|
8385
8383
|
|
|
@@ -8391,7 +8389,7 @@
|
|
|
8391
8389
|
}
|
|
8392
8390
|
}
|
|
8393
8391
|
|
|
8394
|
-
async function
|
|
8392
|
+
async function writeData(writable, array) {
|
|
8395
8393
|
const streamWriter = writable.getWriter();
|
|
8396
8394
|
await streamWriter.ready;
|
|
8397
8395
|
await streamWriter.write(array);
|
|
@@ -8512,6 +8510,7 @@
|
|
|
8512
8510
|
exports.configure = configure;
|
|
8513
8511
|
exports.getMimeType = getMimeType;
|
|
8514
8512
|
exports.initShimAsyncCodec = streamCodecShim;
|
|
8513
|
+
exports.initStream = initStream;
|
|
8515
8514
|
exports.terminateWorkers = terminateWorkers;
|
|
8516
8515
|
|
|
8517
8516
|
Object.defineProperty(exports, '__esModule', { value: true });
|