13 lines
100 KiB
JavaScript
13 lines
100 KiB
JavaScript
|
/*!
|
||
|
|
||
|
JSZip v3.1.5 - A JavaScript class for generating and reading zip files
|
||
|
<http://stuartk.com/jszip>
|
||
|
|
||
|
(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
|
||
|
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown.
|
||
|
|
||
|
JSZip uses the library pako released under the MIT license :
|
||
|
https://github.com/nodeca/pako/blob/master/LICENSE
|
||
|
*/(function(c){if(typeof exports=="object"&&typeof module!="undefined")module.exports=c();else if(typeof define=="function"&&define.amd)define([],c);else{var O;O=typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:this,O.JSZip=c()}})(function(){return function c(O,v,i){function f(p,a){if(!v[p]){if(!O[p]){var o=typeof require=="function"&&require;if(!a&&o)return o(p,!0);if(d)return d(p,!0);var g=new Error("Cannot find module '"+p+"'");throw g.code="MODULE_NOT_FOUND",g}var b=v[p]={exports:{}};O[p][0].call(b.exports,function(I){var B=O[p][1][I];return f(B||I)},b,b.exports,c,O,v,i)}return v[p].exports}for(var d=typeof require=="function"&&require,s=0;s<i.length;s++)f(i[s]);return f}({1:[function(c,O,v){"use strict";var i=c("./utils"),f=c("./support"),d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";v.encode=function(s){for(var p,a,o,g,b,I,B,l=[],t=0,u=s.length,w=u,C=i.getTypeOf(s)!=="string";t<s.length;)w=u-t,C?(p=s[t++],a=t<u?s[t++]:0,o=t<u?s[t++]:0):(p=s.charCodeAt(t++),a=t<u?s.charCodeAt(t++):0,o=t<u?s.charCodeAt(t++):0),g=p>>2,b=(3&p)<<4|a>>4,I=w>1?(15&a)<<2|o>>6:64,B=w>2?63&o:64,l.push(d.charAt(g)+d.charAt(b)+d.charAt(I)+d.charAt(B));return l.join("")},v.decode=function(s){var p,a,o,g,b,I,B,l=0,t=0,u="data:";if(s.substr(0,u.length)===u)throw new Error("Invalid base64 input, it looks like a data url.");s=s.replace(/[^A-Za-z0-9\+\/\=]/g,"");var w=3*s.length/4;if(s.charAt(s.length-1)===d.charAt(64)&&w--,s.charAt(s.length-2)===d.charAt(64)&&w--,w%1!=0)throw new Error("Invalid base64 input, bad content length.");var C;for(C=f.uint8array?new Uint8Array(0|w):new Array(0|w);l<s.length;)g=d.indexOf(s.charAt(l++)),b=d.indexOf(s.charAt(l++)),I=d.indexOf(s.charAt(l++)),B=d.indexOf(s.charAt(l++)),p=g<<2|b>>4,a=(15&b)<<4|I>>2,o=(3&I)<<6|B,C[t++]=p,I!==64&&(C[t++]=a),B!==64&&(C[t++]=o);return C}},{"./support":30,"./utils":32}],2:[function(c,O,v){"use strict";function i(a,o,g,b,I){this.compressedSize=a,this.uncompressedSize=o,this.crc32=g,this.compression=b,this.compressedContent=I}var f=c("./external"),d=c("./stream/DataWorker"),s=c("./stream/DataLengthProbe"),p=c("./stream/Crc32Probe"),s=c("./stream/DataLengthProbe");i.prototype={getContentWorker:function(){var a=new d(f.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new s("data_length")),o=this;return a.on("end",function(){if(this.streamInfo.data_length!==o.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),a},getCompressedWorker:function(){return new d(f.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},i.createWorkerFrom=function(a,o,g){return a.pipe(new p).pipe(new s("uncompressedSize")).pipe(o.compressWorker(g)).pipe(new s("compressedSize")).withStreamInfo("compression",o)},O.exports=i},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(c,O,v){"use strict";var i=c("./stream/GenericWorker");v.STORE={magic:"\0\0",compressWorker:function(f){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},v.DEFLATE=c("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(c,O,v){"use strict";function i(){for(var a,o=[],g=0;g<256;g++){a=g;for(var b=0;b<8;b++)a=1&a?3988292384^a>>>1:a>>>1;o[g]=a}return o}function f(a,o,g,b){var I=p,B=b+g;a^=-1;for(var l=b;l<B;l++)a=a>>>8^I[255&(a^o[l])];return a^-1}function d(a,o,g,b){var I=p,B=b+g;a^=-1;for(var l=b;l<B;l++)a=a>>>8^I[255&(a^o.charCodeAt(l))];return a^-1}var s=c("./utils"),p=i();O.exports=function(a,o){if(typeof a=="undefined"||!a.length)return 0;var g=s.getTypeOf(a)!=="string";return g?f(0|o,a,a.length,0):d(0|o,a,a.length,0)}},{"./utils":32}],5:[function(c,O,v){"use strict";v.base64=!1,v.binary=!1,v.dir=!1,v.createFolders=!0,v.date=null,v.compression=null,v.compressionOptions=null,v.comment=null,v.unixPermissions=null,
|
||
|
\0`,$+=o(fe,2),$+=F.magic,$+=o(E,2),$+=o(z,2),$+=o(te.crc32,4),$+=o(te.compressedSize,4),$+=o(te.uncompressedSize,4),$+=o(W.length,2),$+=o(J.length,2);var ke=a.LOCAL_FILE_HEADER+$+W+J,ae=a.CENTRAL_FILE_HEADER+o(le,2)+$+o(Q.length,2)+"\0\0\0\0"+o(se,4)+o(C,4)+W+J+Q;return{fileRecord:ke,dirRecord:ae}},B=function(t,u,w,C,_){var S="",E=f.transformTo("string",_(C));return S=a.CENTRAL_DIRECTORY_END+"\0\0\0\0"+o(t,2)+o(t,2)+o(u,4)+o(w,4)+o(E.length,2)+E},l=function(t){var u="";return u=a.DATA_DESCRIPTOR+o(t.crc32,4)+o(t.compressedSize,4)+o(t.uncompressedSize,4)};f.inherits(i,d),i.prototype.push=function(t){var u=t.meta.percent||0,w=this.entriesCount,C=this._sources.length;this.accumulate?this.contentBuffer.push(t):(this.bytesWritten+=t.data.length,d.prototype.push.call(this,{data:t.data,meta:{currentFile:this.currentFile,percent:w?(u+100*(w-C-1))/w:100}}))},i.prototype.openedSource=function(t){this.currentSourceOffset=this.bytesWritten,this.currentFile=t.file.name;var u=this.streamFiles&&!t.file.dir;if(u){var w=I(t,u,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:w.fileRecord,meta:{percent:0}})}else this.accumulate=!0},i.prototype.closedSource=function(t){this.accumulate=!1;var u=this.streamFiles&&!t.file.dir,w=I(t,u,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(w.dirRecord),u)this.push({data:l(t),meta:{percent:100}});else for(this.push({data:w.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},i.prototype.flush=function(){for(var t=this.bytesWritten,u=0;u<this.dirRecords.length;u++)this.push({data:this.dirRecords[u],meta:{percent:100}});var w=this.bytesWritten-t,C=B(this.dirRecords.length,w,t,this.zipComment,this.encodeFileName);this.push({data:C,meta:{percent:100}})},i.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},i.prototype.registerPrevious=function(t){this._sources.push(t);var u=this;return t.on("data",function(w){u.processChunk(w)}),t.on("end",function(){u.closedSource(u.previous.streamInfo),u._sources.length?u.prepareNextSource():u.end()}),t.on("error",function(w){u.error(w)}),this},i.prototype.resume=function(){return!!d.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},i.prototype.error=function(t){var u=this._sources;if(!d.prototype.error.call(this,t))return!1;for(var w=0;w<u.length;w++)try{u[w].error(t)}catch(C){}return!0},i.prototype.lock=function(){d.prototype.lock.call(this);for(var t=this._sources,u=0;u<t.length;u++)t[u].lock()},O.exports=i},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(c,O,v){"use strict";var i=c("../compressions"),f=c("./ZipFileWorker"),d=function(s,p){var a=s||p,o=i[a];if(!o)throw new Error(a+" is not a valid compression method !");return o};v.generateWorker=function(s,p,a){var o=new f(p.streamFiles,a,p.platform,p.encodeFileName),g=0;try{s.forEach(function(b,I){g++;var B=d(I.options.compression,p.compression),l=I.options.compressionOptions||p.compressionOptions||{},t=I.dir,u=I.date;I._compressWorker(B,l).withStreamInfo("file",{name:b,dir:t,date:u,comment:I.comment||"",unixPermissions:I.unixPermissions,dosPermissions:I.dosPermissions}).pipe(o)}),o.entriesCount=g}catch(b){o.error(b)}return o}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(c,O,v){"use strict";function i(){if(!(this instanceof i))return new i;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files={},this.comment=null,this.root="",this.clone=function(){var f=new i;for(var d in this)typeof this[d]!="function"&&(f[d]=this[d]);return f}}i.prototype=c("./object"),i.prototype.loadAsync=c("./load"),i.support=c("./support"),i.defaults=c("./defaults"),i.version="3.1.5",i.loadAsync=func
|