Skip to content

Commit

Permalink
update built files
Browse files Browse the repository at this point in the history
  • Loading branch information
gildas-lormeau committed Feb 24, 2024
1 parent 9c65c7a commit c3fb91d
Show file tree
Hide file tree
Showing 13 changed files with 424 additions and 104 deletions.
104 changes: 84 additions & 20 deletions dist/zip-fs-full.js
Original file line number Diff line number Diff line change
Expand Up @@ -8923,8 +8923,8 @@

constructor(writerGenerator, maxSize = 4294967295) {
super();
const zipWriter = this;
Object.assign(zipWriter, {
const writer = this;
Object.assign(writer, {
diskNumber: 0,
diskOffset: 0,
size: 0,
Expand All @@ -8934,7 +8934,7 @@
let diskSourceWriter, diskWritable, diskWriter;
const writable = new WritableStream({
async write(chunk) {
const { availableSize } = zipWriter;
const { availableSize } = writer;
if (!diskWriter) {
const { value, done } = await writerGenerator.next();
if (done && !value) {
Expand All @@ -8943,9 +8943,9 @@
diskSourceWriter = value;
diskSourceWriter.size = 0;
if (diskSourceWriter.maxSize) {
zipWriter.maxSize = diskSourceWriter.maxSize;
writer.maxSize = diskSourceWriter.maxSize;
}
zipWriter.availableSize = zipWriter.maxSize;
writer.availableSize = writer.maxSize;
await initStream(diskSourceWriter);
diskWritable = value.writable;
diskWriter = diskWritable.getWriter();
Expand All @@ -8954,8 +8954,8 @@
} else if (chunk.length >= availableSize) {
await writeChunk(chunk.slice(0, availableSize));
await closeDisk();
zipWriter.diskOffset += diskSourceWriter.size;
zipWriter.diskNumber++;
writer.diskOffset += diskSourceWriter.size;
writer.diskNumber++;
diskWriter = null;
await this.write(chunk.slice(availableSize));
} else {
Expand All @@ -8967,7 +8967,7 @@
await closeDisk();
}
});
Object.defineProperty(zipWriter, PROPERTY_NAME_WRITABLE, {
Object.defineProperty(writer, PROPERTY_NAME_WRITABLE, {
get() {
return writable;
}
Expand All @@ -8979,8 +8979,8 @@
await diskWriter.ready;
await diskWriter.write(chunk);
diskSourceWriter.size += chunkLength;
zipWriter.size += chunkLength;
zipWriter.availableSize -= chunkLength;
writer.size += chunkLength;
writer.availableSize -= chunkLength;
}
}

Expand All @@ -9000,6 +9000,8 @@
async function initStream(stream, initSize) {
if (stream.init && !stream.initialized) {
await stream.init(initSize);
} else {
return Promise.resolve();
}
}

Expand Down Expand Up @@ -9201,8 +9203,8 @@
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
3. The names of the authors may not be used to endorse or promote products
Expand Down Expand Up @@ -9331,7 +9333,7 @@
}
if (directoryDataOffset >= reader.size) {
prependedDataLength = reader.size - directoryDataOffset - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
directoryDataOffset = reader.size - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
directoryDataOffset = reader.size - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
}
if (expectedLastDiskNumber != lastDiskNumber) {
throw new Error(ERR_SPLIT_ZIP_FILE);
Expand Down Expand Up @@ -9448,6 +9450,34 @@
}
}

class ZipReaderStream {

constructor(options = {}) {
const { readable, writable } = new TransformStream();
const gen = new ZipReader(readable, options).getEntriesGenerator();
this.readable = new ReadableStream({
async pull(controller) {
const { done, value } = await gen.next();
if (done)
return controller.close();
const chunk = {
...value,
readable: (function () {
const { readable, writable } = new TransformStream();
if (value.getData) {
value.getData(writable);
return readable;
}
})()
};
delete chunk.getData;
controller.enqueue(chunk);
}
});
this.writable = writable;
}
}

class ZipEntry$1 {

constructor(reader, config, options) {
Expand Down Expand Up @@ -9837,8 +9867,8 @@
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
3. The names of the authors may not be used to endorse or promote products
Expand Down Expand Up @@ -9875,9 +9905,12 @@

constructor(writer, options = {}) {
writer = initWriter(writer);
const addSplitZipSignature =
writer.availableSize !== UNDEFINED_VALUE && writer.availableSize > 0 && writer.availableSize !== Infinity &&
writer.maxSize !== UNDEFINED_VALUE && writer.maxSize > 0 && writer.maxSize !== Infinity;
Object.assign(this, {
writer,
addSplitZipSignature: writer instanceof SplitDataWriter,
addSplitZipSignature,
options,
config: getConfiguration(),
files: new Map(),
Expand Down Expand Up @@ -9940,6 +9973,33 @@
}
}

class ZipWriterStream {

constructor(options = {}) {
const { readable, writable } = new TransformStream();
this.readable = readable;
this.zipWriter = new ZipWriter(writable, options);
}

transform(path) {
const { readable, writable } = new TransformStream({
flush: () => { this.zipWriter.close(); }
});
this.zipWriter.add(path, readable);
return { readable: this.readable, writable };
}

writable(path) {
const { readable, writable } = new TransformStream();
this.zipWriter.add(path, readable);
return writable;
}

close(comment = undefined, options = {}) {
return this.zipWriter.close(comment, options);
}
}

async function addFile(zipWriter, name, reader, options) {
name = name.trim();
if (options.directory && (!name.endsWith(DIRECTORY_SIGNATURE))) {
Expand Down Expand Up @@ -10110,6 +10170,7 @@
let writingBufferedEntryData;
let writingEntryData;
let fileWriter;
let blobPromise;
files.set(name, fileEntry);
try {
let lockPreviousFileEntry;
Expand All @@ -10118,7 +10179,8 @@
requestLockCurrentFileEntry();
}
if ((options.bufferedWrite || zipWriter.writerLocked || (zipWriter.bufferedWrites && keepOrder) || !dataDescriptor) && !usdz) {
fileWriter = new BlobWriter();
fileWriter = new TransformStream();
blobPromise = new Response(fileWriter.readable).blob();
fileWriter.writable.size = 0;
bufferedWrite = true;
zipWriter.bufferedWrites++;
Expand Down Expand Up @@ -10154,7 +10216,7 @@
fileEntry.filename = name;
if (bufferedWrite) {
await fileWriter.writable.getWriter().close();
let blob = await fileWriter.getData();
let blob = await blobPromise;
await lockPreviousFileEntry;
await requestLockWriter();
writingBufferedEntryData = true;
Expand Down Expand Up @@ -11745,8 +11807,8 @@
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
3. The names of the authors may not be used to endorse or promote products
Expand Down Expand Up @@ -11818,7 +11880,9 @@
exports.Uint8ArrayWriter = Uint8ArrayWriter;
exports.Writer = Writer;
exports.ZipReader = ZipReader;
exports.ZipReaderStream = ZipReaderStream;
exports.ZipWriter = ZipWriter;
exports.ZipWriterStream = ZipWriterStream;
exports.configure = configure;
exports.fs = fs;
exports.getMimeType = getMimeType;
Expand Down
2 changes: 1 addition & 1 deletion dist/zip-fs-full.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit c3fb91d

Please sign in to comment.