protobufjs
Advanced tools
| /*! | ||
| * protobuf.js v8.6.6 (c) 2016, daniel wirtz | ||
| * compiled sat, 04 jul 2026 01:09:57 utc | ||
| * protobuf.js v8.7.0 (c) 2016, daniel wirtz | ||
| * compiled mon, 06 jul 2026 13:50:00 utc | ||
| * licensed under the bsd-3-clause license | ||
| * see: https://github.com/dcodeio/protobuf.js for details | ||
| */ | ||
| !function(p){"use strict";var i,e,n;i={1:[function(t,n,r){function i(){r.util.t(),r.Writer.t(r.BufferWriter),r.Reader.t(r.BufferReader)}r.build="minimal",r.Writer=t(15),r.BufferWriter=t(16),r.Reader=t(2),r.BufferReader=t(3),r.util=t(12),r.rpc=t(5),r.roots=t(4),r.configure=i,i()},{12:12,15:15,16:16,2:2,3:3,4:4,5:5}],2:[function(t,n,r){n.exports=h;var i,e=t(12),u=e.LongBits,o=e.utf8;function s(t,n){return RangeError("index out of range: "+t.pos+" + "+(n||1)+" > "+t.len)}function h(t){this.buf=t,this.pos=0,this.len=t.length,this.discardUnknown=h.discardUnknown}function f(){return e.Buffer?function(t){return(h.create=function(t){return e.Buffer.isBuffer(t)?new i(t):c(t)})(t)}:c}var c="undefined"!=typeof Uint8Array?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new h(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new h(t);throw Error("illegal buffer")};function a(){var t=new u(0,0),n=0;if(!(4<this.len-this.pos)){for(;n<4;++n){if(this.pos>=this.len)throw s(this);if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*n)>>>0,this.buf[this.pos++]<128)return t}throw s(this)}for(;n<4;++n)if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*n)>>>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(n=0,4<this.len-this.pos){for(;n<5;++n)if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*n+3)>>>0,this.buf[this.pos++]<128)return t}else for(;n<5;++n){if(this.pos>=this.len)throw s(this);if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*n+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}function l(t,n){return(t[n-4]|t[n-3]<<8|t[n-2]<<16|t[n-1]<<24)>>>0}function v(){if(this.pos+8>this.len)throw s(this,8);return new u(l(this.buf,this.pos+=4),l(this.buf,this.pos+=4))}h.create=f(),h.prototype.n=e.Array.prototype.subarray||e.Array.prototype.slice,h.prototype.raw=function(t,n){return Array.isArray(this.buf)?this.buf.slice(t,n):t===n?new this.buf.constructor(0):this.n.call(this.buf,t,n)},h.prototype.uint32=function(){var t=this.buf,n=this.pos,r=(127&t[n])>>>0;if(t[n++]<128)return this.pos=n,r;if(r=(r|(127&t[n])<<7)>>>0,t[n++]<128)return this.pos=n,r;if(r=(r|(127&t[n])<<14)>>>0,t[n++]<128)return this.pos=n,r;if(r=(r|(127&t[n])<<21)>>>0,t[n++]<128)return this.pos=n,r;if(r=(r|(15&t[n])<<28)>>>0,t[n++]<128)return this.pos=n,r;for(var i=0;i<5;++i){if(n>=this.len)throw this.pos=n,s(this);if(t[n++]<128)return this.pos=n,r}throw this.pos=n,Error("invalid varint encoding")},h.prototype.tag=function(){var t=this.buf,n=this.pos,r=(127&t[n])>>>0;if(t[n++]<128)return this.pos=n,r;if(r=(r|(127&t[n])<<7)>>>0,t[n++]<128)return this.pos=n,r;if(r=(r|(127&t[n])<<14)>>>0,t[n++]<128)return this.pos=n,r;if(r=(r|(127&t[n])<<21)>>>0,t[n++]<128)return this.pos=n,r;if(r=(r|(15&t[n])<<28)>>>0,t[n]<128&&0==(112&t[n]))return this.pos=n+1,r;throw this.pos=n+1,Error("invalid tag encoding")},h.prototype.int32=function(){return 0|this.uint32()},h.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(1&t)|0},h.prototype.bool=function(){for(var t,n=!1,r=0;r<10;++r){if(this.pos>=this.len)throw s(this);if(127&(t=this.buf[this.pos++])&&(n=!0),t<128)return n}throw Error("invalid varint encoding")},h.prototype.fixed32=function(){if(this.pos+4>this.len)throw s(this,4);return l(this.buf,this.pos+=4)},h.prototype.sfixed32=function(){if(this.pos+4>this.len)throw s(this,4);return 0|l(this.buf,this.pos+=4)},h.prototype.float=function(){if(this.pos+4>this.len)throw s(this,4);var t=e.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t},h.prototype.double=function(){if(this.pos+8>this.len)throw s(this,4);var t=e.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t},h.prototype.bytes=function(){var t=this.uint32(),n=this.pos,r=this.pos+t;if(r>this.len)throw s(this,t);return this.pos=r,this.raw(n,r)},h.prototype.string=function(){var t=this.uint32(),n=this.pos,r=this.pos+t;if(r>this.len)throw s(this,t);return this.pos=r,o.read(this.buf,n,r)},h.prototype.stringVerify=function(){var t=this.uint32(),n=this.pos,r=this.pos+t;if(r>this.len)throw s(this,t);return this.pos=r,o.readStrict(this.buf,n,r)},h.prototype.skip=function(t){if("number"==typeof t){if(this.pos+t>this.len)throw s(this,t);this.pos+=t}else do{if(this.pos>=this.len)throw s(this)}while(128&this.buf[this.pos++]);return this},h.recursionLimit=e.recursionLimit,h.discardUnknown=!0,h.prototype.skipType=function(t,n,r){if(h.recursionLimit<(n=n===p?0:n))throw Error("max depth exceeded");if(0===r)throw Error("illegal tag: field number 0");switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;;){var i=this.tag(),e=i>>>3;if(!e)throw Error("illegal tag: field number 0");if(4===(t=7&i)){if(r!==p&&e!==r)throw Error("invalid end group tag");break}this.skipType(t,n+1,e)}break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+t+" at offset "+this.pos)}return this},h.t=function(t){i=t,h.create=f(),i.t();var n=e.Long?"toLong":"toNumber";e.merge(h.prototype,{int64:function(){return a.call(this)[n](!1)},uint64:function(){return a.call(this)[n](!0)},sint64:function(){return a.call(this).zzDecode()[n](!1)},fixed64:function(){return v.call(this)[n](!0)},sfixed64:function(){return v.call(this)[n](!1)}})}},{12:12}],3:[function(t,n,r){n.exports=u;var i=t(2),e=(u.prototype=Object.create(i.prototype,{constructor:{value:u,writable:!0,enumerable:!1,configurable:!0}}),t(12));function u(t){i.call(this,t)}u.t=function(){e.Buffer&&(u.prototype.n=e.Buffer.prototype.slice)},u.prototype.raw=function(t,n){return t===n?e.Buffer.alloc(0):this.n.call(this.buf,t,n)},u.prototype.string=function(){var t=this.uint32(),n=this.pos,r=this.pos+t;if(r>this.len)throw RangeError("index out of range: "+this.pos+" + "+t+" > "+this.len);return this.pos=r,this.buf.utf8Slice?this.buf.utf8Slice(n,r):this.buf.toString("utf-8",n,r)},u.t()},{12:12,2:2}],4:[function(t,n,r){n.exports=Object.create(null)},{}],5:[function(t,n,r){r.Service=t(6)},{6:6}],6:[function(t,n,r){n.exports=i;var s=t(12);function i(t,n,r){if("function"!=typeof t)throw TypeError("rpcImpl must be a function");s.EventEmitter.call(this),this.rpcImpl=t,this.requestDelimited=!!n,this.responseDelimited=!!r}(i.prototype=Object.create(s.EventEmitter.prototype,{constructor:{value:i,writable:!0,enumerable:!1,configurable:!0}})).rpcCall=function t(r,n,i,e,u){if(!e)throw TypeError("request must be specified");var o=this;if(!u)return s.asPromise(t,o,r,n,i,e);if(!o.rpcImpl)return setTimeout(function(){u(Error("already ended"))},0),p;try{return o.rpcImpl(r,n[o.requestDelimited?"encodeDelimited":"encode"](e).finish(),function(t,n){if(t)return o.emit("error",t,r),u(t);if(null===n)return o.end(!0),p;if(!(n instanceof i))try{n=i[o.responseDelimited?"decodeDelimited":"decode"](n)}catch(t){return o.emit("error",t,r),u(t)}return o.emit("data",n,r),u(null,n)})}catch(t){return o.emit("error",t,r),setTimeout(function(){u(t)},0),p}},i.prototype.end=function(t){return this.rpcImpl&&(t||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},{12:12}],7:[function(t,n,r){n.exports=function(t,n){var r=Array(arguments.length-1),u=0,i=2,o=!0;for(;i<arguments.length;)r[u++]=arguments[i++];return new Promise(function(i,e){r[u]=function(t){if(o)if(o=!1,t)e(t);else{for(var n=Array(arguments.length-1),r=0;r<n.length;)n[r++]=arguments[r];i.apply(null,n)}};try{t.apply(n||null,r)}catch(t){o&&(o=!1,e(t))}})}},{}],8:[function(t,n,r){r.length=function(t){var n=t.length;if(!n)return 0;for(;0<n&&"="==(t[0|n-1]||"");)--n;return Math.floor(3*n/4)};for(var f=Array(64),h=Array(123),i=0;i<64;)h[f[i]=i<26?i+65:i<52?i+71:i<62?i-4:i-59|43]=i++;h[45]=62,h[95]=63,r.encode=function(t,n,r){for(var i,e=null,u=[],o=0,s=0;n<r;){var h=t[n++];switch(s){case 0:u[o++]=f[h>>2],i=(3&h)<<4,s=1;break;case 1:u[o++]=f[i|h>>4],i=(15&h)<<2,s=2;break;case 2:u[o++]=f[i|h>>6],u[o++]=f[63&h],s=0}8191<o&&((e=e||[]).push(String.fromCharCode.apply(String,u)),o=0)}return s&&(u[o++]=f[i],u[o++]=61,1===s&&(u[o++]=61)),e?(o&&e.push(String.fromCharCode.apply(String,u.slice(0,o))),e.join("")):String.fromCharCode.apply(String,u.slice(0,o))};var c="invalid encoding",e=(r.decode=function(t,n,r){for(var i,e=r,u=0,o=0;o<t.length;){var s=t.charCodeAt(o++);if(61==s&&1<u)break;if((s=h[s])===p)throw Error(c);switch(u){case 0:i=s,u=1;break;case 1:n[r++]=i<<2|(48&s)>>4,i=s,u=2;break;case 2:n[r++]=(15&i)<<4|(60&s)>>2,i=s,u=3;break;case 3:n[r++]=(3&i)<<6|s,u=0}}if(1===u)throw Error(c);return r-e},/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/),u=/[-_]/,o=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2}(?:==)?|[A-Za-z0-9_-]{3}=?)?$/;r.test=function(t){return e.test(t)||u.test(t)&&o.test(t)}},{}],9:[function(t,n,r){function i(){this.r=Object.create(null)}(n.exports=i).prototype.on=function(t,n,r){return(this.r[t]||(this.r[t]=[])).push({fn:n,ctx:r||this}),this},i.prototype.off=function(t,n){if(t===p)this.r=Object.create(null);else if(n===p)this.r[t]=[];else{var r=this.r[t];if(!r)return this;for(var i=0;i<r.length;)r[i].fn===n?r.splice(i,1):++i}return this},i.prototype.emit=function(t){var n=this.r[t];if(n){for(var r=[],i=1;i<arguments.length;)r.push(arguments[i++]);for(i=0;i<n.length;)n[i].fn.apply(n[i++].ctx,r)}return this}},{}],10:[function(t,n,r){function i(t){function n(t,n,r,i){var e=n<0?1:0;t(0===(n=e?-n:n)?0<1/n?0:2147483648:isNaN(n)?2143289344:34028234663852886e22<n?(e<<31|2139095040)>>>0:n<11754943508222875e-54?(e<<31|Math.round(n/1401298464324817e-60))>>>0:(e<<31|127+(t=Math.floor(Math.log(n)/Math.LN2))<<23|8388607&Math.round(n*Math.pow(2,-t)*8388608))>>>0,r,i)}function r(t,n,r){t=t(n,r),n=2*(t>>31)+1,r=t>>>23&255,t&=8388607;return 255==r?t?NaN:1/0*n:0==r?1401298464324817e-60*n*t:n*Math.pow(2,r-150)*(8388608+t)}function i(t,n,r){s[0]=t,n[r]=h[0],n[r+1]=h[1],n[r+2]=h[2],n[r+3]=h[3]}function e(t,n,r){s[0]=t,n[r]=h[3],n[r+1]=h[2],n[r+2]=h[1],n[r+3]=h[0]}function u(t,n){return h[0]=t[n],h[1]=t[n+1],h[2]=t[n+2],h[3]=t[n+3],s[0]}function o(t,n){return h[3]=t[n],h[2]=t[n+1],h[1]=t[n+2],h[0]=t[n+3],s[0]}var s,h,f,c,a;function l(t,n,r,i,e,u){var o,s=i<0?1:0;0===(i=s?-i:i)?(t(0,e,u+n),t(0<1/i?0:2147483648,e,u+r)):isNaN(i)?(t(0,e,u+n),t(2146959360,e,u+r)):17976931348623157e292<i?(t(0,e,u+n),t((s<<31|2146435072)>>>0,e,u+r)):i<22250738585072014e-324?(t((o=i/5e-324)>>>0,e,u+n),t((s<<31|o/4294967296)>>>0,e,u+r)):(t(4503599627370496*(o=i*Math.pow(2,-(i=1024===(i=Math.floor(Math.log(i)/Math.LN2))?1023:i)))>>>0,e,u+n),t((s<<31|i+1023<<20|1048576*o&1048575)>>>0,e,u+r))}function v(t,n,r,i,e){n=t(i,e+n),t=t(i,e+r),i=2*(t>>31)+1,e=t>>>20&2047,r=4294967296*(1048575&t)+n;return 2047==e?r?NaN:1/0*i:0==e?5e-324*i*r:i*Math.pow(2,e-1075)*(r+4503599627370496)}function b(t,n,r){f[0]=t,n[r]=c[0],n[r+1]=c[1],n[r+2]=c[2],n[r+3]=c[3],n[r+4]=c[4],n[r+5]=c[5],n[r+6]=c[6],n[r+7]=c[7]}function w(t,n,r){f[0]=t,n[r]=c[7],n[r+1]=c[6],n[r+2]=c[5],n[r+3]=c[4],n[r+4]=c[3],n[r+5]=c[2],n[r+6]=c[1],n[r+7]=c[0]}function g(t,n){return c[0]=t[n],c[1]=t[n+1],c[2]=t[n+2],c[3]=t[n+3],c[4]=t[n+4],c[5]=t[n+5],c[6]=t[n+6],c[7]=t[n+7],f[0]}function d(t,n){return c[7]=t[n],c[6]=t[n+1],c[5]=t[n+2],c[4]=t[n+3],c[3]=t[n+4],c[2]=t[n+5],c[1]=t[n+6],c[0]=t[n+7],f[0]}return"undefined"!=typeof Float32Array?(s=new Float32Array([-0]),h=new Uint8Array(s.buffer),a=128===h[3],t.writeFloatLE=a?i:e,t.writeFloatBE=a?e:i,t.readFloatLE=a?u:o,t.readFloatBE=a?o:u):(t.writeFloatLE=n.bind(null,y),t.writeFloatBE=n.bind(null,p),t.readFloatLE=r.bind(null,A),t.readFloatBE=r.bind(null,m)),"undefined"!=typeof Float64Array?(f=new Float64Array([-0]),c=new Uint8Array(f.buffer),a=128===c[7],t.writeDoubleLE=a?b:w,t.writeDoubleBE=a?w:b,t.readDoubleLE=a?g:d,t.readDoubleBE=a?d:g):(t.writeDoubleLE=l.bind(null,y,0,4),t.writeDoubleBE=l.bind(null,p,4,0),t.readDoubleLE=v.bind(null,A,0,4),t.readDoubleBE=v.bind(null,m,4,0)),t}function y(t,n,r){n[r]=255&t,n[r+1]=t>>>8&255,n[r+2]=t>>>16&255,n[r+3]=t>>>24}function p(t,n,r){n[r]=t>>>24,n[r+1]=t>>>16&255,n[r+2]=t>>>8&255,n[r+3]=255&t}function A(t,n){return(t[n]|t[n+1]<<8|t[n+2]<<16|t[n+3]<<24)>>>0}function m(t,n){return(t[n]<<24|t[n+1]<<16|t[n+2]<<8|t[n+3])>>>0}n.exports=i(i)},{}],11:[function(t,n,r){n.exports=e;var i=t(12);function e(t,n){this.lo=t>>>0,this.hi=n>>>0}var u=e.zero=new e(0,0),o=(u.toNumber=function(){return 0},u.zzEncode=u.zzDecode=function(){return this},u.length=function(){return 1},e.zeroHash="\0\0\0\0\0\0\0\0",e.fromNumber=function(t){var n,r;return 0===t?u:(r=(t=(n=t<0)?-t:t)>>>0,t=(t-r)/4294967296>>>0,n&&(t=~t>>>0,r=~r>>>0,4294967295<++r&&(r=0,4294967295<++t&&(t=0))),new e(r,t))},e.from=function(t){if("number"==typeof t)return e.fromNumber(t);if(i.isString(t)){if(!i.Long)return e.fromNumber(parseInt(t,10));t=i.Long.fromString(t)}return t.low||t.high?new e(t.low>>>0,t.high>>>0):u},e.prototype.toNumber=function(t){var n;return!t&&this.hi>>>31?(t=1+~this.lo>>>0,n=~this.hi>>>0,-(t+4294967296*(n=t?n:n+1>>>0))):this.lo+4294967296*this.hi},e.prototype.toLong=function(t){return i.Long?new i.Long(0|this.lo,0|this.hi,!!t):{low:0|this.lo,high:0|this.hi,unsigned:!!t}},String.prototype.charCodeAt);e.fromHash=function(t){return"\0\0\0\0\0\0\0\0"===t?u:new e((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)},e.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)},e.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},e.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},e.prototype.length=function(){var t=this.lo,n=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0==r?0==n?t<16384?t<128?1:2:t<2097152?3:4:n<16384?n<128?5:6:n<2097152?7:8:r<128?9:10}},{12:12}],12:[function(n,t,r){var o=r;function s(t){return"__proto__"===t||"prototype"===t||"constructor"===t}function i(t){for(var n=(r="boolean"==typeof arguments[arguments.length-1])?arguments.length-1:arguments.length,r=r&&arguments[arguments.length-1],i=1;i<n;++i){var e=arguments[i];if(e)for(var u=Object.keys(e),o=0;o<u.length;++o)s(u[o])||r&&Object.prototype.hasOwnProperty.call(t,u[o])&&t[u[o]]!==p||(t[u[o]]=e[u[o]])}return t}function e(t){function r(t,n){if(!(this instanceof r))return new r(t,n);Object.defineProperty(this,"message",{get:function(){return t}}),Error.captureStackTrace?Error.captureStackTrace(this,r):Object.defineProperty(this,"stack",{value:Error().stack||""}),n&&i(this,n)}return r.prototype=Object.create(Error.prototype,{constructor:{value:r,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return t},set:p,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),r}o.asPromise=n(7),o.base64=n(8),o.EventEmitter=n(9),o.float=n(10),o.utf8=n(14),o.pool=n(13),o.LongBits=n(11),o.isUnsafeProperty=s,o.isNode=!!("undefined"!=typeof global&&global&&global.process&&global.process.versions&&global.process.versions.node),o.global=o.isNode&&global||"undefined"!=typeof window&&window||"undefined"!=typeof self&&self||"undefined"!=typeof globalThis&&globalThis||this,o.emptyArray=Object.freeze?Object.freeze([]):[],o.emptyObject=Object.freeze?Object.freeze({}):{},o.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},o.isString=function(t){return"string"==typeof t||t instanceof String},o.isObject=function(t){return t&&"object"==typeof t},o.isset=o.isSet=function(t,n){var r=t[n];return!(null==r||!Object.hasOwnProperty.call(t,n))&&("object"!=typeof r||0<(Array.isArray(r)?r:Object.keys(r)).length)},o.Buffer=function(){try{var t=o.global.Buffer;return t.prototype.utf8Write?t:null}catch(t){return null}}(),o.i=null,o.e=null,o.newBuffer=function(t){return"number"==typeof t?o.Buffer?o.e(t):new o.Array(t):o.Buffer?o.i(t):"undefined"==typeof Uint8Array?t:new Uint8Array(t)},o.rawField=function(t,n,r){var i=[],e=t<<3|n;for(e>>>=0;127<e;)i.push(127&e|128),e>>>=7;i.push(e);for(var u=0;u<r.length;++u)i.push(r[u]);return o.newBuffer(i)},o.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,o.Long=o.global.dcodeIO&&o.global.dcodeIO.Long||o.global.Long||function(){try{var t=n("long");return t&&t.isLong?t:null}catch(t){return null}}(),o.key2Re=/^(?:true|false|0|1)$/,o.key32Re=/^-?(?:0|[1-9][0-9]*)$/,o.key64Re=/^(?:[\x00-\xff]{8}|-?(?:0|[1-9][0-9]*))$/,o.longToHash=function(t){return t?o.LongBits.from(t).toHash():o.LongBits.zeroHash},o.longFromHash=function(t,n){t=o.LongBits.fromHash(t);return o.Long?o.Long.fromBits(t.lo,t.hi,n):t.toNumber(!!n)},o.longFromKey=function(t,n){return o.key64Re.test(t)&&!o.key32Re.test(t)?o.longFromHash(t,n):t},o.boolFromKey=function(t){return"true"===t||"1"===t},o.merge=i,o.nestingLimit=32,o.recursionLimit=100,o.makeProp=function(t,n,r){Object.prototype.hasOwnProperty.call(t,n)||Object.defineProperty(t,n,{enumerable:r===p||r,configurable:!0,writable:!0})},o.lcFirst=function(t){return(t[0]||"").toLowerCase()+t.substring(1)},o.newError=e,o.ProtocolError=e("ProtocolError"),o.oneOfGetter=function(t){for(var r={},n=0;n<t.length;++n)r[t[n]]=1;return function(){for(var t=Object.keys(this),n=t.length-1;-1<n;--n)if(1===r[t[n]]&&this[t[n]]!==p&&null!==this[t[n]])return t[n]}},o.oneOfSetter=function(r){return function(t){for(var n=0;n<r.length;++n)r[n]!==t&&delete this[r[n]]}},o.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},o.t=function(){var r=o.Buffer;r?(o.i=r.from!==Uint8Array.from&&r.from||function(t,n){return new r(t,n)},o.e=r.allocUnsafe||function(t){return new r(t)}):o.i=o.e=null}},{10:10,11:11,13:13,14:14,7:7,8:8,9:9,long:"long"}],13:[function(t,n,r){n.exports=function(n,r,t){var i=t||8192,e=i>>>1,u=null,o=i;return function(t){if(t<1||e<t)return n(t);i<o+t&&(u=n(i),o=0);t=r.call(u,o,o+=t);return 7&o&&(o=1+(7|o)),t}}},{}],14:[function(t,n,r){var i;try{i=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}catch(t){i=new TextDecoder("utf-8",{ignoreBOM:!0})}function v(t,n,r,i){for(var e=n;e<r;){var u,o=t[e++];o<=127?i+=String.fromCharCode(o):192<=o&&o<224?i+=128<=(u=(31&o)<<6|63&t[e++])?String.fromCharCode(u):"�":224<=o&&o<240?i+=2048<=(u=(15&o)<<12|(63&t[e++])<<6|63&t[e++])?String.fromCharCode(u):"�":240<=o&&((o=(7&o)<<18|(63&t[e++])<<12|(63&t[e++])<<6|63&t[e++])<65536||1114111<o?i+="�":i=i+String.fromCharCode(55296+((o-=65536)>>10))+String.fromCharCode(56320+(1023&o)))}return i}function b(t,n,r){t=0===n&&r===t.length?t:t.subarray?t.subarray(n,r):t.slice(n,r);return Array.isArray(t)&&(t=Uint8Array.from(t)),i.decode(t)}r.length=function(t){for(var n,r=0,i=0;i<t.length;++i)(n=t.charCodeAt(i))<128?r+=1:n<2048?r+=2:55296==(64512&n)&&56320==(64512&t.charCodeAt(i+1))?(++i,r+=4):r+=3;return r},r.read=function(t,n,r){if(r-n<1)return"";for(var i,e,u,o,s,h,f,c,a="",l=n;l+7<r;l+=8){if(128&((i=t[l])|(e=t[l+1])|(u=t[l+2])|(o=t[l+3])|(s=t[l+4])|(h=t[l+5])|(f=t[l+6])|(c=t[l+7])))return v(t,l,r,a);a+=String.fromCharCode(i,e,u,o,s,h,f,c)}for(;l<r;++l){if(128&(i=t[l]))return v(t,l,r,a);a+=String.fromCharCode(i)}return a},r.readStrict=function(t,n,r){if(r-n<1)return"";for(var i,e,u,o,s,h,f,c,a="",l=n;l+7<r;l+=8){if(128&((i=t[l])|(e=t[l+1])|(u=t[l+2])|(o=t[l+3])|(s=t[l+4])|(h=t[l+5])|(f=t[l+6])|(c=t[l+7])))return a+b(t,l,r);a+=String.fromCharCode(i,e,u,o,s,h,f,c)}for(;l<r;++l){if(128&(i=t[l]))return a+b(t,l,r);a+=String.fromCharCode(i)}return a},r.write=function(t,n,r){for(var i,e,u=r,o=0;o<t.length;++o)(i=t.charCodeAt(o))<128?n[r++]=i:(i<2048?n[r++]=i>>6|192:(55296==(64512&i)&&56320==(64512&(e=t.charCodeAt(o+1)))?(++o,n[r++]=(i=65536+((1023&i)<<10)+(1023&e))>>18|240,n[r++]=i>>12&63|128):n[r++]=i>>12|224,n[r++]=i>>6&63|128),n[r++]=63&i|128);return r-u}},{}],15:[function(t,n,r){n.exports=a;var i,e=t(12),u=e.LongBits,o=e.base64,s=e.utf8;function h(t,n,r){this.fn=t,this.len=n,this.next=p,this.val=r}function f(){}function c(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}function a(){this.len=0,this.head=new h(f,0,0),this.tail=this.head,this.states=null}function l(){return e.Buffer?function(){return(a.create=function(){return new i})()}:function(){return new a}}function v(t,n,r){n[r]=255&t}function b(t,n,r){for(var i=0;i<t.length;)n[r++]=t.charCodeAt(i++)}function w(t,n){this.len=t,this.next=p,this.val=n}function g(t,n,r){for(var i=t.lo,e=t.hi;e;)n[r++]=127&i|128,i=(i>>>7|e<<25)>>>0,e>>>=7;for(;127<i;)n[r++]=127&i|128,i>>>=7;n[r++]=i}function d(t,n,r){n[r]=255&t,n[r+1]=t>>>8&255,n[r+2]=t>>>16&255,n[r+3]=t>>>24}a.create=l(),a.alloc=function(t){return new e.Array(t)},e.Array!==Array&&(a.alloc=e.pool(a.alloc,e.Array.prototype.subarray)),a.prototype.u=function(t,n,r){return this.tail=this.tail.next=new h(t,n,r),this.len+=n,this},(w.prototype=Object.create(h.prototype)).fn=function(t,n,r){for(;127<t;)n[r++]=127&t|128,t>>>=7;n[r]=t},a.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new w((t>>>=0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this},a.prototype.int32=function(t){return(t|=0)<0?this.u(g,10,u.fromNumber(t)):this.uint32(t)},a.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)},a.prototype.int64=a.prototype.uint64=function(t){t=u.from(t);return this.u(g,t.length(),t)},a.prototype.sint64=function(t){t=u.from(t).zzEncode();return this.u(g,t.length(),t)},a.prototype.bool=function(t){return this.u(v,1,t?1:0)},a.prototype.sfixed32=a.prototype.fixed32=function(t){return this.u(d,4,t>>>0)},a.prototype.sfixed64=a.prototype.fixed64=function(t){t=u.from(t);return this.u(d,4,t.lo).u(d,4,t.hi)},a.prototype.float=function(t){return this.u(e.float.writeFloatLE,4,t)},a.prototype.double=function(t){return this.u(e.float.writeDoubleLE,8,t)};var y=e.Array.prototype.set?function(t,n,r){n.set(t,r)}:function(t,n,r){for(var i=0;i<t.length;++i)n[r+i]=t[i]};a.prototype.bytes=function(t){var n,r=t.length>>>0;return r?(e.isString(t)&&(n=a.alloc(r=o.length(t)),o.decode(t,n,0),t=n),this.uint32(r).u(y,r,t)):this.u(v,1,0)},a.prototype.raw=function(t){var n=t.length>>>0;return n?this.u(y,n,t):this},a.prototype.string=function(t){var n=s.length(t);return n?this.uint32(n).u(n===t.length?b:s.write,n,t):this.u(v,1,0)},a.prototype.fork=function(){return this.states=new c(this),this.head=this.tail=new h(f,0,0),this.len=0,this},a.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 h(f,0,0),this.len=0),this},a.prototype.ldelim=function(){var t=this.head,n=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=t.next,this.tail=n,this.len+=r),this},a.prototype.finish=function(){return this.finishInto(this.constructor.alloc(this.len),0)},a.prototype.finishInto=function(t,n){for(var r=this.head.next,i=n=n===p?0:n;r;)r.fn(r.val,t,i),i+=r.len,r=r.next;return t},a.t=function(t){i=t,a.create=l(),i.t()}},{12:12}],16:[function(t,n,r){n.exports=u;var i=t(15),e=(u.prototype=Object.create(i.prototype,{constructor:{value:u,writable:!0,enumerable:!1,configurable:!0}}),t(12));function u(){i.call(this)}function o(t,n,r){for(var i=0;i<t.length;)n[r++]=t.charCodeAt(i++)}function s(t,n,r){t.length<40?e.utf8.write(t,n,r):n.utf8Write?n.utf8Write(t,r):n.write(t,r)}u.t=function(){u.alloc=e.e,u.writeBytesBuffer=e.Buffer&&e.Buffer.prototype instanceof Uint8Array&&"set"===e.Buffer.prototype.set.name?function(t,n,r){n.set(t,r)}:function(t,n,r){if(t.copy)t.copy(n,r,0,t.length);else for(var i=0;i<t.length;)n[r++]=t[i++]}},u.prototype.bytes=function(t){var n=(t=e.isString(t)?e.i(t,"base64"):t).length>>>0;return this.uint32(n),n&&this.u(u.writeBytesBuffer,n,t),this},u.prototype.raw=function(t){var n=t.length>>>0;return n?this.u(u.writeBytesBuffer,n,t):this},u.prototype.string=function(t){var n=e.Buffer.byteLength(t);return this.uint32(n),n&&this.u(n===t.length&&n<40?o:s,n,t),this},u.t()},{12:12,15:15}]},e={},(n=function t(n){var r=e[n];return r||i[n][0].call(r=e[n]={exports:{}},t,r,r.exports),r.exports}([1][0])).util.global.protobuf=n,"function"==typeof define&&define.amd&&define(["long"],function(t){return t&&t.isLong&&(n.util.Long=t,n.configure()),n}),"object"==typeof module&&module&&module.exports&&(module.exports=n)}(); | ||
| !function(b){"use strict";var n,s,i;n={1:[function(t,i,r){function n(){r.Writer.t(r.BufferWriter),r.Reader.t(r.BufferReader)}r.build="minimal",r.Writer=t(15),r.BufferWriter=t(16),r.Reader=t(2),r.BufferReader=t(3),r.util=t(12),r.rpc=t(5),r.roots=t(4),r.configure=n,n()},{12:12,15:15,16:16,2:2,3:3,4:4,5:5}],2:[function(t,i,r){i.exports=u;var n,c=t(12),s=c.LongBits,h=c.utf8;function a(t,i){return RangeError("index out of range: "+t.pos+" + "+(i||1)+" > "+t.len)}function u(t){this.buf=t,this.pos=0,this.len=t.length,this.view=null,this.discardUnknown=u.discardUnknown}function e(t){if((t=Array.isArray(t)?new Uint8Array(t):t)instanceof Uint8Array)return new u(t);throw Error("illegal buffer")}function o(){return c.Buffer?function(t){return(u.create=function(t){return c.Buffer.isBuffer(t)?new n(t):e(t)})(t)}:e}function f(){var t=new s(0,0),i=0;if(!(4<this.len-this.pos)){for(;i<4;++i){if(this.pos>=this.len)throw a(this);if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*i)>>>0,this.buf[this.pos++]<128)return t}throw a(this)}for(;i<4;++i)if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*i)>>>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(i=0,4<this.len-this.pos){for(;i<5;++i)if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*i+3)>>>0,this.buf[this.pos++]<128)return t}else for(;i<5;++i){if(this.pos>=this.len)throw a(this);if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*i+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}function l(t,i){return(t[i-4]|t[i-3]<<8|t[i-2]<<16|t[i-1]<<24)>>>0}function v(){if(this.pos+8>this.len)throw a(this,8);return new s(l(this.buf,this.pos+=4),l(this.buf,this.pos+=4))}u.create=o(),u.prototype.raw=function(t,i){return this.buf.subarray(t,i)},u.prototype.uint32=function(){var t=this.buf,i=this.pos,r=(127&t[i])>>>0;if(t[i++]<128)return this.pos=i,r;if(r=(r|(127&t[i])<<7)>>>0,t[i++]<128)return this.pos=i,r;if(r=(r|(127&t[i])<<14)>>>0,t[i++]<128)return this.pos=i,r;if(r=(r|(127&t[i])<<21)>>>0,t[i++]<128)return this.pos=i,r;if(r=(r|(15&t[i])<<28)>>>0,t[i++]<128)return this.pos=i,r;for(var n=0;n<5;++n){if(i>=this.len)throw this.pos=i,a(this);if(t[i++]<128)return this.pos=i,r}throw this.pos=i,Error("invalid varint encoding")},u.prototype.tag=function(){var t=this.buf,i=this.pos,r=(127&t[i])>>>0;if(t[i++]<128)return this.pos=i,r;if(r=(r|(127&t[i])<<7)>>>0,t[i++]<128)return this.pos=i,r;if(r=(r|(127&t[i])<<14)>>>0,t[i++]<128)return this.pos=i,r;if(r=(r|(127&t[i])<<21)>>>0,t[i++]<128)return this.pos=i,r;if(r=(r|(15&t[i])<<28)>>>0,t[i]<128&&0==(112&t[i]))return this.pos=i+1,r;throw this.pos=i+1,Error("invalid tag encoding")},u.prototype.int32=function(){return 0|this.uint32()},u.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(1&t)|0},u.prototype.bool=function(){for(var t,i=!1,r=0;r<10;++r){if(this.pos>=this.len)throw a(this);if(127&(t=this.buf[this.pos++])&&(i=!0),t<128)return i}throw Error("invalid varint encoding")},u.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return l(this.buf,this.pos+=4)},u.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return 0|l(this.buf,this.pos+=4)},u.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var t=c.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t},u.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var t=c.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t},u.prototype.uint32s=function(t){t===b&&(t=[]);for(var i=this.uint32()+this.pos;this.pos<i;)t.push(this.uint32());return t},u.prototype.int32s=function(t){t===b&&(t=[]);for(var i=this.uint32()+this.pos;this.pos<i;)t.push(this.int32());return t},u.prototype.sint32s=function(t){t===b&&(t=[]);for(var i=this.uint32()+this.pos;this.pos<i;)t.push(this.sint32());return t},u.prototype.bools=function(t){t===b&&(t=[]);for(var i=this.uint32()+this.pos;this.pos<i;)t.push(this.bool());return t};function w(t,i,r){var n=t.view;return n||i<r?n:(i=t.buf,t.view=new DataView(i.buffer,i.byteOffset,i.byteLength))}u.prototype.fixed32s=function(t){t===b&&(t=[]);var i=this.uint32(),r=this.pos+i;if(r>this.len)throw a(this,i);var n=i>>>2,s=t.length,h=this.pos,u=(t.length=s+n,w(this,n,128));if(u)for(var e=0;e<n;++e,h+=4)t[s++]=u.getUint32(h,!0);else for(var o=this.buf,f=0;f<n;++f,h+=4)t[s++]=l(o,h+4);if((this.pos=h)!==r)throw a(this,4);return t},u.prototype.sfixed32s=function(t){t===b&&(t=[]);var i=this.uint32(),r=this.pos+i;if(r>this.len)throw a(this,i);var n=i>>>2,s=t.length,h=this.pos,u=(t.length=s+n,w(this,n,128));if(u)for(var e=0;e<n;++e,h+=4)t[s++]=u.getInt32(h,!0);else for(var o=this.buf,f=0;f<n;++f,h+=4)t[s++]=0|l(o,h+4);if((this.pos=h)!==r)throw a(this,4);return t},u.prototype.floats=function(t){t===b&&(t=[]);var i=this.uint32(),r=this.pos+i;if(r>this.len)throw a(this,i);var n=i>>>2,s=t.length,h=this.pos,u=(t.length=s+n,w(this,n,8));if(u)for(var e=0;e<n;++e,h+=4)t[s++]=u.getFloat32(h,!0);else for(var o=this.buf,f=0;f<n;++f,h+=4)t[s++]=c.float.readFloatLE(o,h);if((this.pos=h)!==r)throw a(this,4);return t},u.prototype.doubles=function(t){t===b&&(t=[]);var i=this.uint32(),r=this.pos+i;if(r>this.len)throw a(this,i);var n=i>>>3,s=t.length,h=this.pos,u=(t.length=s+n,w(this,n,8));if(u)for(var e=0;e<n;++e,h+=8)t[s++]=u.getFloat64(h,!0);else for(var o=this.buf,f=0;f<n;++f,h+=8)t[s++]=c.float.readDoubleLE(o,h);if((this.pos=h)!==r)throw a(this,8);return t},u.prototype.uint64s=function(t){t===b&&(t=[]);for(var i=this.uint32()+this.pos;this.pos<i;)t.push(this.uint64());return t},u.prototype.int64s=function(t){t===b&&(t=[]);for(var i=this.uint32()+this.pos;this.pos<i;)t.push(this.int64());return t},u.prototype.sint64s=function(t){t===b&&(t=[]);for(var i=this.uint32()+this.pos;this.pos<i;)t.push(this.sint64());return t},u.prototype.fixed64s=function(t){t===b&&(t=[]);var i=this.uint32(),r=this.pos+i,n=t.length;if(r>this.len)throw a(this,i);var s=i>>>3;t.length=n+s;for(var h=0;h<s;++h)t[n++]=this.fixed64();if(this.pos!==r)throw a(this,8);return t},u.prototype.sfixed64s=function(t){t===b&&(t=[]);var i=this.uint32(),r=this.pos+i,n=t.length;if(r>this.len)throw a(this,i);var s=i>>>3;t.length=n+s;for(var h=0;h<s;++h)t[n++]=this.sfixed64();if(this.pos!==r)throw a(this,8);return t},u.prototype.bytes=function(){var t=this.uint32(),i=this.pos,r=this.pos+t;if(r>this.len)throw a(this,t);return this.pos=r,this.raw(i,r)},u.prototype.string=function(){var t=this.uint32(),i=this.pos,r=this.pos+t;if(r>this.len)throw a(this,t);return this.pos=r,h.read(this.buf,i,r)},u.prototype.stringVerify=function(){var t=this.uint32(),i=this.pos,r=this.pos+t;if(r>this.len)throw a(this,t);return this.pos=r,h.readStrict(this.buf,i,r)},u.prototype.skip=function(t){if("number"==typeof t){if(this.pos+t>this.len)throw a(this,t);this.pos+=t}else do{if(this.pos>=this.len)throw a(this)}while(128&this.buf[this.pos++]);return this},u.recursionLimit=c.recursionLimit,u.discardUnknown=!0,u.prototype.skipType=function(t,i,r){if(u.recursionLimit<(i=i===b?0:i))throw Error("max depth exceeded");if(0===r)throw Error("illegal tag: field number 0");switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;;){var n=this.tag(),s=n>>>3;if(!s)throw Error("illegal tag: field number 0");if(4===(t=7&n)){if(r!==b&&s!==r)throw Error("invalid end group tag");break}this.skipType(t,i+1,s)}break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+t+" at offset "+this.pos)}return this},u.t=function(t){n=t,u.create=o(),n.t();var i=c.Long?"toLong":"toNumber";c.merge(u.prototype,{int64:function(){return f.call(this)[i](!1)},uint64:function(){return f.call(this)[i](!0)},sint64:function(){return f.call(this).zzDecode()[i](!1)},fixed64:function(){return v.call(this)[i](!0)},sfixed64:function(){return v.call(this)[i](!1)}})}},{12:12}],3:[function(t,i,r){i.exports=h;var n=t(2),s=(h.prototype=Object.create(n.prototype,{constructor:{value:h,writable:!0,enumerable:!1,configurable:!0}}),t(12));function h(t){n.call(this,t)}h.t=function(){s.Buffer&&(h.prototype.i=s.Buffer.prototype.slice)},h.prototype.raw=function(t,i){return this.i.call(this.buf,t,i)},h.prototype.string=function(){var t=this.uint32(),i=this.pos,r=this.pos+t;if(r>this.len)throw RangeError("index out of range: "+this.pos+" + "+t+" > "+this.len);return this.pos=r,this.buf.utf8Slice?this.buf.utf8Slice(i,r):this.buf.toString("utf-8",i,r)},h.t()},{12:12,2:2}],4:[function(t,i,r){i.exports=Object.create(null)},{}],5:[function(t,i,r){r.Service=t(6)},{6:6}],6:[function(t,i,r){i.exports=n;var e=t(12);function n(t,i,r){if("function"!=typeof t)throw TypeError("rpcImpl must be a function");e.EventEmitter.call(this),this.rpcImpl=t,this.requestDelimited=!!i,this.responseDelimited=!!r}(n.prototype=Object.create(e.EventEmitter.prototype,{constructor:{value:n,writable:!0,enumerable:!1,configurable:!0}})).rpcCall=function t(r,i,n,s,h){if(!s)throw TypeError("request must be specified");var u=this;if(!h)return e.asPromise(t,u,r,i,n,s);if(!u.rpcImpl)return setTimeout(function(){h(Error("already ended"))},0),b;try{return u.rpcImpl(r,i[u.requestDelimited?"encodeDelimited":"encode"](s).finish(),function(t,i){if(t)return u.emit("error",t,r),h(t);if(null===i)return u.end(!0),b;if(!(i instanceof n))try{i=n[u.responseDelimited?"decodeDelimited":"decode"](i)}catch(t){return u.emit("error",t,r),h(t)}return u.emit("data",i,r),h(null,i)})}catch(t){return u.emit("error",t,r),setTimeout(function(){h(t)},0),b}},n.prototype.end=function(t){return this.rpcImpl&&(t||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},{12:12}],7:[function(t,i,r){i.exports=function(t,i){var r=Array(arguments.length-1),h=0,n=2,u=!0;for(;n<arguments.length;)r[h++]=arguments[n++];return new Promise(function(n,s){r[h]=function(t){if(u)if(u=!1,t)s(t);else{for(var i=Array(arguments.length-1),r=0;r<i.length;)i[r++]=arguments[r];n.apply(null,i)}};try{t.apply(i||null,r)}catch(t){u&&(u=!1,s(t))}})}},{}],8:[function(t,i,r){r.length=function(t){var i=t.length;if(!i)return 0;for(;0<i&&"="==(t[0|i-1]||"");)--i;return Math.floor(3*i/4)};for(var f=Array(64),o=Array(123),n=0;n<64;)o[f[n]=n<26?n+65:n<52?n+71:n<62?n-4:n-59|43]=n++;o[45]=62,o[95]=63,r.encode=function(t,i,r){for(var n,s=null,h=[],u=0,e=0;i<r;){var o=t[i++];switch(e){case 0:h[u++]=f[o>>2],n=(3&o)<<4,e=1;break;case 1:h[u++]=f[n|o>>4],n=(15&o)<<2,e=2;break;case 2:h[u++]=f[n|o>>6],h[u++]=f[63&o],e=0}8191<u&&((s=s||[]).push(String.fromCharCode.apply(String,h)),u=0)}return e&&(h[u++]=f[n],h[u++]=61,1===e&&(h[u++]=61)),s?(u&&s.push(String.fromCharCode.apply(String,h.slice(0,u))),s.join("")):String.fromCharCode.apply(String,h.slice(0,u))};var c="invalid encoding",s=(r.decode=function(t,i,r){for(var n,s=r,h=0,u=0;u<t.length;){var e=t.charCodeAt(u++);if(61==e&&1<h)break;if((e=o[e])===b)throw Error(c);switch(h){case 0:n=e,h=1;break;case 1:i[r++]=n<<2|(48&e)>>4,n=e,h=2;break;case 2:i[r++]=(15&n)<<4|(60&e)>>2,n=e,h=3;break;case 3:i[r++]=(3&n)<<6|e,h=0}}if(1===h)throw Error(c);return r-s},/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/),h=/[-_]/,u=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2}(?:==)?|[A-Za-z0-9_-]{3}=?)?$/;r.test=function(t){return s.test(t)||h.test(t)&&u.test(t)}},{}],9:[function(t,i,r){function n(){this.r=Object.create(null)}(i.exports=n).prototype.on=function(t,i,r){return(this.r[t]||(this.r[t]=[])).push({fn:i,ctx:r||this}),this},n.prototype.off=function(t,i){if(t===b)this.r=Object.create(null);else if(i===b)this.r[t]=[];else{var r=this.r[t];if(!r)return this;for(var n=0;n<r.length;)r[n].fn===i?r.splice(n,1):++n}return this},n.prototype.emit=function(t){var i=this.r[t];if(i){for(var r=[],n=1;n<arguments.length;)r.push(arguments[n++]);for(n=0;n<i.length;)i[n].fn.apply(i[n++].ctx,r)}return this}},{}],10:[function(t,i,r){function n(t){function i(t,i,r,n){var s=i<0?1:0;t(0===(i=s?-i:i)?0<1/i?0:2147483648:isNaN(i)?2143289344:34028234663852886e22<i?(s<<31|2139095040)>>>0:i<11754943508222875e-54?(s<<31|Math.round(i/1401298464324817e-60))>>>0:(s<<31|127+(t=Math.floor(Math.log(i)/Math.LN2))<<23|8388607&Math.round(i*Math.pow(2,-t)*8388608))>>>0,r,n)}function r(t,i,r){t=t(i,r),i=2*(t>>31)+1,r=t>>>23&255,t&=8388607;return 255==r?t?NaN:1/0*i:0==r?1401298464324817e-60*i*t:i*Math.pow(2,r-150)*(8388608+t)}function n(t,i,r){e[0]=t,i[r]=o[0],i[r+1]=o[1],i[r+2]=o[2],i[r+3]=o[3]}function s(t,i,r){e[0]=t,i[r]=o[3],i[r+1]=o[2],i[r+2]=o[1],i[r+3]=o[0]}function h(t,i){return o[0]=t[i],o[1]=t[i+1],o[2]=t[i+2],o[3]=t[i+3],e[0]}function u(t,i){return o[3]=t[i],o[2]=t[i+1],o[1]=t[i+2],o[0]=t[i+3],e[0]}var e,o,f,c,a;function l(t,i,r,n,s,h){var u,e=n<0?1:0;0===(n=e?-n:n)?(t(0,s,h+i),t(0<1/n?0:2147483648,s,h+r)):isNaN(n)?(t(0,s,h+i),t(2146959360,s,h+r)):17976931348623157e292<n?(t(0,s,h+i),t((e<<31|2146435072)>>>0,s,h+r)):n<22250738585072014e-324?(t((u=n/5e-324)>>>0,s,h+i),t((e<<31|u/4294967296)>>>0,s,h+r)):(t(4503599627370496*(u=n*Math.pow(2,-(n=1024===(n=Math.floor(Math.log(n)/Math.LN2))?1023:n)))>>>0,s,h+i),t((e<<31|n+1023<<20|1048576*u&1048575)>>>0,s,h+r))}function v(t,i,r,n,s){i=t(n,s+i),t=t(n,s+r),n=2*(t>>31)+1,s=t>>>20&2047,r=4294967296*(1048575&t)+i;return 2047==s?r?NaN:1/0*n:0==s?5e-324*n*r:n*Math.pow(2,s-1075)*(r+4503599627370496)}function w(t,i,r){f[0]=t,i[r]=c[0],i[r+1]=c[1],i[r+2]=c[2],i[r+3]=c[3],i[r+4]=c[4],i[r+5]=c[5],i[r+6]=c[6],i[r+7]=c[7]}function b(t,i,r){f[0]=t,i[r]=c[7],i[r+1]=c[6],i[r+2]=c[5],i[r+3]=c[4],i[r+4]=c[3],i[r+5]=c[2],i[r+6]=c[1],i[r+7]=c[0]}function g(t,i){return c[0]=t[i],c[1]=t[i+1],c[2]=t[i+2],c[3]=t[i+3],c[4]=t[i+4],c[5]=t[i+5],c[6]=t[i+6],c[7]=t[i+7],f[0]}function d(t,i){return c[7]=t[i],c[6]=t[i+1],c[5]=t[i+2],c[4]=t[i+3],c[3]=t[i+4],c[2]=t[i+5],c[1]=t[i+6],c[0]=t[i+7],f[0]}return"undefined"!=typeof Float32Array?(e=new Float32Array([-0]),o=new Uint8Array(e.buffer),a=128===o[3],t.writeFloatLE=a?n:s,t.writeFloatBE=a?s:n,t.readFloatLE=a?h:u,t.readFloatBE=a?u:h):(t.writeFloatLE=i.bind(null,y),t.writeFloatBE=i.bind(null,m),t.readFloatLE=r.bind(null,p),t.readFloatBE=r.bind(null,j)),"undefined"!=typeof Float64Array?(f=new Float64Array([-0]),c=new Uint8Array(f.buffer),a=128===c[7],t.writeDoubleLE=a?w:b,t.writeDoubleBE=a?b:w,t.readDoubleLE=a?g:d,t.readDoubleBE=a?d:g):(t.writeDoubleLE=l.bind(null,y,0,4),t.writeDoubleBE=l.bind(null,m,4,0),t.readDoubleLE=v.bind(null,p,0,4),t.readDoubleBE=v.bind(null,j,4,0)),t}function y(t,i,r){i[r]=255&t,i[r+1]=t>>>8&255,i[r+2]=t>>>16&255,i[r+3]=t>>>24}function m(t,i,r){i[r]=t>>>24,i[r+1]=t>>>16&255,i[r+2]=t>>>8&255,i[r+3]=255&t}function p(t,i){return(t[i]|t[i+1]<<8|t[i+2]<<16|t[i+3]<<24)>>>0}function j(t,i){return(t[i]<<24|t[i+1]<<16|t[i+2]<<8|t[i+3])>>>0}i.exports=n(n)},{}],11:[function(t,i,r){i.exports=s;var n=t(12);function s(t,i){this.lo=t>>>0,this.hi=i>>>0}var h=s.zero=new s(0,0),u=(h.toNumber=function(){return 0},h.zzEncode=h.zzDecode=function(){return this},h.length=function(){return 1},s.zeroHash="\0\0\0\0\0\0\0\0",s.fromNumber=function(t){var i,r;return 0===t?h:(r=(t=(i=t<0)?-t:t)>>>0,t=(t-r)/4294967296>>>0,i&&(t=~t>>>0,r=~r>>>0,4294967295<++r&&(r=0,4294967295<++t&&(t=0))),new s(r,t))},s.from=function(t){if("number"==typeof t)return s.fromNumber(t);if(n.isString(t)){if(!n.Long)return s.fromNumber(parseInt(t,10));t=n.Long.fromString(t)}return t.low||t.high?new s(t.low>>>0,t.high>>>0):h},s.prototype.toNumber=function(t){var i;return!t&&this.hi>>>31?(t=1+~this.lo>>>0,i=~this.hi>>>0,-(t+4294967296*(i=t?i:i+1>>>0))):this.lo+4294967296*this.hi},s.prototype.toLong=function(t){return n.Long?new n.Long(0|this.lo,0|this.hi,!!t):{low:0|this.lo,high:0|this.hi,unsigned:!!t}},String.prototype.charCodeAt);s.fromHash=function(t){return"\0\0\0\0\0\0\0\0"===t?h:new s((u.call(t,0)|u.call(t,1)<<8|u.call(t,2)<<16|u.call(t,3)<<24)>>>0,(u.call(t,4)|u.call(t,5)<<8|u.call(t,6)<<16|u.call(t,7)<<24)>>>0)},s.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)},s.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},s.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},s.prototype.length=function(){var t=this.lo,i=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0==r?0==i?t<16384?t<128?1:2:t<2097152?3:4:i<16384?i<128?5:6:i<2097152?7:8:r<128?9:10}},{12:12}],12:[function(i,t,r){var u=r;function e(t){return"__proto__"===t||"prototype"===t||"constructor"===t}function n(t){for(var i=(r="boolean"==typeof arguments[arguments.length-1])?arguments.length-1:arguments.length,r=r&&arguments[arguments.length-1],n=1;n<i;++n){var s=arguments[n];if(s)for(var h=Object.keys(s),u=0;u<h.length;++u)e(h[u])||r&&Object.prototype.hasOwnProperty.call(t,h[u])&&t[h[u]]!==b||(t[h[u]]=s[h[u]])}return t}function s(t){function r(t,i){if(!(this instanceof r))return new r(t,i);Object.defineProperty(this,"message",{get:function(){return t}}),Error.captureStackTrace?Error.captureStackTrace(this,r):Object.defineProperty(this,"stack",{value:Error().stack||""}),i&&n(this,i)}return r.prototype=Object.create(Error.prototype,{constructor:{value:r,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return t},set:b,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),r}u.asPromise=i(7),u.base64=i(8),u.EventEmitter=i(9),u.float=i(10),u.utf8=i(14),u.pool=i(13),u.LongBits=i(11),u.isUnsafeProperty=e,u.isNode=!!("undefined"!=typeof global&&global&&global.process&&global.process.versions&&global.process.versions.node),u.global=u.isNode&&global||"undefined"!=typeof window&&window||"undefined"!=typeof self&&self||"undefined"!=typeof globalThis&&globalThis||this,u.emptyArray=Object.freeze?Object.freeze([]):[],u.emptyObject=Object.freeze?Object.freeze({}):{},u.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},u.isString=function(t){return"string"==typeof t||t instanceof String},u.isObject=function(t){return t&&"object"==typeof t},u.isset=u.isSet=function(t,i){var r=t[i];return!(null==r||!Object.hasOwnProperty.call(t,i))&&("object"!=typeof r||0<(Array.isArray(r)?r:Object.keys(r)).length)},u.Buffer=function(){try{var t=u.global.Buffer;return t.prototype.utf8Write||u.isNode?t:null}catch(t){return null}}(),u.newBuffer=function(t){var i=u.Buffer;return"number"==typeof t?i?i.allocUnsafe(t):new Uint8Array(t):i?i.from(t):new Uint8Array(t)},u.rawField=function(t,i,r){var n=[],s=t<<3|i;for(s>>>=0;127<s;)n.push(127&s|128),s>>>=7;n.push(s);for(var h=0;h<r.length;++h)n.push(r[h]);return u.newBuffer(n)},u.Array=Uint8Array,u.Long=u.global.dcodeIO&&u.global.dcodeIO.Long||u.global.Long||function(){try{var t=i("long");return t&&t.isLong?t:null}catch(t){return null}}(),u.key2Re=/^(?:true|false|0|1)$/,u.key32Re=/^-?(?:0|[1-9][0-9]*)$/,u.key64Re=/^(?:[\x00-\xff]{8}|-?(?:0|[1-9][0-9]*))$/,u.longToHash=function(t){return t?u.LongBits.from(t).toHash():u.LongBits.zeroHash},u.longFromHash=function(t,i){t=u.LongBits.fromHash(t);return u.Long?u.Long.fromBits(t.lo,t.hi,i):t.toNumber(!!i)},u.longFromKey=function(t,i){return u.key64Re.test(t)&&!u.key32Re.test(t)?u.longFromHash(t,i):t},u.boolFromKey=function(t){return"true"===t||"1"===t},u.merge=n,u.nestingLimit=32,u.recursionLimit=100,u.makeProp=function(t,i,r){Object.prototype.hasOwnProperty.call(t,i)||Object.defineProperty(t,i,{enumerable:r===b||r,configurable:!0,writable:!0})},u.lcFirst=function(t){return(t[0]||"").toLowerCase()+t.substring(1)},u.newError=s,u.ProtocolError=s("ProtocolError"),u.oneOfGetter=function(t){for(var r={},i=0;i<t.length;++i)r[t[i]]=1;return function(){for(var t=Object.keys(this),i=t.length-1;-1<i;--i)if(1===r[t[i]]&&this[t[i]]!==b&&null!==this[t[i]])return t[i]}},u.oneOfSetter=function(r){return function(t){for(var i=0;i<r.length;++i)r[i]!==t&&delete this[r[i]]}},u.toJSONOptions={longs:String,enums:String,bytes:String,json:!0}},{10:10,11:11,13:13,14:14,7:7,8:8,9:9,long:"long"}],13:[function(t,i,r){i.exports=function(i,r,t){var n=t||8192,s=n>>>1,h=null,u=n;return function(t){if(t<1||s<t)return i(t);n<u+t&&(h=i(n),u=0);t=r.call(h,u,u+=t);return 7&u&&(u=1+(7|u)),t}}},{}],14:[function(t,i,r){var v,w=new TextDecoder("utf-8",{ignoreBOM:!0});try{v=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}catch(t){v=w}function b(t,i,r,n){for(var s=i;s<r;){var h,u=t[s++];u<=127?n+=String.fromCharCode(u):192<=u&&u<224?n+=128<=(h=(31&u)<<6|63&t[s++])?String.fromCharCode(h):"�":224<=u&&u<240?n+=2048<=(h=(15&u)<<12|(63&t[s++])<<6|63&t[s++])?String.fromCharCode(h):"�":240<=u&&((u=(7&u)<<18|(63&t[s++])<<12|(63&t[s++])<<6|63&t[s++])<65536||1114111<u?n+="�":n=n+String.fromCharCode(55296+((u-=65536)>>10))+String.fromCharCode(56320+(1023&u)))}return n}function g(t,i,r,n){i=0===r&&n===i.length?i:i.subarray(r,n);return t.decode(i)}r.length=function(t){for(var i,r=0,n=0;n<t.length;++n)(i=t.charCodeAt(n))<128?r+=1:i<2048?r+=2:55296==(64512&i)&&56320==(64512&t.charCodeAt(n+1))?(++n,r+=4):r+=3;return r},r.read=function(t,i,r){if(r-i<1)return"";if(64<=r-i)return g(w,t,i,r);for(var n,s,h,u,e,o,f,c,a="",l=i;l+7<r;l+=8){if(128&((n=t[l])|(s=t[l+1])|(h=t[l+2])|(u=t[l+3])|(e=t[l+4])|(o=t[l+5])|(f=t[l+6])|(c=t[l+7])))return b(t,l,r,a);a+=String.fromCharCode(n,s,h,u,e,o,f,c)}for(;l<r;++l){if(128&(n=t[l]))return b(t,l,r,a);a+=String.fromCharCode(n)}return a},r.readStrict=function(t,i,r){if(r-i<1)return"";if(64<=r-i)return g(v,t,i,r);for(var n,s,h,u,e,o,f,c,a="",l=i;l+7<r;l+=8){if(128&((n=t[l])|(s=t[l+1])|(h=t[l+2])|(u=t[l+3])|(e=t[l+4])|(o=t[l+5])|(f=t[l+6])|(c=t[l+7])))return a+g(v,t,l,r);a+=String.fromCharCode(n,s,h,u,e,o,f,c)}for(;l<r;++l){if(128&(n=t[l]))return a+g(v,t,l,r);a+=String.fromCharCode(n)}return a},r.write=function(t,i,r){for(var n,s,h=r,u=0;u<t.length;++u)(n=t.charCodeAt(u))<128?i[r++]=n:(n<2048?i[r++]=n>>6|192:(55296==(64512&n)&&56320==(64512&(s=t.charCodeAt(u+1)))?(++u,i[r++]=(n=65536+((1023&n)<<10)+(1023&s))>>18|240,i[r++]=n>>12&63|128):i[r++]=n>>12|224,i[r++]=n>>6&63|128),i[r++]=63&n|128);return r-h}},{}],15:[function(t,i,r){i.exports=h;var n,e=t(12),o=e.LongBits,s=e.base64,u=e.utf8;function h(){this.pos=0,this.buf=this.constructor.alloc(64),this.view=null,this.states=null}Object.defineProperty(h.prototype,"len",{configurable:!0,enumerable:!0,get:function(){return this.pos}});function f(){return e.Buffer?function(){return(h.create=function(){return new n})()}:function(){return new h}}function c(t){return t<128?1:t<16384?2:t<2097152?3:t<268435456?4:5}function a(t,i,r){for(;127<t;)i[r++]=127&t|128,t>>>=7;return i[r]=t,r+1}function l(t,i,r){for(var n=t.lo,s=t.hi;s;)i[r++]=127&n|128,n=(n>>>7|s<<25)>>>0,s>>>=7;for(;127<n;)i[r++]=127&n|128,n>>>=7;return i[r]=n,r+1}function v(t,i,r){i[r]=255&t,i[r+1]=t>>>8&255,i[r+2]=t>>>16&255,i[r+3]=t>>>24}h.create=f(),h.alloc=e.pool(h.alloc=function(t){return new Uint8Array(t)},Uint8Array.prototype.subarray),h.prototype.n=function(t){var i,t=this.pos+t;t>this.buf.length&&(i=this.buf.length<<1,(t=this.constructor.alloc(i=i<t?t:i)).set(this.buf.subarray(0,this.pos),0),this.buf=t,this.view=null)},h.prototype.uint32=function(t){t>>>=0,this.n(5);var i=this.pos;return this.pos=a(t,this.buf,i),this},h.prototype.int32=function(t){return(t|=0)<0?(this.n(10),l(o.fromNumber(t),this.buf,this.pos),this.pos+=10,this):this.uint32(t)},h.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)},h.prototype.int64=h.prototype.uint64=function(t){var t=o.from(t),i=(this.n(10),this.pos);return this.pos=l(t,this.buf,i),this},h.prototype.sint64=function(t){var t=o.from(t).zzEncode(),i=(this.n(10),this.pos);return this.pos=l(t,this.buf,i),this},h.prototype.bool=function(t){return this.n(1),this.buf[this.pos++]=t?1:0,this},h.prototype.sfixed32=h.prototype.fixed32=function(t){return this.n(4),v(t>>>0,this.buf,this.pos),this.pos+=4,this},h.prototype.sfixed64=h.prototype.fixed64=function(t){t=o.from(t);return this.n(8),v(t.lo,this.buf,this.pos),v(t.hi,this.buf,this.pos+4),this.pos+=8,this},h.prototype.float=function(t){return this.n(4),e.float.writeFloatLE(t,this.buf,this.pos),this.pos+=4,this},h.prototype.double=function(t){return this.n(8),e.float.writeDoubleLE(t,this.buf,this.pos),this.pos+=8,this},h.prototype.bytes=function(t){var i,r=t.length>>>0;return r?(e.isString(t)&&(i=h.alloc(r=s.length(t)),s.decode(t,i,0),t=i),this.uint32(r),this.n(r),this.buf.set(t,this.pos),this.pos+=r):(this.n(1),this.buf[this.pos++]=0),this},h.prototype.raw=function(t){var i=t.length>>>0;return i&&(this.n(i),this.buf.set(t,this.pos),this.pos+=i),this},h.prototype.s=function(t,i){var r=c(i);return 1<r&&this.buf.copyWithin(t+r,t+1,t+1+i),a(i,this.buf,t),this.pos=t+r+i,this},h.prototype.string=function(t){var i=t.length;if(i){if(i<128)return this.n(3*i+5),i=this.pos,this.s(i,u.write(t,this.buf,i+1));i=u.length(t);if(this.uint32(i),this.n(i),i===t.length)for(var r=t,n=this.buf,s=this.pos,h=0;h<r.length;)n[s++]=r.charCodeAt(h++);else u.write(t,this.buf,this.pos);this.pos+=i}else this.n(1),this.buf[this.pos++]=0;return this},h.prototype.uint32s=function(t){for(var i=t.length,r=(this.n(5*i+5),this.buf),n=this.pos,s=n+1,h=0;h<i;++h)s=a(t[h]>>>0,r,s);return this.s(n,s-n-1)},h.prototype.int32s=function(t){for(var i,r=t.length,n=(this.n(10*r+5),this.buf),s=this.pos,h=s+1,u=0;u<r;++u)h=(i=0|t[u])<0?l(o.fromNumber(i),n,h):a(i,n,h);return this.s(s,h-s-1)},h.prototype.sint32s=function(t){for(var i=t.length,r=(this.n(5*i+5),this.buf),n=this.pos,s=n+1,h=0;h<i;++h)s=a((t[h]<<1^t[h]>>31)>>>0,r,s);return this.s(n,s-n-1)},h.prototype.int64s=h.prototype.uint64s=function(t){for(var i=t.length,r=(this.n(10*i+5),this.buf),n=this.pos,s=n+1,h=0;h<i;++h)s=l(o.from(t[h]),r,s);return this.s(n,s-n-1)},h.prototype.sint64s=function(t){for(var i=t.length,r=(this.n(10*i+5),this.buf),n=this.pos,s=n+1,h=0;h<i;++h)s=l(o.from(t[h]).zzEncode(),r,s);return this.s(n,s-n-1)},h.prototype.bools=function(t){for(var i=t.length,r=(this.uint32(i),this.n(i),this.buf),n=this.pos,s=0;s<i;++s)r[n++]=t[s]?1:0;return this.pos+=i,this};function w(t,i,r){var n=t.view;return n||i<r?n:(i=t.buf,t.view=new DataView(i.buffer,i.byteOffset,i.byteLength))}h.prototype.sfixed32s=h.prototype.fixed32s=function(t){var i=t.length,r=4*i,n=(this.uint32(r),this.n(r),this.pos),s=w(this,i,128);if(s)for(u=0;u<i;++u)s.setUint32(n,t[u]>>>0,!0),n+=4;else for(var h=this.buf,u=0;u<i;++u)v(t[u]>>>0,h,n),n+=4;return this.pos+=r,this},h.prototype.sfixed64s=h.prototype.fixed64s=function(t){var i,r=t.length,n=8*r,s=(this.uint32(n),this.n(n),this.pos),h=w(this,r,128);if(h)for(e=0;e<r;++e)i=o.from(t[e]),h.setUint32(s,i.lo,!0),h.setUint32(s+4,i.hi,!0),s+=8;else for(var u=this.buf,e=0;e<r;++e)v((i=o.from(t[e])).lo,u,s),v(i.hi,u,s+4),s+=8;return this.pos+=n,this},h.prototype.floats=function(t){var i=t.length,r=4*i,n=(this.uint32(r),this.n(r),this.pos),s=w(this,i,16);if(s)for(u=0;u<i;++u)s.setFloat32(n,t[u],!0),n+=4;else for(var h=this.buf,u=0;u<i;++u)e.float.writeFloatLE(t[u],h,n),n+=4;return this.pos+=r,this},h.prototype.doubles=function(t){var i=t.length,r=8*i,n=(this.uint32(r),this.n(r),this.pos),s=w(this,i,16);if(s)for(u=0;u<i;++u)s.setFloat64(n,t[u],!0),n+=8;else for(var h=this.buf,u=0;u<i;++u)e.float.writeDoubleLE(t[u],h,n),n+=8;return this.pos+=r,this},h.prototype.fork=function(){return this.n(1),(this.states||(this.states=[])).push(this.pos),this.pos+=1,this},h.prototype.reset=function(){var t=this.states;return t&&t.length?this.pos=t.pop():this.pos=0,this},h.prototype.ldelim=function(){var t,i,r=this.states;return r&&r.length?(r=r.pop(),1<(i=c(t=this.pos-r-1))?(this.n(i-1),this.buf.copyWithin(r+i,r+1,r+1+t),this.pos+=i-1,a(t,this.buf,r)):this.buf[r]=t):(i=c(t=this.pos),this.n(i),this.buf.copyWithin(i,0,t),a(t,this.buf,0),this.pos+=i),this},h.prototype.finish=function(t){return t?this.buf.subarray(0,this.pos):((t=this.constructor.alloc(this.pos)).set(this.buf.subarray(0,this.pos),0),t)},h.prototype.finishInto=function(t,i){return i===b&&(i=0),t.set(this.buf.subarray(0,this.pos),i),t},h.t=function(t){n=t,h.create=f(),n.t()}},{12:12}],16:[function(t,i,r){i.exports=u;var s,n=t(15),h=(u.prototype=Object.create(n.prototype,{constructor:{value:u,writable:!0,enumerable:!1,configurable:!0}}),t(12));function u(){n.call(this)}u.t=function(){u.alloc=h.Buffer&&h.Buffer.allocUnsafe,s=h.Buffer&&h.Buffer.prototype.utf8Write?function(t,i,r){return i.utf8Write(t,r)}:function(t,i,r){return i.write(t,r)}},u.prototype.bytes=function(t){var i=(t=h.isString(t)?h.Buffer.from(t,"base64"):t).length>>>0;return this.uint32(i),i&&(this.n(i),this.buf.set(t,this.pos),this.pos+=i),this},u.prototype.string=function(t){var i,r,n=t.length;if(n){if(n<128)return this.n(3*n+5),i=this.pos,r=this.buf,this.s(i,n<40?h.utf8.write(t,r,i+1):s(t,r,i+1));n=h.Buffer.byteLength(t);this.uint32(n),this.n(n),s(t,this.buf,this.pos),this.pos+=n}else this.n(1),this.buf[this.pos++]=0;return this},u.t()},{12:12,15:15}]},s={},(i=function t(i){var r=s[i];return r||n[i][0].call(r=s[i]={exports:{}},t,r,r.exports),r.exports}([1][0])).util.global.protobuf=i,"function"==typeof define&&define.amd&&define(["long"],function(t){return t&&t.isLong&&(i.util.Long=t,i.configure()),i}),"object"==typeof module&&module&&module.exports&&(module.exports=i)}(); | ||
| //# sourceMappingURL=protobuf.min.js.map |
+2
-2
| { | ||
| "name": "protobufjs", | ||
| "version": "8.6.6", | ||
| "version": "8.7.0", | ||
| "description": "Protocol Buffers for JavaScript & TypeScript.", | ||
@@ -25,3 +25,3 @@ "author": "Daniel Wirtz <dcode+protobufjs@dcode.io>", | ||
| "scripts": { | ||
| "bench": "node bench", | ||
| "bench": "npm --prefix bench run bench", | ||
| "build": "npm run build:bundle && npm run build:types", | ||
@@ -28,0 +28,0 @@ "build:bundle": "gulp --gulpfile scripts/gulpfile.js", |
+46
-47
@@ -12,8 +12,10 @@ <h1><p align="center"><img alt="protobuf.js" src="https://github.com/protobufjs/protobuf.js/raw/master/pbjs.svg" height="100" /><br/>protobuf.js</p></h1> | ||
| **protobuf.js** is a standalone JavaScript implementation of Protocol Buffers for Node.js and browsers. It is tuned for fast binary I/O, battle-tested at scale, and validated against the official Protocol Buffers conformance suite. It can load `.proto` files directly, does not require protoc, and supports runtime reflection plus reflection-free and reflection-backed code generation with strong TypeScript declarations. | ||
| **protobuf.js** is a very fast, conformant, and unusually versatile JavaScript implementation of Protocol Buffers for Node.js and browsers. It works with `.proto` files out of the box, does not require protoc, and supports runtime reflection as well as specialized code generation with strong TypeScript declarations. | ||
| If protobuf.js is important to your project or organization, especially if you depend on it commercially, [consider supporting its ongoing maintenance](https://github.com/sponsors/dcodeIO). | ||
| If protobuf.js is important to your project or organization, or if you depend on it commercially, [consider supporting](https://github.com/sponsors/dcodeIO) its ongoing maintenance. Sponsorship helps make bug fixes, releases, LTS/security handling, and user support more sustainable. | ||
| ## Getting started | ||
| Getting up and running is simple: Install the package, load a `.proto` file, and you are all set to encode and decode Protobuf messages. From there, protobuf.js grows with your requirements: Add any combination of capabilities, such as [code generation](#code-generation), [TypeScript declarations](#typescript-integration), [transport-agnostic services](#services), [programmatic schemas](#programmatic-schemas), [optional extensions](#extensions), and more as needed. All in one flexible toolkit. | ||
| ### Install | ||
@@ -318,2 +320,19 @@ | ||
| Integration example with [@grpc/grpc-js](https://www.npmjs.com/package/@grpc/grpc-js): | ||
| ```js | ||
| const grpc = require('@grpc/grpc-js'); | ||
| const Client = grpc.makeGenericClientConstructor({}); | ||
| const client = new Client(serverAddress, grpc.credentials.createInsecure()); | ||
| const rpcImpl = (method, requestData, callback) => | ||
| client.makeUnaryRequest(method.path, (data) => data, (data) => data, requestData, callback); | ||
| const greeter = root.lookupService("example.Greeter").create(rpcImpl); | ||
| const reply = await greeter.sayHello({ name: "world" }); | ||
| ``` | ||
| See [examples/grpc-service.js](./examples/grpc-service.js) for a complete example. | ||
| ### Extensions | ||
@@ -337,4 +356,6 @@ | ||
| protobuf.js targets complete binary wire-format conformance for **Proto2**, **Proto3** and **Editions** in both static and reflection modes, plus complete **ProtoJSON** and **Text Format** conformance with reflection metadata present. CI runs the official Protocol Buffers conformance suite for validation, with logs [uploaded as artifacts](https://github.com/protobufjs/protobuf.js/actions/workflows/test.yml?query=branch%3Amaster+event%3Apush). | ||
| protobuf.js is validated against the official Protocol Buffers conformance suite, achieving complete binary wire-format conformance for **Proto2**, **Proto3** and **Editions**, plus complete **ProtoJSON** and **Text Format** conformance in its default configuration with reflection metadata present. | ||
| <!-- BEGIN CONFORMANCE DATA --> | ||
| | Category | Total | Required | Recommended | | ||
@@ -345,3 +366,3 @@ | ---------- | ------------------: | ------------------: | ------------------: | | ||
| | ↳ Proto3 | 100.00% (707/707) | 100.00% (486/486) | 100.00% (221/221) | | ||
| | ↳ Editions | 100.00% (1419/1419) | 100.00% (981/981) | 100.00% (438/438) | | ||
| | ↳ Editions | 100.00% (1421/1421) | 100.00% (983/983) | 100.00% (438/438) | | ||
| | ProtoJSON | 100.00% (2796/2796) | 100.00% (2362/2362) | 100.00% (434/434) | | ||
@@ -351,58 +372,36 @@ | TextFormat | 100.00% (909/909) | 100.00% (845/845) | 100.00% (64/64) | | ||
| ## Performance | ||
| <!-- END CONFORMANCE DATA --> | ||
| In both reflection and reflection-free modes, protobuf.js builds specialized encoders and decoders instead of interpreting descriptors at runtime. | ||
| [Structured results](https://github.com/protobufjs/protobuf.js/actions/workflows/test.yml?query=branch%3Amaster+event%3Apush) are available as CI artifacts. In case of contradicting claims by your favorite LLM, [see](https://dev.to/dcode/when-the-model-is-the-marketing-device-a-protobuf-short-story-2p7p). | ||
| The repository includes a [small benchmark](./bench). It compares protobuf.js reflection and static code against JSON encode/decode, protoc-gen-js, and protoc-gen-es. Results depend on hardware, Node.js version, and message shape, so they should be treated as indicative rather than absolute. | ||
| ## Performance | ||
| <details> | ||
| <summary>Benchmark run on AMD Ryzen 9 9950X3D with Node.js 24.15.0</summary> | ||
| In both reflection and reflection-free modes, protobuf.js builds specialized encoders and decoders on top of hand-tuned reader and writer primitives, making it a strong fit from battery-powered devices to high-traffic servers, or generally for projects and their downstream users adopting protobuf as a faster, smaller alternative to JSON. | ||
| ``` | ||
| benchmarking encode performance ... | ||
| The repository includes a [small benchmark](./bench) over a common message shape, plus Mapbox's vector tile fixture and Buf's perf payload, both unmodified. For each case, it compares protobuf.js encode and decode throughput against JSON encode/decode, Google's protoc-gen-js, and Buf's protoc-gen-es. Results show that protobuf.js is consistently faster than the other Protobuf implementations, up to an order of magnitude on real-world data, and among the libraries tested, it is the only one that is an upgrade over using JSON. | ||
| protobuf.js reflect x 2,430,103 ops/sec ±0.62% (95 runs sampled) | ||
| protobuf.js static x 2,390,407 ops/sec ±0.42% (96 runs sampled) | ||
| JSON encode x 2,155,918 ops/sec ±0.63% (92 runs sampled) | ||
| protoc-gen-js x 995,429 ops/sec ±0.18% (98 runs sampled) | ||
| protoc-gen-es x 403,334 ops/sec ±0.14% (96 runs sampled) | ||
| <!-- BEGIN BENCHMARK DATA --> | ||
| protobuf.js reflect was fastest | ||
| protobuf.js static was 1.4% ops/sec slower (factor 1.0) | ||
| JSON encode was 11.3% ops/sec slower (factor 1.1) | ||
| protoc-gen-js was 58.9% ops/sec slower (factor 2.4) | ||
| protoc-gen-es was 83.3% ops/sec slower (factor 6.0) | ||
|  | ||
| benchmarking decode performance ... | ||
| | Case | protobuf.js static | protobuf.js reflect | JSON | protoc-gen-js | protoc-gen-es | | ||
| | --- | ---: | ---: | ---: | ---: | ---: | | ||
| | Common | 3.18M ops/s | 3.25M ops/s | 2.07M ops/s | 1.01M ops/s | 395K ops/s | | ||
| | Vector tile | 2.82K ops/s | 2.76K ops/s | 859 ops/s | 680 ops/s | 231 ops/s | | ||
| | Buf perf | 41.4K ops/s | 39.9K ops/s | 6.59K ops/s | 13.5K ops/s | 8.00K ops/s | | ||
| protobuf.js reflect x 6,440,387 ops/sec ±0.25% (97 runs sampled) | ||
| protobuf.js static x 6,463,283 ops/sec ±0.27% (101 runs sampled) | ||
| JSON decode x 1,409,923 ops/sec ±0.11% (97 runs sampled) | ||
| protoc-gen-js x 947,647 ops/sec ±0.15% (99 runs sampled) | ||
| protoc-gen-es x 731,819 ops/sec ±0.28% (98 runs sampled) | ||
|  | ||
| protobuf.js static was fastest | ||
| protobuf.js reflect was 0.3% ops/sec slower (factor 1.0) | ||
| JSON decode was 78.2% ops/sec slower (factor 4.6) | ||
| protoc-gen-js was 85.3% ops/sec slower (factor 6.8) | ||
| protoc-gen-es was 88.7% ops/sec slower (factor 8.8) | ||
| | Case | protobuf.js static | protobuf.js reflect | JSON | protoc-gen-js | protoc-gen-es | | ||
| | --- | ---: | ---: | ---: | ---: | ---: | | ||
| | Common | 6.11M ops/s | 6.09M ops/s | 1.31M ops/s | 790K ops/s | 710K ops/s | | ||
| | Vector tile | 2.45K ops/s | 2.78K ops/s | 1.04K ops/s | 858 ops/s | 392 ops/s | | ||
| | Buf perf | 72.5K ops/s | 66.4K ops/s | 19.0K ops/s | 21.1K ops/s | 14.2K ops/s | | ||
| benchmarking round-trip performance ... | ||
| <!-- END BENCHMARK DATA --> | ||
| protobuf.js reflect x 1,310,677 ops/sec ±0.21% (97 runs sampled) | ||
| protobuf.js static x 1,310,926 ops/sec ±0.26% (101 runs sampled) | ||
| JSON encode/decode x 741,714 ops/sec ±0.24% (99 runs sampled) | ||
| protoc-gen-js x 472,844 ops/sec ±0.09% (96 runs sampled) | ||
| protoc-gen-es x 254,044 ops/sec ±0.05% (101 runs sampled) | ||
| [Structured results](./bench/results/latest.json) of this run are available as committed artifacts. | ||
| protobuf.js reflect was fastest | ||
| protobuf.js static was 0.0% ops/sec slower (factor 1.0) | ||
| JSON encode/decode was 43.4% ops/sec slower (factor 1.8) | ||
| protoc-gen-js was 63.9% ops/sec slower (factor 2.8) | ||
| protoc-gen-es was 80.6% ops/sec slower (factor 5.2) | ||
| ``` | ||
| </details> | ||
| To run the benchmark yourself on your own hardware: | ||
| Run it locally with: | ||
| ```sh | ||
@@ -409,0 +408,0 @@ npm --prefix bench install |
+4
-7
@@ -144,9 +144,5 @@ "use strict"; | ||
| ("if(u===2){"); | ||
| if (!closed) gen | ||
| ("if(!(%s&&%s.length))", ref, ref) | ||
| ("%s=[]", ref); | ||
| gen | ||
| ("var c2=r.uint32()+r.pos"); | ||
| if (closed) { | ||
| gen | ||
| ("var c2=r.uint32()+r.pos") | ||
| ("while(r.pos<c2){") | ||
@@ -163,4 +159,5 @@ ("s=r.pos") | ||
| } else gen | ||
| ("while(r.pos<c2)") | ||
| ("%s.push(r.%s())", ref, type); | ||
| ("if(!(%s&&%s.length))", ref, ref) | ||
| ("%s=[]", ref) | ||
| ("r.%ss(%s)", type, ref); | ||
| gen | ||
@@ -167,0 +164,0 @@ ("continue") |
+1
-4
@@ -75,6 +75,3 @@ "use strict"; | ||
| ("w.uint32(%i).fork()", (field.id << 3 | 2) >>> 0) | ||
| ("for(var i=0;i<%s.length;++i)", ref) | ||
| ("w.%s(%s[i])", type, ref) | ||
| ("w.ldelim()"); | ||
| ("w.uint32(%i).%ss(%s)", (field.id << 3 | 2) >>> 0, type, ref); | ||
@@ -81,0 +78,0 @@ // Non-packed |
@@ -29,3 +29,2 @@ "use strict"; | ||
| function configure() { | ||
| exports.util._configure(); | ||
| exports.Writer._configure(exports.BufferWriter); | ||
@@ -32,0 +31,0 @@ exports.Reader._configure(exports.BufferReader); |
+23
-13
@@ -223,2 +223,5 @@ "use strict"; | ||
| function parseId(token, acceptNegative, max) { | ||
| if (token === null) { | ||
| throw illegal(token, "end of input"); | ||
| } | ||
| switch (token) { | ||
@@ -256,3 +259,3 @@ case "max": case "MAX": case "Max": | ||
| /* istanbul ignore if */ | ||
| if (!typeRefRe.test(pkg)) | ||
| if (pkg === null || !typeRefRe.test(pkg)) | ||
| throw illegal(pkg, "name"); | ||
@@ -394,3 +397,3 @@ | ||
| /* istanbul ignore if */ | ||
| if (!nameRe.test(token = next())) | ||
| if ((token = next()) === null || !nameRe.test(token)) | ||
| throw illegal(token, "type name"); | ||
@@ -462,2 +465,5 @@ | ||
| var type = next(); | ||
| if (type === null) { | ||
| throw illegal(type, "end of input"); | ||
| } | ||
| if (type === "group") { | ||
@@ -474,4 +480,8 @@ parseGroup(parent, rule, extend, depth); | ||
| // and the next token does not start with a period. | ||
| while (type.endsWith(".") || peek().startsWith(".")) { | ||
| type += next(); | ||
| while (type.endsWith(".") || (peek() || "").startsWith(".")) { | ||
| var part = next(); | ||
| if (part === null) { | ||
| throw illegal(part, "end of input"); | ||
| } | ||
| type += part; | ||
| } | ||
@@ -484,2 +494,5 @@ | ||
| var name = next(); | ||
| if (name === null) { | ||
| throw illegal(name, "end of input"); | ||
| } | ||
@@ -537,3 +550,3 @@ /* istanbul ignore if */ | ||
| /* istanbul ignore if */ | ||
| if (!nameRe.test(name)) | ||
| if (name === null || !nameRe.test(name)) | ||
| throw illegal(name, "name"); | ||
@@ -636,3 +649,3 @@ | ||
| /* istanbul ignore if */ | ||
| if (!nameRe.test(name)) | ||
| if (name === null || !nameRe.test(name)) | ||
| throw illegal(name, "name"); | ||
@@ -664,3 +677,3 @@ | ||
| /* istanbul ignore if */ | ||
| if (!nameRe.test(token = next())) | ||
| if ((token = next()) === null || !nameRe.test(token)) | ||
| throw illegal(token, "name"); | ||
@@ -684,3 +697,3 @@ | ||
| /* istanbul ignore if */ | ||
| if (!nameRe.test(token = next())) | ||
| if ((token = next()) === null || !nameRe.test(token)) | ||
| throw illegal(token, "name"); | ||
@@ -867,3 +880,2 @@ | ||
| parent.jsonName = value; | ||
| return; | ||
| } | ||
@@ -875,4 +887,2 @@ if (parent.setOption) | ||
| function setParsedOption(parent, name, value, propName) { | ||
| if (name === "json_name" && parent instanceof Field) | ||
| return; // lifted onto Field#jsonName above | ||
| if (parent.setParsedOption) | ||
@@ -899,3 +909,3 @@ parent.setParsedOption(name, value, propName); | ||
| /* istanbul ignore if */ | ||
| if (!nameRe.test(token = next())) | ||
| if ((token = next()) === null || !nameRe.test(token)) | ||
| throw illegal(token, "service name"); | ||
@@ -978,3 +988,3 @@ | ||
| /* istanbul ignore if */ | ||
| if (!typeRefRe.test(token = next())) | ||
| if ((token = next()) === null || !typeRefRe.test(token)) | ||
| throw illegal(token, "reference"); | ||
@@ -981,0 +991,0 @@ |
@@ -31,3 +31,3 @@ "use strict"; | ||
| * @type {Buffer} | ||
| */ | ||
| */ | ||
| } | ||
@@ -50,4 +50,2 @@ | ||
| BufferReader.prototype.raw = function read_raw_buffer(start, end) { | ||
| if (start === end) | ||
| return util.Buffer.alloc(0); | ||
| return this._slice.call(this.buf, start, end); | ||
@@ -54,0 +52,0 @@ }; |
+251
-21
@@ -18,3 +18,3 @@ "use strict"; | ||
| * Constructs a new reader instance using the specified buffer. | ||
| * @classdesc Wire format reader using `Uint8Array` if available, otherwise `Array`. | ||
| * @classdesc Wire format reader using `Uint8Array`. | ||
| * @constructor | ||
@@ -44,2 +44,8 @@ * @param {Uint8Array} buffer Buffer to read from | ||
| /** | ||
| * Cached DataView for packed reads. | ||
| * @type {DataView|null} | ||
| */ | ||
| this.view = null; | ||
| /** | ||
| * Whether to discard unknown fields while decoding. | ||
@@ -51,14 +57,10 @@ * @type {boolean} | ||
| var create_array = typeof Uint8Array !== "undefined" | ||
| ? function create_typed_array(buffer) { | ||
| if (buffer instanceof Uint8Array || Array.isArray(buffer)) | ||
| return new Reader(buffer); | ||
| throw Error("illegal buffer"); | ||
| } | ||
| /* istanbul ignore next */ | ||
| : function create_array(buffer) { | ||
| if (Array.isArray(buffer)) | ||
| return new Reader(buffer); | ||
| throw Error("illegal buffer"); | ||
| }; | ||
| function create_array(buffer) { | ||
| // TODO: Remove plain array reader support in the next major release. | ||
| if (Array.isArray(buffer)) | ||
| buffer = new Uint8Array(buffer); | ||
| if (buffer instanceof Uint8Array) | ||
| return new Reader(buffer); | ||
| throw Error("illegal buffer"); | ||
| } | ||
@@ -88,4 +90,2 @@ var create = function create() { | ||
| Reader.prototype._slice = util.Array.prototype.subarray || /* istanbul ignore next */ util.Array.prototype.slice; | ||
| /** | ||
@@ -98,8 +98,3 @@ * Returns raw bytes from the backing buffer without advancing the reader. | ||
| Reader.prototype.raw = function read_raw(start, end) { | ||
| if (Array.isArray(this.buf)) // plain array | ||
| return this.buf.slice(start, end); | ||
| if (start === end) // fix for IE 10/Win8 and others' subarray returning array of size 1 | ||
| return new this.buf.constructor(0); | ||
| return this._slice.call(this.buf, start, end); | ||
| return this.buf.subarray(start, end); | ||
| }; | ||
@@ -402,2 +397,237 @@ | ||
| /** | ||
| * Reads a packed repeated field of unsigned 32 bit varints. | ||
| * @param {number[]} [array] Array to read into; a new one is created if omitted | ||
| * @returns {number[]} Array read into | ||
| */ | ||
| Reader.prototype.uint32s = function read_uint32s(array) { | ||
| if (array === undefined) array = []; | ||
| var end = this.uint32() + this.pos; | ||
| while (this.pos < end) | ||
| array.push(this.uint32()); | ||
| return array; | ||
| }; | ||
| /** | ||
| * Reads a packed repeated field of signed 32 bit varints. | ||
| * @param {number[]} [array] Array to read into; a new one is created if omitted | ||
| * @returns {number[]} Array read into | ||
| */ | ||
| Reader.prototype.int32s = function read_int32s(array) { | ||
| if (array === undefined) array = []; | ||
| var end = this.uint32() + this.pos; | ||
| while (this.pos < end) | ||
| array.push(this.int32()); | ||
| return array; | ||
| }; | ||
| /** | ||
| * Reads a packed repeated field of zig-zag encoded signed 32 bit varints. | ||
| * @param {number[]} [array] Array to read into; a new one is created if omitted | ||
| * @returns {number[]} Array read into | ||
| */ | ||
| Reader.prototype.sint32s = function read_sint32s(array) { | ||
| if (array === undefined) array = []; | ||
| var end = this.uint32() + this.pos; | ||
| while (this.pos < end) | ||
| array.push(this.sint32()); | ||
| return array; | ||
| }; | ||
| /** | ||
| * Reads a packed repeated field of booleans. | ||
| * @param {boolean[]} [array] Array to read into; a new one is created if omitted | ||
| * @returns {boolean[]} Array read into | ||
| */ | ||
| Reader.prototype.bools = function read_bools(array) { | ||
| if (array === undefined) array = []; | ||
| var end = this.uint32() + this.pos; | ||
| while (this.pos < end) | ||
| array.push(this.bool()); | ||
| return array; | ||
| }; | ||
| // The view allocation only pays off when amortized over enough reads | ||
| var VIEW_THRESHOLD_FLOAT = 8, | ||
| VIEW_THRESHOLD_INT = 128; | ||
| function getLazyView(reader, count, threshold) { | ||
| var view = reader.view; | ||
| if (view || count < threshold) | ||
| return view; | ||
| var buf = reader.buf; | ||
| return reader.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength); | ||
| } | ||
| /** | ||
| * Reads a packed repeated field of unsigned 32 bit fixed values. | ||
| * @param {number[]} [array] Array to read into; a new one is created if omitted | ||
| * @returns {number[]} Array read into | ||
| */ | ||
| Reader.prototype.fixed32s = function read_fixed32s(array) { | ||
| if (array === undefined) array = []; | ||
| var len = this.uint32(), end = this.pos + len; | ||
| /* istanbul ignore if */ | ||
| if (end > this.len) throw indexOutOfRange(this, len); | ||
| var count = len >>> 2, i = array.length, pos = this.pos; | ||
| array.length = i + count; | ||
| var dv = getLazyView(this, count, VIEW_THRESHOLD_INT); | ||
| if (dv) | ||
| for (var k = 0; k < count; ++k, pos += 4) array[i++] = dv.getUint32(pos, true); | ||
| else { | ||
| var buf = this.buf; | ||
| for (var j = 0; j < count; ++j, pos += 4) array[i++] = readFixed32_end(buf, pos + 4); | ||
| } | ||
| this.pos = pos; | ||
| if (pos !== end) throw indexOutOfRange(this, 4); | ||
| return array; | ||
| }; | ||
| /** | ||
| * Reads a packed repeated field of signed 32 bit fixed values. | ||
| * @param {number[]} [array] Array to read into; a new one is created if omitted | ||
| * @returns {number[]} Array read into | ||
| */ | ||
| Reader.prototype.sfixed32s = function read_sfixed32s(array) { | ||
| if (array === undefined) array = []; | ||
| var len = this.uint32(), end = this.pos + len; | ||
| /* istanbul ignore if */ | ||
| if (end > this.len) throw indexOutOfRange(this, len); | ||
| var count = len >>> 2, i = array.length, pos = this.pos; | ||
| array.length = i + count; | ||
| var dv = getLazyView(this, count, VIEW_THRESHOLD_INT); | ||
| if (dv) | ||
| for (var k = 0; k < count; ++k, pos += 4) array[i++] = dv.getInt32(pos, true); | ||
| else { | ||
| var buf = this.buf; | ||
| for (var j = 0; j < count; ++j, pos += 4) array[i++] = readFixed32_end(buf, pos + 4) | 0; | ||
| } | ||
| this.pos = pos; | ||
| if (pos !== end) throw indexOutOfRange(this, 4); | ||
| return array; | ||
| }; | ||
| /** | ||
| * Reads a packed repeated field of floats (32 bit). | ||
| * @param {number[]} [array] Array to read into; a new one is created if omitted | ||
| * @returns {number[]} Array read into | ||
| */ | ||
| Reader.prototype.floats = function read_floats(array) { | ||
| if (array === undefined) array = []; | ||
| var len = this.uint32(), end = this.pos + len; | ||
| /* istanbul ignore if */ | ||
| if (end > this.len) throw indexOutOfRange(this, len); | ||
| var count = len >>> 2, i = array.length, pos = this.pos; | ||
| array.length = i + count; | ||
| var dv = getLazyView(this, count, VIEW_THRESHOLD_FLOAT); | ||
| if (dv) | ||
| for (var k = 0; k < count; ++k, pos += 4) array[i++] = dv.getFloat32(pos, true); | ||
| else { | ||
| var buf = this.buf; | ||
| for (var j = 0; j < count; ++j, pos += 4) array[i++] = util.float.readFloatLE(buf, pos); | ||
| } | ||
| this.pos = pos; | ||
| if (pos !== end) throw indexOutOfRange(this, 4); | ||
| return array; | ||
| }; | ||
| /** | ||
| * Reads a packed repeated field of doubles (64 bit float). | ||
| * @param {number[]} [array] Array to read into; a new one is created if omitted | ||
| * @returns {number[]} Array read into | ||
| */ | ||
| Reader.prototype.doubles = function read_doubles(array) { | ||
| if (array === undefined) array = []; | ||
| var len = this.uint32(), end = this.pos + len; | ||
| /* istanbul ignore if */ | ||
| if (end > this.len) throw indexOutOfRange(this, len); | ||
| var count = len >>> 3, i = array.length, pos = this.pos; | ||
| array.length = i + count; | ||
| var dv = getLazyView(this, count, VIEW_THRESHOLD_FLOAT); | ||
| if (dv) | ||
| for (var k = 0; k < count; ++k, pos += 8) array[i++] = dv.getFloat64(pos, true); | ||
| else { | ||
| var buf = this.buf; | ||
| for (var j = 0; j < count; ++j, pos += 8) array[i++] = util.float.readDoubleLE(buf, pos); | ||
| } | ||
| this.pos = pos; | ||
| if (pos !== end) throw indexOutOfRange(this, 8); | ||
| return array; | ||
| }; | ||
| /** | ||
| * Reads a packed repeated field of unsigned 64 bit varints. | ||
| * @param {Array.<Long|number>} [array] Array to read into; a new one is created if omitted | ||
| * @returns {Array.<Long|number>} Array read into | ||
| */ | ||
| Reader.prototype.uint64s = function read_uint64s(array) { | ||
| if (array === undefined) array = []; | ||
| var end = this.uint32() + this.pos; | ||
| while (this.pos < end) | ||
| array.push(this.uint64()); | ||
| return array; | ||
| }; | ||
| /** | ||
| * Reads a packed repeated field of signed 64 bit varints. | ||
| * @param {Array.<Long|number>} [array] Array to read into; a new one is created if omitted | ||
| * @returns {Array.<Long|number>} Array read into | ||
| */ | ||
| Reader.prototype.int64s = function read_int64s(array) { | ||
| if (array === undefined) array = []; | ||
| var end = this.uint32() + this.pos; | ||
| while (this.pos < end) | ||
| array.push(this.int64()); | ||
| return array; | ||
| }; | ||
| /** | ||
| * Reads a packed repeated field of zig-zag encoded signed 64 bit varints. | ||
| * @param {Array.<Long|number>} [array] Array to read into; a new one is created if omitted | ||
| * @returns {Array.<Long|number>} Array read into | ||
| */ | ||
| Reader.prototype.sint64s = function read_sint64s(array) { | ||
| if (array === undefined) array = []; | ||
| var end = this.uint32() + this.pos; | ||
| while (this.pos < end) | ||
| array.push(this.sint64()); | ||
| return array; | ||
| }; | ||
| /** | ||
| * Reads a packed repeated field of unsigned 64 bit fixed values. | ||
| * @param {Array.<Long|number>} [array] Array to read into; a new one is created if omitted | ||
| * @returns {Array.<Long|number>} Array read into | ||
| */ | ||
| Reader.prototype.fixed64s = function read_fixed64s(array) { | ||
| if (array === undefined) array = []; | ||
| var len = this.uint32(), end = this.pos + len, i = array.length; | ||
| /* istanbul ignore if */ | ||
| if (end > this.len) throw indexOutOfRange(this, len); | ||
| var count = len >>> 3; | ||
| array.length = i + count; // 8 bytes per value, count is known | ||
| for (var j = 0; j < count; ++j) | ||
| array[i++] = this.fixed64(); | ||
| if (this.pos !== end) throw indexOutOfRange(this, 8); | ||
| return array; | ||
| }; | ||
| /** | ||
| * Reads a packed repeated field of signed 64 bit fixed values. | ||
| * @param {Array.<Long|number>} [array] Array to read into; a new one is created if omitted | ||
| * @returns {Array.<Long|number>} Array read into | ||
| */ | ||
| Reader.prototype.sfixed64s = function read_sfixed64s(array) { | ||
| if (array === undefined) array = []; | ||
| var len = this.uint32(), end = this.pos + len, i = array.length; | ||
| /* istanbul ignore if */ | ||
| if (end > this.len) throw indexOutOfRange(this, len); | ||
| var count = len >>> 3; | ||
| array.length = i + count; // 8 bytes per value, count is known | ||
| for (var j = 0; j < count; ++j) | ||
| array[i++] = this.sfixed64(); | ||
| if (this.pos !== end) throw indexOutOfRange(this, 8); | ||
| return array; | ||
| }; | ||
| /** | ||
| * Reads a sequence of bytes preceeded by its length as a varint. | ||
@@ -404,0 +634,0 @@ * @returns {Uint8Array} Value read |
+9
-1
@@ -497,2 +497,10 @@ "use strict"; | ||
| // Resolve feature defaults incl. field presence before generating codecs | ||
| var root = this.root; | ||
| if (root && root._needsRecursiveFeatureResolution) { | ||
| var edition = root._edition || this._edition; | ||
| if (edition) | ||
| root._resolveFeaturesRecursive(edition); | ||
| } | ||
| var fullName = this.fullName, | ||
@@ -561,3 +569,3 @@ types = []; | ||
| Type.prototype.encodeDelimited = function encodeDelimited(message, writer) { | ||
| return this.encode(message, writer && writer.len ? writer.fork() : writer).ldelim(); | ||
| return this.encode(message, (writer || Writer.create()).fork()).ldelim(); | ||
| }; | ||
@@ -564,0 +572,0 @@ |
+12
-40
@@ -140,4 +140,4 @@ "use strict"; | ||
| var Buffer = util.global.Buffer; | ||
| // refuse to use non-node buffers if not explicitly assigned (perf reasons): | ||
| return Buffer.prototype.utf8Write ? Buffer : /* istanbul ignore next */ null; | ||
| // refuse to use non-node buffers if not explicitly assigned (perf reasons) | ||
| return Buffer.prototype.utf8Write || util.isNode ? Buffer : /* istanbul ignore next */ null; | ||
| } catch (e) { | ||
@@ -149,8 +149,2 @@ /* istanbul ignore next */ | ||
| // Internal alias of or polyfull for Buffer.from. | ||
| util._Buffer_from = null; | ||
| // Internal alias of or polyfill for Buffer.allocUnsafe. | ||
| util._Buffer_allocUnsafe = null; | ||
| /** | ||
@@ -162,12 +156,11 @@ * Creates a new buffer of whatever type supported by the environment. | ||
| util.newBuffer = function newBuffer(sizeOrArray) { | ||
| var Buffer = util.Buffer; | ||
| /* istanbul ignore next */ | ||
| return typeof sizeOrArray === "number" | ||
| ? util.Buffer | ||
| ? util._Buffer_allocUnsafe(sizeOrArray) | ||
| : new util.Array(sizeOrArray) | ||
| : util.Buffer | ||
| ? util._Buffer_from(sizeOrArray) | ||
| : typeof Uint8Array === "undefined" | ||
| ? sizeOrArray | ||
| : new Uint8Array(sizeOrArray); | ||
| ? Buffer | ||
| ? Buffer.allocUnsafe(sizeOrArray) | ||
| : new Uint8Array(sizeOrArray) | ||
| : Buffer | ||
| ? Buffer.from(sizeOrArray) | ||
| : new Uint8Array(sizeOrArray); | ||
| }; | ||
@@ -198,6 +191,7 @@ | ||
| /** | ||
| * Array implementation used in the browser. `Uint8Array` if supported, otherwise `Array`. | ||
| * Array implementation used in the browser. | ||
| * @type {Constructor<Uint8Array>} | ||
| * @deprecated Use `Uint8Array` instead. | ||
| */ | ||
| util.Array = typeof Uint8Array !== "undefined" ? Uint8Array /* istanbul ignore next */ : Array; | ||
| util.Array = Uint8Array; | ||
@@ -522,23 +516,1 @@ /** | ||
| }; | ||
| // Sets up buffer utility according to the environment (called in index-minimal) | ||
| util._configure = function() { | ||
| var Buffer = util.Buffer; | ||
| /* istanbul ignore if */ | ||
| if (!Buffer) { | ||
| util._Buffer_from = util._Buffer_allocUnsafe = null; | ||
| return; | ||
| } | ||
| // because node 4.x buffers are incompatible & immutable | ||
| // see: https://github.com/dcodeIO/protobuf.js/pull/665 | ||
| util._Buffer_from = Buffer.from !== Uint8Array.from && Buffer.from || | ||
| /* istanbul ignore next */ | ||
| function Buffer_from(value, encoding) { | ||
| return new Buffer(value, encoding); | ||
| }; | ||
| util._Buffer_allocUnsafe = Buffer.allocUnsafe || | ||
| /* istanbul ignore next */ | ||
| function Buffer_allocUnsafe(size) { | ||
| return new Buffer(size); | ||
| }; | ||
| }; |
+19
-17
| "use strict"; | ||
| /** | ||
| * A minimal UTF8 implementation for number arrays. | ||
| * A minimal UTF8 implementation. | ||
| * @memberof util | ||
@@ -10,3 +10,5 @@ * @namespace | ||
| replacementChar = "\ufffd", | ||
| looseDecoder = new TextDecoder("utf-8", { ignoreBOM: true }), | ||
| strictDecoder; | ||
| var TEXT_DECODER_MIN_LENGTH = 64; | ||
@@ -17,3 +19,3 @@ try { | ||
| // "fatal" option is not supported on Node.js compiled without ICU | ||
| strictDecoder = new TextDecoder("utf-8", { ignoreBOM: true }); | ||
| strictDecoder = looseDecoder; | ||
| } | ||
@@ -69,2 +71,9 @@ | ||
| function utf8_read_decoder(decoder, buffer, start, end) { | ||
| var source = start === 0 && end === buffer.length | ||
| ? buffer | ||
| : buffer.subarray(start, end); | ||
| return decoder.decode(source); | ||
| } | ||
| /** | ||
@@ -77,5 +86,7 @@ * Reads UTF8 bytes as a string. | ||
| */ | ||
| utf8.read = function utf8_read_ascii(buffer, start, end) { | ||
| utf8.read = function utf8_read_loose(buffer, start, end) { | ||
| if (end - start < 1) | ||
| return ""; | ||
| if (end - start >= TEXT_DECODER_MIN_LENGTH) | ||
| return utf8_read_decoder(looseDecoder, buffer, start, end); | ||
@@ -110,13 +121,2 @@ var str = "", | ||
| function utf8_read_strict(buffer, start, end) { | ||
| var source = start === 0 && end === buffer.length | ||
| ? buffer | ||
| : buffer.subarray | ||
| ? buffer.subarray(start, end) | ||
| : buffer.slice(start, end); | ||
| if (Array.isArray(source)) | ||
| source = Uint8Array.from(source); | ||
| return strictDecoder.decode(source); | ||
| } | ||
| /** | ||
@@ -129,5 +129,7 @@ * Reads UTF8 bytes as a string, rejecting invalid UTF8. | ||
| */ | ||
| utf8.readStrict = function utf8_read_strict_ascii(buffer, start, end) { | ||
| utf8.readStrict = function utf8_read_strict(buffer, start, end) { | ||
| if (end - start < 1) | ||
| return ""; | ||
| if (end - start >= TEXT_DECODER_MIN_LENGTH) | ||
| return utf8_read_decoder(strictDecoder, buffer, start, end); | ||
@@ -148,3 +150,3 @@ var str = "", | ||
| if ((c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8) & 0x80) | ||
| return str + utf8_read_strict(buffer, i, end); | ||
| return str + utf8_read_decoder(strictDecoder, buffer, i, end); | ||
| str += String.fromCharCode(c1, c2, c3, c4, c5, c6, c7, c8); | ||
@@ -156,3 +158,3 @@ } | ||
| if (c1 & 0x80) | ||
| return str + utf8_read_strict(buffer, i, end); | ||
| return str + utf8_read_decoder(strictDecoder, buffer, i, end); | ||
| str += String.fromCharCode(c1); | ||
@@ -159,0 +161,0 @@ } |
+33
-42
@@ -27,2 +27,4 @@ "use strict"; | ||
| var writeStringBuffer; | ||
| BufferWriter._configure = function () { | ||
@@ -35,15 +37,10 @@ /** | ||
| */ | ||
| BufferWriter.alloc = util._Buffer_allocUnsafe; | ||
| BufferWriter.alloc = util.Buffer && util.Buffer.allocUnsafe; | ||
| BufferWriter.writeBytesBuffer = util.Buffer && util.Buffer.prototype instanceof Uint8Array && util.Buffer.prototype.set.name === "set" | ||
| ? function writeBytesBuffer_set(val, buf, pos) { | ||
| buf.set(val, pos); // faster than copy (requires node >= 4 where Buffers extend Uint8Array and set is properly inherited) | ||
| // also works for plain array values | ||
| writeStringBuffer = util.Buffer && util.Buffer.prototype.utf8Write | ||
| ? function writeStringBuffer_utf8Write(val, buf, pos) { | ||
| return buf.utf8Write(val, pos); | ||
| } | ||
| /* istanbul ignore next */ | ||
| : function writeBytesBuffer_copy(val, buf, pos) { | ||
| if (val.copy) // Buffer values | ||
| val.copy(buf, pos, 0, val.length); | ||
| else for (var i = 0; i < val.length;) // plain array values | ||
| buf[pos++] = val[i++]; | ||
| : function writeStringBuffer_write(val, buf, pos) { | ||
| return buf.write(val, pos); | ||
| }; | ||
@@ -58,7 +55,10 @@ }; | ||
| if (util.isString(value)) | ||
| value = util._Buffer_from(value, "base64"); | ||
| value = util.Buffer.from(value, "base64"); | ||
| var len = value.length >>> 0; | ||
| this.uint32(len); | ||
| if (len) | ||
| this._push(BufferWriter.writeBytesBuffer, len, value); | ||
| if (len) { | ||
| this._reserve(len); | ||
| this.buf.set(value, this.pos); | ||
| this.pos += len; | ||
| } | ||
| return this; | ||
@@ -68,35 +68,26 @@ }; | ||
| /** | ||
| * Writes raw bytes without a tag or length prefix. | ||
| * @name BufferWriter#raw | ||
| * @function | ||
| * @param {Uint8Array} value Raw bytes | ||
| * @returns {BufferWriter} `this` | ||
| */ | ||
| BufferWriter.prototype.raw = function write_raw_buffer(value) { | ||
| var len = value.length >>> 0; | ||
| return len ? this._push(BufferWriter.writeBytesBuffer, len, value) : this; | ||
| }; | ||
| function writeStringBufferAscii(val, buf, pos) { | ||
| for (var i = 0; i < val.length;) | ||
| buf[pos++] = val.charCodeAt(i++); | ||
| } | ||
| function writeStringBuffer(val, buf, pos) { | ||
| if (val.length < 40) // plain js is faster for short strings (probably due to redundant assertions) | ||
| util.utf8.write(val, buf, pos); | ||
| else if (buf.utf8Write) | ||
| buf.utf8Write(val, pos); | ||
| else | ||
| buf.write(val, pos); | ||
| } | ||
| /** | ||
| * @override | ||
| */ | ||
| BufferWriter.prototype.string = function write_string_buffer(value) { | ||
| var n = value.length; | ||
| if (!n) { | ||
| this._reserve(1); | ||
| this.buf[this.pos++] = 0; | ||
| return this; | ||
| } | ||
| if (n < 0x80) { | ||
| this._reserve(n * 3 + 5); // worst case | ||
| var pos = this.pos, | ||
| buf = this.buf; | ||
| return this._delim(pos, | ||
| n < 40 | ||
| ? util.utf8.write(value, buf, pos + 1) | ||
| : writeStringBuffer(value, buf, pos + 1) | ||
| ); | ||
| } | ||
| var len = util.Buffer.byteLength(value); | ||
| this.uint32(len); | ||
| if (len) | ||
| this._push(len === value.length && len < 40 ? writeStringBufferAscii : writeStringBuffer, len, value); | ||
| this._reserve(len); | ||
| writeStringBuffer(value, this.buf, this.pos); | ||
| this.pos += len; | ||
| return this; | ||
@@ -103,0 +94,0 @@ }; |
+399
-194
@@ -13,113 +13,47 @@ "use strict"; | ||
| /** | ||
| * Constructs a new writer operation instance. | ||
| * @classdesc Scheduled writer operation. | ||
| * Constructs a new writer instance. | ||
| * @classdesc Wire format writer using `Uint8Array`. | ||
| * @constructor | ||
| * @param {function(*, Uint8Array, number)} fn Function to call | ||
| * @param {number} len Value byte length | ||
| * @param {*} val Value to write | ||
| * @ignore | ||
| */ | ||
| function Op(fn, len, val) { | ||
| function Writer() { | ||
| /** | ||
| * Function to call. | ||
| * @type {function(Uint8Array, number, *)} | ||
| */ | ||
| this.fn = fn; | ||
| /** | ||
| * Value byte length. | ||
| * Write cursor into {@link Writer#buf}. | ||
| * @type {number} | ||
| */ | ||
| this.len = len; | ||
| this.pos = 0; | ||
| /** | ||
| * Next operation. | ||
| * @type {Writer.Op|undefined} | ||
| * Backing buffer. | ||
| * @type {Uint8Array} | ||
| */ | ||
| this.next = undefined; | ||
| this.buf = this.constructor.alloc(64); | ||
| /** | ||
| * Value to write. | ||
| * @type {*} | ||
| * Cached DataView over {@link Writer#buf}. | ||
| * @type {DataView|null} | ||
| */ | ||
| this.val = val; // type varies | ||
| } | ||
| this.view = null; | ||
| /* istanbul ignore next */ | ||
| function noop() {} // eslint-disable-line no-empty-function | ||
| /** | ||
| * Constructs a new writer state instance. | ||
| * @classdesc Copied writer state. | ||
| * @memberof Writer | ||
| * @constructor | ||
| * @param {Writer} writer Writer to copy state from | ||
| * @ignore | ||
| */ | ||
| function State(writer) { | ||
| /** | ||
| * Current head. | ||
| * @type {Writer.Op} | ||
| * Stack of forked length-prefix positions. | ||
| * @type {Array<number>|null} | ||
| */ | ||
| this.head = writer.head; | ||
| /** | ||
| * Current tail. | ||
| * @type {Writer.Op} | ||
| */ | ||
| this.tail = writer.tail; | ||
| /** | ||
| * Current buffer length. | ||
| * @type {number} | ||
| */ | ||
| this.len = writer.len; | ||
| /** | ||
| * Next state. | ||
| * @type {State|null} | ||
| */ | ||
| this.next = writer.states; | ||
| this.states = null; | ||
| } | ||
| /** | ||
| * Constructs a new writer instance. | ||
| * @classdesc Wire format writer using `Uint8Array` if available, otherwise `Array`. | ||
| * @constructor | ||
| * Current write position. | ||
| * @name Writer#len | ||
| * @type {number} | ||
| * @deprecated Use {@link Writer#pos} instead. | ||
| */ | ||
| function Writer() { | ||
| Object.defineProperty(Writer.prototype, "len", { | ||
| configurable: true, | ||
| enumerable: true, | ||
| get: function get_len() { | ||
| return this.pos; | ||
| } | ||
| }); | ||
| /** | ||
| * Current length. | ||
| * @type {number} | ||
| */ | ||
| this.len = 0; | ||
| /** | ||
| * Operations head. | ||
| * @type {Object} | ||
| */ | ||
| this.head = new Op(noop, 0, 0); | ||
| /** | ||
| * Operations tail | ||
| * @type {Object} | ||
| */ | ||
| this.tail = this.head; | ||
| /** | ||
| * Linked forked states. | ||
| * @type {Object|null} | ||
| */ | ||
| this.states = null; | ||
| // When a value is written, the writer calculates its byte length and puts it into a linked | ||
| // list of operations to perform when finish() is called. This both allows us to allocate | ||
| // buffers of the exact required size and reduces the amount of work we have to do compared | ||
| // to first calculating over objects and then encoding over objects. In our case, the encoding | ||
| // part is just a linked list walk calling operations with already prepared values. | ||
| } | ||
| var create = function create() { | ||
@@ -151,28 +85,41 @@ return util.Buffer | ||
| Writer.alloc = function alloc(size) { | ||
| return new util.Array(size); | ||
| return new Uint8Array(size); | ||
| }; | ||
| // Use Uint8Array buffer pool in the browser, just like node does with buffers | ||
| /* istanbul ignore else */ | ||
| if (util.Array !== Array) | ||
| Writer.alloc = util.pool(Writer.alloc, util.Array.prototype.subarray); | ||
| Writer.alloc = util.pool(Writer.alloc, Uint8Array.prototype.subarray); | ||
| /** | ||
| * Pushes a new operation to the queue. | ||
| * @param {function(Uint8Array, number, *)} fn Function to call | ||
| * @param {number} len Value byte length | ||
| * @param {number} val Value to write | ||
| * @returns {Writer} `this` | ||
| * Calculates the number of bytes a value occupies as a varint. | ||
| * @param {number} value Value to size (unsigned) | ||
| * @returns {number} Byte length (1..5) | ||
| * @ignore | ||
| */ | ||
| function sizeVarint32(value) { | ||
| return value < 128 ? 1 | ||
| : value < 16384 ? 2 | ||
| : value < 2097152 ? 3 | ||
| : value < 268435456 ? 4 | ||
| : 5; | ||
| } | ||
| /** | ||
| * Ensures that at least `n` more bytes fit into the backing buffer, doubling it if not. | ||
| * @param {number} n Number of additional bytes required | ||
| * @returns {undefined} | ||
| * @private | ||
| */ | ||
| Writer.prototype._push = function push(fn, len, val) { | ||
| this.tail = this.tail.next = new Op(fn, len, val); | ||
| this.len += len; | ||
| return this; | ||
| Writer.prototype._reserve = function _reserve(n) { | ||
| var need = this.pos + n; | ||
| if (need > this.buf.length) { | ||
| var size = this.buf.length << 1; | ||
| if (size < need) | ||
| size = need; | ||
| var buf = this.constructor.alloc(size); | ||
| buf.set(this.buf.subarray(0, this.pos), 0); | ||
| this.buf = buf; | ||
| this.view = null; // invalidate | ||
| } | ||
| }; | ||
| function writeByte(val, buf, pos) { | ||
| buf[pos] = val & 255; | ||
| } | ||
| function writeStringAscii(val, buf, pos) { | ||
@@ -189,23 +136,6 @@ for (var i = 0; i < val.length;) | ||
| buf[pos] = val; | ||
| return pos + 1; | ||
| } | ||
| /** | ||
| * Constructs a new varint writer operation instance. | ||
| * @classdesc Scheduled varint writer operation. | ||
| * @extends Op | ||
| * @constructor | ||
| * @param {number} len Value byte length | ||
| * @param {number} val Value to write | ||
| * @ignore | ||
| */ | ||
| function VarintOp(len, val) { | ||
| this.len = len; | ||
| this.next = undefined; | ||
| this.val = val; | ||
| } | ||
| VarintOp.prototype = Object.create(Op.prototype); | ||
| VarintOp.prototype.fn = writeVarint32; | ||
| /** | ||
| * Writes an unsigned 32 bit value as a varint. | ||
@@ -216,12 +146,6 @@ * @param {number} value Value to write | ||
| Writer.prototype.uint32 = function write_uint32(value) { | ||
| // here, the call to this.push has been inlined and a varint specific Op subclass is used. | ||
| // uint32 is by far the most frequently used operation and benefits significantly from this. | ||
| this.len += (this.tail = this.tail.next = new VarintOp( | ||
| (value = value >>> 0) | ||
| < 128 ? 1 | ||
| : value < 16384 ? 2 | ||
| : value < 2097152 ? 3 | ||
| : value < 268435456 ? 4 | ||
| : 5, | ||
| value)).len; | ||
| value = value >>> 0; | ||
| this._reserve(5); | ||
| var pos = this.pos; | ||
| this.pos = writeVarint32(value, this.buf, pos); | ||
| return this; | ||
@@ -237,5 +161,9 @@ }; | ||
| Writer.prototype.int32 = function write_int32(value) { | ||
| return (value |= 0) < 0 | ||
| ? this._push(writeVarint64, 10, LongBits.fromNumber(value)) // 10 bytes per spec | ||
| : this.uint32(value); | ||
| if ((value |= 0) < 0) { // 10 bytes per spec | ||
| this._reserve(10); | ||
| writeVarint64(LongBits.fromNumber(value), this.buf, this.pos); | ||
| this.pos += 10; | ||
| return this; | ||
| } | ||
| return this.uint32(value); | ||
| }; | ||
@@ -264,3 +192,4 @@ | ||
| } | ||
| buf[pos++] = lo; | ||
| buf[pos] = lo; | ||
| return pos + 1; | ||
| } | ||
@@ -276,3 +205,6 @@ | ||
| var bits = LongBits.from(value); | ||
| return this._push(writeVarint64, bits.length(), bits); | ||
| this._reserve(10); | ||
| var pos = this.pos; | ||
| this.pos = writeVarint64(bits, this.buf, pos); | ||
| return this; | ||
| }; | ||
@@ -297,3 +229,6 @@ | ||
| var bits = LongBits.from(value).zzEncode(); | ||
| return this._push(writeVarint64, bits.length(), bits); | ||
| this._reserve(10); | ||
| var pos = this.pos; | ||
| this.pos = writeVarint64(bits, this.buf, pos); | ||
| return this; | ||
| }; | ||
@@ -307,3 +242,5 @@ | ||
| Writer.prototype.bool = function write_bool(value) { | ||
| return this._push(writeByte, 1, value ? 1 : 0); | ||
| this._reserve(1); | ||
| this.buf[this.pos++] = value ? 1 : 0; | ||
| return this; | ||
| }; | ||
@@ -324,3 +261,6 @@ | ||
| Writer.prototype.fixed32 = function write_fixed32(value) { | ||
| return this._push(writeFixed32, 4, value >>> 0); | ||
| this._reserve(4); | ||
| writeFixed32(value >>> 0, this.buf, this.pos); | ||
| this.pos += 4; | ||
| return this; | ||
| }; | ||
@@ -344,3 +284,7 @@ | ||
| var bits = LongBits.from(value); | ||
| return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi); | ||
| this._reserve(8); | ||
| writeFixed32(bits.lo, this.buf, this.pos); | ||
| writeFixed32(bits.hi, this.buf, this.pos + 4); | ||
| this.pos += 8; | ||
| return this; | ||
| }; | ||
@@ -364,3 +308,6 @@ | ||
| Writer.prototype.float = function write_float(value) { | ||
| return this._push(util.float.writeFloatLE, 4, value); | ||
| this._reserve(4); | ||
| util.float.writeFloatLE(value, this.buf, this.pos); | ||
| this.pos += 4; | ||
| return this; | ||
| }; | ||
@@ -375,15 +322,8 @@ | ||
| Writer.prototype.double = function write_double(value) { | ||
| return this._push(util.float.writeDoubleLE, 8, value); | ||
| this._reserve(8); | ||
| util.float.writeDoubleLE(value, this.buf, this.pos); | ||
| this.pos += 8; | ||
| return this; | ||
| }; | ||
| var writeBytes = util.Array.prototype.set | ||
| ? function writeBytes_set(val, buf, pos) { | ||
| buf.set(val, pos); // also works for plain array values | ||
| } | ||
| /* istanbul ignore next */ | ||
| : function writeBytes_for(val, buf, pos) { | ||
| for (var i = 0; i < val.length; ++i) | ||
| buf[pos + i] = val[i]; | ||
| }; | ||
| /** | ||
@@ -396,4 +336,7 @@ * Writes a sequence of bytes. | ||
| var len = value.length >>> 0; | ||
| if (!len) | ||
| return this._push(writeByte, 1, 0); | ||
| if (!len) { | ||
| this._reserve(1); | ||
| this.buf[this.pos++] = 0; | ||
| return this; | ||
| } | ||
| if (util.isString(value)) { | ||
@@ -404,3 +347,7 @@ var buf = Writer.alloc(len = base64.length(value)); | ||
| } | ||
| return this.uint32(len)._push(writeBytes, len, value); | ||
| this.uint32(len); | ||
| this._reserve(len); | ||
| this.buf.set(value, this.pos); | ||
| this.pos += len; | ||
| return this; | ||
| }; | ||
@@ -415,6 +362,27 @@ | ||
| var len = value.length >>> 0; | ||
| return len ? this._push(writeBytes, len, value) : this; | ||
| if (!len) | ||
| return this; | ||
| this._reserve(len); | ||
| this.buf.set(value, this.pos); | ||
| this.pos += len; | ||
| return this; | ||
| }; | ||
| /** | ||
| * Backfills the length varint. | ||
| * @param {number} pos Position of reserved length byte | ||
| * @param {number} len Length of content after length varint | ||
| * @returns {Writer} `this` | ||
| * @private | ||
| */ | ||
| Writer.prototype._delim = function _delim(pos, len) { | ||
| var n = sizeVarint32(len); | ||
| if (n > 1) | ||
| this.buf.copyWithin(pos + n, pos + 1, pos + 1 + len); | ||
| writeVarint32(len, this.buf, pos); | ||
| this.pos = pos + n + len; | ||
| return this; | ||
| }; | ||
| /** | ||
| * Writes a string. | ||
@@ -425,17 +393,241 @@ * @param {string} value Value to write | ||
| Writer.prototype.string = function write_string(value) { | ||
| var n = value.length; | ||
| if (!n) { | ||
| this._reserve(1); | ||
| this.buf[this.pos++] = 0; | ||
| return this; | ||
| } | ||
| if (n < 0x80) { | ||
| this._reserve(n * 3 + 5); // worst case | ||
| var lenPos = this.pos; | ||
| return this._delim(lenPos, utf8.write(value, this.buf, lenPos + 1)); | ||
| } | ||
| var len = utf8.length(value); | ||
| return len | ||
| ? this.uint32(len)._push(len === value.length ? writeStringAscii : utf8.write, len, value) | ||
| : this._push(writeByte, 1, 0); | ||
| this.uint32(len); | ||
| this._reserve(len); | ||
| if (len === value.length) | ||
| writeStringAscii(value, this.buf, this.pos); | ||
| else | ||
| utf8.write(value, this.buf, this.pos); | ||
| this.pos += len; | ||
| return this; | ||
| }; | ||
| /** | ||
| * Writes an array of unsigned 32 bit values as a packed repeated field. | ||
| * @param {number[]} value Values to write | ||
| * @returns {Writer} `this` | ||
| */ | ||
| Writer.prototype.uint32s = function write_uint32s(value) { | ||
| var n = value.length; | ||
| this._reserve(n * 5 + 5); // worst case: 5 bytes per value + length varint | ||
| var buf = this.buf, lenPos = this.pos, p = lenPos + 1; | ||
| for (var i = 0; i < n; ++i) | ||
| p = writeVarint32(value[i] >>> 0, buf, p); | ||
| return this._delim(lenPos, p - lenPos - 1); | ||
| }; | ||
| /** | ||
| * Writes an array of signed 32 bit values as a packed repeated field. | ||
| * @param {number[]} value Values to write | ||
| * @returns {Writer} `this` | ||
| */ | ||
| Writer.prototype.int32s = function write_int32s(value) { | ||
| var n = value.length; | ||
| this._reserve(n * 10 + 5); // worst case: 10 bytes per negative value + length varint | ||
| var buf = this.buf, lenPos = this.pos, pos = lenPos + 1, val; | ||
| for (var i = 0; i < n; ++i) { | ||
| if ((val = value[i] | 0) < 0) { // negatives are 10 bytes per spec | ||
| pos = writeVarint64(LongBits.fromNumber(val), buf, pos); | ||
| } else { | ||
| pos = writeVarint32(val, buf, pos); | ||
| } | ||
| } | ||
| return this._delim(lenPos, pos - lenPos - 1); | ||
| }; | ||
| /** | ||
| * Writes an array of 32 bit values as packed, zig-zag encoded varints. | ||
| * @param {number[]} value Values to write | ||
| * @returns {Writer} `this` | ||
| */ | ||
| Writer.prototype.sint32s = function write_sint32s(value) { | ||
| var n = value.length; | ||
| this._reserve(n * 5 + 5); | ||
| var buf = this.buf, lenPos = this.pos, pos = lenPos + 1; | ||
| for (var i = 0; i < n; ++i) | ||
| pos = writeVarint32((value[i] << 1 ^ value[i] >> 31) >>> 0, buf, pos); | ||
| return this._delim(lenPos, pos - lenPos - 1); | ||
| }; | ||
| /** | ||
| * Writes an array of unsigned 64 bit values as a packed repeated field. | ||
| * @param {Array.<Long|number|string>} value Values to write | ||
| * @returns {Writer} `this` | ||
| */ | ||
| Writer.prototype.uint64s = function write_uint64s(value) { | ||
| var n = value.length; | ||
| this._reserve(n * 10 + 5); | ||
| var buf = this.buf, lenPos = this.pos, pos = lenPos + 1; | ||
| for (var i = 0; i < n; ++i) { | ||
| pos = writeVarint64(LongBits.from(value[i]), buf, pos); | ||
| } | ||
| return this._delim(lenPos, pos - lenPos - 1); | ||
| }; | ||
| /** | ||
| * Writes an array of signed 64 bit values as a packed repeated field. | ||
| * @function | ||
| * @param {Array.<Long|number|string>} value Values to write | ||
| * @returns {Writer} `this` | ||
| */ | ||
| Writer.prototype.int64s = Writer.prototype.uint64s; | ||
| /** | ||
| * Writes an array of 64 bit values as packed, zig-zag encoded varints. | ||
| * @param {Array.<Long|number|string>} value Values to write | ||
| * @returns {Writer} `this` | ||
| */ | ||
| Writer.prototype.sint64s = function write_sint64s(value) { | ||
| var n = value.length; | ||
| this._reserve(n * 10 + 5); | ||
| var buf = this.buf, lenPos = this.pos, pos = lenPos + 1; | ||
| for (var i = 0; i < n; ++i) { | ||
| pos = writeVarint64(LongBits.from(value[i]).zzEncode(), buf, pos); | ||
| } | ||
| return this._delim(lenPos, pos - lenPos - 1); | ||
| }; | ||
| /** | ||
| * Writes an array of boolish values as a packed repeated field. | ||
| * @param {boolean[]} value Values to write | ||
| * @returns {Writer} `this` | ||
| */ | ||
| Writer.prototype.bools = function write_bools(value) { | ||
| var n = value.length; | ||
| this.uint32(n); // one byte per value | ||
| this._reserve(n); | ||
| var buf = this.buf, p = this.pos; | ||
| for (var i = 0; i < n; ++i) | ||
| buf[p++] = value[i] ? 1 : 0; | ||
| this.pos += n; | ||
| return this; | ||
| }; | ||
| // The view allocation only pays off when amortized over enough writes | ||
| var VIEW_THRESHOLD_FLOAT = 16, | ||
| VIEW_THRESHOLD_INT = 128; | ||
| function getLazyView(writer, count, threshold) { | ||
| var view = writer.view; | ||
| if (view || count < threshold) | ||
| return view; | ||
| var buf = writer.buf; | ||
| return writer.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength); | ||
| } | ||
| /** | ||
| * Writes an array of unsigned 32 bit values as packed, fixed 32 bits. | ||
| * @param {number[]} value Values to write | ||
| * @returns {Writer} `this` | ||
| */ | ||
| Writer.prototype.fixed32s = function write_fixed32s(value) { | ||
| var n = value.length, bytes = n * 4; | ||
| this.uint32(bytes); // length is known exactly | ||
| this._reserve(bytes); | ||
| var p = this.pos, i, dv = getLazyView(this, n, VIEW_THRESHOLD_INT); | ||
| if (dv) | ||
| for (i = 0; i < n; ++i) { dv.setUint32(p, value[i] >>> 0, true); p += 4; } | ||
| else { | ||
| var buf = this.buf; | ||
| for (i = 0; i < n; ++i) { writeFixed32(value[i] >>> 0, buf, p); p += 4; } | ||
| } | ||
| this.pos += bytes; | ||
| return this; | ||
| }; | ||
| /** | ||
| * Writes an array of signed 32 bit values as packed, fixed 32 bits. | ||
| * @function | ||
| * @param {number[]} value Values to write | ||
| * @returns {Writer} `this` | ||
| */ | ||
| Writer.prototype.sfixed32s = Writer.prototype.fixed32s; | ||
| /** | ||
| * Writes an array of unsigned 64 bit values as packed, fixed 64 bits. | ||
| * @param {Array.<Long|number|string>} value Values to write | ||
| * @returns {Writer} `this` | ||
| */ | ||
| Writer.prototype.fixed64s = function write_fixed64s(value) { | ||
| var n = value.length, bytes = n * 8; | ||
| this.uint32(bytes); | ||
| this._reserve(bytes); | ||
| var p = this.pos, i, bits, dv = getLazyView(this, n, VIEW_THRESHOLD_INT); | ||
| if (dv) | ||
| for (i = 0; i < n; ++i) { bits = LongBits.from(value[i]); dv.setUint32(p, bits.lo, true); dv.setUint32(p + 4, bits.hi, true); p += 8; } | ||
| else { | ||
| var buf = this.buf; | ||
| for (i = 0; i < n; ++i) { bits = LongBits.from(value[i]); writeFixed32(bits.lo, buf, p); writeFixed32(bits.hi, buf, p + 4); p += 8; } | ||
| } | ||
| this.pos += bytes; | ||
| return this; | ||
| }; | ||
| /** | ||
| * Writes an array of signed 64 bit values as packed, fixed 64 bits. | ||
| * @function | ||
| * @param {Array.<Long|number|string>} value Values to write | ||
| * @returns {Writer} `this` | ||
| */ | ||
| Writer.prototype.sfixed64s = Writer.prototype.fixed64s; | ||
| /** | ||
| * Writes an array of floats (32 bit) as a packed repeated field. | ||
| * @param {number[]} value Values to write | ||
| * @returns {Writer} `this` | ||
| */ | ||
| Writer.prototype.floats = function write_floats(value) { | ||
| var n = value.length, bytes = n * 4; | ||
| this.uint32(bytes); | ||
| this._reserve(bytes); | ||
| var p = this.pos, i, dv = getLazyView(this, n, VIEW_THRESHOLD_FLOAT); | ||
| if (dv) | ||
| for (i = 0; i < n; ++i) { dv.setFloat32(p, value[i], true); p += 4; } | ||
| else { | ||
| var buf = this.buf; | ||
| for (i = 0; i < n; ++i) { util.float.writeFloatLE(value[i], buf, p); p += 4; } | ||
| } | ||
| this.pos += bytes; | ||
| return this; | ||
| }; | ||
| /** | ||
| * Writes an array of doubles (64 bit float) as a packed repeated field. | ||
| * @param {number[]} value Values to write | ||
| * @returns {Writer} `this` | ||
| */ | ||
| Writer.prototype.doubles = function write_doubles(value) { | ||
| var n = value.length, bytes = n * 8; | ||
| this.uint32(bytes); | ||
| this._reserve(bytes); | ||
| var p = this.pos, i, dv = getLazyView(this, n, VIEW_THRESHOLD_FLOAT); | ||
| if (dv) | ||
| for (i = 0; i < n; ++i) { dv.setFloat64(p, value[i], true); p += 8; } | ||
| else { | ||
| var buf = this.buf; | ||
| for (i = 0; i < n; ++i) { util.float.writeDoubleLE(value[i], buf, p); p += 8; } | ||
| } | ||
| this.pos += bytes; | ||
| return this; | ||
| }; | ||
| /** | ||
| * Forks this writer's state by pushing it to a stack. | ||
| * Calling {@link Writer#reset|reset} or {@link Writer#ldelim|ldelim} resets the writer to the previous state. | ||
| * @returns {Writer} `this` | ||
| */ | ||
| Writer.prototype.fork = function fork() { | ||
| this.states = new State(this); | ||
| this.head = this.tail = new Op(noop, 0, 0); | ||
| this.len = 0; | ||
| this._reserve(1); | ||
| (this.states || (this.states = [])).push(this.pos); | ||
| this.pos += 1; | ||
| return this; | ||
@@ -449,10 +641,7 @@ }; | ||
| Writer.prototype.reset = function reset() { | ||
| if (this.states) { | ||
| this.head = this.states.head; | ||
| this.tail = this.states.tail; | ||
| this.len = this.states.len; | ||
| this.states = this.states.next; | ||
| var states = this.states; | ||
| if (states && states.length) { | ||
| this.pos = states.pop(); | ||
| } else { | ||
| this.head = this.tail = new Op(noop, 0, 0); | ||
| this.len = 0; | ||
| this.pos = 0; | ||
| } | ||
@@ -463,14 +652,30 @@ return this; | ||
| /** | ||
| * Resets to the last state and appends the fork state's current write length as a varint followed by its operations. | ||
| * Resets to the last state and prepends the fork state's current write length as a varint. | ||
| * @returns {Writer} `this` | ||
| */ | ||
| Writer.prototype.ldelim = function ldelim() { | ||
| var head = this.head, | ||
| tail = this.tail, | ||
| len = this.len; | ||
| this.reset().uint32(len); | ||
| if (len) { | ||
| this.tail.next = head.next; // skip noop | ||
| this.tail = tail; | ||
| this.len += len; | ||
| var states = this.states, | ||
| len, | ||
| vlen; | ||
| if (states && states.length) { | ||
| var lenPos = states.pop(); | ||
| len = this.pos - lenPos - 1; | ||
| vlen = sizeVarint32(len); | ||
| if (vlen > 1) { // grow the reserved single byte and shift content forward | ||
| this._reserve(vlen - 1); | ||
| this.buf.copyWithin(lenPos + vlen, lenPos + 1, lenPos + 1 + len); | ||
| this.pos += vlen - 1; | ||
| writeVarint32(len, this.buf, lenPos); | ||
| } else { | ||
| this.buf[lenPos] = len; | ||
| } | ||
| } else { // not forked: prefix the entire buffer with its length | ||
| // TODO: Compatibility with older generated code. | ||
| // Remove this branch in the next major release. | ||
| len = this.pos; | ||
| vlen = sizeVarint32(len); | ||
| this._reserve(vlen); | ||
| this.buf.copyWithin(vlen, 0, len); | ||
| writeVarint32(len, this.buf, 0); | ||
| this.pos += vlen; | ||
| } | ||
@@ -482,6 +687,12 @@ return this; | ||
| * Finishes the write operation. | ||
| * Returns a buffer sized to the written data by default. | ||
| * @param {boolean} [shared=false] Whether to return a shared view instead of a unique copy | ||
| * @returns {Uint8Array} Finished buffer | ||
| */ | ||
| Writer.prototype.finish = function finish() { | ||
| return this.finishInto(this.constructor.alloc(this.len), 0); | ||
| Writer.prototype.finish = function finish(shared) { | ||
| if (shared) | ||
| return this.buf.subarray(0, this.pos); | ||
| var buf = this.constructor.alloc(this.pos); | ||
| buf.set(this.buf.subarray(0, this.pos), 0); | ||
| return buf; | ||
| }; | ||
@@ -492,3 +703,3 @@ | ||
| * The caller must ensure that `buf` has enough space starting at `offset` | ||
| * to hold {@link Writer#len} bytes. | ||
| * to hold {@link Writer#pos} bytes. | ||
| * @param {T} buf Target buffer | ||
@@ -502,9 +713,3 @@ * @param {number} [offset=0] Offset to start writing at | ||
| offset = 0; | ||
| var head = this.head.next, | ||
| pos = offset; | ||
| while (head) { | ||
| head.fn(head.val, buf, pos); | ||
| pos += head.len; | ||
| head = head.next; | ||
| } | ||
| buf.set(this.buf.subarray(0, this.pos), offset); | ||
| return buf; | ||
@@ -511,0 +716,0 @@ }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
3682011
5.54%40961
4.56%441
-0.23%