{“ast”:null,“code”:“'use strict';nnvar readerFor = require('./reader/readerFor');nnvar utils = require('./utils');nnvar sig = require('./signature');nnvar ZipEntry = require('./zipEntry');nnvar utf8 = require('./utf8');nnvar support = require('./support'); // class ZipEntries {{{nn/**n * All the entries in the zip file.n * @constructorn * @param {Object} loadOptions Options for loading the stream.n */nnnfunction ZipEntries(loadOptions) {n this.files = [];n this.loadOptions = loadOptions;n}nnZipEntries.prototype = {n /**n * Check that the reader is on the specified signature.n * @param {string} expectedSignature the expected signature.n * @throws {Error} if it is an other signature.n */n checkSignature: function checkSignature(expectedSignature) {n if (!this.reader.readAndCheckSignature(expectedSignature)) {n this.reader.index -= 4;n var signature = this.reader.readString(4);n throw new Error("Corrupted zip or bug: unexpected signature " + "(" + utils.pretty(signature) + ", expected " + utils.pretty(expectedSignature) + ")");n }n },nn /**n * Check if the given signature is at the given index.n * @param {number} askedIndex the index to check.n * @param {string} expectedSignature the signature to expect.n * @return {boolean} true if the signature is here, false otherwise.n */n isSignature: function isSignature(askedIndex, expectedSignature) {n var currentIndex = this.reader.index;n this.reader.setIndex(askedIndex);n var signature = this.reader.readString(4);n var result = signature === expectedSignature;n this.reader.setIndex(currentIndex);n return result;n },nn /**n * Read the end of the central directory.n */n readBlockEndOfCentral: function readBlockEndOfCentral() {n this.diskNumber = this.reader.readInt(2);n this.diskWithCentralDirStart = this.reader.readInt(2);n this.centralDirRecordsOnThisDisk = this.reader.readInt(2);n this.centralDirRecords = this.reader.readInt(2);n this.centralDirSize = this.reader.readInt(4);n this.centralDirOffset = this.reader.readInt(4);n this.zipCommentLength = this.reader.readInt(2); // warning : the encoding depends of the system localen // On a linux machine with LANG=en_US.utf8, this field is utf8 encoded.n // On a windows machine, this field is encoded with the localized windows code page.nn var zipComment = this.reader.readData(this.zipCommentLength);n var decodeParamType = support.uint8array ? "uint8array" : "array"; // To get consistent behavior with the generation part, we will assume thatn // this is utf8 encoded unless specified otherwise.nn var decodeContent = utils.transformTo(decodeParamType, zipComment);n this.zipComment = this.loadOptions.decodeFileName(decodeContent);n },nn /**n * Read the end of the Zip 64 central directory.n * Not merged with the method readEndOfCentral :n * The end of central can coexist with its Zip64 brother,n * I don't want to read the wrong number of bytes !n */n readBlockZip64EndOfCentral: function readBlockZip64EndOfCentral() {n this.zip64EndOfCentralSize = this.reader.readInt(8);n this.reader.skip(4); // this.versionMadeBy = this.reader.readString(2);n // this.versionNeeded = this.reader.readInt(2);nn this.diskNumber = this.reader.readInt(4);n this.diskWithCentralDirStart = this.reader.readInt(4);n this.centralDirRecordsOnThisDisk = this.reader.readInt(8);n this.centralDirRecords = this.reader.readInt(8);n this.centralDirSize = this.reader.readInt(8);n this.centralDirOffset = this.reader.readInt(8);n this.zip64ExtensibleData = {};n var extraDataSize = this.zip64EndOfCentralSize - 44,n index = 0,n extraFieldId,n extraFieldLength,n extraFieldValue;nn while (index < extraDataSize) {n extraFieldId = this.reader.readInt(2);n extraFieldLength = this.reader.readInt(4);n extraFieldValue = this.reader.readData(extraFieldLength);n this.zip64ExtensibleData = {n id: extraFieldId,n length: extraFieldLength,n value: extraFieldValuen };n }n },nn /**n * Read the end of the Zip 64 central directory locator.n */n readBlockZip64EndOfCentralLocator: function readBlockZip64EndOfCentralLocator() {n this.diskWithZip64CentralDirStart = this.reader.readInt(4);n this.relativeOffsetEndOfZip64CentralDir = this.reader.readInt(8);n this.disksCount = this.reader.readInt(4);nn if (this.disksCount > 1) {n throw new Error("Multi-volumes zip are not supported");n }n },nn /**n * Read the local files, based on the offset read in the central part.n */n readLocalFiles: function readLocalFiles() {n var i, file;nn for (i = 0; i < this.files.length; i++) {n file = this.files;n this.reader.setIndex(file.localHeaderOffset);n this.checkSignature(sig.LOCAL_FILE_HEADER);n file.readLocalPart(this.reader);n file.handleUTF8();n file.processAttributes();n }n },nn /**n * Read the central directory.n */n readCentralDir: function readCentralDir() {n var file;n this.reader.setIndex(this.centralDirOffset);nn while (this.reader.readAndCheckSignature(sig.CENTRAL_FILE_HEADER)) {n file = new ZipEntry({n zip64: this.zip64n }, this.loadOptions);n file.readCentralPart(this.reader);n this.files.push(file);n }nn if (this.centralDirRecords !== this.files.length) {n if (this.centralDirRecords !== 0 && this.files.length === 0) {n // We expected some records but couldn't find ANY.n // This is really suspicious, as if something went wrong.n throw new Error("Corrupted zip or bug: expected " + this.centralDirRecords + " records in central dir, got " + this.files.length);n } else {// We found some records but not all.n // Something is wrong but we got something for the user: no error here.n // console.warn("expected", this.centralDirRecords, "records in central dir, got", this.files.length);n }n }n },nn /**n * Read the end of central directory.n */n readEndOfCentral: function readEndOfCentral() {n var offset = this.reader.lastIndexOfSignature(sig.CENTRAL_DIRECTORY_END);nn if (offset < 0) {n // Check if the content is a truncated zip or complete garbage.n // A "LOCAL_FILE_HEADER" is not required at the beginning (auton // extractible zip for example) but it can give a good hint.n // If an ajax request was used without responseType, we will alson // get unreadable data.n var isGarbage = !this.isSignature(0, sig.LOCAL_FILE_HEADER);nn if (isGarbage) {n throw new Error("Can't find end of central directory : is this a zip file ? " + "If it is, see stuk.github.io/jszip/documentation/howto/read_zip.html");n } else {n throw new Error("Corrupted zip: can't find end of central directory");n }n }nn this.reader.setIndex(offset);n var endOfCentralDirOffset = offset;n this.checkSignature(sig.CENTRAL_DIRECTORY_END);n this.readBlockEndOfCentral();n /* extract from the zip spec :n 4) If one of the fields in the end of central directoryn record is too small to hold required data, the fieldn should be set to -1 (0xFFFF or 0xFFFFFFFF) and then ZIP64 format record should be created.n 5) The end of central directory record and then Zip64 end of central directory locator record mustn reside on the same disk when splitting or spanningn an archive.n */nn if (this.diskNumber === utils.MAX_VALUE_16BITS || this.diskWithCentralDirStart === utils.MAX_VALUE_16BITS || this.centralDirRecordsOnThisDisk === utils.MAX_VALUE_16BITS || this.centralDirRecords === utils.MAX_VALUE_16BITS || this.centralDirSize === utils.MAX_VALUE_32BITS || this.centralDirOffset === utils.MAX_VALUE_32BITS) {n this.zip64 = true;n /*n Warning : the zip64 extension is supported, but ONLY if the 64bits integer read fromn the zip file can fit into a 32bits integer. This cannot be solved : JavaScript representsn all numbers as 64-bit double precision IEEE 754 floating point numbers.n So, we have 53bits for integers and bitwise operations treat everything as 32bits.n see developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Bitwise_Operatorsn and www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf section 8.5n */n // should look for a zip64 EOCD locatornn offset = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);nn if (offset < 0) {n throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");n }nn this.reader.setIndex(offset);n this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);n this.readBlockZip64EndOfCentralLocator(); // now the zip64 EOCD recordnn if (!this.isSignature(this.relativeOffsetEndOfZip64CentralDir, sig.ZIP64_CENTRAL_DIRECTORY_END)) {n // console.warn("ZIP64 end of central directory not where expected.");n this.relativeOffsetEndOfZip64CentralDir = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);nn if (this.relativeOffsetEndOfZip64CentralDir < 0) {n throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");n }n }nn this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir);n this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);n this.readBlockZip64EndOfCentral();n }nn var expectedEndOfCentralDirOffset = this.centralDirOffset + this.centralDirSize;nn if (this.zip64) {n expectedEndOfCentralDirOffset += 20; // end of central dir 64 locatornn expectedEndOfCentralDirOffset += 12n /* should not include the leading 12 bytes */n + this.zip64EndOfCentralSize;n }nn var extraBytes = endOfCentralDirOffset - expectedEndOfCentralDirOffset;nn if (extraBytes > 0) {n // console.warn(extraBytes, "extra bytes at beginning or within zipfile");n if (this.isSignature(endOfCentralDirOffset, sig.CENTRAL_FILE_HEADER)) {// The offsets seem wrong, but we have something at the specified offset.n // So… we keep it.n } else {n // the offset is wrong, update the "zero" of the readern // this happens if data has been prepended (crx files for example)n this.reader.zero = extraBytes;n }n } else if (extraBytes < 0) {n throw new Error("Corrupted zip: missing " + Math.abs(extraBytes) + " bytes.");n }n },n prepareReader: function prepareReader(data) {n this.reader = readerFor(data);n },nn /**n * Read a zip file and create ZipEntries.n * @param {String|ArrayBuffer|Uint8Array|Buffer} data the binary string representing a zip file.n */n load: function load(data) {n this.prepareReader(data);n this.readEndOfCentral();n this.readCentralDir();n this.readLocalFiles();n }n}; // }}} end of ZipEntriesnnmodule.exports = ZipEntries;”,“map”:null,“metadata”:{},“sourceType”:“module”}