@zip.js/zip.js 2.7.34 → 2.7.35
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/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 +121 -7
- 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-fs.js
CHANGED
|
@@ -3069,8 +3069,8 @@
|
|
|
3069
3069
|
|
|
3070
3070
|
constructor(writerGenerator, maxSize = 4294967295) {
|
|
3071
3071
|
super();
|
|
3072
|
-
const
|
|
3073
|
-
Object.assign(
|
|
3072
|
+
const writer = this;
|
|
3073
|
+
Object.assign(writer, {
|
|
3074
3074
|
diskNumber: 0,
|
|
3075
3075
|
diskOffset: 0,
|
|
3076
3076
|
size: 0,
|
|
@@ -3080,7 +3080,7 @@
|
|
|
3080
3080
|
let diskSourceWriter, diskWritable, diskWriter;
|
|
3081
3081
|
const writable = new WritableStream({
|
|
3082
3082
|
async write(chunk) {
|
|
3083
|
-
const { availableSize } =
|
|
3083
|
+
const { availableSize } = writer;
|
|
3084
3084
|
if (!diskWriter) {
|
|
3085
3085
|
const { value, done } = await writerGenerator.next();
|
|
3086
3086
|
if (done && !value) {
|
|
@@ -3089,9 +3089,9 @@
|
|
|
3089
3089
|
diskSourceWriter = value;
|
|
3090
3090
|
diskSourceWriter.size = 0;
|
|
3091
3091
|
if (diskSourceWriter.maxSize) {
|
|
3092
|
-
|
|
3092
|
+
writer.maxSize = diskSourceWriter.maxSize;
|
|
3093
3093
|
}
|
|
3094
|
-
|
|
3094
|
+
writer.availableSize = writer.maxSize;
|
|
3095
3095
|
await initStream(diskSourceWriter);
|
|
3096
3096
|
diskWritable = value.writable;
|
|
3097
3097
|
diskWriter = diskWritable.getWriter();
|
|
@@ -3100,8 +3100,8 @@
|
|
|
3100
3100
|
} else if (chunk.length >= availableSize) {
|
|
3101
3101
|
await writeChunk(chunk.slice(0, availableSize));
|
|
3102
3102
|
await closeDisk();
|
|
3103
|
-
|
|
3104
|
-
|
|
3103
|
+
writer.diskOffset += diskSourceWriter.size;
|
|
3104
|
+
writer.diskNumber++;
|
|
3105
3105
|
diskWriter = null;
|
|
3106
3106
|
await this.write(chunk.slice(availableSize));
|
|
3107
3107
|
} else {
|
|
@@ -3113,7 +3113,7 @@
|
|
|
3113
3113
|
await closeDisk();
|
|
3114
3114
|
}
|
|
3115
3115
|
});
|
|
3116
|
-
Object.defineProperty(
|
|
3116
|
+
Object.defineProperty(writer, PROPERTY_NAME_WRITABLE, {
|
|
3117
3117
|
get() {
|
|
3118
3118
|
return writable;
|
|
3119
3119
|
}
|
|
@@ -3125,8 +3125,8 @@
|
|
|
3125
3125
|
await diskWriter.ready;
|
|
3126
3126
|
await diskWriter.write(chunk);
|
|
3127
3127
|
diskSourceWriter.size += chunkLength;
|
|
3128
|
-
|
|
3129
|
-
|
|
3128
|
+
writer.size += chunkLength;
|
|
3129
|
+
writer.availableSize -= chunkLength;
|
|
3130
3130
|
}
|
|
3131
3131
|
}
|
|
3132
3132
|
|
|
@@ -3146,6 +3146,8 @@
|
|
|
3146
3146
|
async function initStream(stream, initSize) {
|
|
3147
3147
|
if (stream.init && !stream.initialized) {
|
|
3148
3148
|
await stream.init(initSize);
|
|
3149
|
+
} else {
|
|
3150
|
+
return Promise.resolve();
|
|
3149
3151
|
}
|
|
3150
3152
|
}
|
|
3151
3153
|
|
|
@@ -3347,8 +3349,8 @@
|
|
|
3347
3349
|
1. Redistributions of source code must retain the above copyright notice,
|
|
3348
3350
|
this list of conditions and the following disclaimer.
|
|
3349
3351
|
|
|
3350
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
3351
|
-
notice, this list of conditions and the following disclaimer in
|
|
3352
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
3353
|
+
notice, this list of conditions and the following disclaimer in
|
|
3352
3354
|
the documentation and/or other materials provided with the distribution.
|
|
3353
3355
|
|
|
3354
3356
|
3. The names of the authors may not be used to endorse or promote products
|
|
@@ -3477,7 +3479,7 @@
|
|
|
3477
3479
|
}
|
|
3478
3480
|
if (directoryDataOffset >= reader.size) {
|
|
3479
3481
|
prependedDataLength = reader.size - directoryDataOffset - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
|
|
3480
|
-
directoryDataOffset = reader.size - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
|
|
3482
|
+
directoryDataOffset = reader.size - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
|
|
3481
3483
|
}
|
|
3482
3484
|
if (expectedLastDiskNumber != lastDiskNumber) {
|
|
3483
3485
|
throw new Error(ERR_SPLIT_ZIP_FILE);
|
|
@@ -3594,6 +3596,34 @@
|
|
|
3594
3596
|
}
|
|
3595
3597
|
}
|
|
3596
3598
|
|
|
3599
|
+
class ZipReaderStream {
|
|
3600
|
+
|
|
3601
|
+
constructor(options = {}) {
|
|
3602
|
+
const { readable, writable } = new TransformStream();
|
|
3603
|
+
const gen = new ZipReader(readable, options).getEntriesGenerator();
|
|
3604
|
+
this.readable = new ReadableStream({
|
|
3605
|
+
async pull(controller) {
|
|
3606
|
+
const { done, value } = await gen.next();
|
|
3607
|
+
if (done)
|
|
3608
|
+
return controller.close();
|
|
3609
|
+
const chunk = {
|
|
3610
|
+
...value,
|
|
3611
|
+
readable: (function () {
|
|
3612
|
+
const { readable, writable } = new TransformStream();
|
|
3613
|
+
if (value.getData) {
|
|
3614
|
+
value.getData(writable);
|
|
3615
|
+
return readable;
|
|
3616
|
+
}
|
|
3617
|
+
})()
|
|
3618
|
+
};
|
|
3619
|
+
delete chunk.getData;
|
|
3620
|
+
controller.enqueue(chunk);
|
|
3621
|
+
}
|
|
3622
|
+
});
|
|
3623
|
+
this.writable = writable;
|
|
3624
|
+
}
|
|
3625
|
+
}
|
|
3626
|
+
|
|
3597
3627
|
class ZipEntry$1 {
|
|
3598
3628
|
|
|
3599
3629
|
constructor(reader, config, options) {
|
|
@@ -3983,8 +4013,8 @@
|
|
|
3983
4013
|
1. Redistributions of source code must retain the above copyright notice,
|
|
3984
4014
|
this list of conditions and the following disclaimer.
|
|
3985
4015
|
|
|
3986
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
3987
|
-
notice, this list of conditions and the following disclaimer in
|
|
4016
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
4017
|
+
notice, this list of conditions and the following disclaimer in
|
|
3988
4018
|
the documentation and/or other materials provided with the distribution.
|
|
3989
4019
|
|
|
3990
4020
|
3. The names of the authors may not be used to endorse or promote products
|
|
@@ -4021,9 +4051,12 @@
|
|
|
4021
4051
|
|
|
4022
4052
|
constructor(writer, options = {}) {
|
|
4023
4053
|
writer = initWriter(writer);
|
|
4054
|
+
const addSplitZipSignature =
|
|
4055
|
+
writer.availableSize !== UNDEFINED_VALUE && writer.availableSize > 0 && writer.availableSize !== Infinity &&
|
|
4056
|
+
writer.maxSize !== UNDEFINED_VALUE && writer.maxSize > 0 && writer.maxSize !== Infinity;
|
|
4024
4057
|
Object.assign(this, {
|
|
4025
4058
|
writer,
|
|
4026
|
-
addSplitZipSignature
|
|
4059
|
+
addSplitZipSignature,
|
|
4027
4060
|
options,
|
|
4028
4061
|
config: getConfiguration(),
|
|
4029
4062
|
files: new Map(),
|
|
@@ -4086,6 +4119,33 @@
|
|
|
4086
4119
|
}
|
|
4087
4120
|
}
|
|
4088
4121
|
|
|
4122
|
+
class ZipWriterStream {
|
|
4123
|
+
|
|
4124
|
+
constructor(options = {}) {
|
|
4125
|
+
const { readable, writable } = new TransformStream();
|
|
4126
|
+
this.readable = readable;
|
|
4127
|
+
this.zipWriter = new ZipWriter(writable, options);
|
|
4128
|
+
}
|
|
4129
|
+
|
|
4130
|
+
transform(path) {
|
|
4131
|
+
const { readable, writable } = new TransformStream({
|
|
4132
|
+
flush: () => { this.zipWriter.close(); }
|
|
4133
|
+
});
|
|
4134
|
+
this.zipWriter.add(path, readable);
|
|
4135
|
+
return { readable: this.readable, writable };
|
|
4136
|
+
}
|
|
4137
|
+
|
|
4138
|
+
writable(path) {
|
|
4139
|
+
const { readable, writable } = new TransformStream();
|
|
4140
|
+
this.zipWriter.add(path, readable);
|
|
4141
|
+
return writable;
|
|
4142
|
+
}
|
|
4143
|
+
|
|
4144
|
+
close(comment = undefined, options = {}) {
|
|
4145
|
+
return this.zipWriter.close(comment, options);
|
|
4146
|
+
}
|
|
4147
|
+
}
|
|
4148
|
+
|
|
4089
4149
|
async function addFile(zipWriter, name, reader, options) {
|
|
4090
4150
|
name = name.trim();
|
|
4091
4151
|
if (options.directory && (!name.endsWith(DIRECTORY_SIGNATURE))) {
|
|
@@ -4256,6 +4316,7 @@
|
|
|
4256
4316
|
let writingBufferedEntryData;
|
|
4257
4317
|
let writingEntryData;
|
|
4258
4318
|
let fileWriter;
|
|
4319
|
+
let blobPromise;
|
|
4259
4320
|
files.set(name, fileEntry);
|
|
4260
4321
|
try {
|
|
4261
4322
|
let lockPreviousFileEntry;
|
|
@@ -4264,7 +4325,8 @@
|
|
|
4264
4325
|
requestLockCurrentFileEntry();
|
|
4265
4326
|
}
|
|
4266
4327
|
if ((options.bufferedWrite || zipWriter.writerLocked || (zipWriter.bufferedWrites && keepOrder) || !dataDescriptor) && !usdz) {
|
|
4267
|
-
fileWriter = new
|
|
4328
|
+
fileWriter = new TransformStream();
|
|
4329
|
+
blobPromise = new Response(fileWriter.readable).blob();
|
|
4268
4330
|
fileWriter.writable.size = 0;
|
|
4269
4331
|
bufferedWrite = true;
|
|
4270
4332
|
zipWriter.bufferedWrites++;
|
|
@@ -4300,7 +4362,7 @@
|
|
|
4300
4362
|
fileEntry.filename = name;
|
|
4301
4363
|
if (bufferedWrite) {
|
|
4302
4364
|
await fileWriter.writable.getWriter().close();
|
|
4303
|
-
let blob = await
|
|
4365
|
+
let blob = await blobPromise;
|
|
4304
4366
|
await lockPreviousFileEntry;
|
|
4305
4367
|
await requestLockWriter();
|
|
4306
4368
|
writingBufferedEntryData = true;
|
|
@@ -5891,8 +5953,8 @@
|
|
|
5891
5953
|
1. Redistributions of source code must retain the above copyright notice,
|
|
5892
5954
|
this list of conditions and the following disclaimer.
|
|
5893
5955
|
|
|
5894
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
5895
|
-
notice, this list of conditions and the following disclaimer in
|
|
5956
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
5957
|
+
notice, this list of conditions and the following disclaimer in
|
|
5896
5958
|
the documentation and/or other materials provided with the distribution.
|
|
5897
5959
|
|
|
5898
5960
|
3. The names of the authors may not be used to endorse or promote products
|
|
@@ -5960,7 +6022,9 @@
|
|
|
5960
6022
|
exports.Uint8ArrayWriter = Uint8ArrayWriter;
|
|
5961
6023
|
exports.Writer = Writer;
|
|
5962
6024
|
exports.ZipReader = ZipReader;
|
|
6025
|
+
exports.ZipReaderStream = ZipReaderStream;
|
|
5963
6026
|
exports.ZipWriter = ZipWriter;
|
|
6027
|
+
exports.ZipWriterStream = ZipWriterStream;
|
|
5964
6028
|
exports.configure = configure;
|
|
5965
6029
|
exports.fs = fs;
|
|
5966
6030
|
exports.getMimeType = getMimeType;
|