Comparing version 2.1.6 to 2.1.7
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.wsgrpc=e():t.wsgrpc=e()}(global,(function(){return(()=>{"use strict";var __webpack_modules__={537:t=>{t.exports=function(t,e){for(var r=new Array(arguments.length-1),s=0,n=2,a=!0;n<arguments.length;)r[s++]=arguments[n++];return new Promise((function(n,i){r[s]=function(t){if(a)if(a=!1,t)i(t);else{for(var e=new Array(arguments.length-1),r=0;r<e.length;)e[r++]=arguments[r];n.apply(null,e)}};try{t.apply(e||null,r)}catch(t){a&&(a=!1,i(t))}}))}},419:(t,e)=>{var r=e;r.length=function(t){var e=t.length;if(!e)return 0;for(var r=0;--e%4>1&&"="===t.charAt(e);)++r;return Math.ceil(3*t.length)/4-r};for(var s=new Array(64),n=new Array(123),a=0;a<64;)n[s[a]=a<26?a+65:a<52?a+71:a<62?a-4:a-59|43]=a++;r.encode=function(t,e,r){for(var n,a=null,i=[],o=0,l=0;e<r;){var u=t[e++];switch(l){case 0:i[o++]=s[u>>2],n=(3&u)<<4,l=1;break;case 1:i[o++]=s[n|u>>4],n=(15&u)<<2,l=2;break;case 2:i[o++]=s[n|u>>6],i[o++]=s[63&u],l=0}o>8191&&((a||(a=[])).push(String.fromCharCode.apply(String,i)),o=0)}return l&&(i[o++]=s[n],i[o++]=61,1===l&&(i[o++]=61)),a?(o&&a.push(String.fromCharCode.apply(String,i.slice(0,o))),a.join("")):String.fromCharCode.apply(String,i.slice(0,o))};var i="invalid encoding";r.decode=function(t,e,r){for(var s,a=r,o=0,l=0;l<t.length;){var u=t.charCodeAt(l++);if(61===u&&o>1)break;if(void 0===(u=n[u]))throw Error(i);switch(o){case 0:s=u,o=1;break;case 1:e[r++]=s<<2|(48&u)>>4,s=u,o=2;break;case 2:e[r++]=(15&s)<<4|(60&u)>>2,s=u,o=3;break;case 3:e[r++]=(3&s)<<6|u,o=0}}if(1===o)throw Error(i);return r-a},r.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}},211:t=>{function e(){this._listeners={}}t.exports=e,e.prototype.on=function(t,e,r){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:e,ctx:r||this}),this},e.prototype.off=function(t,e){if(void 0===t)this._listeners={};else if(void 0===e)this._listeners[t]=[];else for(var r=this._listeners[t],s=0;s<r.length;)r[s].fn===e?r.splice(s,1):++s;return this},e.prototype.emit=function(t){var e=this._listeners[t];if(e){for(var r=[],s=1;s<arguments.length;)r.push(arguments[s++]);for(s=0;s<e.length;)e[s].fn.apply(e[s++].ctx,r)}return this}},945:t=>{function e(t){return"undefined"!=typeof Float32Array?function(){var e=new Float32Array([-0]),r=new Uint8Array(e.buffer),s=128===r[3];function n(t,s,n){e[0]=t,s[n]=r[0],s[n+1]=r[1],s[n+2]=r[2],s[n+3]=r[3]}function a(t,s,n){e[0]=t,s[n]=r[3],s[n+1]=r[2],s[n+2]=r[1],s[n+3]=r[0]}function i(t,s){return r[0]=t[s],r[1]=t[s+1],r[2]=t[s+2],r[3]=t[s+3],e[0]}function o(t,s){return r[3]=t[s],r[2]=t[s+1],r[1]=t[s+2],r[0]=t[s+3],e[0]}t.writeFloatLE=s?n:a,t.writeFloatBE=s?a:n,t.readFloatLE=s?i:o,t.readFloatBE=s?o:i}():function(){function e(t,e,r,s){var n=e<0?1:0;if(n&&(e=-e),0===e)t(1/e>0?0:2147483648,r,s);else if(isNaN(e))t(2143289344,r,s);else if(e>34028234663852886e22)t((n<<31|2139095040)>>>0,r,s);else if(e<11754943508222875e-54)t((n<<31|Math.round(e/1401298464324817e-60))>>>0,r,s);else{var a=Math.floor(Math.log(e)/Math.LN2);t((n<<31|a+127<<23|8388607&Math.round(e*Math.pow(2,-a)*8388608))>>>0,r,s)}}function i(t,e,r){var s=t(e,r),n=2*(s>>31)+1,a=s>>>23&255,i=8388607&s;return 255===a?i?NaN:n*(1/0):0===a?1401298464324817e-60*n*i:n*Math.pow(2,a-150)*(i+8388608)}t.writeFloatLE=e.bind(null,r),t.writeFloatBE=e.bind(null,s),t.readFloatLE=i.bind(null,n),t.readFloatBE=i.bind(null,a)}(),"undefined"!=typeof Float64Array?function(){var e=new Float64Array([-0]),r=new Uint8Array(e.buffer),s=128===r[7];function n(t,s,n){e[0]=t,s[n]=r[0],s[n+1]=r[1],s[n+2]=r[2],s[n+3]=r[3],s[n+4]=r[4],s[n+5]=r[5],s[n+6]=r[6],s[n+7]=r[7]}function a(t,s,n){e[0]=t,s[n]=r[7],s[n+1]=r[6],s[n+2]=r[5],s[n+3]=r[4],s[n+4]=r[3],s[n+5]=r[2],s[n+6]=r[1],s[n+7]=r[0]}function i(t,s){return r[0]=t[s],r[1]=t[s+1],r[2]=t[s+2],r[3]=t[s+3],r[4]=t[s+4],r[5]=t[s+5],r[6]=t[s+6],r[7]=t[s+7],e[0]}function o(t,s){return r[7]=t[s],r[6]=t[s+1],r[5]=t[s+2],r[4]=t[s+3],r[3]=t[s+4],r[2]=t[s+5],r[1]=t[s+6],r[0]=t[s+7],e[0]}t.writeDoubleLE=s?n:a,t.writeDoubleBE=s?a:n,t.readDoubleLE=s?i:o,t.readDoubleBE=s?o:i}():function(){function e(t,e,r,s,n,a){var i=s<0?1:0;if(i&&(s=-s),0===s)t(0,n,a+e),t(1/s>0?0:2147483648,n,a+r);else if(isNaN(s))t(0,n,a+e),t(2146959360,n,a+r);else if(s>17976931348623157e292)t(0,n,a+e),t((i<<31|2146435072)>>>0,n,a+r);else{var o;if(s<22250738585072014e-324)t((o=s/5e-324)>>>0,n,a+e),t((i<<31|o/4294967296)>>>0,n,a+r);else{var l=Math.floor(Math.log(s)/Math.LN2);1024===l&&(l=1023),t(4503599627370496*(o=s*Math.pow(2,-l))>>>0,n,a+e),t((i<<31|l+1023<<20|1048576*o&1048575)>>>0,n,a+r)}}}function i(t,e,r,s,n){var a=t(s,n+e),i=t(s,n+r),o=2*(i>>31)+1,l=i>>>20&2047,u=4294967296*(1048575&i)+a;return 2047===l?u?NaN:o*(1/0):0===l?5e-324*o*u:o*Math.pow(2,l-1075)*(u+4503599627370496)}t.writeDoubleLE=e.bind(null,r,0,4),t.writeDoubleBE=e.bind(null,s,4,0),t.readDoubleLE=i.bind(null,n,0,4),t.readDoubleBE=i.bind(null,a,4,0)}(),t}function r(t,e,r){e[r]=255&t,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function s(t,e,r){e[r]=t>>>24,e[r+1]=t>>>16&255,e[r+2]=t>>>8&255,e[r+3]=255&t}function n(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}function a(t,e){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}t.exports=e(e)},199:module=>{function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(t){}return null}module.exports=inquire},662:t=>{t.exports=function(t,e,r){var s=r||8192,n=s>>>1,a=null,i=s;return function(r){if(r<1||r>n)return t(r);i+r>s&&(a=t(s),i=0);var o=e.call(a,i,i+=r);return 7&i&&(i=1+(7|i)),o}}},997:(t,e)=>{var r=e;r.length=function(t){for(var e=0,r=0,s=0;s<t.length;++s)(r=t.charCodeAt(s))<128?e+=1:r<2048?e+=2:55296==(64512&r)&&56320==(64512&t.charCodeAt(s+1))?(++s,e+=4):e+=3;return e},r.read=function(t,e,r){if(r-e<1)return"";for(var s,n=null,a=[],i=0;e<r;)(s=t[e++])<128?a[i++]=s:s>191&&s<224?a[i++]=(31&s)<<6|63&t[e++]:s>239&&s<365?(s=((7&s)<<18|(63&t[e++])<<12|(63&t[e++])<<6|63&t[e++])-65536,a[i++]=55296+(s>>10),a[i++]=56320+(1023&s)):a[i++]=(15&s)<<12|(63&t[e++])<<6|63&t[e++],i>8191&&((n||(n=[])).push(String.fromCharCode.apply(String,a)),i=0);return n?(i&&n.push(String.fromCharCode.apply(String,a.slice(0,i))),n.join("")):String.fromCharCode.apply(String,a.slice(0,i))},r.write=function(t,e,r){for(var s,n,a=r,i=0;i<t.length;++i)(s=t.charCodeAt(i))<128?e[r++]=s:s<2048?(e[r++]=s>>6|192,e[r++]=63&s|128):55296==(64512&s)&&56320==(64512&(n=t.charCodeAt(i+1)))?(s=65536+((1023&s)<<10)+(1023&n),++i,e[r++]=s>>18|240,e[r++]=s>>12&63|128,e[r++]=s>>6&63|128,e[r++]=63&s|128):(e[r++]=s>>12|224,e[r++]=s>>6&63|128,e[r++]=63&s|128);return r-a}},100:(t,e,r)=>{t.exports=r(482)},482:(t,e,r)=>{var s=e;function n(){s.util._configure(),s.Writer._configure(s.BufferWriter),s.Reader._configure(s.BufferReader)}s.build="minimal",s.Writer=r(173),s.BufferWriter=r(155),s.Reader=r(408),s.BufferReader=r(593),s.util=r(693),s.rpc=r(994),s.roots=r(54),s.configure=n,n()},408:(t,e,r)=>{t.exports=l;var s,n=r(693),a=n.LongBits,i=n.utf8;function o(t,e){return RangeError("index out of range: "+t.pos+" + "+(e||1)+" > "+t.len)}function l(t){this.buf=t,this.pos=0,this.len=t.length}var u,c="undefined"!=typeof Uint8Array?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new l(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new l(t);throw Error("illegal buffer")},h=function(){return n.Buffer?function(t){return(l.create=function(t){return n.Buffer.isBuffer(t)?new s(t):c(t)})(t)}:c};function f(){var t=new a(0,0),e=0;if(!(this.len-this.pos>4)){for(;e<3;++e){if(this.pos>=this.len)throw o(this);if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*e)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(127&this.buf[this.pos++])<<7*e)>>>0,t}for(;e<4;++e)if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*e)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(127&this.buf[this.pos])<<28)>>>0,t.hi=(t.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return t;if(e=0,this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*e+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw o(this);if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*e+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}function d(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}function p(){if(this.pos+8>this.len)throw o(this,8);return new a(d(this.buf,this.pos+=4),d(this.buf,this.pos+=4))}l.create=h(),l.prototype._slice=n.Array.prototype.subarray||n.Array.prototype.slice,l.prototype.uint32=(u=4294967295,function(){if(u=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return u;if((this.pos+=5)>this.len)throw this.pos=this.len,o(this,10);return u}),l.prototype.int32=function(){return 0|this.uint32()},l.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(1&t)|0},l.prototype.bool=function(){return 0!==this.uint32()},l.prototype.fixed32=function(){if(this.pos+4>this.len)throw o(this,4);return d(this.buf,this.pos+=4)},l.prototype.sfixed32=function(){if(this.pos+4>this.len)throw o(this,4);return 0|d(this.buf,this.pos+=4)},l.prototype.float=function(){if(this.pos+4>this.len)throw o(this,4);var t=n.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t},l.prototype.double=function(){if(this.pos+8>this.len)throw o(this,4);var t=n.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t},l.prototype.bytes=function(){var t=this.uint32(),e=this.pos,r=this.pos+t;if(r>this.len)throw o(this,t);return this.pos+=t,Array.isArray(this.buf)?this.buf.slice(e,r):e===r?new this.buf.constructor(0):this._slice.call(this.buf,e,r)},l.prototype.string=function(){var t=this.bytes();return i.read(t,0,t.length)},l.prototype.skip=function(t){if("number"==typeof t){if(this.pos+t>this.len)throw o(this,t);this.pos+=t}else do{if(this.pos>=this.len)throw o(this)}while(128&this.buf[this.pos++]);return this},l.prototype.skipType=function(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(t=7&this.uint32());)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+t+" at offset "+this.pos)}return this},l._configure=function(t){s=t,l.create=h(),s._configure();var e=n.Long?"toLong":"toNumber";n.merge(l.prototype,{int64:function(){return f.call(this)[e](!1)},uint64:function(){return f.call(this)[e](!0)},sint64:function(){return f.call(this).zzDecode()[e](!1)},fixed64:function(){return p.call(this)[e](!0)},sfixed64:function(){return p.call(this)[e](!1)}})}},593:(t,e,r)=>{t.exports=a;var s=r(408);(a.prototype=Object.create(s.prototype)).constructor=a;var n=r(693);function a(t){s.call(this,t)}a._configure=function(){n.Buffer&&(a.prototype._slice=n.Buffer.prototype.slice)},a.prototype.string=function(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))},a._configure()},54:t=>{t.exports={}},994:(t,e,r)=>{e.Service=r(948)},948:(t,e,r)=>{t.exports=n;var s=r(693);function n(t,e,r){if("function"!=typeof t)throw TypeError("rpcImpl must be a function");s.EventEmitter.call(this),this.rpcImpl=t,this.requestDelimited=Boolean(e),this.responseDelimited=Boolean(r)}(n.prototype=Object.create(s.EventEmitter.prototype)).constructor=n,n.prototype.rpcCall=function t(e,r,n,a,i){if(!a)throw TypeError("request must be specified");var o=this;if(!i)return s.asPromise(t,o,e,r,n,a);if(o.rpcImpl)try{return o.rpcImpl(e,r[o.requestDelimited?"encodeDelimited":"encode"](a).finish(),(function(t,r){if(t)return o.emit("error",t,e),i(t);if(null!==r){if(!(r instanceof n))try{r=n[o.responseDelimited?"decodeDelimited":"decode"](r)}catch(t){return o.emit("error",t,e),i(t)}return o.emit("data",r,e),i(null,r)}o.end(!0)}))}catch(t){return o.emit("error",t,e),void setTimeout((function(){i(t)}),0)}else setTimeout((function(){i(Error("already ended"))}),0)},n.prototype.end=function(t){return this.rpcImpl&&(t||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},630:(t,e,r)=>{t.exports=n;var s=r(693);function n(t,e){this.lo=t>>>0,this.hi=e>>>0}var a=n.zero=new n(0,0);a.toNumber=function(){return 0},a.zzEncode=a.zzDecode=function(){return this},a.length=function(){return 1};var i=n.zeroHash="\0\0\0\0\0\0\0\0";n.fromNumber=function(t){if(0===t)return a;var e=t<0;e&&(t=-t);var r=t>>>0,s=(t-r)/4294967296>>>0;return e&&(s=~s>>>0,r=~r>>>0,++r>4294967295&&(r=0,++s>4294967295&&(s=0))),new n(r,s)},n.from=function(t){if("number"==typeof t)return n.fromNumber(t);if(s.isString(t)){if(!s.Long)return n.fromNumber(parseInt(t,10));t=s.Long.fromString(t)}return t.low||t.high?new n(t.low>>>0,t.high>>>0):a},n.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var e=1+~this.lo>>>0,r=~this.hi>>>0;return e||(r=r+1>>>0),-(e+4294967296*r)}return this.lo+4294967296*this.hi},n.prototype.toLong=function(t){return s.Long?new s.Long(0|this.lo,0|this.hi,Boolean(t)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(t)}};var o=String.prototype.charCodeAt;n.fromHash=function(t){return t===i?a:new n((o.call(t,0)|o.call(t,1)<<8|o.call(t,2)<<16|o.call(t,3)<<24)>>>0,(o.call(t,4)|o.call(t,5)<<8|o.call(t,6)<<16|o.call(t,7)<<24)>>>0)},n.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},n.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this},n.prototype.zzDecode=function(){var t=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this},n.prototype.length=function(){var t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===e?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:r<128?9:10}},693:function(t,e,r){var s=e;function n(t,e,r){for(var s=Object.keys(e),n=0;n<s.length;++n)void 0!==t[s[n]]&&r||(t[s[n]]=e[s[n]]);return t}function a(t){function e(t,r){if(!(this instanceof e))return new e(t,r);Object.defineProperty(this,"message",{get:function(){return t}}),Error.captureStackTrace?Error.captureStackTrace(this,e):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),r&&n(this,r)}return(e.prototype=Object.create(Error.prototype)).constructor=e,Object.defineProperty(e.prototype,"name",{get:function(){return t}}),e.prototype.toString=function(){return this.name+": "+this.message},e}s.asPromise=r(537),s.base64=r(419),s.EventEmitter=r(211),s.float=r(945),s.inquire=r(199),s.utf8=r(997),s.pool=r(662),s.LongBits=r(630),s.isNode=Boolean("undefined"!=typeof global&&global&&global.process&&global.process.versions&&global.process.versions.node),s.global=s.isNode&&global||"undefined"!=typeof window&&window||"undefined"!=typeof self&&self||this,s.emptyArray=Object.freeze?Object.freeze([]):[],s.emptyObject=Object.freeze?Object.freeze({}):{},s.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},s.isString=function(t){return"string"==typeof t||t instanceof String},s.isObject=function(t){return t&&"object"==typeof t},s.isset=s.isSet=function(t,e){var r=t[e];return!(null==r||!t.hasOwnProperty(e))&&("object"!=typeof r||(Array.isArray(r)?r.length:Object.keys(r).length)>0)},s.Buffer=function(){try{var t=s.inquire("buffer").Buffer;return t.prototype.utf8Write?t:null}catch(t){return null}}(),s._Buffer_from=null,s._Buffer_allocUnsafe=null,s.newBuffer=function(t){return"number"==typeof t?s.Buffer?s._Buffer_allocUnsafe(t):new s.Array(t):s.Buffer?s._Buffer_from(t):"undefined"==typeof Uint8Array?t:new Uint8Array(t)},s.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,s.Long=s.global.dcodeIO&&s.global.dcodeIO.Long||s.global.Long||s.inquire("long"),s.key2Re=/^true|false|0|1$/,s.key32Re=/^-?(?:0|[1-9][0-9]*)$/,s.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,s.longToHash=function(t){return t?s.LongBits.from(t).toHash():s.LongBits.zeroHash},s.longFromHash=function(t,e){var r=s.LongBits.fromHash(t);return s.Long?s.Long.fromBits(r.lo,r.hi,e):r.toNumber(Boolean(e))},s.merge=n,s.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)},s.newError=a,s.ProtocolError=a("ProtocolError"),s.oneOfGetter=function(t){for(var e={},r=0;r<t.length;++r)e[t[r]]=1;return function(){for(var t=Object.keys(this),r=t.length-1;r>-1;--r)if(1===e[t[r]]&&void 0!==this[t[r]]&&null!==this[t[r]])return t[r]}},s.oneOfSetter=function(t){return function(e){for(var r=0;r<t.length;++r)t[r]!==e&&delete this[t[r]]}},s.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},s._configure=function(){var t=s.Buffer;t?(s._Buffer_from=t.from!==Uint8Array.from&&t.from||function(e,r){return new t(e,r)},s._Buffer_allocUnsafe=t.allocUnsafe||function(e){return new t(e)}):s._Buffer_from=s._Buffer_allocUnsafe=null}},173:(t,e,r)=>{t.exports=h;var s,n=r(693),a=n.LongBits,i=n.base64,o=n.utf8;function l(t,e,r){this.fn=t,this.len=e,this.next=void 0,this.val=r}function u(){}function c(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}function h(){this.len=0,this.head=new l(u,0,0),this.tail=this.head,this.states=null}var f=function(){return n.Buffer?function(){return(h.create=function(){return new s})()}:function(){return new h}};function d(t,e,r){e[r]=255&t}function p(t,e){this.len=t,this.next=void 0,this.val=e}function y(t,e,r){for(;t.hi;)e[r++]=127&t.lo|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=127&t.lo|128,t.lo=t.lo>>>7;e[r++]=t.lo}function m(t,e,r){e[r]=255&t,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}h.create=f(),h.alloc=function(t){return new n.Array(t)},n.Array!==Array&&(h.alloc=n.pool(h.alloc,n.Array.prototype.subarray)),h.prototype._push=function(t,e,r){return this.tail=this.tail.next=new l(t,e,r),this.len+=e,this},p.prototype=Object.create(l.prototype),p.prototype.fn=function(t,e,r){for(;t>127;)e[r++]=127&t|128,t>>>=7;e[r]=t},h.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new p((t>>>=0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this},h.prototype.int32=function(t){return t<0?this._push(y,10,a.fromNumber(t)):this.uint32(t)},h.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)},h.prototype.uint64=function(t){var e=a.from(t);return this._push(y,e.length(),e)},h.prototype.int64=h.prototype.uint64,h.prototype.sint64=function(t){var e=a.from(t).zzEncode();return this._push(y,e.length(),e)},h.prototype.bool=function(t){return this._push(d,1,t?1:0)},h.prototype.fixed32=function(t){return this._push(m,4,t>>>0)},h.prototype.sfixed32=h.prototype.fixed32,h.prototype.fixed64=function(t){var e=a.from(t);return this._push(m,4,e.lo)._push(m,4,e.hi)},h.prototype.sfixed64=h.prototype.fixed64,h.prototype.float=function(t){return this._push(n.float.writeFloatLE,4,t)},h.prototype.double=function(t){return this._push(n.float.writeDoubleLE,8,t)};var g=n.Array.prototype.set?function(t,e,r){e.set(t,r)}:function(t,e,r){for(var s=0;s<t.length;++s)e[r+s]=t[s]};h.prototype.bytes=function(t){var e=t.length>>>0;if(!e)return this._push(d,1,0);if(n.isString(t)){var r=h.alloc(e=i.length(t));i.decode(t,r,0),t=r}return this.uint32(e)._push(g,e,t)},h.prototype.string=function(t){var e=o.length(t);return e?this.uint32(e)._push(o.write,e,t):this._push(d,1,0)},h.prototype.fork=function(){return this.states=new c(this),this.head=this.tail=new l(u,0,0),this.len=0,this},h.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new l(u,0,0),this.len=0),this},h.prototype.ldelim=function(){var t=this.head,e=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=t.next,this.tail=e,this.len+=r),this},h.prototype.finish=function(){for(var t=this.head.next,e=this.constructor.alloc(this.len),r=0;t;)t.fn(t.val,e,r),r+=t.len,t=t.next;return e},h._configure=function(t){s=t,h.create=f(),s._configure()}},155:(t,e,r)=>{t.exports=a;var s=r(173);(a.prototype=Object.create(s.prototype)).constructor=a;var n=r(693);function a(){s.call(this)}function i(t,e,r){t.length<40?n.utf8.write(t,e,r):e.utf8Write?e.utf8Write(t,r):e.write(t,r)}a._configure=function(){a.alloc=n._Buffer_allocUnsafe,a.writeBytesBuffer=n.Buffer&&n.Buffer.prototype instanceof Uint8Array&&"set"===n.Buffer.prototype.set.name?function(t,e,r){e.set(t,r)}:function(t,e,r){if(t.copy)t.copy(e,r,0,t.length);else for(var s=0;s<t.length;)e[r++]=t[s++]}},a.prototype.bytes=function(t){n.isString(t)&&(t=n._Buffer_from(t,"base64"));var e=t.length>>>0;return this.uint32(e),e&&this._push(a.writeBytesBuffer,e,t),this},a.prototype.string=function(t){var e=n.Buffer.byteLength(t);return this.uint32(e),e&&this._push(i,e,t),this},a._configure()},110:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Channel=void 0;const s=r(87),n=r(795);e.Channel=class{constructor(t,e){if(this.callback=e,!t)throw new Error("no url provided.");this.reset(t)}reset(t){var e;if(null===(e=this.agent)||void 0===e||e.reset(),t)if(t.startsWith("http:")||t.startsWith("https:"))this.agent=new a(t);else{if(!t.startsWith("ws:")&&!t.startsWith("wss:"))throw new Error("channel url not supported: "+t);this.agent=new i(t)}}async rpcUnaryUnary(t,e,r,s,n){return(await this.agent.getConnection()).rpcUnaryUnary(t,e,r,s,n).then((t=>(this.callback&&this.callback(n,t),t)),(t=>{throw this.callback&&this.callback(n,null,t),t}))}async rpcUnaryStream(t,e,r,s,n){return(await this.agent.getConnection()).rpcUnaryStream(t,e,r,s,n)}async rpcStreamStream(t,e,r,s,n){return(await this.agent.getConnection()).rpcStreamStream(t,e,r,s,n)}async rpcStreamUnary(t,e,r,s,n){return(await this.agent.getConnection()).rpcStreamUnary(t,e,r,s,n).then((t=>(this.callback&&this.callback(n,t),t)),(t=>{throw this.callback&&this.callback(n,null,t),t}))}};class a{constructor(t){this.url=t+(t.endsWith("/")?"":"/")}getConnection(){return this}reset(){}async rpcUnaryUnary(t,e,r,s,n){const a=this.url+t+"/"+e,i=await fetch(a,{method:"post",body:JSON.stringify(n),headers:{"Content-Type":"application/json"}});return await i.json()}rpcUnaryStream(t,e,r,s,n){throw new Error("method not supported")}rpcStreamStream(t,e,r,s,n){throw new Error("method not supported")}rpcStreamUnary(t,e,r,s,n){throw new Error("method not supported")}}class i{constructor(t){this.url=t,this.connectionFuture=null}async getConnection(){var t;if((null===(t=this.connectionFuture)||void 0===t?void 0:t.resolved)&&(this.connectionFuture.result?1!=this.connectionFuture.result.ws.readyState&&(this.connectionFuture=null):this.connectionFuture=null),!this.connectionFuture){const t=new s.Future,e=new WebSocket(this.url);e.binaryType="arraybuffer",e.onopen=()=>{t.resolve(new o(e))},e.onclose=e=>{t.reject(e)},this.connectionFuture=t}return await this.connectionFuture.promise}reset(){var t;(null===(t=this.connectionFuture)||void 0===t?void 0:t.result)&&1==this.connectionFuture.result.ws.readyState&&this.connectionFuture.result.ws.close(),this.connectionFuture=null}}class o{constructor(t){this.ws=t,this._nextCallID=1,this._calls=new Map,t.onmessage=t=>{let e=n.data.DataFrame.decode(new Uint8Array(t.data)),r=this._calls.get(e.callID);r&&r(e)},t.onclose=()=>{t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null,this._calls.forEach((t=>t(null))),this._calls.clear()}}registerCall(t){const e=this._nextCallID;return this._calls.set(e,t),this._nextCallID+=2,e}sendMessage(t){if(1!=this.ws.readyState)return;const e=n.data.DataFrame.encode(t);"undefined"!=typeof window&&window.wx?this.ws.send(e.buffer.slice(e.byteOffset,e.byteOffset+e.length)):this.ws.send(e)}rpcUnaryUnary(t,e,r,a,i){const o=new s.Future,l=this.registerCall((t=>{if(t)if(this._calls.delete(l),t.body){const e=a(t.body);o.resolve(e)}else t.trailer&&t.trailer.status==n.data.DataFrame.Trailer.Status.ERROR&&o.reject(new Error(t.trailer.message));else o.reject(new Error("lost connection"))})),u=r(i);return this.sendMessage({callID:l,header:{service:t,method:e},body:u}),o.promise}rpcUnaryStream(t,e,r,a,i){const o=new s.Stream((t=>{this.sendMessage({callID:l,trailer:{status:n.data.DataFrame.Trailer.Status.ABORT,message:null==t?void 0:t.toString()}})})),l=this.registerCall((t=>{if(t){if(t.body){const e=a(t.body);o.write(e)}t.trailer&&(this._calls.delete(l),t.trailer.status==n.data.DataFrame.Trailer.Status.OK?o.end():t.trailer.status==n.data.DataFrame.Trailer.Status.ERROR&&o.error(new Error(t.trailer.message)))}else o.error(new Error("lost connection"))})),u=r(i);return this.sendMessage({callID:l,header:{service:t,method:e},body:u}),o}rpcStreamStream(t,e,r,a,i){const o=new s.Stream((t=>{this.sendMessage({callID:u,trailer:{status:n.data.DataFrame.Trailer.Status.ABORT,message:null==t?void 0:t.toString()}})})),l=()=>{o.closed&&i.closed&&this._calls.delete(u)},u=this.registerCall((t=>{if(!t)return o.error(new Error("lost connection")),void i.abort(new Error("lost connection"));if(t.body){const e=a(t.body);o.write(e)}t.trailer&&(t.trailer.status==n.data.DataFrame.Trailer.Status.OK?o.end():t.trailer.status==n.data.DataFrame.Trailer.Status.ABORT?i.abort(new Error(t.trailer.message)):t.trailer.status==n.data.DataFrame.Trailer.Status.ERROR&&o.error(new Error(t.trailer.message)),l())}));return this.sendMessage({callID:u,header:{service:t,method:e}}),i.read((t=>{const e=r(t);this.sendMessage({callID:u,body:e})})).then((()=>{this.sendMessage({callID:u,trailer:{status:n.data.DataFrame.Trailer.Status.OK}})})).catch((t=>{this.sendMessage({callID:u,trailer:{status:n.data.DataFrame.Trailer.Status.ERROR,message:t.toString()}})})).finally(l),o}rpcStreamUnary(t,e,r,a,i){const o=new s.Future,l=()=>{o.resolved&&i.closed&&this._calls.delete(u)},u=this.registerCall((t=>{if(!t)return o.reject(new Error("lost connection")),void i.abort(new Error("lost connection"));if(t.body){const e=a(t.body);o.resolve(e)}t.trailer&&(t.trailer.status==n.data.DataFrame.Trailer.Status.ABORT?i.abort(new Error(t.trailer.message)):t.trailer.status==n.data.DataFrame.Trailer.Status.ERROR&&o.reject(new Error(t.trailer.message))),l()}));return this.sendMessage({callID:u,header:{service:t,method:e}}),i.read((t=>{const e=r(t);this.sendMessage({callID:u,body:e})})).then((()=>{this.sendMessage({callID:u,trailer:{status:n.data.DataFrame.Trailer.Status.OK}})})).catch((t=>{this.sendMessage({callID:u,trailer:{status:n.data.DataFrame.Trailer.Status.ERROR,message:t.toString()}})})).finally(l),o.promise}}},795:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.data=void 0;const s=r(100);!function(t){let e;!function(t){let e,r;!function(t){t.encode=function(t,e){const r=!e;return e||(e=s.Writer.create()),null!=t.service&&null!=t.service&&e.uint32(10).string(t.service),null!=t.method&&null!=t.method&&e.uint32(18).string(t.method),r?e.finish():e},t.decode=function(t,e){t instanceof s.Reader||(t=s.Reader.create(t));let r=void 0===e?t.len:t.pos+e;const n={};for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.service=t.string();break;case 2:n.method=t.string();break;default:t.skipType(7&e)}}return n}}(e=t.Header||(t.Header={})),function(t){t.Status={UNKNOWN:0,OK:1,ERROR:2,ABORT:3},t.encode=function(t,e){const r=!e;return e||(e=s.Writer.create()),null!=t.status&&null!=t.status&&e.uint32(8).int32(t.status),null!=t.message&&null!=t.message&&e.uint32(18).string(t.message),r?e.finish():e},t.decode=function(t,e){t instanceof s.Reader||(t=s.Reader.create(t));let r=void 0===e?t.len:t.pos+e;const n={};for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.status=t.int32();break;case 2:n.message=t.string();break;default:t.skipType(7&e)}}return n}}(r=t.Trailer||(t.Trailer={})),t.encode=function(t,n){const a=!n;return n||(n=s.Writer.create()),null!=t.callID&&null!=t.callID&&n.uint32(8).int32(t.callID),null!=t.header&&null!=t.header&&e.encode(t.header,n.uint32(58).fork()).ldelim(),null!=t.trailer&&null!=t.trailer&&r.encode(t.trailer,n.uint32(66).fork()).ldelim(),null!=t.body&&null!=t.body&&n.uint32(74).bytes(t.body),a?n.finish():n},t.decode=function(t,n){t instanceof s.Reader||(t=s.Reader.create(t));let a=void 0===n?t.len:t.pos+n;const i={};for(;t.pos<a;){let s=t.uint32();switch(s>>>3){case 1:i.callID=t.int32();break;case 7:i.header=e.decode(t,t.uint32());break;case 8:i.trailer=r.decode(t,t.uint32());break;case 9:i.body=t.bytes();break;default:t.skipType(7&s)}}return i}}(e=t.DataFrame||(t.DataFrame={}))}(e.data||(e.data={}))},728:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Server=void 0;const s=r(87),n=r(795),a=r(615);e.Server=class{constructor(){this.services={},this.fallbacks={}}addService(t,e,r){this.services[t]={rpcs:e,factory:r}}mountHttpServer(t,e){const r=new o(e,this.services);t.on("request",((t,s)=>{var n,a;(null===(n=t.url)||void 0===n?void 0:n.startsWith(e))?r.handle(t,s):(null===(a=this.fallbacks)||void 0===a?void 0:a.onrequest)?this.fallbacks.onrequest(t,s):(s.statusCode=404,s.end())}));const s=new WebSocket.Server({noServer:!0});t.on("upgrade",((t,r,n)=>{var a;new URL(t.url,`http://${t.headers.host}`).pathname==e?s.handleUpgrade(t,r,n,((t,e)=>new l(t,e,this.services))):(null===(a=this.fallbacks)||void 0===a?void 0:a.onupgrade)?this.fallbacks.onupgrade(t,r,n):(r.write("HTTP/1.1 404 Not Found\r\n\r\n"),r.destroy())}))}fallback(t,e){this.fallbacks={onrequest:t,onupgrade:e}}};class i{constructor(t){this.serviceDirectory=t,this.services={}}async getRpc(t,e,r,n=!1){const a=this.serviceDirectory[e];if(!a)throw new Error(`service not found: ${e}.${r}`);if(!((r=s.lcFirst(r))in a.rpcs))throw new Error(`method not found: ${e}.${r}`);let i;if(n){if(i=a.factory(t),!i)throw new Error(`create service error: ${e}.${r}`)}else if(i=this.services[e],!i){if(i=a.factory(t),!i)throw new Error(`create service error: ${e}.${r}`);this.services[e]=i}const o=await i,l=o[r];if(!l)throw new Error(`method not implemented: ${e}.${r}`);const[u,c,h,f]=a.rpcs[r];return{requestDecode:u,responseEncode:c,requestStream:h,responseStream:f,exec:l.bind(o)}}}class o{constructor(t,e){t.endsWith("/")||(t+="/"),this.pathPrefix=t,this.caller=new i(e)}async handle(t,e){if("OPTIONS"==t.method)return void this._corsOptions(t,e);if("POST"!=t.method)throw new Error("http method not supported");const[r,s]=t.url.substr(this.pathPrefix.length).split("/");try{const n=await this.caller.getRpc(t,r,s,!0);n.requestStream||n.responseStream?(e.statusCode=501,e.end()):await this.rpcUnaryUnary(t,e,n)}catch(t){e.statusCode=500,e.end(t.toString())}}_corsOptions(t,e){const r=t.headers.origin;if(!r)return e.writeHead(400),void e.end("no header: Origin");if(!t.headers["access-control-request-method"])return e.writeHead(400),void e.end("no header: Access-Control-Request-Method");let s=t.headers["access-control-request-headers"];s||(s="Authentication"),e.writeHead(204,{"Access-Control-Allow-Origin":r,"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Methods":"POST","Access-Control-Allow-Headers":s}),e.end()}_readRequestText(t){return new Promise(((e,r)=>{let s=[];t.on("error",(t=>{r(t)})).on("data",(t=>{s.push(t)})).on("end",(()=>{const t=Buffer.concat(s).toString();e(t)}))}))}async rpcUnaryUnary(t,e,r){if("application/json"!=t.headers["content-type"])throw new Error("codec not supported");const s=JSON.parse(await this._readRequestText(t)),n=await r.exec(s);e.setHeader("content-type","application/json"),e.end(JSON.stringify(n))}}class l{constructor(t,e,r){this.ws=t,this._calls=new Map,this._v="";const s=new i(r);t.onmessage=async t=>{let r=n.data.DataFrame.decode(new Uint8Array(t.data));if(!r.callID)return;if(!r.header&&!r.trailer&&!r.body){if(r=a.v1to2.tryDecodeDataFrame(new Uint8Array(t.data)),!r)return;if(this._v="v1",r.header){const t=r.callID,{service:i,method:o}=r.header;try{const l=await s.getRpc(e,i,o);this.ws.send(a.v1to2.encodeRequestOKResponse(r.callID)),this._calls.set(t,(e=>{e&&(l.requestStream||l.responseStream?this._calls.delete(t):this.rpcUnaryUnary(e,l).then((()=>{this.sendMessage({callID:t,trailer:{status:n.data.DataFrame.Trailer.Status.OK}})})).finally((()=>{this._calls.delete(t)})))}))}catch(t){console.warn("rpc error:",t.stack),this.sendMessage({callID:r.callID,trailer:{status:n.data.DataFrame.Trailer.Status.ERROR,message:t.toString()}})}return}}let i=this._calls.get(r.callID);if(i)i(r);else if(r.header){const{service:t,method:a}=r.header;try{const n=await s.getRpc(e,t,a);n.requestStream||n.responseStream?!n.requestStream&&n.responseStream?await this.rpcUnaryStream(r,n):(n.requestStream&&!n.responseStream||n.requestStream&&n.responseStream)&&await this.rpcStreamStream(r,n):await this.rpcUnaryUnary(r,n)}catch(t){this.sendMessage({callID:r.callID,trailer:{status:n.data.DataFrame.Trailer.Status.ERROR,message:t.toString()}})}}},t.onclose=()=>{this._calls.forEach((t=>t(null))),this._calls.clear()}}sendMessage(t){if(this.ws.readyState!=WebSocket.OPEN)return;if("v1"==this._v){const e=a.v1to2.encodeDataFrame(t);for(const t of e)this.ws.send(t);return}const e=n.data.DataFrame.encode(t);this.ws.send(e)}registerCall(t,e){this._calls.set(t,e)}async rpcUnaryUnary({callID:t,body:e},r){const s=r.requestDecode(e),n=await r.exec(s);this.sendMessage({callID:t,body:r.responseEncode(n)})}async rpcUnaryStream({callID:t,body:e},r){const s=r.requestDecode(e),a=await r.exec(s);this.registerCall(t,(t=>{t?t.trailer&&t.trailer.status==n.data.DataFrame.Trailer.Status.ABORT&&a.abort(new Error(t.trailer.message)):a.abort(new Error("lost connection"))})),a.read((e=>{this.sendMessage({callID:t,body:r.responseEncode(e)})})).then((()=>{this.sendMessage({callID:t,trailer:{status:n.data.DataFrame.Trailer.Status.OK}})})).catch((e=>{this.sendMessage({callID:t,trailer:{status:n.data.DataFrame.Trailer.Status.ERROR,message:e.toString()}})})).finally((()=>{this._calls.delete(t)}))}async rpcStreamStream({callID:t},e){const r=new s.Stream((e=>{this.sendMessage({callID:t,trailer:{status:n.data.DataFrame.Trailer.Status.ABORT,message:null==e?void 0:e.toString()}})})),a=await e.exec(r),i=()=>{r.closed&&a.closed&&this._calls.delete(t)};this.registerCall(t,(t=>{if(t){if(t.body){const s=e.requestDecode(t.body);r.write(s)}t.trailer&&(t.trailer.status==n.data.DataFrame.Trailer.Status.OK?r.end():t.trailer.status==n.data.DataFrame.Trailer.Status.ERROR?r.error(new Error(t.trailer.message)):t.trailer.status==n.data.DataFrame.Trailer.Status.ABORT&&a.abort(new Error(t.trailer.message)),i())}else a.abort(new Error("lost connection"))})),a.read((r=>{this.sendMessage({callID:t,body:e.responseEncode(r)})})).then((()=>{this.sendMessage({callID:t,trailer:{status:n.data.DataFrame.Trailer.Status.OK}})})).catch((e=>{this.sendMessage({callID:t,trailer:{status:n.data.DataFrame.Trailer.Status.ERROR,message:e.toString()}})})).finally(i)}async rpcStreamUnary({callID:t},e){const r=new s.Stream((e=>{this.sendMessage({callID:t,trailer:{status:n.data.DataFrame.Trailer.Status.ABORT,message:null==e?void 0:e.toString()}})}));this.registerCall(t,(s=>{if(s){if(s.body){const t=e.requestDecode(s.body);r.write(t)}s.trailer&&(s.trailer.status==n.data.DataFrame.Trailer.Status.OK?r.end():s.trailer.status==n.data.DataFrame.Trailer.Status.ERROR&&r.error(new Error(s.trailer.message)),this._calls.delete(t))}}));const a=await e.exec(r);this.sendMessage({callID:t,body:e.responseEncode(a)})}}},87:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Stream=e.Future=e.lcFirst=void 0,e.lcFirst=function(t){return t[0].toLowerCase()+t.substr(1)};class r{constructor(){this._resolved=!1,this.promise=new Promise(((t,e)=>{this._resovle=t,this._reject=e}))}resolve(t){this._resolved=!0,this.result=t,this._resovle(t)}reject(t){this._resolved=!0,this.error=t,this._reject(t)}get resolved(){return this._resolved}}e.Future=r,e.Stream=class{constructor(t){this._onabort=t,this._readers=[],this._closed=!1}write(t){this._readers.forEach((e=>{e.onMessage(t)}))}error(t){this._closed=!0,this._readers.forEach((e=>{e.future.reject(t)})),this._readers=[]}end(){this._closed=!0,this._readers.forEach((t=>{t.future.resolve()})),this._readers=[]}get closed(){return this._closed}abort(t){this._closed=!0,this._onabort&&this._onabort(t),this._readers.forEach((t=>{t.future.resolve()})),this._readers=[]}read(t){const e=new r,s={future:e,onMessage:t};return this._readers.push(s),e.promise}async*readToItorator(){const t=[];let e=new r;for(this.read((s=>{t.push(s),e.resolve(!1),e=new r})).then((()=>e.resolve(!0))).catch((t=>e.reject(t)));;){const r=t.shift();if(r)yield r;else if(await e.promise)return}}async writeFromIterator(t){try{for await(const e of t()){if(this._closed)return;this.write(e)}this.end()}catch(t){this.error(t)}}}},836:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.data=void 0;const s=r(100);!function(t){let e;!function(t){let e,r;!function(t){t.encode=function(t,e){const r=!e;return e||(e=s.Writer.create()),null!=t.path&&null!=t.path&&e.uint32(10).string(t.path),null!=t.status&&null!=t.status&&e.uint32(18).string(t.status),null!=t.rpcStatus&&null!=t.rpcStatus&&e.uint32(26).string(t.rpcStatus),null!=t.rpcMessage&&null!=t.rpcMessage&&e.uint32(34).string(t.rpcMessage),r?e.finish():e},t.decode=function(t,e){t instanceof s.Reader||(t=s.Reader.create(t));let r=void 0===e?t.len:t.pos+e;const n={};for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.path=t.string();break;case 2:n.status=t.string();break;case 3:n.rpcStatus=t.string();break;case 4:n.rpcMessage=t.string();break;default:t.skipType(7&e)}}return n}}(e=t.Headers||(t.Headers={})),function(t){t.encode=function(t,e){const r=!e;return e||(e=s.Writer.create()),null!=t.path&&null!=t.path&&e.uint32(10).string(t.path),null!=t.status&&null!=t.status&&e.uint32(18).string(t.status),null!=t.rpcStatus&&null!=t.rpcStatus&&e.uint32(26).string(t.rpcStatus),null!=t.rpcMessage&&null!=t.rpcMessage&&e.uint32(34).string(t.rpcMessage),r?e.finish():e},t.decode=function(t,e){t instanceof s.Reader||(t=s.Reader.create(t));let r=void 0===e?t.len:t.pos+e;const n={};for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.path=t.string();break;case 2:n.status=t.string();break;case 3:n.rpcStatus=t.string();break;case 4:n.rpcMessage=t.string();break;default:t.skipType(7&e)}}return n}}(r=t.Trailers||(t.Trailers={})),t.Types={HEADERS:1,TRAILERS:2,MESSAGE:3},t.encode=function(t,n){const a=!n;return n||(n=s.Writer.create()),null!=t.streamId&&null!=t.streamId&&n.uint32(8).int32(t.streamId),null!=t.endStream&&null!=t.endStream&&n.uint32(16).bool(t.endStream),null!=t.type&&null!=t.type&&n.uint32(24).int32(t.type),null!=t.headers&&null!=t.headers&&e.encode(t.headers,n.uint32(34).fork()).ldelim(),null!=t.trailers&&null!=t.trailers&&r.encode(t.trailers,n.uint32(42).fork()).ldelim(),null!=t.message&&null!=t.message&&n.uint32(50).bytes(t.message),a?n.finish():n},t.decode=function(t,n){t instanceof s.Reader||(t=s.Reader.create(t));let a=void 0===n?t.len:t.pos+n;const i={};for(;t.pos<a;){let s=t.uint32();switch(s>>>3){case 1:i.streamId=t.int32();break;case 2:i.endStream=t.bool();break;case 3:i.type=t.int32();break;case 4:i.headers=e.decode(t,t.uint32());break;case 5:i.trailers=r.decode(t,t.uint32());break;case 6:i.message=t.bytes();break;default:t.skipType(7&s)}}return i}}(e=t.DataFrame||(t.DataFrame={}))}(e.data||(e.data={}))},615:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.v1to2=void 0;const s=r(795),n=r(836);e.v1to2={tryDecodeDataFrame:function(t){var e;const r=n.data.DataFrame.decode(t);if(r.type==n.data.DataFrame.Types.HEADERS&&r.headers){if(r.endStream)return{callID:r.streamId,body:r.message,trailer:{status:"0"==r.headers.rpcStatus?s.data.DataFrame.Trailer.Status.OK:s.data.DataFrame.Trailer.Status.ERROR,message:r.headers.rpcMessage}};{const[t,s]=null===(e=r.headers.path)||void 0===e?void 0:e.substr(1).split("/");return{callID:r.streamId,body:r.message,header:{service:t,method:s}}}}return r.type==n.data.DataFrame.Types.TRAILERS?null:r.type==n.data.DataFrame.Types.MESSAGE&&r.message?{callID:r.streamId,body:r.message}:null},encodeDataFrame:function(t){var e;const r=[];return t.header&&r.push({streamId:t.callID,type:n.data.DataFrame.Types.HEADERS,endStream:!1,headers:{path:`${t.header.service}/${t.header.method}`}}),t.body&&r.push({streamId:t.callID,type:n.data.DataFrame.Types.MESSAGE,endStream:!1,message:t.body}),t.trailer&&(t.trailer.status==s.data.DataFrame.Trailer.Status.OK?r.push({streamId:t.callID,type:n.data.DataFrame.Types.HEADERS,endStream:!0,headers:{rpcStatus:"0"}}):r.push({streamId:t.callID,type:n.data.DataFrame.Types.HEADERS,endStream:!0,headers:{status:"400",rpcMessage:t.trailer.message,rpcStatus:null===(e=t.trailer.status)||void 0===e?void 0:e.toString()}})),r.map((t=>n.data.DataFrame.encode(t)))},encodeRequestOKResponse:function(t){return n.data.DataFrame.encode({streamId:t,type:n.data.DataFrame.Types.HEADERS,endStream:!1,headers:{status:"200"}})}}}},__webpack_module_cache__={};function __webpack_require__(t){var e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;var r=__webpack_module_cache__[t]={exports:{}};return __webpack_modules__[t].call(r.exports,r,r.exports,__webpack_require__),r.exports}var __webpack_exports__={};return(()=>{var t=__webpack_exports__;Object.defineProperty(t,"__esModule",{value:!0}),t.Server=t.Channel=t.Future=t.Stream=t.Reader=t.Writer=void 0,__webpack_require__(693).Long=null;var e=__webpack_require__(100);Object.defineProperty(t,"Writer",{enumerable:!0,get:function(){return e.Writer}}),Object.defineProperty(t,"Reader",{enumerable:!0,get:function(){return e.Reader}});var r=__webpack_require__(87);Object.defineProperty(t,"Stream",{enumerable:!0,get:function(){return r.Stream}}),Object.defineProperty(t,"Future",{enumerable:!0,get:function(){return r.Future}});var s=__webpack_require__(110);Object.defineProperty(t,"Channel",{enumerable:!0,get:function(){return s.Channel}});var n=__webpack_require__(728);Object.defineProperty(t,"Server",{enumerable:!0,get:function(){return n.Server}})})(),__webpack_exports__})()})); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.wsgrpc=e():t.wsgrpc=e()}(global,(function(){return(()=>{"use strict";var __webpack_modules__={537:t=>{t.exports=function(t,e){for(var r=new Array(arguments.length-1),s=0,n=2,a=!0;n<arguments.length;)r[s++]=arguments[n++];return new Promise((function(n,i){r[s]=function(t){if(a)if(a=!1,t)i(t);else{for(var e=new Array(arguments.length-1),r=0;r<e.length;)e[r++]=arguments[r];n.apply(null,e)}};try{t.apply(e||null,r)}catch(t){a&&(a=!1,i(t))}}))}},419:(t,e)=>{var r=e;r.length=function(t){var e=t.length;if(!e)return 0;for(var r=0;--e%4>1&&"="===t.charAt(e);)++r;return Math.ceil(3*t.length)/4-r};for(var s=new Array(64),n=new Array(123),a=0;a<64;)n[s[a]=a<26?a+65:a<52?a+71:a<62?a-4:a-59|43]=a++;r.encode=function(t,e,r){for(var n,a=null,i=[],o=0,l=0;e<r;){var u=t[e++];switch(l){case 0:i[o++]=s[u>>2],n=(3&u)<<4,l=1;break;case 1:i[o++]=s[n|u>>4],n=(15&u)<<2,l=2;break;case 2:i[o++]=s[n|u>>6],i[o++]=s[63&u],l=0}o>8191&&((a||(a=[])).push(String.fromCharCode.apply(String,i)),o=0)}return l&&(i[o++]=s[n],i[o++]=61,1===l&&(i[o++]=61)),a?(o&&a.push(String.fromCharCode.apply(String,i.slice(0,o))),a.join("")):String.fromCharCode.apply(String,i.slice(0,o))};var i="invalid encoding";r.decode=function(t,e,r){for(var s,a=r,o=0,l=0;l<t.length;){var u=t.charCodeAt(l++);if(61===u&&o>1)break;if(void 0===(u=n[u]))throw Error(i);switch(o){case 0:s=u,o=1;break;case 1:e[r++]=s<<2|(48&u)>>4,s=u,o=2;break;case 2:e[r++]=(15&s)<<4|(60&u)>>2,s=u,o=3;break;case 3:e[r++]=(3&s)<<6|u,o=0}}if(1===o)throw Error(i);return r-a},r.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}},211:t=>{function e(){this._listeners={}}t.exports=e,e.prototype.on=function(t,e,r){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:e,ctx:r||this}),this},e.prototype.off=function(t,e){if(void 0===t)this._listeners={};else if(void 0===e)this._listeners[t]=[];else for(var r=this._listeners[t],s=0;s<r.length;)r[s].fn===e?r.splice(s,1):++s;return this},e.prototype.emit=function(t){var e=this._listeners[t];if(e){for(var r=[],s=1;s<arguments.length;)r.push(arguments[s++]);for(s=0;s<e.length;)e[s].fn.apply(e[s++].ctx,r)}return this}},945:t=>{function e(t){return"undefined"!=typeof Float32Array?function(){var e=new Float32Array([-0]),r=new Uint8Array(e.buffer),s=128===r[3];function n(t,s,n){e[0]=t,s[n]=r[0],s[n+1]=r[1],s[n+2]=r[2],s[n+3]=r[3]}function a(t,s,n){e[0]=t,s[n]=r[3],s[n+1]=r[2],s[n+2]=r[1],s[n+3]=r[0]}function i(t,s){return r[0]=t[s],r[1]=t[s+1],r[2]=t[s+2],r[3]=t[s+3],e[0]}function o(t,s){return r[3]=t[s],r[2]=t[s+1],r[1]=t[s+2],r[0]=t[s+3],e[0]}t.writeFloatLE=s?n:a,t.writeFloatBE=s?a:n,t.readFloatLE=s?i:o,t.readFloatBE=s?o:i}():function(){function e(t,e,r,s){var n=e<0?1:0;if(n&&(e=-e),0===e)t(1/e>0?0:2147483648,r,s);else if(isNaN(e))t(2143289344,r,s);else if(e>34028234663852886e22)t((n<<31|2139095040)>>>0,r,s);else if(e<11754943508222875e-54)t((n<<31|Math.round(e/1401298464324817e-60))>>>0,r,s);else{var a=Math.floor(Math.log(e)/Math.LN2);t((n<<31|a+127<<23|8388607&Math.round(e*Math.pow(2,-a)*8388608))>>>0,r,s)}}function i(t,e,r){var s=t(e,r),n=2*(s>>31)+1,a=s>>>23&255,i=8388607&s;return 255===a?i?NaN:n*(1/0):0===a?1401298464324817e-60*n*i:n*Math.pow(2,a-150)*(i+8388608)}t.writeFloatLE=e.bind(null,r),t.writeFloatBE=e.bind(null,s),t.readFloatLE=i.bind(null,n),t.readFloatBE=i.bind(null,a)}(),"undefined"!=typeof Float64Array?function(){var e=new Float64Array([-0]),r=new Uint8Array(e.buffer),s=128===r[7];function n(t,s,n){e[0]=t,s[n]=r[0],s[n+1]=r[1],s[n+2]=r[2],s[n+3]=r[3],s[n+4]=r[4],s[n+5]=r[5],s[n+6]=r[6],s[n+7]=r[7]}function a(t,s,n){e[0]=t,s[n]=r[7],s[n+1]=r[6],s[n+2]=r[5],s[n+3]=r[4],s[n+4]=r[3],s[n+5]=r[2],s[n+6]=r[1],s[n+7]=r[0]}function i(t,s){return r[0]=t[s],r[1]=t[s+1],r[2]=t[s+2],r[3]=t[s+3],r[4]=t[s+4],r[5]=t[s+5],r[6]=t[s+6],r[7]=t[s+7],e[0]}function o(t,s){return r[7]=t[s],r[6]=t[s+1],r[5]=t[s+2],r[4]=t[s+3],r[3]=t[s+4],r[2]=t[s+5],r[1]=t[s+6],r[0]=t[s+7],e[0]}t.writeDoubleLE=s?n:a,t.writeDoubleBE=s?a:n,t.readDoubleLE=s?i:o,t.readDoubleBE=s?o:i}():function(){function e(t,e,r,s,n,a){var i=s<0?1:0;if(i&&(s=-s),0===s)t(0,n,a+e),t(1/s>0?0:2147483648,n,a+r);else if(isNaN(s))t(0,n,a+e),t(2146959360,n,a+r);else if(s>17976931348623157e292)t(0,n,a+e),t((i<<31|2146435072)>>>0,n,a+r);else{var o;if(s<22250738585072014e-324)t((o=s/5e-324)>>>0,n,a+e),t((i<<31|o/4294967296)>>>0,n,a+r);else{var l=Math.floor(Math.log(s)/Math.LN2);1024===l&&(l=1023),t(4503599627370496*(o=s*Math.pow(2,-l))>>>0,n,a+e),t((i<<31|l+1023<<20|1048576*o&1048575)>>>0,n,a+r)}}}function i(t,e,r,s,n){var a=t(s,n+e),i=t(s,n+r),o=2*(i>>31)+1,l=i>>>20&2047,u=4294967296*(1048575&i)+a;return 2047===l?u?NaN:o*(1/0):0===l?5e-324*o*u:o*Math.pow(2,l-1075)*(u+4503599627370496)}t.writeDoubleLE=e.bind(null,r,0,4),t.writeDoubleBE=e.bind(null,s,4,0),t.readDoubleLE=i.bind(null,n,0,4),t.readDoubleBE=i.bind(null,a,4,0)}(),t}function r(t,e,r){e[r]=255&t,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function s(t,e,r){e[r]=t>>>24,e[r+1]=t>>>16&255,e[r+2]=t>>>8&255,e[r+3]=255&t}function n(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}function a(t,e){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}t.exports=e(e)},199:module=>{function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(t){}return null}module.exports=inquire},662:t=>{t.exports=function(t,e,r){var s=r||8192,n=s>>>1,a=null,i=s;return function(r){if(r<1||r>n)return t(r);i+r>s&&(a=t(s),i=0);var o=e.call(a,i,i+=r);return 7&i&&(i=1+(7|i)),o}}},997:(t,e)=>{var r=e;r.length=function(t){for(var e=0,r=0,s=0;s<t.length;++s)(r=t.charCodeAt(s))<128?e+=1:r<2048?e+=2:55296==(64512&r)&&56320==(64512&t.charCodeAt(s+1))?(++s,e+=4):e+=3;return e},r.read=function(t,e,r){if(r-e<1)return"";for(var s,n=null,a=[],i=0;e<r;)(s=t[e++])<128?a[i++]=s:s>191&&s<224?a[i++]=(31&s)<<6|63&t[e++]:s>239&&s<365?(s=((7&s)<<18|(63&t[e++])<<12|(63&t[e++])<<6|63&t[e++])-65536,a[i++]=55296+(s>>10),a[i++]=56320+(1023&s)):a[i++]=(15&s)<<12|(63&t[e++])<<6|63&t[e++],i>8191&&((n||(n=[])).push(String.fromCharCode.apply(String,a)),i=0);return n?(i&&n.push(String.fromCharCode.apply(String,a.slice(0,i))),n.join("")):String.fromCharCode.apply(String,a.slice(0,i))},r.write=function(t,e,r){for(var s,n,a=r,i=0;i<t.length;++i)(s=t.charCodeAt(i))<128?e[r++]=s:s<2048?(e[r++]=s>>6|192,e[r++]=63&s|128):55296==(64512&s)&&56320==(64512&(n=t.charCodeAt(i+1)))?(s=65536+((1023&s)<<10)+(1023&n),++i,e[r++]=s>>18|240,e[r++]=s>>12&63|128,e[r++]=s>>6&63|128,e[r++]=63&s|128):(e[r++]=s>>12|224,e[r++]=s>>6&63|128,e[r++]=63&s|128);return r-a}},100:(t,e,r)=>{t.exports=r(482)},482:(t,e,r)=>{var s=e;function n(){s.util._configure(),s.Writer._configure(s.BufferWriter),s.Reader._configure(s.BufferReader)}s.build="minimal",s.Writer=r(173),s.BufferWriter=r(155),s.Reader=r(408),s.BufferReader=r(593),s.util=r(693),s.rpc=r(994),s.roots=r(54),s.configure=n,n()},408:(t,e,r)=>{t.exports=l;var s,n=r(693),a=n.LongBits,i=n.utf8;function o(t,e){return RangeError("index out of range: "+t.pos+" + "+(e||1)+" > "+t.len)}function l(t){this.buf=t,this.pos=0,this.len=t.length}var u,c="undefined"!=typeof Uint8Array?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new l(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new l(t);throw Error("illegal buffer")},h=function(){return n.Buffer?function(t){return(l.create=function(t){return n.Buffer.isBuffer(t)?new s(t):c(t)})(t)}:c};function f(){var t=new a(0,0),e=0;if(!(this.len-this.pos>4)){for(;e<3;++e){if(this.pos>=this.len)throw o(this);if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*e)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(127&this.buf[this.pos++])<<7*e)>>>0,t}for(;e<4;++e)if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*e)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(127&this.buf[this.pos])<<28)>>>0,t.hi=(t.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return t;if(e=0,this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*e+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw o(this);if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*e+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}function d(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}function p(){if(this.pos+8>this.len)throw o(this,8);return new a(d(this.buf,this.pos+=4),d(this.buf,this.pos+=4))}l.create=h(),l.prototype._slice=n.Array.prototype.subarray||n.Array.prototype.slice,l.prototype.uint32=(u=4294967295,function(){if(u=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return u;if((this.pos+=5)>this.len)throw this.pos=this.len,o(this,10);return u}),l.prototype.int32=function(){return 0|this.uint32()},l.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(1&t)|0},l.prototype.bool=function(){return 0!==this.uint32()},l.prototype.fixed32=function(){if(this.pos+4>this.len)throw o(this,4);return d(this.buf,this.pos+=4)},l.prototype.sfixed32=function(){if(this.pos+4>this.len)throw o(this,4);return 0|d(this.buf,this.pos+=4)},l.prototype.float=function(){if(this.pos+4>this.len)throw o(this,4);var t=n.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t},l.prototype.double=function(){if(this.pos+8>this.len)throw o(this,4);var t=n.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t},l.prototype.bytes=function(){var t=this.uint32(),e=this.pos,r=this.pos+t;if(r>this.len)throw o(this,t);return this.pos+=t,Array.isArray(this.buf)?this.buf.slice(e,r):e===r?new this.buf.constructor(0):this._slice.call(this.buf,e,r)},l.prototype.string=function(){var t=this.bytes();return i.read(t,0,t.length)},l.prototype.skip=function(t){if("number"==typeof t){if(this.pos+t>this.len)throw o(this,t);this.pos+=t}else do{if(this.pos>=this.len)throw o(this)}while(128&this.buf[this.pos++]);return this},l.prototype.skipType=function(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(t=7&this.uint32());)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+t+" at offset "+this.pos)}return this},l._configure=function(t){s=t,l.create=h(),s._configure();var e=n.Long?"toLong":"toNumber";n.merge(l.prototype,{int64:function(){return f.call(this)[e](!1)},uint64:function(){return f.call(this)[e](!0)},sint64:function(){return f.call(this).zzDecode()[e](!1)},fixed64:function(){return p.call(this)[e](!0)},sfixed64:function(){return p.call(this)[e](!1)}})}},593:(t,e,r)=>{t.exports=a;var s=r(408);(a.prototype=Object.create(s.prototype)).constructor=a;var n=r(693);function a(t){s.call(this,t)}a._configure=function(){n.Buffer&&(a.prototype._slice=n.Buffer.prototype.slice)},a.prototype.string=function(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))},a._configure()},54:t=>{t.exports={}},994:(t,e,r)=>{e.Service=r(948)},948:(t,e,r)=>{t.exports=n;var s=r(693);function n(t,e,r){if("function"!=typeof t)throw TypeError("rpcImpl must be a function");s.EventEmitter.call(this),this.rpcImpl=t,this.requestDelimited=Boolean(e),this.responseDelimited=Boolean(r)}(n.prototype=Object.create(s.EventEmitter.prototype)).constructor=n,n.prototype.rpcCall=function t(e,r,n,a,i){if(!a)throw TypeError("request must be specified");var o=this;if(!i)return s.asPromise(t,o,e,r,n,a);if(o.rpcImpl)try{return o.rpcImpl(e,r[o.requestDelimited?"encodeDelimited":"encode"](a).finish(),(function(t,r){if(t)return o.emit("error",t,e),i(t);if(null!==r){if(!(r instanceof n))try{r=n[o.responseDelimited?"decodeDelimited":"decode"](r)}catch(t){return o.emit("error",t,e),i(t)}return o.emit("data",r,e),i(null,r)}o.end(!0)}))}catch(t){return o.emit("error",t,e),void setTimeout((function(){i(t)}),0)}else setTimeout((function(){i(Error("already ended"))}),0)},n.prototype.end=function(t){return this.rpcImpl&&(t||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},630:(t,e,r)=>{t.exports=n;var s=r(693);function n(t,e){this.lo=t>>>0,this.hi=e>>>0}var a=n.zero=new n(0,0);a.toNumber=function(){return 0},a.zzEncode=a.zzDecode=function(){return this},a.length=function(){return 1};var i=n.zeroHash="\0\0\0\0\0\0\0\0";n.fromNumber=function(t){if(0===t)return a;var e=t<0;e&&(t=-t);var r=t>>>0,s=(t-r)/4294967296>>>0;return e&&(s=~s>>>0,r=~r>>>0,++r>4294967295&&(r=0,++s>4294967295&&(s=0))),new n(r,s)},n.from=function(t){if("number"==typeof t)return n.fromNumber(t);if(s.isString(t)){if(!s.Long)return n.fromNumber(parseInt(t,10));t=s.Long.fromString(t)}return t.low||t.high?new n(t.low>>>0,t.high>>>0):a},n.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var e=1+~this.lo>>>0,r=~this.hi>>>0;return e||(r=r+1>>>0),-(e+4294967296*r)}return this.lo+4294967296*this.hi},n.prototype.toLong=function(t){return s.Long?new s.Long(0|this.lo,0|this.hi,Boolean(t)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(t)}};var o=String.prototype.charCodeAt;n.fromHash=function(t){return t===i?a:new n((o.call(t,0)|o.call(t,1)<<8|o.call(t,2)<<16|o.call(t,3)<<24)>>>0,(o.call(t,4)|o.call(t,5)<<8|o.call(t,6)<<16|o.call(t,7)<<24)>>>0)},n.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},n.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this},n.prototype.zzDecode=function(){var t=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this},n.prototype.length=function(){var t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===e?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:r<128?9:10}},693:function(t,e,r){var s=e;function n(t,e,r){for(var s=Object.keys(e),n=0;n<s.length;++n)void 0!==t[s[n]]&&r||(t[s[n]]=e[s[n]]);return t}function a(t){function e(t,r){if(!(this instanceof e))return new e(t,r);Object.defineProperty(this,"message",{get:function(){return t}}),Error.captureStackTrace?Error.captureStackTrace(this,e):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),r&&n(this,r)}return(e.prototype=Object.create(Error.prototype)).constructor=e,Object.defineProperty(e.prototype,"name",{get:function(){return t}}),e.prototype.toString=function(){return this.name+": "+this.message},e}s.asPromise=r(537),s.base64=r(419),s.EventEmitter=r(211),s.float=r(945),s.inquire=r(199),s.utf8=r(997),s.pool=r(662),s.LongBits=r(630),s.isNode=Boolean("undefined"!=typeof global&&global&&global.process&&global.process.versions&&global.process.versions.node),s.global=s.isNode&&global||"undefined"!=typeof window&&window||"undefined"!=typeof self&&self||this,s.emptyArray=Object.freeze?Object.freeze([]):[],s.emptyObject=Object.freeze?Object.freeze({}):{},s.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},s.isString=function(t){return"string"==typeof t||t instanceof String},s.isObject=function(t){return t&&"object"==typeof t},s.isset=s.isSet=function(t,e){var r=t[e];return!(null==r||!t.hasOwnProperty(e))&&("object"!=typeof r||(Array.isArray(r)?r.length:Object.keys(r).length)>0)},s.Buffer=function(){try{var t=s.inquire("buffer").Buffer;return t.prototype.utf8Write?t:null}catch(t){return null}}(),s._Buffer_from=null,s._Buffer_allocUnsafe=null,s.newBuffer=function(t){return"number"==typeof t?s.Buffer?s._Buffer_allocUnsafe(t):new s.Array(t):s.Buffer?s._Buffer_from(t):"undefined"==typeof Uint8Array?t:new Uint8Array(t)},s.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,s.Long=s.global.dcodeIO&&s.global.dcodeIO.Long||s.global.Long||s.inquire("long"),s.key2Re=/^true|false|0|1$/,s.key32Re=/^-?(?:0|[1-9][0-9]*)$/,s.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,s.longToHash=function(t){return t?s.LongBits.from(t).toHash():s.LongBits.zeroHash},s.longFromHash=function(t,e){var r=s.LongBits.fromHash(t);return s.Long?s.Long.fromBits(r.lo,r.hi,e):r.toNumber(Boolean(e))},s.merge=n,s.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)},s.newError=a,s.ProtocolError=a("ProtocolError"),s.oneOfGetter=function(t){for(var e={},r=0;r<t.length;++r)e[t[r]]=1;return function(){for(var t=Object.keys(this),r=t.length-1;r>-1;--r)if(1===e[t[r]]&&void 0!==this[t[r]]&&null!==this[t[r]])return t[r]}},s.oneOfSetter=function(t){return function(e){for(var r=0;r<t.length;++r)t[r]!==e&&delete this[t[r]]}},s.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},s._configure=function(){var t=s.Buffer;t?(s._Buffer_from=t.from!==Uint8Array.from&&t.from||function(e,r){return new t(e,r)},s._Buffer_allocUnsafe=t.allocUnsafe||function(e){return new t(e)}):s._Buffer_from=s._Buffer_allocUnsafe=null}},173:(t,e,r)=>{t.exports=h;var s,n=r(693),a=n.LongBits,i=n.base64,o=n.utf8;function l(t,e,r){this.fn=t,this.len=e,this.next=void 0,this.val=r}function u(){}function c(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}function h(){this.len=0,this.head=new l(u,0,0),this.tail=this.head,this.states=null}var f=function(){return n.Buffer?function(){return(h.create=function(){return new s})()}:function(){return new h}};function d(t,e,r){e[r]=255&t}function p(t,e){this.len=t,this.next=void 0,this.val=e}function y(t,e,r){for(;t.hi;)e[r++]=127&t.lo|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=127&t.lo|128,t.lo=t.lo>>>7;e[r++]=t.lo}function m(t,e,r){e[r]=255&t,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}h.create=f(),h.alloc=function(t){return new n.Array(t)},n.Array!==Array&&(h.alloc=n.pool(h.alloc,n.Array.prototype.subarray)),h.prototype._push=function(t,e,r){return this.tail=this.tail.next=new l(t,e,r),this.len+=e,this},p.prototype=Object.create(l.prototype),p.prototype.fn=function(t,e,r){for(;t>127;)e[r++]=127&t|128,t>>>=7;e[r]=t},h.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new p((t>>>=0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this},h.prototype.int32=function(t){return t<0?this._push(y,10,a.fromNumber(t)):this.uint32(t)},h.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)},h.prototype.uint64=function(t){var e=a.from(t);return this._push(y,e.length(),e)},h.prototype.int64=h.prototype.uint64,h.prototype.sint64=function(t){var e=a.from(t).zzEncode();return this._push(y,e.length(),e)},h.prototype.bool=function(t){return this._push(d,1,t?1:0)},h.prototype.fixed32=function(t){return this._push(m,4,t>>>0)},h.prototype.sfixed32=h.prototype.fixed32,h.prototype.fixed64=function(t){var e=a.from(t);return this._push(m,4,e.lo)._push(m,4,e.hi)},h.prototype.sfixed64=h.prototype.fixed64,h.prototype.float=function(t){return this._push(n.float.writeFloatLE,4,t)},h.prototype.double=function(t){return this._push(n.float.writeDoubleLE,8,t)};var g=n.Array.prototype.set?function(t,e,r){e.set(t,r)}:function(t,e,r){for(var s=0;s<t.length;++s)e[r+s]=t[s]};h.prototype.bytes=function(t){var e=t.length>>>0;if(!e)return this._push(d,1,0);if(n.isString(t)){var r=h.alloc(e=i.length(t));i.decode(t,r,0),t=r}return this.uint32(e)._push(g,e,t)},h.prototype.string=function(t){var e=o.length(t);return e?this.uint32(e)._push(o.write,e,t):this._push(d,1,0)},h.prototype.fork=function(){return this.states=new c(this),this.head=this.tail=new l(u,0,0),this.len=0,this},h.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new l(u,0,0),this.len=0),this},h.prototype.ldelim=function(){var t=this.head,e=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=t.next,this.tail=e,this.len+=r),this},h.prototype.finish=function(){for(var t=this.head.next,e=this.constructor.alloc(this.len),r=0;t;)t.fn(t.val,e,r),r+=t.len,t=t.next;return e},h._configure=function(t){s=t,h.create=f(),s._configure()}},155:(t,e,r)=>{t.exports=a;var s=r(173);(a.prototype=Object.create(s.prototype)).constructor=a;var n=r(693);function a(){s.call(this)}function i(t,e,r){t.length<40?n.utf8.write(t,e,r):e.utf8Write?e.utf8Write(t,r):e.write(t,r)}a._configure=function(){a.alloc=n._Buffer_allocUnsafe,a.writeBytesBuffer=n.Buffer&&n.Buffer.prototype instanceof Uint8Array&&"set"===n.Buffer.prototype.set.name?function(t,e,r){e.set(t,r)}:function(t,e,r){if(t.copy)t.copy(e,r,0,t.length);else for(var s=0;s<t.length;)e[r++]=t[s++]}},a.prototype.bytes=function(t){n.isString(t)&&(t=n._Buffer_from(t,"base64"));var e=t.length>>>0;return this.uint32(e),e&&this._push(a.writeBytesBuffer,e,t),this},a.prototype.string=function(t){var e=n.Buffer.byteLength(t);return this.uint32(e),e&&this._push(i,e,t),this},a._configure()},110:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Channel=void 0;const s=r(87),n=r(795);e.Channel=class{constructor(t,e){if(this.callback=e,!t)throw new Error("no url provided.");this.reset(t)}reset(t){var e;if(null===(e=this.agent)||void 0===e||e.reset(),t)if(t.startsWith("http:")||t.startsWith("https:"))this.agent=new a(t);else{if(!t.startsWith("ws:")&&!t.startsWith("wss:"))throw new Error("channel url not supported: "+t);this.agent=new i(t)}}async rpcUnaryUnary(t,e,r,s,n){return(await this.agent.getConnection()).rpcUnaryUnary(t,e,r,s,n).then((t=>(this.callback&&this.callback(n,t),t)),(t=>{throw this.callback&&this.callback(n,null,t),t}))}async rpcUnaryStream(t,e,r,s,n){return(await this.agent.getConnection()).rpcUnaryStream(t,e,r,s,n)}async rpcStreamStream(t,e,r,s,n){return(await this.agent.getConnection()).rpcStreamStream(t,e,r,s,n)}async rpcStreamUnary(t,e,r,s,n){return(await this.agent.getConnection()).rpcStreamUnary(t,e,r,s,n).then((t=>(this.callback&&this.callback(n,t),t)),(t=>{throw this.callback&&this.callback(n,null,t),t}))}};class a{constructor(t){this.url=t+(t.endsWith("/")?"":"/")}getConnection(){return this}reset(){}async rpcUnaryUnary(t,e,r,s,n){const a=this.url+t+"/"+e,i=await fetch(a,{method:"post",body:JSON.stringify(n),headers:{"Content-Type":"application/json"}});return await i.json()}rpcUnaryStream(t,e,r,s,n){throw new Error("method not supported")}rpcStreamStream(t,e,r,s,n){throw new Error("method not supported")}rpcStreamUnary(t,e,r,s,n){throw new Error("method not supported")}}class i{constructor(t){this.url=t,this.connectionFuture=null}async getConnection(){var t;if((null===(t=this.connectionFuture)||void 0===t?void 0:t.resolved)&&(this.connectionFuture.result?1!=this.connectionFuture.result.ws.readyState&&(this.connectionFuture=null):this.connectionFuture=null),!this.connectionFuture){const t=new s.Future,e=new WebSocket(this.url);e.binaryType="arraybuffer",e.onopen=()=>{t.resolve(new o(e))},e.onclose=e=>{t.reject(e)},this.connectionFuture=t}return await this.connectionFuture.promise}reset(){var t;(null===(t=this.connectionFuture)||void 0===t?void 0:t.result)&&1==this.connectionFuture.result.ws.readyState&&this.connectionFuture.result.ws.close(),this.connectionFuture=null}}class o{constructor(t){this.ws=t,this._nextCallID=1,this._calls=new Map,t.onmessage=t=>{let e=n.data.DataFrame.decode(new Uint8Array(t.data)),r=this._calls.get(e.callID);r&&r(e)},t.onclose=()=>{t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null,this._calls.forEach((t=>t(null))),this._calls.clear()}}registerCall(t){const e=this._nextCallID;return this._calls.set(e,t),this._nextCallID+=2,e}sendMessage(t){if(1!=this.ws.readyState)return;const e=n.data.DataFrame.encode(t);"undefined"!=typeof window&&window.wx?this.ws.send(e.buffer.slice(e.byteOffset,e.byteOffset+e.length)):this.ws.send(e)}rpcUnaryUnary(t,e,r,a,i){const o=new s.Future,l=this.registerCall((t=>{if(t)if(this._calls.delete(l),t.body){const e=a(t.body);o.resolve(e)}else t.trailer&&t.trailer.status==n.data.DataFrame.Trailer.Status.ERROR&&o.reject(new Error(t.trailer.message));else o.reject(new Error("lost connection"))})),u=r(i);return this.sendMessage({callID:l,header:{service:t,method:e},body:u}),o.promise}rpcUnaryStream(t,e,r,a,i){const o=new s.Stream((t=>{this.sendMessage({callID:l,trailer:{status:n.data.DataFrame.Trailer.Status.ABORT,message:null==t?void 0:t.toString()}})})),l=this.registerCall((t=>{if(t){if(t.body){const e=a(t.body);o.write(e)}t.trailer&&(this._calls.delete(l),t.trailer.status==n.data.DataFrame.Trailer.Status.OK?o.end():t.trailer.status==n.data.DataFrame.Trailer.Status.ERROR&&o.error(new Error(t.trailer.message)))}else o.error(new Error("lost connection"))})),u=r(i);return this.sendMessage({callID:l,header:{service:t,method:e},body:u}),o}rpcStreamStream(t,e,r,a,i){const o=new s.Stream((t=>{this.sendMessage({callID:u,trailer:{status:n.data.DataFrame.Trailer.Status.ABORT,message:null==t?void 0:t.toString()}})})),l=()=>{o.closed&&i.closed&&this._calls.delete(u)},u=this.registerCall((t=>{if(!t)return o.error(new Error("lost connection")),void i.abort(new Error("lost connection"));if(t.body){const e=a(t.body);o.write(e)}t.trailer&&(t.trailer.status==n.data.DataFrame.Trailer.Status.OK?o.end():t.trailer.status==n.data.DataFrame.Trailer.Status.ABORT?i.abort(new Error(t.trailer.message)):t.trailer.status==n.data.DataFrame.Trailer.Status.ERROR&&o.error(new Error(t.trailer.message)),l())}));return this.sendMessage({callID:u,header:{service:t,method:e}}),i.read((t=>{const e=r(t);this.sendMessage({callID:u,body:e})})).then((()=>{this.sendMessage({callID:u,trailer:{status:n.data.DataFrame.Trailer.Status.OK}})})).catch((t=>{this.sendMessage({callID:u,trailer:{status:n.data.DataFrame.Trailer.Status.ERROR,message:t.toString()}})})).finally(l),o}rpcStreamUnary(t,e,r,a,i){const o=new s.Future,l=()=>{o.resolved&&i.closed&&this._calls.delete(u)},u=this.registerCall((t=>{if(!t)return o.reject(new Error("lost connection")),void i.abort(new Error("lost connection"));if(t.body){const e=a(t.body);o.resolve(e)}t.trailer&&(t.trailer.status==n.data.DataFrame.Trailer.Status.ABORT?i.abort(new Error(t.trailer.message)):t.trailer.status==n.data.DataFrame.Trailer.Status.ERROR&&o.reject(new Error(t.trailer.message))),l()}));return this.sendMessage({callID:u,header:{service:t,method:e}}),i.read((t=>{const e=r(t);this.sendMessage({callID:u,body:e})})).then((()=>{this.sendMessage({callID:u,trailer:{status:n.data.DataFrame.Trailer.Status.OK}})})).catch((t=>{this.sendMessage({callID:u,trailer:{status:n.data.DataFrame.Trailer.Status.ERROR,message:t.toString()}})})).finally(l),o.promise}}},795:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.data=void 0;const s=r(100);!function(t){let e;!function(t){let e,r;!function(t){t.encode=function(t,e){const r=!e;return e||(e=s.Writer.create()),null!=t.service&&null!=t.service&&e.uint32(10).string(t.service),null!=t.method&&null!=t.method&&e.uint32(18).string(t.method),r?e.finish():e},t.decode=function(t,e){t instanceof s.Reader||(t=s.Reader.create(t));let r=void 0===e?t.len:t.pos+e;const n={};for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.service=t.string();break;case 2:n.method=t.string();break;default:t.skipType(7&e)}}return n}}(e=t.Header||(t.Header={})),function(t){t.Status={UNKNOWN:0,OK:1,ERROR:2,ABORT:3},t.encode=function(t,e){const r=!e;return e||(e=s.Writer.create()),null!=t.status&&null!=t.status&&e.uint32(8).int32(t.status),null!=t.message&&null!=t.message&&e.uint32(18).string(t.message),r?e.finish():e},t.decode=function(t,e){t instanceof s.Reader||(t=s.Reader.create(t));let r=void 0===e?t.len:t.pos+e;const n={};for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.status=t.int32();break;case 2:n.message=t.string();break;default:t.skipType(7&e)}}return n}}(r=t.Trailer||(t.Trailer={})),t.encode=function(t,n){const a=!n;return n||(n=s.Writer.create()),null!=t.callID&&null!=t.callID&&n.uint32(8).int32(t.callID),null!=t.header&&null!=t.header&&e.encode(t.header,n.uint32(58).fork()).ldelim(),null!=t.trailer&&null!=t.trailer&&r.encode(t.trailer,n.uint32(66).fork()).ldelim(),null!=t.body&&null!=t.body&&n.uint32(74).bytes(t.body),a?n.finish():n},t.decode=function(t,n){t instanceof s.Reader||(t=s.Reader.create(t));let a=void 0===n?t.len:t.pos+n;const i={};for(;t.pos<a;){let s=t.uint32();switch(s>>>3){case 1:i.callID=t.int32();break;case 7:i.header=e.decode(t,t.uint32());break;case 8:i.trailer=r.decode(t,t.uint32());break;case 9:i.body=t.bytes();break;default:t.skipType(7&s)}}return i}}(e=t.DataFrame||(t.DataFrame={}))}(e.data||(e.data={}))},728:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Server=void 0;const s=r(87),n=r(795),a=r(615);e.Server=class{constructor(){this.services={},this.fallbacks={}}addService(t,e,r){this.services[t]={rpcs:e,factory:r}}mountHttpServer(t,e){const r=new o(e,this.services);t.on("request",((t,s)=>{var n,a;(null===(n=t.url)||void 0===n?void 0:n.startsWith(e))?r.handle(t,s):(null===(a=this.fallbacks)||void 0===a?void 0:a.onrequest)?this.fallbacks.onrequest(t,s):(s.statusCode=404,s.end())}));const s=new WebSocket.Server({noServer:!0});t.on("upgrade",((t,r,n)=>{var a;new URL(t.url,`http://${t.headers.host}`).pathname==e?s.handleUpgrade(t,r,n,((t,e)=>new l(t,e,this.services))):(null===(a=this.fallbacks)||void 0===a?void 0:a.onupgrade)?this.fallbacks.onupgrade(t,r,n):(r.write("HTTP/1.1 404 Not Found\r\n\r\n"),r.destroy())}))}fallback(t,e){this.fallbacks={onrequest:t,onupgrade:e}}};class i{constructor(t){this.serviceDirectory=t,this.services={}}async getRpc(t,e,r,n=!1){const a=this.serviceDirectory[e];if(!a)throw new Error(`service not found: ${e}.${r}`);if(!((r=s.lcFirst(r))in a.rpcs))throw new Error(`method not found: ${e}.${r}`);let i;if(n){if(i=a.factory(t),!i)throw new Error(`create service error: ${e}.${r}`)}else if(i=this.services[e],!i){if(i=a.factory(t),!i)throw new Error(`create service error: ${e}.${r}`);this.services[e]=i}const o=await i,l=o[r];if(!l)throw new Error(`method not implemented: ${e}.${r}`);const[u,c,h,f]=a.rpcs[r];return{requestDecode:u,responseEncode:c,requestStream:h,responseStream:f,exec:l.bind(o)}}}class o{constructor(t,e){t.endsWith("/")||(t+="/"),this.pathPrefix=t,this.caller=new i(e)}async handle(t,e){if("OPTIONS"==t.method)return void this._corsOptions(t,e);if("POST"!=t.method)throw new Error("http method not supported");const[r,s]=t.url.substr(this.pathPrefix.length).split("/");try{const n=await this.caller.getRpc(t,r,s,!0);n.requestStream||n.responseStream?(e.statusCode=501,e.end()):await this.rpcUnaryUnary(t,e,n)}catch(t){e.statusCode=500,e.end(t.toString())}}_corsOptions(t,e){const r=t.headers.origin;if(!r)return e.writeHead(400),void e.end("no header: Origin");if(!t.headers["access-control-request-method"])return e.writeHead(400),void e.end("no header: Access-Control-Request-Method");let s=t.headers["access-control-request-headers"];s||(s="Authentication"),e.writeHead(204,{"Access-Control-Allow-Origin":r,"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Methods":"POST","Access-Control-Allow-Headers":s}),e.end()}_readRequestText(t){return new Promise(((e,r)=>{let s=[];t.on("error",(t=>{r(t)})).on("data",(t=>{s.push(t)})).on("end",(()=>{const t=Buffer.concat(s).toString();e(t)}))}))}async rpcUnaryUnary(t,e,r){if("application/json"!=t.headers["content-type"])throw new Error("codec not supported");const s=JSON.parse(await this._readRequestText(t)),n=await r.exec(s);e.setHeader("content-type","application/json"),e.end(JSON.stringify(n))}}class l{constructor(t,e,r){this.ws=t,this._calls=new Map,this._v="";const s=new i(r);t.onmessage=async t=>{let r=n.data.DataFrame.decode(new Uint8Array(t.data));if(!r.callID)return;if(!r.header&&!r.trailer&&!r.body){if(r=a.v1to2.tryDecodeDataFrame(new Uint8Array(t.data)),!r)return;if(this._v="v1",r.header){const t=r.callID,{service:i,method:o}=r.header;try{const l=await s.getRpc(e,i,o);if(l.requestStream||l.responseStream)throw new Error("stream not implemented for v1 compatibility");this.ws.send(a.v1to2.encodeRequestOKResponse(r.callID)),this._calls.set(t,(e=>{e&&this.rpcUnaryUnary(e,l).then((()=>{this.sendMessage({callID:t,trailer:{status:n.data.DataFrame.Trailer.Status.OK}})})).finally((()=>{this._calls.delete(t)}))}))}catch(t){console.warn("v1 rpc error:",t.stack),this.sendMessage({callID:r.callID,trailer:{status:n.data.DataFrame.Trailer.Status.ERROR,message:t.toString()}})}return}}let i=this._calls.get(r.callID);if(i)i(r);else if(r.header){const{service:t,method:a}=r.header;try{const n=await s.getRpc(e,t,a);n.requestStream||n.responseStream?!n.requestStream&&n.responseStream?await this.rpcUnaryStream(r,n):(n.requestStream&&!n.responseStream||n.requestStream&&n.responseStream)&&await this.rpcStreamStream(r,n):await this.rpcUnaryUnary(r,n)}catch(t){this.sendMessage({callID:r.callID,trailer:{status:n.data.DataFrame.Trailer.Status.ERROR,message:t.toString()}})}}},t.onclose=()=>{this._calls.forEach((t=>t(null))),this._calls.clear()}}sendMessage(t){if(this.ws.readyState!=WebSocket.OPEN)return;if("v1"==this._v){const e=a.v1to2.encodeDataFrame(t);for(const t of e)this.ws.send(t);return}const e=n.data.DataFrame.encode(t);this.ws.send(e)}registerCall(t,e){this._calls.set(t,e)}async rpcUnaryUnary({callID:t,body:e},r){const s=r.requestDecode(e),n=await r.exec(s);this.sendMessage({callID:t,body:r.responseEncode(n)})}async rpcUnaryStream({callID:t,body:e},r){const s=r.requestDecode(e),a=await r.exec(s);this.registerCall(t,(t=>{t?t.trailer&&t.trailer.status==n.data.DataFrame.Trailer.Status.ABORT&&a.abort(new Error(t.trailer.message)):a.abort(new Error("lost connection"))})),a.read((e=>{this.sendMessage({callID:t,body:r.responseEncode(e)})})).then((()=>{this.sendMessage({callID:t,trailer:{status:n.data.DataFrame.Trailer.Status.OK}})})).catch((e=>{this.sendMessage({callID:t,trailer:{status:n.data.DataFrame.Trailer.Status.ERROR,message:e.toString()}})})).finally((()=>{this._calls.delete(t)}))}async rpcStreamStream({callID:t},e){const r=new s.Stream((e=>{this.sendMessage({callID:t,trailer:{status:n.data.DataFrame.Trailer.Status.ABORT,message:null==e?void 0:e.toString()}})})),a=await e.exec(r),i=()=>{r.closed&&a.closed&&this._calls.delete(t)};this.registerCall(t,(t=>{if(t){if(t.body){const s=e.requestDecode(t.body);r.write(s)}t.trailer&&(t.trailer.status==n.data.DataFrame.Trailer.Status.OK?r.end():t.trailer.status==n.data.DataFrame.Trailer.Status.ERROR?r.error(new Error(t.trailer.message)):t.trailer.status==n.data.DataFrame.Trailer.Status.ABORT&&a.abort(new Error(t.trailer.message)),i())}else a.abort(new Error("lost connection"))})),a.read((r=>{this.sendMessage({callID:t,body:e.responseEncode(r)})})).then((()=>{this.sendMessage({callID:t,trailer:{status:n.data.DataFrame.Trailer.Status.OK}})})).catch((e=>{this.sendMessage({callID:t,trailer:{status:n.data.DataFrame.Trailer.Status.ERROR,message:e.toString()}})})).finally(i)}async rpcStreamUnary({callID:t},e){const r=new s.Stream((e=>{this.sendMessage({callID:t,trailer:{status:n.data.DataFrame.Trailer.Status.ABORT,message:null==e?void 0:e.toString()}})}));this.registerCall(t,(s=>{if(s){if(s.body){const t=e.requestDecode(s.body);r.write(t)}s.trailer&&(s.trailer.status==n.data.DataFrame.Trailer.Status.OK?r.end():s.trailer.status==n.data.DataFrame.Trailer.Status.ERROR&&r.error(new Error(s.trailer.message)),this._calls.delete(t))}}));const a=await e.exec(r);this.sendMessage({callID:t,body:e.responseEncode(a)})}}},87:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Stream=e.Future=e.lcFirst=void 0,e.lcFirst=function(t){return t[0].toLowerCase()+t.substr(1)};class r{constructor(){this._resolved=!1,this.promise=new Promise(((t,e)=>{this._resovle=t,this._reject=e}))}resolve(t){this._resolved=!0,this.result=t,this._resovle(t)}reject(t){this._resolved=!0,this.error=t,this._reject(t)}get resolved(){return this._resolved}}e.Future=r,e.Stream=class{constructor(t){this._onabort=t,this._readers=[],this._closed=!1}write(t){this._readers.forEach((e=>{e.onMessage(t)}))}error(t){this._closed=!0,this._readers.forEach((e=>{e.future.reject(t)})),this._readers=[]}end(){this._closed=!0,this._readers.forEach((t=>{t.future.resolve()})),this._readers=[]}get closed(){return this._closed}abort(t){this._closed=!0,this._onabort&&this._onabort(t),this._readers.forEach((t=>{t.future.resolve()})),this._readers=[]}read(t){const e=new r,s={future:e,onMessage:t};return this._readers.push(s),e.promise}async*readToItorator(){const t=[];let e=new r;for(this.read((s=>{t.push(s),e.resolve(!1),e=new r})).then((()=>e.resolve(!0))).catch((t=>e.reject(t)));;){const r=t.shift();if(r)yield r;else if(await e.promise)return}}async writeFromIterator(t){try{for await(const e of t()){if(this._closed)return;this.write(e)}this.end()}catch(t){this.error(t)}}}},836:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.data=void 0;const s=r(100);!function(t){let e;!function(t){let e,r;!function(t){t.encode=function(t,e){const r=!e;return e||(e=s.Writer.create()),null!=t.path&&null!=t.path&&e.uint32(10).string(t.path),null!=t.status&&null!=t.status&&e.uint32(18).string(t.status),null!=t.rpcStatus&&null!=t.rpcStatus&&e.uint32(26).string(t.rpcStatus),null!=t.rpcMessage&&null!=t.rpcMessage&&e.uint32(34).string(t.rpcMessage),r?e.finish():e},t.decode=function(t,e){t instanceof s.Reader||(t=s.Reader.create(t));let r=void 0===e?t.len:t.pos+e;const n={};for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.path=t.string();break;case 2:n.status=t.string();break;case 3:n.rpcStatus=t.string();break;case 4:n.rpcMessage=t.string();break;default:t.skipType(7&e)}}return n}}(e=t.Headers||(t.Headers={})),function(t){t.encode=function(t,e){const r=!e;return e||(e=s.Writer.create()),null!=t.path&&null!=t.path&&e.uint32(10).string(t.path),null!=t.status&&null!=t.status&&e.uint32(18).string(t.status),null!=t.rpcStatus&&null!=t.rpcStatus&&e.uint32(26).string(t.rpcStatus),null!=t.rpcMessage&&null!=t.rpcMessage&&e.uint32(34).string(t.rpcMessage),r?e.finish():e},t.decode=function(t,e){t instanceof s.Reader||(t=s.Reader.create(t));let r=void 0===e?t.len:t.pos+e;const n={};for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.path=t.string();break;case 2:n.status=t.string();break;case 3:n.rpcStatus=t.string();break;case 4:n.rpcMessage=t.string();break;default:t.skipType(7&e)}}return n}}(r=t.Trailers||(t.Trailers={})),t.Types={HEADERS:1,TRAILERS:2,MESSAGE:3},t.encode=function(t,n){const a=!n;return n||(n=s.Writer.create()),null!=t.streamId&&null!=t.streamId&&n.uint32(8).int32(t.streamId),null!=t.endStream&&null!=t.endStream&&n.uint32(16).bool(t.endStream),null!=t.type&&null!=t.type&&n.uint32(24).int32(t.type),null!=t.headers&&null!=t.headers&&e.encode(t.headers,n.uint32(34).fork()).ldelim(),null!=t.trailers&&null!=t.trailers&&r.encode(t.trailers,n.uint32(42).fork()).ldelim(),null!=t.message&&null!=t.message&&n.uint32(50).bytes(t.message),a?n.finish():n},t.decode=function(t,n){t instanceof s.Reader||(t=s.Reader.create(t));let a=void 0===n?t.len:t.pos+n;const i={};for(;t.pos<a;){let s=t.uint32();switch(s>>>3){case 1:i.streamId=t.int32();break;case 2:i.endStream=t.bool();break;case 3:i.type=t.int32();break;case 4:i.headers=e.decode(t,t.uint32());break;case 5:i.trailers=r.decode(t,t.uint32());break;case 6:i.message=t.bytes();break;default:t.skipType(7&s)}}return i}}(e=t.DataFrame||(t.DataFrame={}))}(e.data||(e.data={}))},615:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.v1to2=void 0;const s=r(795),n=r(836);e.v1to2={tryDecodeDataFrame:function(t){var e;const r=n.data.DataFrame.decode(t);if(r.type==n.data.DataFrame.Types.HEADERS&&r.headers){if(r.endStream)return{callID:r.streamId,body:r.message,trailer:{status:"0"==r.headers.rpcStatus?s.data.DataFrame.Trailer.Status.OK:s.data.DataFrame.Trailer.Status.ERROR,message:r.headers.rpcMessage}};{const[t,s]=null===(e=r.headers.path)||void 0===e?void 0:e.substr(1).split("/");return{callID:r.streamId,body:r.message,header:{service:t,method:s}}}}return r.type==n.data.DataFrame.Types.TRAILERS?null:r.type==n.data.DataFrame.Types.MESSAGE&&r.message?{callID:r.streamId,body:r.message}:null},encodeDataFrame:function(t){var e;const r=[];return t.header&&r.push({streamId:t.callID,type:n.data.DataFrame.Types.HEADERS,endStream:!1,headers:{path:`${t.header.service}/${t.header.method}`}}),t.body&&r.push({streamId:t.callID,type:n.data.DataFrame.Types.MESSAGE,endStream:!1,message:t.body}),t.trailer&&(t.trailer.status==s.data.DataFrame.Trailer.Status.OK?r.push({streamId:t.callID,type:n.data.DataFrame.Types.HEADERS,endStream:!0,headers:{rpcStatus:"0"}}):r.push({streamId:t.callID,type:n.data.DataFrame.Types.HEADERS,endStream:!0,headers:{status:"400",rpcMessage:t.trailer.message,rpcStatus:null===(e=t.trailer.status)||void 0===e?void 0:e.toString()}})),r.map((t=>n.data.DataFrame.encode(t)))},encodeRequestOKResponse:function(t){return n.data.DataFrame.encode({streamId:t,type:n.data.DataFrame.Types.HEADERS,endStream:!1,headers:{status:"200"}})}}}},__webpack_module_cache__={};function __webpack_require__(t){var e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;var r=__webpack_module_cache__[t]={exports:{}};return __webpack_modules__[t].call(r.exports,r,r.exports,__webpack_require__),r.exports}var __webpack_exports__={};return(()=>{var t=__webpack_exports__;Object.defineProperty(t,"__esModule",{value:!0}),t.Server=t.Channel=t.Future=t.Stream=t.Reader=t.Writer=void 0,__webpack_require__(693).Long=null;var e=__webpack_require__(100);Object.defineProperty(t,"Writer",{enumerable:!0,get:function(){return e.Writer}}),Object.defineProperty(t,"Reader",{enumerable:!0,get:function(){return e.Reader}});var r=__webpack_require__(87);Object.defineProperty(t,"Stream",{enumerable:!0,get:function(){return r.Stream}}),Object.defineProperty(t,"Future",{enumerable:!0,get:function(){return r.Future}});var s=__webpack_require__(110);Object.defineProperty(t,"Channel",{enumerable:!0,get:function(){return s.Channel}});var n=__webpack_require__(728);Object.defineProperty(t,"Server",{enumerable:!0,get:function(){return n.Server}})})(),__webpack_exports__})()})); |
{ | ||
"name": "wsgrpc", | ||
"version": "2.1.6", | ||
"version": "2.1.7", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/lib.js", |
141294