mirror of
https://github.com/kristoferssolo/solorice.git
synced 2025-10-21 20:10:34 +00:00
7 lines
14 KiB
JavaScript
7 lines
14 KiB
JavaScript
module.exports=function(t){var e={};function r(i){if(e[i])return e[i].exports;var n=e[i]={i:i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(i,n,function(e){return t[e]}.bind(null,n));return i},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=250)}({1:function(t,e){t.exports=require("util")},10:function(t,e){t.exports=require("stream")},18:function(t,e){t.exports=require("path")},19:function(t,e){t.exports=require("fs")},250:function(t,e,r){
|
|
/**
|
|
* @license node-stream-zip | (c) 2015 Antelle | https://github.com/antelle/node-stream-zip/blob/master/LICENSE
|
|
* Portions copyright https://github.com/cthackers/adm-zip | https://raw.githubusercontent.com/cthackers/adm-zip/master/LICENSE
|
|
*/
|
|
var i=r(1),n=r(19),s=r(18),o=r(31),a=r(42),f=r(10),h=30,c=67324752,u=4,l=6,d=8,p=10,m=14,y=18,E=22,v=26,L=28,w=46,g=33639248,b=4,I=6,U=8,z=10,S=12,k=16,x=20,P=24,B=28,j=30,O=32,R=34,M=36,D=38,C=42,T=22,_=101010256,q=80,F=8,H=10,N=12,A=16,Y=20,Z=65535,G=20,V=117853008,W=80,X=56,$=101075792,J=80,K=24,Q=32,tt=40,et=48,rt=0,it=8,nt=9,st=1,ot=1,at=4294967295,ft=65535,ht=function(t){var e,r,i,o,f,c=this,u=!1!==t.storeEntries?{}:null,l=t.file;function d(t,e){if(t||!e)return c.emit("error",t||"Archive read error");for(var r=o.win.buffer,i=o.lastPos,n=i-o.win.position,s=o.minPos;--i>=s&&--n>=0;)if(r.length-n>=4&&r[n]===o.firstByte&&r.readUInt32LE(n)===o.sig)return o.lastBufferPosition=n,o.lastBytesRead=e,void o.complete();if(i===s)return c.emit("error","Bad archive");if(o.lastPos=i+1,o.chunkSize*=2,i<=s)return c.emit("error","Bad archive");var a=Math.min(o.chunkSize,i-s);o.win.expandLeft(a,d)}function p(){var t,e=o.win.buffer,r=o.lastBufferPosition;try{(f=new ct).read(e.slice(r,r+T)),f.headerOffset=o.win.position+r,f.commentLength?c.comment=e.slice(r+T,r+T+f.commentLength).toString():c.comment=null,c.entriesCount=f.volumeEntries,c.centralDirectory=f,f.volumeEntries===ft&&f.totalEntries===ft||f.size===at||f.offset===at?(t=G,o.lastBufferPosition>t?(o.lastBufferPosition-=t,m()):(o={win:o.win,totalReadLength:t,minPos:o.win.position-t,lastPos:o.win.position,chunkSize:o.chunkSize,firstByte:W,sig:V,complete:m}).win.read(o.lastPos-o.chunkSize,o.chunkSize,d)):(o={},E())}catch(t){c.emit("error",t)}}function m(){var t=o.win.buffer,e=new ut;e.read(t.slice(o.lastBufferPosition,o.lastBufferPosition+G));var i=r-e.headerOffset;(o={win:o.win,totalReadLength:i,minPos:e.headerOffset,lastPos:o.lastPos,chunkSize:o.chunkSize,firstByte:J,sig:$,complete:y}).win.read(r-o.chunkSize,o.chunkSize,d)}function y(){var t=o.win.buffer,e=new lt;e.read(t.slice(o.lastBufferPosition,o.lastBufferPosition+X)),c.centralDirectory.volumeEntries=e.volumeEntries,c.centralDirectory.totalEntries=e.totalEntries,c.centralDirectory.size=e.size,c.centralDirectory.offset=e.offset,c.entriesCount=e.volumeEntries,o={},E()}function E(){(o={win:new Et(e),pos:f.offset,chunkSize:i,entriesLeft:f.volumeEntries}).win.read(o.pos,Math.min(i,r-o.pos),v)}function v(e,r){if(e||!r)return c.emit("error",e||"Entries read error");var n=o.win.buffer,s=o.pos-o.win.position,a=n.length,f=o.entry;try{for(;o.entriesLeft>0;){f||((f=new dt).readHeader(n,s),f.headerOffset=o.win.position+s,o.entry=f,o.pos+=w,s+=w);var h=f.fnameLen+f.extraLen+f.comLen;if(a-s<h+(o.entriesLeft>1?w:0))return o.win.moveRight(i,v,s),void(o.move=!0);f.read(n,s),t.skipEntryNameValidation||f.validateName(),u&&(u[f.name]=f),c.emit("entry",f),o.entry=f=null,o.entriesLeft--,o.pos+=h,s+=h}c.emit("ready")}catch(e){c.emit("error",e)}}function L(){if(!u)throw new Error("storeEntries disabled")}function g(t){return t.offset+h+t.fnameLen+t.extraLen}function b(t){return 8!=(8&t.flags)}function I(t,r,i){c.stream(t,(function(s,o){var a,f;s?i(s):(o.on("error",(function(t){f=t,a&&(o.unpipe(a),a.close((function(){i(t)})))})),n.open(r,"w",(function(s,h){if(s)return i(s||f);f?n.close(e,(function(){i(f)})):((a=n.createWriteStream(r,{fd:h})).on("finish",(function(){c.emit("extract",t,r),f||i()})),o.pipe(a))})))}))}function U(t,e,r,i,n){if(!r.length)return i(null,n);var o=r.shift(),a=s.join(t,o.name.replace(e,""));I(o,a,(function(s){if(s)return i(s,n);U(t,e,r,i,n+1)}))}n.open(l,"r",(function(s,a){if(s)return c.emit("error",s);e=a,n.fstat(e,(function(n,s){if(n)return c.emit("error",n);var a;r=s.size,i=t.chunkSize||Math.round(r/1e3),i=Math.max(Math.min(i,Math.min(131072,r)),Math.min(1024,r)),a=Math.min(T+Z,r),(o={win:new Et(e),totalReadLength:a,minPos:r-a,lastPos:r,chunkSize:Math.min(1024,i),firstByte:q,sig:_,complete:p}).win.read(r-o.chunkSize,o.chunkSize,d)}))})),Object.defineProperty(this,"ready",{get:function(){return!1}}),this.entry=function(t){return L(),u[t]},this.entries=function(){return L(),u},this.stream=function(t,r){return this.openEntry(t,(function(t,i){if(t)return r(t);var n=g(i),s=new vt(e,n,i.compressedSize);if(i.method===rt);else{if(i.method!==it&&i.method!==nt)return r("Unknown compression method: "+i.method);s=s.pipe(a.createInflateRaw())}b(i)&&(s=s.pipe(new Lt(s,i.crc,i.size))),r(null,s)}),!1)},this.entryDataSync=function(t){var r=null;if(this.openEntry(t,(function(e,i){r=e,t=i}),!0),r)throw r;var i=Buffer.alloc(t.compressedSize);if(new yt(e,i,0,t.compressedSize,g(t),(function(t,e){r=t,e})).read(!0),r)throw r;if(t.method===rt);else{if(t.method!==it&&t.method!==nt)throw new Error("Unknown compression method: "+t.method);i=a.inflateRawSync(i)}if(i.length!==t.size)throw new Error("Invalid size");b(t)&&new wt(t.crc,t.size).data(i);return i},this.openEntry=function(t,r,i){if("string"==typeof t&&(L(),!(t=u[t])))return r("Entry not found");if(!t.isFile)return r("Entry is not file");if(!e)return r("Archive closed");var n=Buffer.alloc(h);new yt(e,n,0,n.length,t.offset,(function(e){if(e)return r(e);var i;try{t.readDataHeader(n),t.encrypted&&(i="Entry encrypted")}catch(t){i=t}r(i,t)})).read(i)},this.extract=function(t,e,r){var i=t||"";if("string"==typeof t&&((t=this.entry(t))?i=t.name:i.length&&"/"!==i[i.length-1]&&(i+="/")),!t||t.isDirectory){var o=[],a=[],f={};for(var h in u)if(Object.prototype.hasOwnProperty.call(u,h)&&0===h.lastIndexOf(i,0)){var c=h.replace(i,""),l=u[h];if(l.isFile&&(o.push(l),c=s.dirname(c)),c&&!f[c]&&"."!==c){f[c]=!0;var d=c.split("/").filter((function(t){return t}));for(d.length&&a.push(d);d.length>1;){var p=(d=d.slice(0,d.length-1)).join("/");if(f[p]||"."===p)break;f[p]=!0,a.push(d)}}}a.sort((function(t,e){return t.length-e.length})),a.length?function t(e,r,i){if(!r.length)return i();var o=r.shift();o=s.join(e,s.join.apply(s,o)),n.mkdir(o,(function(n){if(n&&"EEXIST"!==n.code)return i(n);t(e,r,i)}))}(e,a,(function(t){t?r(t):U(e,i,o,r,0)})):U(e,i,o,r,0)}else n.stat(e,(function(i,n){n&&n.isDirectory()?I(t,s.join(e,s.basename(t.name)),r):I(t,e,r)}))},this.close=function(t){e?n.close(e,(function(r){e=null,t&&t(r)})):t&&t()}};ht.setFs=function(t){n=t},i.inherits(ht,o.EventEmitter);var ct=function(){};ct.prototype.read=function(t){if(t.length!=T||t.readUInt32LE(0)!=_)throw new Error("Invalid central directory");this.volumeEntries=t.readUInt16LE(F),this.totalEntries=t.readUInt16LE(H),this.size=t.readUInt32LE(N),this.offset=t.readUInt32LE(A),this.commentLength=t.readUInt16LE(Y)};var ut=function(){};ut.prototype.read=function(t){if(t.length!=G||t.readUInt32LE(0)!=V)throw new Error("Invalid zip64 central directory locator");this.headerOffset=gt.readUInt64LE(t,F)};var lt=function(){};lt.prototype.read=function(t){if(t.length!=X||t.readUInt32LE(0)!=$)throw new Error("Invalid central directory");this.volumeEntries=gt.readUInt64LE(t,K),this.totalEntries=gt.readUInt64LE(t,Q),this.size=gt.readUInt64LE(t,tt),this.offset=gt.readUInt64LE(t,et)};var dt=function(){};function pt(t,e){for(var r=(t>>>0).toString(2);r.length<e;)r="0"+r;return r.split("")}function mt(t,e){var r=pt(t,16),i=pt(e,16),n={h:parseInt(r.slice(0,5).join(""),2),m:parseInt(r.slice(5,11).join(""),2),s:2*parseInt(r.slice(11,16).join(""),2),Y:parseInt(i.slice(0,7).join(""),2)+1980,M:parseInt(i.slice(7,11).join(""),2),D:parseInt(i.slice(11,16).join(""),2)},s=[n.Y,n.M,n.D].join("-")+" "+[n.h,n.m,n.s].join(":")+" GMT+0";return new Date(s).getTime()}dt.prototype.readHeader=function(t,e){if(t.length<e+w||t.readUInt32LE(e)!=g)throw new Error("Invalid entry header");this.verMade=t.readUInt16LE(e+b),this.version=t.readUInt16LE(e+I),this.flags=t.readUInt16LE(e+U),this.method=t.readUInt16LE(e+z);var r=t.readUInt16LE(e+S),i=t.readUInt16LE(e+S+2);this.time=mt(r,i),this.crc=t.readUInt32LE(e+k),this.compressedSize=t.readUInt32LE(e+x),this.size=t.readUInt32LE(e+P),this.fnameLen=t.readUInt16LE(e+B),this.extraLen=t.readUInt16LE(e+j),this.comLen=t.readUInt16LE(e+O),this.diskStart=t.readUInt16LE(e+R),this.inattr=t.readUInt16LE(e+M),this.attr=t.readUInt32LE(e+D),this.offset=t.readUInt32LE(e+C)},dt.prototype.readDataHeader=function(t){if(t.readUInt32LE(0)!=c)throw new Error("Invalid local header");this.version=t.readUInt16LE(u),this.flags=t.readUInt16LE(l),this.method=t.readUInt16LE(d);var e=t.readUInt16LE(p),r=t.readUInt16LE(p+2);this.time=mt(e,r),this.crc=t.readUInt32LE(m)||this.crc;var i=t.readUInt32LE(y);i&&i!==at&&(this.compressedSize=i);var n=t.readUInt32LE(E);n&&n!==at&&(this.size=n),this.fnameLen=t.readUInt16LE(v),this.extraLen=t.readUInt16LE(L)},dt.prototype.read=function(t,e){this.name=t.slice(e,e+=this.fnameLen).toString();var r=t[e-1];this.isDirectory=47==r||92==r,this.extraLen&&(this.readExtra(t,e),e+=this.extraLen),this.comment=this.comLen?t.slice(e,e+this.comLen).toString():null},dt.prototype.validateName=function(){if(/\\|^\w+:|^\/|(^|\/)\.\.(\/|$)/.test(this.name))throw new Error("Malicious entry: "+this.name)},dt.prototype.readExtra=function(t,e){for(var r,i,n=e+this.extraLen;e<n;)r=t.readUInt16LE(e),e+=2,i=t.readUInt16LE(e),e+=2,ot===r&&this.parseZip64Extra(t,e,i),e+=i},dt.prototype.parseZip64Extra=function(t,e,r){r>=8&&this.size===at&&(this.size=gt.readUInt64LE(t,e),e+=8,r-=8),r>=8&&this.compressedSize===at&&(this.compressedSize=gt.readUInt64LE(t,e),e+=8,r-=8),r>=8&&this.offset===at&&(this.offset=gt.readUInt64LE(t,e),e+=8,r-=8),r>=4&&this.diskStart===ft&&(this.diskStart=t.readUInt32LE(e))},Object.defineProperty(dt.prototype,"encrypted",{get:function(){return(this.flags&st)==st}}),Object.defineProperty(dt.prototype,"isFile",{get:function(){return!this.isDirectory}});var yt=function(t,e,r,i,n,s){this.fd=t,this.buffer=e,this.offset=r,this.length=i,this.position=n,this.callback=s,this.bytesRead=0,this.waiting=!1};yt.prototype.read=function(t){var e;if(ht.debug&&console.log("read",this.position,this.bytesRead,this.length,this.offset),this.waiting=!0,t){try{var r=n.readSync(this.fd,this.buffer,this.offset+this.bytesRead,this.length-this.bytesRead,this.position+this.bytesRead)}catch(t){e=t}this.readCallback(t,e,e?r:null)}else n.read(this.fd,this.buffer,this.offset+this.bytesRead,this.length-this.bytesRead,this.position+this.bytesRead,this.readCallback.bind(this,t))},yt.prototype.readCallback=function(t,e,r){if("number"==typeof r&&(this.bytesRead+=r),e||!r||this.bytesRead===this.length)return this.waiting=!1,this.callback(e,this.bytesRead);this.read(t)};var Et=function(t){this.position=0,this.buffer=Buffer.alloc(0);var e=null;this.checkOp=function(){if(e&&e.waiting)throw new Error("Operation in progress")},this.read=function(r,i,n){this.checkOp(),this.buffer.length<i&&(this.buffer=Buffer.alloc(i)),this.position=r,e=new yt(t,this.buffer,0,i,this.position,n).read()},this.expandLeft=function(r,i){this.checkOp(),this.buffer=Buffer.concat([Buffer.alloc(r),this.buffer]),this.position-=r,this.position<0&&(this.position=0),e=new yt(t,this.buffer,0,r,this.position,i).read()},this.expandRight=function(r,i){this.checkOp();var n=this.buffer.length;this.buffer=Buffer.concat([this.buffer,Buffer.alloc(r)]),e=new yt(t,this.buffer,n,r,this.position+n,i).read()},this.moveRight=function(r,i,n){this.checkOp(),n?this.buffer.copy(this.buffer,0,n):n=0,this.position+=n,e=new yt(t,this.buffer,this.buffer.length-n,n,this.position+this.buffer.length-n,i).read()}},vt=function(t,e,r){f.Readable.prototype.constructor.call(this),this.fd=t,this.offset=e,this.length=r,this.pos=0,this.readCallback=this.readCallback.bind(this)};i.inherits(vt,f.Readable),vt.prototype._read=function(t){var e=Buffer.alloc(Math.min(t,this.length-this.pos));e.length?n.read(this.fd,e,0,e.length,this.offset+this.pos,this.readCallback):this.push(null)},vt.prototype.readCallback=function(t,e,r){this.pos+=e,t?(this.emit("error",t),this.push(null)):e?(e!==r.length&&(r=r.slice(0,e)),this.push(r)):this.push(null)};var Lt=function(t,e,r){f.Transform.prototype.constructor.call(this),this.verify=new wt(e,r);var i=this;t.on("error",(function(t){i.emit("error",t)}))};i.inherits(Lt,f.Transform),Lt.prototype._transform=function(t,e,r){var i;try{this.verify.data(t)}catch(t){i=t}r(i,t)};var wt=function(t,e){this.crc=t,this.size=e,this.state={crc:-1,size:0}};wt.prototype.data=function(t){for(var e=wt.getCrcTable(),r=this.state.crc,i=0,n=t.length;--n>=0;)r=e[255&(r^t[i++])]^r>>>8;if(this.state.crc=r,this.state.size+=t.length,this.state.size>=this.size){var s=Buffer.alloc(4);if(s.writeInt32LE(4294967295&~this.state.crc,0),(r=s.readUInt32LE(0))!==this.crc)throw new Error("Invalid CRC");if(this.state.size!==this.size)throw new Error("Invalid size")}},wt.getCrcTable=function(){var t=wt.crcTable;if(!t){wt.crcTable=t=[];for(var e=Buffer.alloc(4),r=0;r<256;r++){for(var i=r,n=8;--n>=0;)0!=(1&i)?i=3988292384^i>>>1:i>>>=1;i<0&&(e.writeInt32LE(i,0),i=e.readUInt32LE(0)),t[r]=i}}return t};var gt={readUInt64LE:function(t,e){return 4294967296*t.readUInt32LE(e+4)+t.readUInt32LE(e)}};t.exports=ht},31:function(t,e){t.exports=require("events")},42:function(t,e){t.exports=require("zlib")}});
|
|
//# sourceMappingURL=node-stream-zip.js.map
|