@zip.js/zip.js 2.7.34 → 2.7.36
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/README.md +1 -1
- package/deno.json +5 -0
- package/dist/zip-fs-full.js +84 -20
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +84 -20
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +82 -18
- 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 +82 -18
- package/dist/zip.min.js +1 -1
- package/index.cjs +84 -20
- package/index.d.ts +166 -49
- package/index.js +5 -3
- package/index.min.js +1 -1
- package/lib/core/io.js +12 -10
- package/lib/core/zip-reader.js +34 -5
- package/lib/core/zip-writer.js +41 -10
- package/lib/zip-fs.js +3 -3
- package/package.json +1 -1
package/dist/zip-full.js
CHANGED
|
@@ -7292,8 +7292,8 @@
|
|
|
7292
7292
|
|
|
7293
7293
|
constructor(writerGenerator, maxSize = 4294967295) {
|
|
7294
7294
|
super();
|
|
7295
|
-
const
|
|
7296
|
-
Object.assign(
|
|
7295
|
+
const writer = this;
|
|
7296
|
+
Object.assign(writer, {
|
|
7297
7297
|
diskNumber: 0,
|
|
7298
7298
|
diskOffset: 0,
|
|
7299
7299
|
size: 0,
|
|
@@ -7303,7 +7303,7 @@
|
|
|
7303
7303
|
let diskSourceWriter, diskWritable, diskWriter;
|
|
7304
7304
|
const writable = new WritableStream({
|
|
7305
7305
|
async write(chunk) {
|
|
7306
|
-
const { availableSize } =
|
|
7306
|
+
const { availableSize } = writer;
|
|
7307
7307
|
if (!diskWriter) {
|
|
7308
7308
|
const { value, done } = await writerGenerator.next();
|
|
7309
7309
|
if (done && !value) {
|
|
@@ -7312,9 +7312,9 @@
|
|
|
7312
7312
|
diskSourceWriter = value;
|
|
7313
7313
|
diskSourceWriter.size = 0;
|
|
7314
7314
|
if (diskSourceWriter.maxSize) {
|
|
7315
|
-
|
|
7315
|
+
writer.maxSize = diskSourceWriter.maxSize;
|
|
7316
7316
|
}
|
|
7317
|
-
|
|
7317
|
+
writer.availableSize = writer.maxSize;
|
|
7318
7318
|
await initStream(diskSourceWriter);
|
|
7319
7319
|
diskWritable = value.writable;
|
|
7320
7320
|
diskWriter = diskWritable.getWriter();
|
|
@@ -7323,8 +7323,8 @@
|
|
|
7323
7323
|
} else if (chunk.length >= availableSize) {
|
|
7324
7324
|
await writeChunk(chunk.slice(0, availableSize));
|
|
7325
7325
|
await closeDisk();
|
|
7326
|
-
|
|
7327
|
-
|
|
7326
|
+
writer.diskOffset += diskSourceWriter.size;
|
|
7327
|
+
writer.diskNumber++;
|
|
7328
7328
|
diskWriter = null;
|
|
7329
7329
|
await this.write(chunk.slice(availableSize));
|
|
7330
7330
|
} else {
|
|
@@ -7336,7 +7336,7 @@
|
|
|
7336
7336
|
await closeDisk();
|
|
7337
7337
|
}
|
|
7338
7338
|
});
|
|
7339
|
-
Object.defineProperty(
|
|
7339
|
+
Object.defineProperty(writer, PROPERTY_NAME_WRITABLE, {
|
|
7340
7340
|
get() {
|
|
7341
7341
|
return writable;
|
|
7342
7342
|
}
|
|
@@ -7348,8 +7348,8 @@
|
|
|
7348
7348
|
await diskWriter.ready;
|
|
7349
7349
|
await diskWriter.write(chunk);
|
|
7350
7350
|
diskSourceWriter.size += chunkLength;
|
|
7351
|
-
|
|
7352
|
-
|
|
7351
|
+
writer.size += chunkLength;
|
|
7352
|
+
writer.availableSize -= chunkLength;
|
|
7353
7353
|
}
|
|
7354
7354
|
}
|
|
7355
7355
|
|
|
@@ -7369,6 +7369,8 @@
|
|
|
7369
7369
|
async function initStream(stream, initSize) {
|
|
7370
7370
|
if (stream.init && !stream.initialized) {
|
|
7371
7371
|
await stream.init(initSize);
|
|
7372
|
+
} else {
|
|
7373
|
+
return Promise.resolve();
|
|
7372
7374
|
}
|
|
7373
7375
|
}
|
|
7374
7376
|
|
|
@@ -7570,8 +7572,8 @@
|
|
|
7570
7572
|
1. Redistributions of source code must retain the above copyright notice,
|
|
7571
7573
|
this list of conditions and the following disclaimer.
|
|
7572
7574
|
|
|
7573
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
7574
|
-
notice, this list of conditions and the following disclaimer in
|
|
7575
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
7576
|
+
notice, this list of conditions and the following disclaimer in
|
|
7575
7577
|
the documentation and/or other materials provided with the distribution.
|
|
7576
7578
|
|
|
7577
7579
|
3. The names of the authors may not be used to endorse or promote products
|
|
@@ -7700,7 +7702,7 @@
|
|
|
7700
7702
|
}
|
|
7701
7703
|
if (directoryDataOffset >= reader.size) {
|
|
7702
7704
|
prependedDataLength = reader.size - directoryDataOffset - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
|
|
7703
|
-
directoryDataOffset = reader.size - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
|
|
7705
|
+
directoryDataOffset = reader.size - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
|
|
7704
7706
|
}
|
|
7705
7707
|
if (expectedLastDiskNumber != lastDiskNumber) {
|
|
7706
7708
|
throw new Error(ERR_SPLIT_ZIP_FILE);
|
|
@@ -7817,6 +7819,34 @@
|
|
|
7817
7819
|
}
|
|
7818
7820
|
}
|
|
7819
7821
|
|
|
7822
|
+
class ZipReaderStream {
|
|
7823
|
+
|
|
7824
|
+
constructor(options = {}) {
|
|
7825
|
+
const { readable, writable } = new TransformStream();
|
|
7826
|
+
const gen = new ZipReader(readable, options).getEntriesGenerator();
|
|
7827
|
+
this.readable = new ReadableStream({
|
|
7828
|
+
async pull(controller) {
|
|
7829
|
+
const { done, value } = await gen.next();
|
|
7830
|
+
if (done)
|
|
7831
|
+
return controller.close();
|
|
7832
|
+
const chunk = {
|
|
7833
|
+
...value,
|
|
7834
|
+
readable: (function () {
|
|
7835
|
+
const { readable, writable } = new TransformStream();
|
|
7836
|
+
if (value.getData) {
|
|
7837
|
+
value.getData(writable);
|
|
7838
|
+
return readable;
|
|
7839
|
+
}
|
|
7840
|
+
})()
|
|
7841
|
+
};
|
|
7842
|
+
delete chunk.getData;
|
|
7843
|
+
controller.enqueue(chunk);
|
|
7844
|
+
}
|
|
7845
|
+
});
|
|
7846
|
+
this.writable = writable;
|
|
7847
|
+
}
|
|
7848
|
+
}
|
|
7849
|
+
|
|
7820
7850
|
class ZipEntry {
|
|
7821
7851
|
|
|
7822
7852
|
constructor(reader, config, options) {
|
|
@@ -8206,8 +8236,8 @@
|
|
|
8206
8236
|
1. Redistributions of source code must retain the above copyright notice,
|
|
8207
8237
|
this list of conditions and the following disclaimer.
|
|
8208
8238
|
|
|
8209
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
8210
|
-
notice, this list of conditions and the following disclaimer in
|
|
8239
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
8240
|
+
notice, this list of conditions and the following disclaimer in
|
|
8211
8241
|
the documentation and/or other materials provided with the distribution.
|
|
8212
8242
|
|
|
8213
8243
|
3. The names of the authors may not be used to endorse or promote products
|
|
@@ -8244,9 +8274,12 @@
|
|
|
8244
8274
|
|
|
8245
8275
|
constructor(writer, options = {}) {
|
|
8246
8276
|
writer = initWriter(writer);
|
|
8277
|
+
const addSplitZipSignature =
|
|
8278
|
+
writer.availableSize !== UNDEFINED_VALUE && writer.availableSize > 0 && writer.availableSize !== Infinity &&
|
|
8279
|
+
writer.maxSize !== UNDEFINED_VALUE && writer.maxSize > 0 && writer.maxSize !== Infinity;
|
|
8247
8280
|
Object.assign(this, {
|
|
8248
8281
|
writer,
|
|
8249
|
-
addSplitZipSignature
|
|
8282
|
+
addSplitZipSignature,
|
|
8250
8283
|
options,
|
|
8251
8284
|
config: getConfiguration(),
|
|
8252
8285
|
files: new Map(),
|
|
@@ -8309,6 +8342,33 @@
|
|
|
8309
8342
|
}
|
|
8310
8343
|
}
|
|
8311
8344
|
|
|
8345
|
+
class ZipWriterStream {
|
|
8346
|
+
|
|
8347
|
+
constructor(options = {}) {
|
|
8348
|
+
const { readable, writable } = new TransformStream();
|
|
8349
|
+
this.readable = readable;
|
|
8350
|
+
this.zipWriter = new ZipWriter(writable, options);
|
|
8351
|
+
}
|
|
8352
|
+
|
|
8353
|
+
transform(path) {
|
|
8354
|
+
const { readable, writable } = new TransformStream({
|
|
8355
|
+
flush: () => { this.zipWriter.close(); }
|
|
8356
|
+
});
|
|
8357
|
+
this.zipWriter.add(path, readable);
|
|
8358
|
+
return { readable: this.readable, writable };
|
|
8359
|
+
}
|
|
8360
|
+
|
|
8361
|
+
writable(path) {
|
|
8362
|
+
const { readable, writable } = new TransformStream();
|
|
8363
|
+
this.zipWriter.add(path, readable);
|
|
8364
|
+
return writable;
|
|
8365
|
+
}
|
|
8366
|
+
|
|
8367
|
+
close(comment = undefined, options = {}) {
|
|
8368
|
+
return this.zipWriter.close(comment, options);
|
|
8369
|
+
}
|
|
8370
|
+
}
|
|
8371
|
+
|
|
8312
8372
|
async function addFile(zipWriter, name, reader, options) {
|
|
8313
8373
|
name = name.trim();
|
|
8314
8374
|
if (options.directory && (!name.endsWith(DIRECTORY_SIGNATURE))) {
|
|
@@ -8479,6 +8539,7 @@
|
|
|
8479
8539
|
let writingBufferedEntryData;
|
|
8480
8540
|
let writingEntryData;
|
|
8481
8541
|
let fileWriter;
|
|
8542
|
+
let blobPromise;
|
|
8482
8543
|
files.set(name, fileEntry);
|
|
8483
8544
|
try {
|
|
8484
8545
|
let lockPreviousFileEntry;
|
|
@@ -8487,7 +8548,8 @@
|
|
|
8487
8548
|
requestLockCurrentFileEntry();
|
|
8488
8549
|
}
|
|
8489
8550
|
if ((options.bufferedWrite || zipWriter.writerLocked || (zipWriter.bufferedWrites && keepOrder) || !dataDescriptor) && !usdz) {
|
|
8490
|
-
fileWriter = new
|
|
8551
|
+
fileWriter = new TransformStream();
|
|
8552
|
+
blobPromise = new Response(fileWriter.readable).blob();
|
|
8491
8553
|
fileWriter.writable.size = 0;
|
|
8492
8554
|
bufferedWrite = true;
|
|
8493
8555
|
zipWriter.bufferedWrites++;
|
|
@@ -8523,7 +8585,7 @@
|
|
|
8523
8585
|
fileEntry.filename = name;
|
|
8524
8586
|
if (bufferedWrite) {
|
|
8525
8587
|
await fileWriter.writable.getWriter().close();
|
|
8526
|
-
let blob = await
|
|
8588
|
+
let blob = await blobPromise;
|
|
8527
8589
|
await lockPreviousFileEntry;
|
|
8528
8590
|
await requestLockWriter();
|
|
8529
8591
|
writingBufferedEntryData = true;
|
|
@@ -9346,7 +9408,9 @@
|
|
|
9346
9408
|
exports.Uint8ArrayWriter = Uint8ArrayWriter;
|
|
9347
9409
|
exports.Writer = Writer;
|
|
9348
9410
|
exports.ZipReader = ZipReader;
|
|
9411
|
+
exports.ZipReaderStream = ZipReaderStream;
|
|
9349
9412
|
exports.ZipWriter = ZipWriter;
|
|
9413
|
+
exports.ZipWriterStream = ZipWriterStream;
|
|
9350
9414
|
exports.configure = configure;
|
|
9351
9415
|
exports.getMimeType = getMimeType;
|
|
9352
9416
|
exports.initReader = initReader;
|