huskee-install
Version:
Huskee server installer
56 lines (55 loc) • 23.9 kB
JavaScript
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}};$jscomp.arrayIterator=function(a){return{next:$jscomp.arrayIteratorImpl(a)}};$jscomp.makeIterator=function(a){var b="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];return b?b.call(a):$jscomp.arrayIterator(a)};
$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};
$jscomp.polyfill=function(a,b,c,e){if(b){c=$jscomp.global;a=a.split(".");for(e=0;e<a.length-1;e++){var d=a[e];d in c||(c[d]={});c=c[d]}a=a[a.length-1];e=c[a];b=b(e);b!=e&&null!=b&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})}};$jscomp.FORCE_POLYFILL_PROMISE=!1;
$jscomp.polyfill("Promise",function(a){function b(){this.batch_=null}function c(a){return a instanceof d?a:new d(function(b,g){b(a)})}if(a&&!$jscomp.FORCE_POLYFILL_PROMISE)return a;b.prototype.asyncExecute=function(a){if(null==this.batch_){this.batch_=[];var b=this;this.asyncExecuteFunction(function(){b.executeBatch_()})}this.batch_.push(a)};var e=$jscomp.global.setTimeout;b.prototype.asyncExecuteFunction=function(a){e(a,0)};b.prototype.executeBatch_=function(){for(;this.batch_&&this.batch_.length;){var a=
this.batch_;this.batch_=[];for(var b=0;b<a.length;++b){var g=a[b];a[b]=null;try{g()}catch(l){this.asyncThrow_(l)}}}this.batch_=null};b.prototype.asyncThrow_=function(a){this.asyncExecuteFunction(function(){throw a;})};var d=function(a){this.state_=0;this.result_=void 0;this.onSettledCallbacks_=[];var b=this.createResolveAndReject_();try{a(b.resolve,b.reject)}catch(g){b.reject(g)}};d.prototype.createResolveAndReject_=function(){function a(a){return function(c){g||(g=!0,a.call(b,c))}}var b=this,g=!1;
return{resolve:a(this.resolveTo_),reject:a(this.reject_)}};d.prototype.resolveTo_=function(a){if(a===this)this.reject_(new TypeError("A Promise cannot resolve to itself"));else if(a instanceof d)this.settleSameAsPromise_(a);else{a:switch(typeof a){case "object":var b=null!=a;break a;case "function":b=!0;break a;default:b=!1}b?this.resolveToNonPromiseObj_(a):this.fulfill_(a)}};d.prototype.resolveToNonPromiseObj_=function(a){var b=void 0;try{b=a.then}catch(g){this.reject_(g);return}"function"==typeof b?
this.settleSameAsThenable_(b,a):this.fulfill_(a)};d.prototype.reject_=function(a){this.settle_(2,a)};d.prototype.fulfill_=function(a){this.settle_(1,a)};d.prototype.settle_=function(a,b){if(0!=this.state_)throw Error("Cannot settle("+a+", "+b+"): Promise already settled in state"+this.state_);this.state_=a;this.result_=b;this.executeOnSettledCallbacks_()};d.prototype.executeOnSettledCallbacks_=function(){if(null!=this.onSettledCallbacks_){for(var a=0;a<this.onSettledCallbacks_.length;++a)f.asyncExecute(this.onSettledCallbacks_[a]);
this.onSettledCallbacks_=null}};var f=new b;d.prototype.settleSameAsPromise_=function(a){var b=this.createResolveAndReject_();a.callWhenSettled_(b.resolve,b.reject)};d.prototype.settleSameAsThenable_=function(a,b){var g=this.createResolveAndReject_();try{a.call(b,g.resolve,g.reject)}catch(l){g.reject(l)}};d.prototype.then=function(a,b){function g(a,b){return"function"==typeof a?function(b){try{c(a(b))}catch(k){e(k)}}:b}var c,e,f=new d(function(a,b){c=a;e=b});this.callWhenSettled_(g(a,c),g(b,e));return f};
d.prototype.catch=function(a){return this.then(void 0,a)};d.prototype.callWhenSettled_=function(a,b){function g(){switch(c.state_){case 1:a(c.result_);break;case 2:b(c.result_);break;default:throw Error("Unexpected state: "+c.state_);}}var c=this;null==this.onSettledCallbacks_?f.asyncExecute(g):this.onSettledCallbacks_.push(g)};d.resolve=c;d.reject=function(a){return new d(function(b,g){g(a)})};d.race=function(a){return new d(function(b,g){for(var d=$jscomp.makeIterator(a),e=d.next();!e.done;e=d.next())c(e.value).callWhenSettled_(b,
g)})};d.all=function(a){var b=$jscomp.makeIterator(a),g=b.next();return g.done?c([]):new d(function(a,d){function e(b){return function(g){l[b]=g;p--;0==p&&a(l)}}var l=[],p=0;do l.push(void 0),p++,c(g.value).callWhenSettled_(e(l.length-1),d),g=b.next();while(!g.done)})};return d},"es6","es3");$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};
$jscomp.SymbolClass=function(a,b){this.$jscomp$symbol$id_=a;$jscomp.defineProperty(this,"description",{configurable:!0,writable:!0,value:b})};$jscomp.SymbolClass.prototype.toString=function(){return this.$jscomp$symbol$id_};$jscomp.Symbol=function(){function a(c){if(this instanceof a)throw new TypeError("Symbol is not a constructor");return new $jscomp.SymbolClass($jscomp.SYMBOL_PREFIX+(c||"")+"_"+b++,c)}var b=0;return a}();
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("Symbol.iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.iteratorPrototype($jscomp.arrayIteratorImpl(this))}});$jscomp.initSymbolIterator=function(){}};
$jscomp.initSymbolAsyncIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.asyncIterator;a||(a=$jscomp.global.Symbol.asyncIterator=$jscomp.global.Symbol("Symbol.asyncIterator"));$jscomp.initSymbolAsyncIterator=function(){}};$jscomp.iteratorPrototype=function(a){$jscomp.initSymbolIterator();a={next:a};a[$jscomp.global.Symbol.iterator]=function(){return this};return a};$jscomp.underscoreProtoCanBeSet=function(){var a={a:!0},b={};try{return b.__proto__=a,b.a}catch(c){}return!1};
$jscomp.setPrototypeOf="function"==typeof Object.setPrototypeOf?Object.setPrototypeOf:$jscomp.underscoreProtoCanBeSet()?function(a,b){a.__proto__=b;if(a.__proto__!==b)throw new TypeError(a+" is not extensible");return a}:null;$jscomp.generator={};$jscomp.generator.ensureIteratorResultIsObject_=function(a){if(!(a instanceof Object))throw new TypeError("Iterator result "+a+" is not an object");};
$jscomp.generator.Context=function(){this.isRunning_=!1;this.yieldAllIterator_=null;this.yieldResult=void 0;this.nextAddress=1;this.finallyAddress_=this.catchAddress_=0;this.finallyContexts_=this.abruptCompletion_=null};$jscomp.generator.Context.prototype.start_=function(){if(this.isRunning_)throw new TypeError("Generator is already running");this.isRunning_=!0};$jscomp.generator.Context.prototype.stop_=function(){this.isRunning_=!1};
$jscomp.generator.Context.prototype.jumpToErrorHandler_=function(){this.nextAddress=this.catchAddress_||this.finallyAddress_};$jscomp.generator.Context.prototype.next_=function(a){this.yieldResult=a};$jscomp.generator.Context.prototype.throw_=function(a){this.abruptCompletion_={exception:a,isException:!0};this.jumpToErrorHandler_()};$jscomp.generator.Context.prototype.return=function(a){this.abruptCompletion_={return:a};this.nextAddress=this.finallyAddress_};
$jscomp.generator.Context.prototype.jumpThroughFinallyBlocks=function(a){this.abruptCompletion_={jumpTo:a};this.nextAddress=this.finallyAddress_};$jscomp.generator.Context.prototype.yield=function(a,b){this.nextAddress=b;return{value:a}};$jscomp.generator.Context.prototype.yieldAll=function(a,b){a=$jscomp.makeIterator(a);var c=a.next();$jscomp.generator.ensureIteratorResultIsObject_(c);if(c.done)this.yieldResult=c.value,this.nextAddress=b;else return this.yieldAllIterator_=a,this.yield(c.value,b)};
$jscomp.generator.Context.prototype.jumpTo=function(a){this.nextAddress=a};$jscomp.generator.Context.prototype.jumpToEnd=function(){this.nextAddress=0};$jscomp.generator.Context.prototype.setCatchFinallyBlocks=function(a,b){this.catchAddress_=a;void 0!=b&&(this.finallyAddress_=b)};$jscomp.generator.Context.prototype.setFinallyBlock=function(a){this.catchAddress_=0;this.finallyAddress_=a||0};$jscomp.generator.Context.prototype.leaveTryBlock=function(a,b){this.nextAddress=a;this.catchAddress_=b||0};
$jscomp.generator.Context.prototype.enterCatchBlock=function(a){this.catchAddress_=a||0;a=this.abruptCompletion_.exception;this.abruptCompletion_=null;return a};$jscomp.generator.Context.prototype.enterFinallyBlock=function(a,b,c){c?this.finallyContexts_[c]=this.abruptCompletion_:this.finallyContexts_=[this.abruptCompletion_];this.catchAddress_=a||0;this.finallyAddress_=b||0};
$jscomp.generator.Context.prototype.leaveFinallyBlock=function(a,b){b=this.finallyContexts_.splice(b||0)[0];if(b=this.abruptCompletion_=this.abruptCompletion_||b){if(b.isException)return this.jumpToErrorHandler_();void 0!=b.jumpTo&&this.finallyAddress_<b.jumpTo?(this.nextAddress=b.jumpTo,this.abruptCompletion_=null):this.nextAddress=this.finallyAddress_}else this.nextAddress=a};$jscomp.generator.Context.prototype.forIn=function(a){return new $jscomp.generator.Context.PropertyIterator(a)};
$jscomp.generator.Context.PropertyIterator=function(a){this.object_=a;this.properties_=[];for(var b in a)this.properties_.push(b);this.properties_.reverse()};$jscomp.generator.Context.PropertyIterator.prototype.getNext=function(){for(;0<this.properties_.length;){var a=this.properties_.pop();if(a in this.object_)return a}return null};$jscomp.generator.Engine_=function(a){this.context_=new $jscomp.generator.Context;this.program_=a};
$jscomp.generator.Engine_.prototype.next_=function(a){this.context_.start_();if(this.context_.yieldAllIterator_)return this.yieldAllStep_(this.context_.yieldAllIterator_.next,a,this.context_.next_);this.context_.next_(a);return this.nextStep_()};
$jscomp.generator.Engine_.prototype.return_=function(a){this.context_.start_();var b=this.context_.yieldAllIterator_;if(b)return this.yieldAllStep_("return"in b?b["return"]:function(a){return{value:a,done:!0}},a,this.context_.return);this.context_.return(a);return this.nextStep_()};
$jscomp.generator.Engine_.prototype.throw_=function(a){this.context_.start_();if(this.context_.yieldAllIterator_)return this.yieldAllStep_(this.context_.yieldAllIterator_["throw"],a,this.context_.next_);this.context_.throw_(a);return this.nextStep_()};
$jscomp.generator.Engine_.prototype.yieldAllStep_=function(a,b,c){try{var e=a.call(this.context_.yieldAllIterator_,b);$jscomp.generator.ensureIteratorResultIsObject_(e);if(!e.done)return this.context_.stop_(),e;var d=e.value}catch(f){return this.context_.yieldAllIterator_=null,this.context_.throw_(f),this.nextStep_()}this.context_.yieldAllIterator_=null;c.call(this.context_,d);return this.nextStep_()};
$jscomp.generator.Engine_.prototype.nextStep_=function(){for(;this.context_.nextAddress;)try{var a=this.program_(this.context_);if(a)return this.context_.stop_(),{value:a.value,done:!1}}catch(b){this.context_.yieldResult=void 0,this.context_.throw_(b)}this.context_.stop_();if(this.context_.abruptCompletion_){a=this.context_.abruptCompletion_;this.context_.abruptCompletion_=null;if(a.isException)throw a.exception;return{value:a.return,done:!0}}return{value:void 0,done:!0}};
$jscomp.generator.Generator_=function(a){this.next=function(b){return a.next_(b)};this.throw=function(b){return a.throw_(b)};this.return=function(b){return a.return_(b)};$jscomp.initSymbolIterator();this[Symbol.iterator]=function(){return this}};$jscomp.generator.createGenerator=function(a,b){b=new $jscomp.generator.Generator_(new $jscomp.generator.Engine_(b));$jscomp.setPrototypeOf&&$jscomp.setPrototypeOf(b,a.prototype);return b};
$jscomp.asyncExecutePromiseGenerator=function(a){function b(b){return a.next(b)}function c(b){return a.throw(b)}return new Promise(function(e,d){function f(a){a.done?e(a.value):Promise.resolve(a.value).then(b,c).then(f,d)}f(a.next())})};$jscomp.asyncExecutePromiseGeneratorFunction=function(a){return $jscomp.asyncExecutePromiseGenerator(a())};$jscomp.asyncExecutePromiseGeneratorProgram=function(a){return $jscomp.asyncExecutePromiseGenerator(new $jscomp.generator.Generator_(new $jscomp.generator.Engine_(a)))};
$jscomp.checkEs6ConformanceViaProxy=function(){try{var a={},b=Object.create(new $jscomp.global.Proxy(a,{get:function(c,e,d){return c==a&&"q"==e&&d==b}}));return!0===b.q}catch(c){return!1}};$jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS=!1;$jscomp.ES6_CONFORMANCE=$jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS&&$jscomp.checkEs6ConformanceViaProxy();$jscomp.owns=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};
$jscomp.polyfill("WeakMap",function(a){function b(){if(!a||!Object.seal)return!1;try{var b=Object.seal({}),c=Object.seal({}),d=new a([[b,2],[c,3]]);if(2!=d.get(b)||3!=d.get(c))return!1;d.delete(b);d.set(c,4);return!d.has(b)&&4==d.get(c)}catch(r){return!1}}function c(){}function e(a){if(!$jscomp.owns(a,f)){var b=new c;$jscomp.defineProperty(a,f,{value:b})}}function d(a){var b=Object[a];b&&(Object[a]=function(a){if(a instanceof c)return a;e(a);return b(a)})}if($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(a&&
$jscomp.ES6_CONFORMANCE)return a}else if(b())return a;var f="$jscomp_hidden_"+Math.random();d("freeze");d("preventExtensions");d("seal");var m=0,n=function(a){this.id_=(m+=Math.random()+1).toString();if(a){a=$jscomp.makeIterator(a);for(var b;!(b=a.next()).done;)b=b.value,this.set(b[0],b[1])}};n.prototype.set=function(a,b){e(a);if(!$jscomp.owns(a,f))throw Error("WeakMap key fail: "+a);a[f][this.id_]=b;return this};n.prototype.get=function(a){return $jscomp.owns(a,f)?a[f][this.id_]:void 0};n.prototype.has=
function(a){return $jscomp.owns(a,f)&&$jscomp.owns(a[f],this.id_)};n.prototype.delete=function(a){return $jscomp.owns(a,f)&&$jscomp.owns(a[f],this.id_)?delete a[f][this.id_]:!1};return n},"es6","es3");$jscomp.MapEntry=function(){};
$jscomp.polyfill("Map",function(a){function b(){if($jscomp.ASSUME_NO_NATIVE_MAP||!a||"function"!=typeof a||!a.prototype.entries||"function"!=typeof Object.seal)return!1;try{var b=Object.seal({x:4}),c=new a($jscomp.makeIterator([[b,"s"]]));if("s"!=c.get(b)||1!=c.size||c.get({x:4})||c.set({x:4},"t")!=c||2!=c.size)return!1;var d=c.entries(),e=d.next();if(e.done||e.value[0]!=b||"s"!=e.value[1])return!1;e=d.next();return e.done||4!=e.value[0].x||"t"!=e.value[1]||!d.next().done?!1:!0}catch(q){return!1}}
if($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(a&&$jscomp.ES6_CONFORMANCE)return a}else if(b())return a;$jscomp.initSymbolIterator();var c=new WeakMap,e=function(a){this.data_={};this.head_=m();this.size=0;if(a){a=$jscomp.makeIterator(a);for(var b;!(b=a.next()).done;)b=b.value,this.set(b[0],b[1])}};e.prototype.set=function(a,b){a=0===a?0:a;var c=d(this,a);c.list||(c.list=this.data_[c.id]=[]);c.entry?c.entry.value=b:(c.entry={next:this.head_,previous:this.head_.previous,head:this.head_,key:a,
value:b},c.list.push(c.entry),this.head_.previous.next=c.entry,this.head_.previous=c.entry,this.size++);return this};e.prototype.delete=function(a){a=d(this,a);return a.entry&&a.list?(a.list.splice(a.index,1),a.list.length||delete this.data_[a.id],a.entry.previous.next=a.entry.next,a.entry.next.previous=a.entry.previous,a.entry.head=null,this.size--,!0):!1};e.prototype.clear=function(){this.data_={};this.head_=this.head_.previous=m();this.size=0};e.prototype.has=function(a){return!!d(this,a).entry};
e.prototype.get=function(a){return(a=d(this,a).entry)&&a.value};e.prototype.entries=function(){return f(this,function(a){return[a.key,a.value]})};e.prototype.keys=function(){return f(this,function(a){return a.key})};e.prototype.values=function(){return f(this,function(a){return a.value})};e.prototype.forEach=function(a,b){for(var c=this.entries(),d;!(d=c.next()).done;)d=d.value,a.call(b,d[1],d[0],this)};e.prototype[Symbol.iterator]=e.prototype.entries;var d=function(a,b){var d=b&&typeof b;"object"==
d||"function"==d?c.has(b)?d=c.get(b):(d=""+ ++n,c.set(b,d)):d="p_"+b;var e=a.data_[d];if(e&&$jscomp.owns(a.data_,d))for(a=0;a<e.length;a++){var f=e[a];if(b!==b&&f.key!==f.key||b===f.key)return{id:d,list:e,index:a,entry:f}}return{id:d,list:e,index:-1,entry:void 0}},f=function(a,b){var c=a.head_;return $jscomp.iteratorPrototype(function(){if(c){for(;c.head!=a.head_;)c=c.previous;for(;c.next!=c.head;)return c=c.next,{done:!1,value:b(c)};c=null}return{done:!0,value:void 0}})},m=function(){var a={};return a.previous=
a.next=a.head=a},n=0;return e},"es6","es3");$jscomp.checkStringArgs=function(a,b,c){if(null==a)throw new TypeError("The 'this' value for String.prototype."+c+" must not be null or undefined");if(b instanceof RegExp)throw new TypeError("First argument to String.prototype."+c+" must not be a regular expression");return a+""};
$jscomp.polyfill("String.prototype.startsWith",function(a){return a?a:function(a,c){var b=$jscomp.checkStringArgs(this,a,"startsWith");a+="";var d=b.length,f=a.length;c=Math.max(0,Math.min(c|0,b.length));for(var m=0;m<f&&c<d;)if(b[c++]!=a[m++])return!1;return m>=f}},"es6","es3");$jscomp.findInternal=function(a,b,c){a instanceof String&&(a=String(a));for(var e=a.length,d=0;d<e;d++){var f=a[d];if(b.call(c,f,d,a))return{i:d,v:f}}return{i:-1,v:void 0}};
$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,c){return $jscomp.findInternal(this,a,c).v}},"es6","es3");$jscomp.polyfill("Object.is",function(a){return a?a:function(a,c){return a===c?0!==a||1/a===1/c:a!==a&&c!==c}},"es6","es3");
$jscomp.polyfill("Array.prototype.includes",function(a){return a?a:function(a,c){var b=this;b instanceof String&&(b=String(b));var d=b.length;c=c||0;for(0>c&&(c=Math.max(c+d,0));c<d;c++){var f=b[c];if(f===a||Object.is(f,a))return!0}return!1}},"es7","es3");$jscomp.polyfill("String.prototype.includes",function(a){return a?a:function(a,c){return-1!==$jscomp.checkStringArgs(this,a,"includes").indexOf(a,c||0)}},"es6","es3");
var url=require("url"),path=require("path"),fs=require("fs"),zlib=require("zlib"),mimeModule=require("./mime"),punycode=require("punycode"),forbidden=path.join(__dirname,"../www"),mtimeCache=new Map,net=require("net"),config=require("../conf/main"),hostsConfig=require("../conf/hosts"),$jscomp$destructuring$var0=config,proxyport=$jscomp$destructuring$var0.proxyport,winStatic,sendfile,os=require("os");"win32"===os.platform()?winStatic=require("./winstatic"):sendfile=require("../build/Release/addon");
var fsStatAsync=function(a){return new Promise(function(b){fs.stat(a,function(a,e){return a?b(0):b(e)})})},Connection=function(a,b,c){var e=this;this.req=a;this.res=b;this.rejected=!1;this.urlParsed=url.parse(a.url,!0);if(c)try{this.data=JSON.parse(c)}catch(d){console.log(d),this.data={}}else this.data=this.urlParsed.query;this.hostname=punycode.toUnicode(a.headers.host||"").replace(":","_port_");this.requestPath=this.urlParsed.pathname;this.extname=path.extname(this.requestPath).substring(1);this.fullPath=
path.join(__dirname,"../www",String(this.hostname),String(this.requestPath));this.protocol=a.connection.encrypted?"https":"http";this.fd=a.client._handle.fd;this.decline=function(a,b){e._endConnection(200,{error:a,errorname:b});e.rejected=!0};this.declineWithError=function(a,b){e._endConnection(a,{error:a,errorname:b});e.rejected=!0};this.parseCookies=function(){var a=e.req;return a.headers.cookie&&a.headers.cookie.split(";").reduce?a.headers.cookie.split(";").reduce(function(a,b){b=b.trim().split("=");
a[b[0]]=b[1];return a},{}):!1};this._connect()};
Connection.prototype._connect=function(){var a=this,b,c,e,d,f,m,n,g,l,p,r,q;return $jscomp.asyncExecutePromiseGeneratorProgram(function(h){switch(h.nextAddress){case 1:b=a;c=b.fullPath;e=b.extname;d=b.res;f=b.hostname;m=b.requestPath;a.fullPath=path.join(a.fullPath,"index.html");a.extname="html";if(!c.startsWith(forbidden))return h.return(d.end("403"));n=(hostsConfig||[]).find(function(a){return a.host===f})||{};g=n.loader;if(!g){h.jumpTo(2);break}return h.yield(g({connection:a,path:m}),3);case 3:l=
h.yieldResult;case 2:return l?h.return():h.yield(a._getAPI(),4);case 4:return p=h.yieldResult,"done"===p?h.return():h.yield(a._getPage(),5);case 5:r=h.yieldResult;if("unchanged"===r)return h.return(a._endConnection(304));if("done"===r)return h.return();if(r)return h.return(a._endConnectionWithPage(r));a.fullPath=c;a.extname=e;return h.yield(a._getStatic(),6);case 6:q=h.yieldResult;if("unchanged"===q)return h.return(a._endConnection(304));if("done"===q)return h.return();if(q)return h.return(a._endConnection(200,
q));a._endWith404();h.jumpToEnd()}})};Connection.prototype.renderStatic=function(a){var b=this;return $jscomp.asyncExecutePromiseGeneratorProgram(function(c){b.fullPath=path.join(__dirname,"../www",String(b.hostname),String(a));b.extname=a;return c.yield(b._getStatic(),0)})};
Connection.prototype._getStatic=function(){var a=this,b,c,e,d,f,m,n,g,l,p,r,q,h,t;return $jscomp.asyncExecutePromiseGeneratorProgram(function(k){switch(k.nextAddress){case 1:if(!winStatic){k.jumpTo(2);break}return k.yield(winStatic.bind(a)(),3);case 3:return k.return(k.yieldResult);case 2:return b=a,c=b.req,e=b.res,d=b.fullPath,f=b.extname,m=c,n=m.headers,g=mimeModule.see(f),k.yield(fsStatAsync(d),4);case 4:l=k.yieldResult;if(!l)return k.return();p=l.mtime.toUTCString();r=l;q=r.size;h=g.includes("text/")||
g.includes("application/");t="no-cache"!==n["cache-control"]&&n["if-modified-since"]&&n["if-modified-since"]==p;e.writeHead(t?304:200,{"Content-Encoding":h?"gzip":"plain","Content-Type":""+g,"Cache-Control":"no-cache","Last-Modified":p});return t?(e.end(),k.return("done")):k.yield(new Promise(function(a){return fs.open(d,"r",function(b,c){var d,f;return $jscomp.asyncExecutePromiseGeneratorProgram(function(g){if(1==g.nextAddress){if(b)return g.return(console.error(b));d=new net.Socket;return g.yield(new Promise(function(a){d.connect(proxyport,
function(){return a(d._handle.fd)})}),2)}if(3!=g.nextAddress)return f=g.yieldResult,g.yield(new Promise(function(a){h?d.pipe(zlib.createGzip()).pipe(e):d.pipe(e);sendfile.send(c,f,q);d.end()}),3);a();g.jumpToEnd()})})}),5);case 5:return k.return("done")}})};
Connection.prototype._getAPI=function(){var a=this,b,c,e,d,f,m,n,g,l,p,r,q,h,t;return $jscomp.asyncExecutePromiseGeneratorProgram(function(k){switch(k.nextAddress){case 1:return b=a,c=b.hostname,e=b.requestPath,d=path.join(__dirname,"../dynamic",c,e,"index.js"),k.yield(fsStatAsync(d),2);case 2:f=k.yieldResult;if(!f)return k.return("");m=f.mtime.toUTCString();mtimeCache.get(d)!==m&&delete require.cache[require.resolve(d)];k.setCatchFinallyBlocks(3);n=require(d);mtimeCache.set(d,m);return k.yield(n.connect(a),
5);case 5:g=k.yieldResult;if(!g&&a.rejected)return k.return("done");l=g;p=l.mime;r=l.text;q=l.code;h=l.isHTML;a._endConnection(q,r,p,h);return k.return("done");case 3:return t=k.enterCatchBlock(),a.declineWithError(500,"Internal Server Error"),console.log(t),k.return("")}})};Connection.prototype._getPage=function(){var a=this,b;return $jscomp.asyncExecutePromiseGeneratorProgram(function(c){return 1==c.nextAddress?c.yield(a._getStatic(),2):(b=c.yieldResult)?c.return(b):c.return("")})};
Connection.prototype._endConnectionWithPage=function(a){this._endConnection(200,a,"text/html; charset=utf-8")};Connection.prototype.renderFile=function(a){this._endConnection(void 0===a.status?200:a.status,void 0===a.file?"":a.file,void 0===a.mime?"text/plain":a.mime,!0)};
Connection.prototype._endConnection=function(a,b,c,e,d){a=void 0===a?200:a;var f=this.res;if(!this.rejected){c=c||(e?"text/html; charset=utf-8":"application/json; charset=utf-8");try{f.statusCode=a,f.setHeader("Content-Type",c),f.writeHead(a)}catch(m){console.log(m)}f.end(e||d?b:JSON.stringify(b))}};Connection.prototype._endWith404=function(){this._endConnection(404,"There is no such file on the disk","text/html")};exports.Connection=Connection;