Skip to content

Commit

Permalink
bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
gildas-lormeau committed Feb 11, 2021
1 parent 2a6c57e commit f1a4c87
Show file tree
Hide file tree
Showing 12 changed files with 178 additions and 108 deletions.
71 changes: 45 additions & 26 deletions dist/zip-fs-full.js
Original file line number Diff line number Diff line change
Expand Up @@ -4235,7 +4235,7 @@
workerScripts: undefined
};

let config = Object.assign({}, DEFAULT_CONFIGURATION);
const config = Object.assign({}, DEFAULT_CONFIGURATION);

function getConfiguration() {
return config;
Expand Down Expand Up @@ -5471,7 +5471,8 @@

async writeUint8Array(array) {
super.writeUint8Array(array);
let indexArray = 0, dataString = this.pending;
let indexArray = 0;
let dataString = this.pending;
const delta = this.pending.length;
this.pending = "";
for (indexArray = 0; indexArray < (Math.floor((delta + array.length) / 3) * 3) - delta; indexArray++) {
Expand Down Expand Up @@ -6207,7 +6208,8 @@
}

async flush() {
let signature, data = new Uint8Array(0);
let signature;
let data = new Uint8Array(0);
if (this.encrypted) {
const result = await this.decrypt.flush();
if (!result.valid) {
Expand Down Expand Up @@ -6255,7 +6257,8 @@
}

async flush() {
let data = new Uint8Array(0), signature;
let signature;
let data = new Uint8Array(0);
if (this.compressed) {
data = (await this.deflate.flush()) || new Uint8Array(0);
}
Expand Down Expand Up @@ -6467,7 +6470,8 @@
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

let pool = [], pendingRequests = [];
let pool = [];
let pendingRequests = [];

function createCodec$1(options, config) {
const streamCopy =
Expand Down Expand Up @@ -6669,8 +6673,9 @@
const endOfDirectoryView = new DataView(endOfDirectoryInfo.buffer);
let directoryDataLength = getUint32(endOfDirectoryView, 12);
let directoryDataOffset = getUint32(endOfDirectoryView, 16);
let filesLength = getUint16(endOfDirectoryView, 8), prependedBytesLength = 0;
if (directoryDataOffset == MAX_32_BITS || filesLength == MAX_16_BITS) {
let filesLength = getUint16(endOfDirectoryView, 8);
let prependedBytesLength = 0;
if (directoryDataOffset == MAX_32_BITS || directoryDataLength == MAX_32_BITS || filesLength == MAX_16_BITS) {
const endOfDirectoryLocatorArray = await reader.readUint8Array(endOfDirectoryInfo.offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH, ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH);
const endOfDirectoryLocatorView = new DataView(endOfDirectoryLocatorArray.buffer);
if (getUint32(endOfDirectoryLocatorView, 0) != ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
Expand Down Expand Up @@ -6780,7 +6785,7 @@
readCommonHeader(localDirectory, dataView, 4);
localDirectory.rawExtraField = dataArray.subarray(this.offset + 30 + localDirectory.filenameLength, this.offset + 30 + localDirectory.filenameLength + localDirectory.extraFieldLength);
readCommonFooter(this, localDirectory, dataView, 4);
let dataOffset = this.offset + 30 + localDirectory.filenameLength + localDirectory.extraFieldLength;
const dataOffset = this.offset + 30 + localDirectory.filenameLength + localDirectory.extraFieldLength;
const inputEncrypted = this.bitFlag.encrypted && localDirectory.bitFlag.encrypted;
const inputEncryptionStrength = this.extraFieldAES && this.extraFieldAES.strength;
if (inputEncrypted) {
Expand Down Expand Up @@ -6855,7 +6860,7 @@
if (extraFieldUnicodePath) {
readExtraFieldUnicode(extraFieldUnicodePath, "filename", "rawFilename", directory, fileEntry);
}
let extraFieldUnicodeComment = directory.extraFieldUnicodeComment = extraField.get(EXTRAFIELD_TYPE_UNICODE_COMMENT);
const extraFieldUnicodeComment = directory.extraFieldUnicodeComment = extraField.get(EXTRAFIELD_TYPE_UNICODE_COMMENT);
if (extraFieldUnicodeComment) {
readExtraFieldUnicode(extraFieldUnicodeComment, "comment", "rawComment", directory, fileEntry);
}
Expand Down Expand Up @@ -6927,12 +6932,7 @@
const signatureView = new DataView(signatureArray.buffer);
setUint32(signatureView, 0, signature);
const maximumBytes = minimumBytes + maximumLength;
let offset = minimumBytes;
let dataInfo = await seek(offset);
if (!dataInfo) {
dataInfo = await seek(Math.min(maximumBytes, reader.size));
}
return dataInfo;
return (await seek(minimumBytes)) || await seek(Math.min(maximumBytes, reader.size));

async function seek(length) {
const offset = reader.size - length;
Expand Down Expand Up @@ -7114,7 +7114,8 @@
let rawExtraField = new Uint8Array(0);
const extraField = options.extraField;
if (extraField) {
let extraFieldSize = 0, offset = 0;
let extraFieldSize = 0;
let offset = 0;
extraField.forEach(data => extraFieldSize += 4 + data.length);
rawExtraField = new Uint8Array(extraFieldSize);
extraField.forEach((data, type) => {
Expand Down Expand Up @@ -7146,11 +7147,19 @@
async close(comment = new Uint8Array(0)) {
const writer = this.writer;
const files = this.files;
let offset = 0, directoryDataLength = 0, directoryOffset = this.offset, filesLength = files.size;
let offset = 0;
let directoryDataLength = 0;
let directoryOffset = this.offset;
let filesLength = files.size;
for (const [, fileEntry] of files) {
directoryDataLength += 46 + fileEntry.rawFilename.length + fileEntry.rawComment.length + fileEntry.rawExtraFieldZip64.length + fileEntry.rawExtraFieldAES.length + fileEntry.rawExtraField.length;
}
const zip64 = this.options.zip64 || directoryOffset + directoryDataLength >= MAX_32_BITS || filesLength >= MAX_16_BITS;
directoryDataLength += 46 +
fileEntry.rawFilename.length +
fileEntry.rawComment.length +
fileEntry.rawExtraFieldZip64.length +
fileEntry.rawExtraFieldAES.length +
fileEntry.rawExtraField.length;
}
const zip64 = this.options.zip64 || directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || filesLength >= MAX_16_BITS;
const directoryArray = new Uint8Array(directoryDataLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH));
const directoryView = new DataView(directoryArray.buffer);
if (comment.length) {
Expand Down Expand Up @@ -7199,6 +7208,7 @@
setUint32$1(directoryView, offset + 72, ZIP64_TOTAL_NUMBER_OF_DISKS);
filesLength = MAX_16_BITS;
directoryOffset = MAX_32_BITS;
directoryDataLength = MAX_32_BITS;
offset += 76;
}
setUint32$1(directoryView, offset, END_OF_CENTRAL_DIR_SIGNATURE);
Expand All @@ -7217,9 +7227,12 @@
async function addFile(zipWriter, name, reader, options) {
const files = zipWriter.files, writer = zipWriter.writer;
files.set(name, null);
let resolveLockWrite, lockPreviousFile, resolveLockPreviousFile;
let resolveLockWrite;
let lockPreviousFile;
let resolveLockPreviousFile;
try {
let fileWriter, fileEntry;
let fileWriter;
let fileEntry;
try {
if (options.keepOrder) {
lockPreviousFile = zipWriter.lockPreviousFile;
Expand Down Expand Up @@ -7276,7 +7289,8 @@
const level = options.level;
const outputCompressed = level !== 0 && !options.directory;
const zip64 = options.zip64;
let rawExtraFieldAES, outputEncryptionStrength;
let rawExtraFieldAES;
let outputEncryptionStrength;
if (outputEncrypted) {
rawExtraFieldAES = new Uint8Array(EXTRAFIELD_DATA_AES.length + 2);
const extraFieldAESView = new DataView(rawExtraFieldAES.buffer);
Expand Down Expand Up @@ -7333,7 +7347,9 @@
setUint32$1(fileDataView, 0, LOCAL_FILE_HEADER_SIGNATURE);
fileDataArray.set(headerArray, 4);
fileDataArray.set(rawFilename, 30);
let result, uncompressedSize = 0, compressedSize = 0;
let result;
let uncompressedSize = 0;
let compressedSize = 0;
if (reader) {
uncompressedSize = reader.size;
const codec = await createCodec$1({
Expand Down Expand Up @@ -7506,7 +7522,8 @@
}

getRelativeName(ancestor = this.fs.root) {
let relativeName = this.name, entry = this.parent;
let relativeName = this.name;
let entry = this.parent;
while (entry && entry != ancestor) {
relativeName = (entry.name ? entry.name + "/" : "") + relativeName;
entry = entry.parent;
Expand Down Expand Up @@ -7690,7 +7707,9 @@
const zipReader = new ZipReader$1(reader, options);
const entries = await zipReader.getEntries();
entries.forEach((entry) => {
let parent = this, path = entry.filename.split("/"), name = path.pop();
let parent = this;
const path = entry.filename.split("/");
const name = path.pop();
path.forEach(pathPart => parent = parent.getChildByName(pathPart) || new ZipDirectoryEntry(this.fs, pathPart, null, parent));
if (!entry.directory) {
addChild(parent, name, {
Expand Down
2 changes: 1 addition & 1 deletion dist/zip-fs-full.min.js

Large diffs are not rendered by default.

71 changes: 45 additions & 26 deletions dist/zip-fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
workerScripts: undefined
};

let config = Object.assign({}, DEFAULT_CONFIGURATION);
const config = Object.assign({}, DEFAULT_CONFIGURATION);

function getConfiguration() {
return config;
Expand Down Expand Up @@ -273,7 +273,8 @@

async writeUint8Array(array) {
super.writeUint8Array(array);
let indexArray = 0, dataString = this.pending;
let indexArray = 0;
let dataString = this.pending;
const delta = this.pending.length;
this.pending = "";
for (indexArray = 0; indexArray < (Math.floor((delta + array.length) / 3) * 3) - delta; indexArray++) {
Expand Down Expand Up @@ -1009,7 +1010,8 @@
}

async flush() {
let signature, data = new Uint8Array(0);
let signature;
let data = new Uint8Array(0);
if (this.encrypted) {
const result = await this.decrypt.flush();
if (!result.valid) {
Expand Down Expand Up @@ -1057,7 +1059,8 @@
}

async flush() {
let data = new Uint8Array(0), signature;
let signature;
let data = new Uint8Array(0);
if (this.compressed) {
data = (await this.deflate.flush()) || new Uint8Array(0);
}
Expand Down Expand Up @@ -1269,7 +1272,8 @@
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

let pool = [], pendingRequests = [];
let pool = [];
let pendingRequests = [];

function createCodec$1(options, config) {
const streamCopy =
Expand Down Expand Up @@ -1471,8 +1475,9 @@
const endOfDirectoryView = new DataView(endOfDirectoryInfo.buffer);
let directoryDataLength = getUint32(endOfDirectoryView, 12);
let directoryDataOffset = getUint32(endOfDirectoryView, 16);
let filesLength = getUint16(endOfDirectoryView, 8), prependedBytesLength = 0;
if (directoryDataOffset == MAX_32_BITS || filesLength == MAX_16_BITS) {
let filesLength = getUint16(endOfDirectoryView, 8);
let prependedBytesLength = 0;
if (directoryDataOffset == MAX_32_BITS || directoryDataLength == MAX_32_BITS || filesLength == MAX_16_BITS) {
const endOfDirectoryLocatorArray = await reader.readUint8Array(endOfDirectoryInfo.offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH, ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH);
const endOfDirectoryLocatorView = new DataView(endOfDirectoryLocatorArray.buffer);
if (getUint32(endOfDirectoryLocatorView, 0) != ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
Expand Down Expand Up @@ -1582,7 +1587,7 @@
readCommonHeader(localDirectory, dataView, 4);
localDirectory.rawExtraField = dataArray.subarray(this.offset + 30 + localDirectory.filenameLength, this.offset + 30 + localDirectory.filenameLength + localDirectory.extraFieldLength);
readCommonFooter(this, localDirectory, dataView, 4);
let dataOffset = this.offset + 30 + localDirectory.filenameLength + localDirectory.extraFieldLength;
const dataOffset = this.offset + 30 + localDirectory.filenameLength + localDirectory.extraFieldLength;
const inputEncrypted = this.bitFlag.encrypted && localDirectory.bitFlag.encrypted;
const inputEncryptionStrength = this.extraFieldAES && this.extraFieldAES.strength;
if (inputEncrypted) {
Expand Down Expand Up @@ -1657,7 +1662,7 @@
if (extraFieldUnicodePath) {
readExtraFieldUnicode(extraFieldUnicodePath, "filename", "rawFilename", directory, fileEntry);
}
let extraFieldUnicodeComment = directory.extraFieldUnicodeComment = extraField.get(EXTRAFIELD_TYPE_UNICODE_COMMENT);
const extraFieldUnicodeComment = directory.extraFieldUnicodeComment = extraField.get(EXTRAFIELD_TYPE_UNICODE_COMMENT);
if (extraFieldUnicodeComment) {
readExtraFieldUnicode(extraFieldUnicodeComment, "comment", "rawComment", directory, fileEntry);
}
Expand Down Expand Up @@ -1729,12 +1734,7 @@
const signatureView = new DataView(signatureArray.buffer);
setUint32(signatureView, 0, signature);
const maximumBytes = minimumBytes + maximumLength;
let offset = minimumBytes;
let dataInfo = await seek(offset);
if (!dataInfo) {
dataInfo = await seek(Math.min(maximumBytes, reader.size));
}
return dataInfo;
return (await seek(minimumBytes)) || await seek(Math.min(maximumBytes, reader.size));

async function seek(length) {
const offset = reader.size - length;
Expand Down Expand Up @@ -1916,7 +1916,8 @@
let rawExtraField = new Uint8Array(0);
const extraField = options.extraField;
if (extraField) {
let extraFieldSize = 0, offset = 0;
let extraFieldSize = 0;
let offset = 0;
extraField.forEach(data => extraFieldSize += 4 + data.length);
rawExtraField = new Uint8Array(extraFieldSize);
extraField.forEach((data, type) => {
Expand Down Expand Up @@ -1948,11 +1949,19 @@
async close(comment = new Uint8Array(0)) {
const writer = this.writer;
const files = this.files;
let offset = 0, directoryDataLength = 0, directoryOffset = this.offset, filesLength = files.size;
let offset = 0;
let directoryDataLength = 0;
let directoryOffset = this.offset;
let filesLength = files.size;
for (const [, fileEntry] of files) {
directoryDataLength += 46 + fileEntry.rawFilename.length + fileEntry.rawComment.length + fileEntry.rawExtraFieldZip64.length + fileEntry.rawExtraFieldAES.length + fileEntry.rawExtraField.length;
}
const zip64 = this.options.zip64 || directoryOffset + directoryDataLength >= MAX_32_BITS || filesLength >= MAX_16_BITS;
directoryDataLength += 46 +
fileEntry.rawFilename.length +
fileEntry.rawComment.length +
fileEntry.rawExtraFieldZip64.length +
fileEntry.rawExtraFieldAES.length +
fileEntry.rawExtraField.length;
}
const zip64 = this.options.zip64 || directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || filesLength >= MAX_16_BITS;
const directoryArray = new Uint8Array(directoryDataLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH));
const directoryView = new DataView(directoryArray.buffer);
if (comment.length) {
Expand Down Expand Up @@ -2001,6 +2010,7 @@
setUint32$1(directoryView, offset + 72, ZIP64_TOTAL_NUMBER_OF_DISKS);
filesLength = MAX_16_BITS;
directoryOffset = MAX_32_BITS;
directoryDataLength = MAX_32_BITS;
offset += 76;
}
setUint32$1(directoryView, offset, END_OF_CENTRAL_DIR_SIGNATURE);
Expand All @@ -2019,9 +2029,12 @@
async function addFile(zipWriter, name, reader, options) {
const files = zipWriter.files, writer = zipWriter.writer;
files.set(name, null);
let resolveLockWrite, lockPreviousFile, resolveLockPreviousFile;
let resolveLockWrite;
let lockPreviousFile;
let resolveLockPreviousFile;
try {
let fileWriter, fileEntry;
let fileWriter;
let fileEntry;
try {
if (options.keepOrder) {
lockPreviousFile = zipWriter.lockPreviousFile;
Expand Down Expand Up @@ -2078,7 +2091,8 @@
const level = options.level;
const outputCompressed = level !== 0 && !options.directory;
const zip64 = options.zip64;
let rawExtraFieldAES, outputEncryptionStrength;
let rawExtraFieldAES;
let outputEncryptionStrength;
if (outputEncrypted) {
rawExtraFieldAES = new Uint8Array(EXTRAFIELD_DATA_AES.length + 2);
const extraFieldAESView = new DataView(rawExtraFieldAES.buffer);
Expand Down Expand Up @@ -2135,7 +2149,9 @@
setUint32$1(fileDataView, 0, LOCAL_FILE_HEADER_SIGNATURE);
fileDataArray.set(headerArray, 4);
fileDataArray.set(rawFilename, 30);
let result, uncompressedSize = 0, compressedSize = 0;
let result;
let uncompressedSize = 0;
let compressedSize = 0;
if (reader) {
uncompressedSize = reader.size;
const codec = await createCodec$1({
Expand Down Expand Up @@ -2340,7 +2356,8 @@
}

getRelativeName(ancestor = this.fs.root) {
let relativeName = this.name, entry = this.parent;
let relativeName = this.name;
let entry = this.parent;
while (entry && entry != ancestor) {
relativeName = (entry.name ? entry.name + "/" : "") + relativeName;
entry = entry.parent;
Expand Down Expand Up @@ -2524,7 +2541,9 @@
const zipReader = new ZipReader$1(reader, options);
const entries = await zipReader.getEntries();
entries.forEach((entry) => {
let parent = this, path = entry.filename.split("/"), name = path.pop();
let parent = this;
const path = entry.filename.split("/");
const name = path.pop();
path.forEach(pathPart => parent = parent.getChildByName(pathPart) || new ZipDirectoryEntry(this.fs, pathPart, null, parent));
if (!entry.directory) {
addChild(parent, name, {
Expand Down
2 changes: 1 addition & 1 deletion dist/zip-fs.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit f1a4c87

Please sign in to comment.