protons-runtime
Advanced tools
Comparing version 5.0.3 to 5.0.4
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.ProtonsRuntime = factory()}(typeof self !== 'undefined' ? self : this, function () { | ||
"use strict";var ProtonsRuntime=(()=>{var Xt=Object.create;var I=Object.defineProperty;var Kt=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames;var Yt=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty;var g=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ee=(e,t)=>{for(var r in t)I(e,r,{get:t[r],enumerable:!0})},et=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Qt(t))!te.call(e,i)&&i!==r&&I(e,i,{get:()=>t[i],enumerable:!(n=Kt(t,i))||n.enumerable});return e};var N=(e,t,r)=>(r=e!=null?Xt(Yt(e)):{},et(t||!e||!e.__esModule?I(r,"default",{value:e,enumerable:!0}):r,e)),re=e=>et(I({},"__esModule",{value:!0}),e);var nt=g((ye,rt)=>{"use strict";rt.exports=ne;function ne(e,t){for(var r=new Array(arguments.length-1),n=0,i=2,s=!0;i<arguments.length;)r[n++]=arguments[i++];return new Promise(function(h,o){r[n]=function(l){if(s)if(s=!1,l)o(l);else{for(var y=new Array(arguments.length-1),E=0;E<y.length;)y[E++]=arguments[E];h.apply(null,y)}};try{e.apply(t||null,r)}catch(u){s&&(s=!1,o(u))}})}});var ut=g(st=>{"use strict";var O=st;O.length=function(t){var r=t.length;if(!r)return 0;for(var n=0;--r%4>1&&t.charAt(r)==="=";)++n;return Math.ceil(t.length*3)/4-n};var S=new Array(64),ot=new Array(123);for(m=0;m<64;)ot[S[m]=m<26?m+65:m<52?m+71:m<62?m-4:m-59|43]=m++;var m;O.encode=function(t,r,n){for(var i=null,s=[],f=0,h=0,o;r<n;){var u=t[r++];switch(h){case 0:s[f++]=S[u>>2],o=(u&3)<<4,h=1;break;case 1:s[f++]=S[o|u>>4],o=(u&15)<<2,h=2;break;case 2:s[f++]=S[o|u>>6],s[f++]=S[u&63],h=0;break}f>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),f=0)}return h&&(s[f++]=S[o],s[f++]=61,h===1&&(s[f++]=61)),i?(f&&i.push(String.fromCharCode.apply(String,s.slice(0,f))),i.join("")):String.fromCharCode.apply(String,s.slice(0,f))};var it="invalid encoding";O.decode=function(t,r,n){for(var i=n,s=0,f,h=0;h<t.length;){var o=t.charCodeAt(h++);if(o===61&&s>1)break;if((o=ot[o])===void 0)throw Error(it);switch(s){case 0:f=o,s=1;break;case 1:r[n++]=f<<2|(o&48)>>4,f=o,s=2;break;case 2:r[n++]=(f&15)<<4|(o&60)>>2,f=o,s=3;break;case 3:r[n++]=(f&3)<<6|o,s=0;break}}if(s===1)throw Error(it);return n-i};O.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}});var ht=g((me,ft)=>{"use strict";ft.exports=q;function q(){this._listeners={}}q.prototype.on=function(t,r,n){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:r,ctx:n||this}),this};q.prototype.off=function(t,r){if(t===void 0)this._listeners={};else if(r===void 0)this._listeners[t]=[];else for(var n=this._listeners[t],i=0;i<n.length;)n[i].fn===r?n.splice(i,1):++i;return this};q.prototype.emit=function(t){var r=this._listeners[t];if(r){for(var n=[],i=1;i<arguments.length;)n.push(arguments[i++]);for(i=0;i<r.length;)r[i].fn.apply(r[i++].ctx,n)}return this}});var yt=g((we,gt)=>{"use strict";gt.exports=at(at);function at(e){return typeof Float32Array<"u"?function(){var t=new Float32Array([-0]),r=new Uint8Array(t.buffer),n=r[3]===128;function i(o,u,l){t[0]=o,u[l]=r[0],u[l+1]=r[1],u[l+2]=r[2],u[l+3]=r[3]}function s(o,u,l){t[0]=o,u[l]=r[3],u[l+1]=r[2],u[l+2]=r[1],u[l+3]=r[0]}e.writeFloatLE=n?i:s,e.writeFloatBE=n?s:i;function f(o,u){return r[0]=o[u],r[1]=o[u+1],r[2]=o[u+2],r[3]=o[u+3],t[0]}function h(o,u){return r[3]=o[u],r[2]=o[u+1],r[1]=o[u+2],r[0]=o[u+3],t[0]}e.readFloatLE=n?f:h,e.readFloatBE=n?h:f}():function(){function t(n,i,s,f){var h=i<0?1:0;if(h&&(i=-i),i===0)n(1/i>0?0:2147483648,s,f);else if(isNaN(i))n(2143289344,s,f);else if(i>34028234663852886e22)n((h<<31|2139095040)>>>0,s,f);else if(i<11754943508222875e-54)n((h<<31|Math.round(i/1401298464324817e-60))>>>0,s,f);else{var o=Math.floor(Math.log(i)/Math.LN2),u=Math.round(i*Math.pow(2,-o)*8388608)&8388607;n((h<<31|o+127<<23|u)>>>0,s,f)}}e.writeFloatLE=t.bind(null,lt),e.writeFloatBE=t.bind(null,ct);function r(n,i,s){var f=n(i,s),h=(f>>31)*2+1,o=f>>>23&255,u=f&8388607;return o===255?u?NaN:h*(1/0):o===0?h*1401298464324817e-60*u:h*Math.pow(2,o-150)*(u+8388608)}e.readFloatLE=r.bind(null,pt),e.readFloatBE=r.bind(null,dt)}(),typeof Float64Array<"u"?function(){var t=new Float64Array([-0]),r=new Uint8Array(t.buffer),n=r[7]===128;function i(o,u,l){t[0]=o,u[l]=r[0],u[l+1]=r[1],u[l+2]=r[2],u[l+3]=r[3],u[l+4]=r[4],u[l+5]=r[5],u[l+6]=r[6],u[l+7]=r[7]}function s(o,u,l){t[0]=o,u[l]=r[7],u[l+1]=r[6],u[l+2]=r[5],u[l+3]=r[4],u[l+4]=r[3],u[l+5]=r[2],u[l+6]=r[1],u[l+7]=r[0]}e.writeDoubleLE=n?i:s,e.writeDoubleBE=n?s:i;function f(o,u){return r[0]=o[u],r[1]=o[u+1],r[2]=o[u+2],r[3]=o[u+3],r[4]=o[u+4],r[5]=o[u+5],r[6]=o[u+6],r[7]=o[u+7],t[0]}function h(o,u){return r[7]=o[u],r[6]=o[u+1],r[5]=o[u+2],r[4]=o[u+3],r[3]=o[u+4],r[2]=o[u+5],r[1]=o[u+6],r[0]=o[u+7],t[0]}e.readDoubleLE=n?f:h,e.readDoubleBE=n?h:f}():function(){function t(n,i,s,f,h,o){var u=f<0?1:0;if(u&&(f=-f),f===0)n(0,h,o+i),n(1/f>0?0:2147483648,h,o+s);else if(isNaN(f))n(0,h,o+i),n(2146959360,h,o+s);else if(f>17976931348623157e292)n(0,h,o+i),n((u<<31|2146435072)>>>0,h,o+s);else{var l;if(f<22250738585072014e-324)l=f/5e-324,n(l>>>0,h,o+i),n((u<<31|l/4294967296)>>>0,h,o+s);else{var y=Math.floor(Math.log(f)/Math.LN2);y===1024&&(y=1023),l=f*Math.pow(2,-y),n(l*4503599627370496>>>0,h,o+i),n((u<<31|y+1023<<20|l*1048576&1048575)>>>0,h,o+s)}}}e.writeDoubleLE=t.bind(null,lt,0,4),e.writeDoubleBE=t.bind(null,ct,4,0);function r(n,i,s,f,h){var o=n(f,h+i),u=n(f,h+s),l=(u>>31)*2+1,y=u>>>20&2047,E=4294967296*(u&1048575)+o;return y===2047?E?NaN:l*(1/0):y===0?l*5e-324*E:l*Math.pow(2,y-1075)*(E+4503599627370496)}e.readDoubleLE=r.bind(null,pt,0,4),e.readDoubleBE=r.bind(null,dt,4,0)}(),e}function lt(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function ct(e,t,r){t[r]=e>>>24,t[r+1]=e>>>16&255,t[r+2]=e>>>8&255,t[r+3]=e&255}function pt(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function dt(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}});var _t=g((exports,module)=>{"use strict";module.exports=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}});var wt=g(mt=>{"use strict";var T=mt;T.length=function(t){for(var r=0,n=0,i=0;i<t.length;++i)n=t.charCodeAt(i),n<128?r+=1:n<2048?r+=2:(n&64512)===55296&&(t.charCodeAt(i+1)&64512)===56320?(++i,r+=4):r+=3;return r};T.read=function(t,r,n){var i=n-r;if(i<1)return"";for(var s=null,f=[],h=0,o;r<n;)o=t[r++],o<128?f[h++]=o:o>191&&o<224?f[h++]=(o&31)<<6|t[r++]&63:o>239&&o<365?(o=((o&7)<<18|(t[r++]&63)<<12|(t[r++]&63)<<6|t[r++]&63)-65536,f[h++]=55296+(o>>10),f[h++]=56320+(o&1023)):f[h++]=(o&15)<<12|(t[r++]&63)<<6|t[r++]&63,h>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,f)),h=0);return s?(h&&s.push(String.fromCharCode.apply(String,f.slice(0,h))),s.join("")):String.fromCharCode.apply(String,f.slice(0,h))};T.write=function(t,r,n){for(var i=n,s,f,h=0;h<t.length;++h)s=t.charCodeAt(h),s<128?r[n++]=s:s<2048?(r[n++]=s>>6|192,r[n++]=s&63|128):(s&64512)===55296&&((f=t.charCodeAt(h+1))&64512)===56320?(s=65536+((s&1023)<<10)+(f&1023),++h,r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=s&63|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=s&63|128);return n-i}});var bt=g((be,Bt)=>{"use strict";Bt.exports=ie;function ie(e,t,r){var n=r||8192,i=n>>>1,s=null,f=n;return function(o){if(o<1||o>i)return e(o);f+o>n&&(s=e(n),f=0);var u=t.call(s,f,f+=o);return f&7&&(f=(f|7)+1),u}}});var At=g((xe,xt)=>{"use strict";xt.exports=d;var D=F();function d(e,t){this.lo=e>>>0,this.hi=t>>>0}var L=d.zero=new d(0,0);L.toNumber=function(){return 0};L.zzEncode=L.zzDecode=function(){return this};L.length=function(){return 1};var oe=d.zeroHash="\0\0\0\0\0\0\0\0";d.fromNumber=function(t){if(t===0)return L;var r=t<0;r&&(t=-t);var n=t>>>0,i=(t-n)/4294967296>>>0;return r&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new d(n,i)};d.from=function(t){if(typeof t=="number")return d.fromNumber(t);if(D.isString(t))if(D.Long)t=D.Long.fromString(t);else return d.fromNumber(parseInt(t,10));return t.low||t.high?new d(t.low>>>0,t.high>>>0):L};d.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var r=~this.lo+1>>>0,n=~this.hi>>>0;return r||(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296};d.prototype.toLong=function(t){return D.Long?new D.Long(this.lo|0,this.hi|0,!!t):{low:this.lo|0,high:this.hi|0,unsigned:!!t}};var x=String.prototype.charCodeAt;d.fromHash=function(t){return t===oe?L:new d((x.call(t,0)|x.call(t,1)<<8|x.call(t,2)<<16|x.call(t,3)<<24)>>>0,(x.call(t,4)|x.call(t,5)<<8|x.call(t,6)<<16|x.call(t,7)<<24)>>>0)};d.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};d.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};d.prototype.zzDecode=function(){var t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this};d.prototype.length=function(){var t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}});var F=g(U=>{"use strict";var a=U;a.asPromise=nt();a.base64=ut();a.EventEmitter=ht();a.float=yt();a.inquire=_t();a.utf8=wt();a.pool=bt();a.LongBits=At();a.isNode=!!(typeof globalThis<"u"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node);a.global=a.isNode&&globalThis||typeof window<"u"&&window||typeof self<"u"&&self||U;a.emptyArray=Object.freeze?Object.freeze([]):[];a.emptyObject=Object.freeze?Object.freeze({}):{};a.isInteger=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};a.isString=function(t){return typeof t=="string"||t instanceof String};a.isObject=function(t){return t&&typeof t=="object"};a.isset=a.isSet=function(t,r){var n=t[r];return n!=null&&t.hasOwnProperty(r)?typeof n!="object"||(Array.isArray(n)?n.length:Object.keys(n).length)>0:!1};a.Buffer=function(){try{var e=a.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch{return null}}();a._Buffer_from=null;a._Buffer_allocUnsafe=null;a.newBuffer=function(t){return typeof t=="number"?a.Buffer?a._Buffer_allocUnsafe(t):new a.Array(t):a.Buffer?a._Buffer_from(t):typeof Uint8Array>"u"?t:new Uint8Array(t)};a.Array=typeof Uint8Array<"u"?Uint8Array:Array;a.Long=a.global.dcodeIO&&a.global.dcodeIO.Long||a.global.Long||a.inquire("long");a.key2Re=/^true|false|0|1$/;a.key32Re=/^-?(?:0|[1-9][0-9]*)$/;a.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;a.longToHash=function(t){return t?a.LongBits.from(t).toHash():a.LongBits.zeroHash};a.longFromHash=function(t,r){var n=a.LongBits.fromHash(t);return a.Long?a.Long.fromBits(n.lo,n.hi,r):n.toNumber(!!r)};function Et(e,t,r){for(var n=Object.keys(t),i=0;i<n.length;++i)(e[n[i]]===void 0||!r)&&(e[n[i]]=t[n[i]]);return e}a.merge=Et;a.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)};function Lt(e){function t(r,n){if(!(this instanceof t))return new t(r,n);Object.defineProperty(this,"message",{get:function(){return r}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:new Error().stack||""}),n&&Et(this,n)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return e},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}a.newError=Lt;a.ProtocolError=Lt("ProtocolError");a.oneOfGetter=function(t){for(var r={},n=0;n<t.length;++n)r[t[n]]=1;return function(){for(var i=Object.keys(this),s=i.length-1;s>-1;--s)if(r[i[s]]===1&&this[i[s]]!==void 0&&this[i[s]]!==null)return i[s]}};a.oneOfSetter=function(t){return function(r){for(var n=0;n<t.length;++n)t[n]!==r&&delete this[t[n]]}};a.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};a._configure=function(){var e=a.Buffer;if(!e){a._Buffer_from=a._Buffer_allocUnsafe=null;return}a._Buffer_from=e.from!==Uint8Array.from&&e.from||function(r,n){return new e(r,n)},a._Buffer_allocUnsafe=e.allocUnsafe||function(r){return new e(r)}}});var G=g((Ee,Nt)=>{"use strict";Nt.exports=p;var w=F(),V,St=w.LongBits,se=w.utf8;function B(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function p(e){this.buf=e,this.pos=0,this.len=e.length}var Ft=typeof Uint8Array<"u"?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new p(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new p(t);throw Error("illegal buffer")},kt=function(){return w.Buffer?function(r){return(p.create=function(i){return w.Buffer.isBuffer(i)?new V(i):Ft(i)})(r)}:Ft};p.create=kt();p.prototype._slice=w.Array.prototype.subarray||w.Array.prototype.slice;p.prototype.uint32=function(){var t=4294967295;return function(){if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,B(this,10);return t}}();p.prototype.int32=function(){return this.uint32()|0};p.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(t&1)|0};function W(){var e=new St(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw B(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw B(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}p.prototype.bool=function(){return this.uint32()!==0};function C(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}p.prototype.fixed32=function(){if(this.pos+4>this.len)throw B(this,4);return C(this.buf,this.pos+=4)};p.prototype.sfixed32=function(){if(this.pos+4>this.len)throw B(this,4);return C(this.buf,this.pos+=4)|0};function vt(){if(this.pos+8>this.len)throw B(this,8);return new St(C(this.buf,this.pos+=4),C(this.buf,this.pos+=4))}p.prototype.float=function(){if(this.pos+4>this.len)throw B(this,4);var t=w.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t};p.prototype.double=function(){if(this.pos+8>this.len)throw B(this,4);var t=w.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t};p.prototype.bytes=function(){var t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw B(this,t);if(this.pos+=t,Array.isArray(this.buf))return this.buf.slice(r,n);if(r===n){var i=w.Buffer;return i?i.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,r,n)};p.prototype.string=function(){var t=this.bytes();return se.read(t,0,t.length)};p.prototype.skip=function(t){if(typeof t=="number"){if(this.pos+t>this.len)throw B(this,t);this.pos+=t}else do if(this.pos>=this.len)throw B(this);while(this.buf[this.pos++]&128);return this};p.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this};p._configure=function(e){V=e,p.create=kt(),V._configure();var t=w.Long?"toLong":"toNumber";w.merge(p.prototype,{int64:function(){return W.call(this)[t](!1)},uint64:function(){return W.call(this)[t](!0)},sint64:function(){return W.call(this).zzDecode()[t](!1)},fixed64:function(){return vt.call(this)[t](!0)},sfixed64:function(){return vt.call(this)[t](!1)}})}});var Ot=g((Le,It)=>{"use strict";It.exports=v;var Mt=G();(v.prototype=Object.create(Mt.prototype)).constructor=v;var Dt=F();function v(e){Mt.call(this,e)}v._configure=function(){Dt.Buffer&&(v.prototype._slice=Dt.Buffer.prototype.slice)};v.prototype.string=function(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))};v._configure()});var Q=g((Fe,zt)=>{"use strict";zt.exports=c;var _=F(),P,R=_.LongBits,qt=_.base64,Ct=_.utf8;function M(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}function $(){}function ue(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function c(){this.len=0,this.head=new M($,0,0),this.tail=this.head,this.states=null}var Rt=function(){return _.Buffer?function(){return(c.create=function(){return new P})()}:function(){return new c}};c.create=Rt();c.alloc=function(t){return new _.Array(t)};_.Array!==Array&&(c.alloc=_.pool(c.alloc,_.Array.prototype.subarray));c.prototype._push=function(t,r,n){return this.tail=this.tail.next=new M(t,r,n),this.len+=r,this};function J(e,t,r){t[r]=e&255}function fe(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}function X(e,t){this.len=e,this.next=void 0,this.val=t}X.prototype=Object.create(M.prototype);X.prototype.fn=fe;c.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new X((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this};c.prototype.int32=function(t){return t<0?this._push(K,10,R.fromNumber(t)):this.uint32(t)};c.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)};function K(e,t,r){for(;e.hi;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}c.prototype.uint64=function(t){var r=R.from(t);return this._push(K,r.length(),r)};c.prototype.int64=c.prototype.uint64;c.prototype.sint64=function(t){var r=R.from(t).zzEncode();return this._push(K,r.length(),r)};c.prototype.bool=function(t){return this._push(J,1,t?1:0)};function Z(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}c.prototype.fixed32=function(t){return this._push(Z,4,t>>>0)};c.prototype.sfixed32=c.prototype.fixed32;c.prototype.fixed64=function(t){var r=R.from(t);return this._push(Z,4,r.lo)._push(Z,4,r.hi)};c.prototype.sfixed64=c.prototype.fixed64;c.prototype.float=function(t){return this._push(_.float.writeFloatLE,4,t)};c.prototype.double=function(t){return this._push(_.float.writeDoubleLE,8,t)};var he=_.Array.prototype.set?function(t,r,n){r.set(t,n)}:function(t,r,n){for(var i=0;i<t.length;++i)r[n+i]=t[i]};c.prototype.bytes=function(t){var r=t.length>>>0;if(!r)return this._push(J,1,0);if(_.isString(t)){var n=c.alloc(r=qt.length(t));qt.decode(t,n,0),t=n}return this.uint32(r)._push(he,r,t)};c.prototype.string=function(t){var r=Ct.length(t);return r?this.uint32(r)._push(Ct.write,r,t):this._push(J,1,0)};c.prototype.fork=function(){return this.states=new ue(this),this.head=this.tail=new M($,0,0),this.len=0,this};c.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 M($,0,0),this.len=0),this};c.prototype.ldelim=function(){var t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=t.next,this.tail=r,this.len+=n),this};c.prototype.finish=function(){for(var t=this.head.next,r=this.constructor.alloc(this.len),n=0;t;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r};c._configure=function(e){P=e,c.create=Rt(),P._configure()}});var Tt=g((ve,Ht)=>{"use strict";Ht.exports=b;var jt=Q();(b.prototype=Object.create(jt.prototype)).constructor=b;var A=F();function b(){jt.call(this)}b._configure=function(){b.alloc=A._Buffer_allocUnsafe,b.writeBytesBuffer=A.Buffer&&A.Buffer.prototype instanceof Uint8Array&&A.Buffer.prototype.set.name==="set"?function(t,r,n){r.set(t,n)}:function(t,r,n){if(t.copy)t.copy(r,n,0,t.length);else for(var i=0;i<t.length;)r[n++]=t[i++]}};b.prototype.bytes=function(t){A.isString(t)&&(t=A._Buffer_from(t,"base64"));var r=t.length>>>0;return this.uint32(r),r&&this._push(b.writeBytesBuffer,r,t),this};function ae(e,t,r){e.length<40?A.utf8.write(e,t,r):t.utf8Write?t.utf8Write(e,r):t.write(e,r)}b.prototype.string=function(t){var r=A.Buffer.byteLength(t);return this.uint32(r),r&&this._push(ae,r,t),this};b._configure()});var de={};ee(de,{decodeMessage:()=>Pt,encodeMessage:()=>Zt,enumeration:()=>$t,message:()=>Jt,reader:()=>z,writer:()=>j});var Y=N(G(),1),Ut=N(Ot(),1),Wt=N(F(),1),tt=N(Q(),1),Vt=N(Tt(),1);function le(){Wt.default._configure(),Y.default._configure(Ut.default),tt.default._configure(Vt.default)}le();var Gt=["uint64","int64","sint64","fixed64","sfixed64"];function ce(e){for(let t of Gt){if(e[t]==null)continue;let r=e[t];e[t]=function(){return BigInt(r.call(this).toString())}}return e}function z(e){return ce(new Y.default(e))}function pe(e){for(let t of Gt){if(e[t]==null)continue;let r=e[t];e[t]=function(n){return r.call(this,n.toString())}}return e}function j(){return pe(tt.default.create())}function Pt(e,t){let r=z(e instanceof Uint8Array?e:e.subarray());return t.decode(r)}function Zt(e,t){let r=j();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var k;(function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"})(k||(k={}));function H(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function $t(e){function t(i){if(e[i.toString()]==null)throw new Error("Invalid enum value");return e[i]}let r=function(s,f){let h=t(s);f.int32(h)},n=function(s){let f=s.int32();return t(f)};return H("enum",k.VARINT,r,n)}function Jt(e,t){return H("message",k.LENGTH_DELIMITED,e,t)}return re(de);})(); | ||
"use strict";var ProtonsRuntime=(()=>{var y=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var Q=(i,t)=>{for(var n in t)y(i,n,{get:t[n],enumerable:!0})},O=(i,t,n,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of J(t))!K.call(i,r)&&r!==n&&y(i,r,{get:()=>t[r],enumerable:!(e=q(t,r))||e.enumerable});return i};var P=i=>O(y({},"__esModule",{value:!0}),i);var rt={};Q(rt,{decodeMessage:()=>H,encodeMessage:()=>j,enumeration:()=>X,message:()=>Z,reader:()=>w,writer:()=>B});var A=new Float32Array([-0]),f=new Uint8Array(A.buffer);function _(i,t,n){A[0]=i,t[n]=f[0],t[n+1]=f[1],t[n+2]=f[2],t[n+3]=f[3]}function V(i,t){return f[0]=i[t],f[1]=i[t+1],f[2]=i[t+2],f[3]=i[t+3],A[0]}var F=new Float64Array([-0]),l=new Uint8Array(F.buffer);function M(i,t,n){F[0]=i,t[n]=l[0],t[n+1]=l[1],t[n+2]=l[2],t[n+3]=l[3],t[n+4]=l[4],t[n+5]=l[5],t[n+6]=l[6],t[n+7]=l[7]}function G(i,t){return l[0]=i[t],l[1]=i[t+1],l[2]=i[t+2],l[3]=i[t+3],l[4]=i[t+4],l[5]=i[t+5],l[6]=i[t+6],l[7]=i[t+7],F[0]}var u=class i{lo;hi;constructor(t,n){this.lo=t|0,this.hi=n|0}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let n=~this.lo+1>>>0,e=~this.hi>>>0;return n===0&&(e=e+1>>>0),-(BigInt(n)+(BigInt(e)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,n=(this.lo>>>28|this.hi<<4)>>>0,e=this.hi>>>24;return e===0?n===0?t<16384?t<128?1:2:t<2097152?3:4:n<16384?n<128?5:6:n<2097152?7:8:e<128?9:10}static fromBigInt(t){if(t===0n)return a;let n=t<0;n&&(t=-t);let e=Number(t>>32n),r=Number(t-(BigInt(e)<<32n));return n&&(e=~e>>>0,r=~r>>>0,++r>z&&(r=0,++e>z&&(e=0))),new i(r,e)}static fromNumber(t){if(t===0)return a;let n=t<0;n&&(t=-t);let e=t>>>0,r=(t-e)/4294967296>>>0;return n&&(r=~r>>>0,e=~e>>>0,++e>4294967295&&(e=0,++r>4294967295&&(r=0))),new i(e,r)}static from(t){return typeof t=="number"?i.fromNumber(t):typeof t=="bigint"?i.fromBigInt(t):typeof t=="string"?i.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new i(t.low>>>0,t.high>>>0):a}},a=new u(0,0);a.toBigInt=function(){return 0n};a.zzEncode=a.zzDecode=function(){return this};a.length=function(){return 1};var z=4294967296n;function W(i){let t=0,n=0;for(let e=0;e<i.length;++e)n=i.charCodeAt(e),n<128?t+=1:n<2048?t+=2:(n&64512)===55296&&(i.charCodeAt(e+1)&64512)===56320?(++e,t+=4):t+=3;return t}function $(i,t,n){if(n-t<1)return"";let r,h=[],s=0,o;for(;t<n;)o=i[t++],o<128?h[s++]=o:o>191&&o<224?h[s++]=(o&31)<<6|i[t++]&63:o>239&&o<365?(o=((o&7)<<18|(i[t++]&63)<<12|(i[t++]&63)<<6|i[t++]&63)-65536,h[s++]=55296+(o>>10),h[s++]=56320+(o&1023)):h[s++]=(o&15)<<12|(i[t++]&63)<<6|i[t++]&63,s>8191&&((r??(r=[])).push(String.fromCharCode.apply(String,h)),s=0);return r!=null?(s>0&&r.push(String.fromCharCode.apply(String,h.slice(0,s))),r.join("")):String.fromCharCode.apply(String,h.slice(0,s))}function L(i,t,n){let e=n,r,h;for(let s=0;s<i.length;++s)r=i.charCodeAt(s),r<128?t[n++]=r:r<2048?(t[n++]=r>>6|192,t[n++]=r&63|128):(r&64512)===55296&&((h=i.charCodeAt(s+1))&64512)===56320?(r=65536+((r&1023)<<10)+(h&1023),++s,t[n++]=r>>18|240,t[n++]=r>>12&63|128,t[n++]=r>>6&63|128,t[n++]=r&63|128):(t[n++]=r>>12|224,t[n++]=r>>6&63|128,t[n++]=r&63|128);return n-e}function c(i,t){return RangeError(`index out of range: ${i.pos} + ${t??1} > ${i.len}`)}function m(i,t){return(i[t-4]|i[t-3]<<8|i[t-2]<<16|i[t-1]<<24)>>>0}var D=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,c(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw c(this,4);return m(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw c(this,4);return m(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw c(this,4);let t=V(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw c(this,4);let t=G(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),n=this.pos,e=this.pos+t;if(e>this.len)throw c(this,t);return this.pos+=t,n===e?new Uint8Array(0):this.buf.subarray(n,e)}string(){let t=this.bytes();return $(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw c(this,t);this.pos+=t}else do if(this.pos>=this.len)throw c(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new u(0,0),n=0;if(this.len-this.pos>4){for(;n<4;++n)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<n*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;n=0}else{for(;n<3;++n){if(this.pos>=this.len)throw c(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<n*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<n*7)>>>0,t}if(this.len-this.pos>4){for(;n<5;++n)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<n*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;n<5;++n){if(this.pos>=this.len)throw c(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<n*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw c(this,8);let t=m(this.buf,this.pos+=4),n=m(this.buf,this.pos+=4);return new u(t,n)}int64(){return this.readLongVarint().toBigInt()}uint64(){return this.readLongVarint().toBigInt(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}fixed64(){return this.readFixed64().toBigInt()}sfixed64(){return this.readFixed64().toBigInt()}};function w(i){return new D(i instanceof Uint8Array?i:i.subarray())}function H(i,t){let n=w(i);return t.decode(n)}function S(i){return globalThis.Buffer!=null?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):i}function x(i=0){return globalThis.Buffer?.allocUnsafe!=null?S(globalThis.Buffer.allocUnsafe(i)):new Uint8Array(i)}function E(i){let t=i??8192,n=t>>>1,e,r=t;return function(s){if(s<1||s>n)return x(s);r+s>t&&(e=x(t),r=0);let o=e.subarray(r,r+=s);return r&7&&(r=(r|7)+1),o}}var p=class{fn;len;next;val;constructor(t,n,e){this.fn=t,this.len=n,this.next=void 0,this.val=e}};function T(){}var N=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Y=E();function v(i){return globalThis.Buffer!=null?x(i):Y(i)}var g=class{len;head;tail;states;constructor(){this.len=0,this.head=new p(T,0,0),this.tail=this.head,this.states=null}_push(t,n,e){return this.tail=this.tail.next=new p(t,n,e),this.len+=n,this}uint32(t){return this.len+=(this.tail=this.tail.next=new R((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(k,10,u.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let n=u.fromBigInt(t);return this._push(k,n.length(),n)}int64(t){return this.uint64(t)}sint64(t){let n=u.fromBigInt(t).zzEncode();return this._push(k,n.length(),n)}bool(t){return this._push(U,1,t?1:0)}fixed32(t){return this._push(b,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let n=u.fromBigInt(t);return this._push(b,4,n.lo)._push(b,4,n.hi)}sfixed64(t){return this.fixed64(t)}float(t){return this._push(_,4,t)}double(t){return this._push(M,8,t)}bytes(t){let n=t.length>>>0;return n===0?this._push(U,1,0):this.uint32(n)._push(it,n,t)}string(t){let n=W(t);return n!==0?this.uint32(n)._push(L,n,t):this._push(U,1,0)}fork(){return this.states=new N(this),this.head=this.tail=new p(T,0,0),this.len=0,this}reset(){return this.states!=null?(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 p(T,0,0),this.len=0),this}ldelim(){let t=this.head,n=this.tail,e=this.len;return this.reset().uint32(e),e!==0&&(this.tail.next=t.next,this.tail=n,this.len+=e),this}finish(){let t=this.head.next,n=v(this.len),e=0;for(;t!=null;)t.fn(t.val,n,e),e+=t.len,t=t.next;return n}};function U(i,t,n){t[n]=i&255}function tt(i,t,n){for(;i>127;)t[n++]=i&127|128,i>>>=7;t[n]=i}var R=class extends p{next;constructor(t,n){super(tt,t,n),this.next=void 0}};function k(i,t,n){for(;i.hi!==0;)t[n++]=i.lo&127|128,i.lo=(i.lo>>>7|i.hi<<25)>>>0,i.hi>>>=7;for(;i.lo>127;)t[n++]=i.lo&127|128,i.lo=i.lo>>>7;t[n++]=i.lo}function b(i,t,n){t[n]=i&255,t[n+1]=i>>>8&255,t[n+2]=i>>>16&255,t[n+3]=i>>>24}function it(i,t,n){t.set(i,n)}globalThis.Buffer!=null&&(g.prototype.bytes=function(i){let t=i.length>>>0;return this.uint32(t),t>0&&this._push(nt,t,i),this},g.prototype.string=function(i){let t=globalThis.Buffer.byteLength(i);return this.uint32(t),t>0&&this._push(et,t,i),this});function nt(i,t,n){t.set(i,n)}function et(i,t,n){i.length<40?L(i,t,n):t.utf8Write!=null?t.utf8Write(i,n):t.write(i,n)}function B(){return new g}function j(i,t){let n=B();return t.encode(i,n,{lengthDelimited:!1}),n.finish()}var d;(function(i){i[i.VARINT=0]="VARINT",i[i.BIT64=1]="BIT64",i[i.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",i[i.START_GROUP=3]="START_GROUP",i[i.END_GROUP=4]="END_GROUP",i[i.BIT32=5]="BIT32"})(d||(d={}));function I(i,t,n,e){return{name:i,type:t,encode:n,decode:e}}function X(i){function t(r){if(i[r.toString()]==null)throw new Error("Invalid enum value");return i[r]}let n=function(h,s){let o=t(h);s.int32(o)},e=function(h){let s=h.int32();return t(s)};return I("enum",d.VARINT,n,e)}function Z(i,t){return I("message",d.LENGTH_DELIMITED,i,t)}return P(rt);})(); | ||
return ProtonsRuntime})); |
@@ -1,6 +0,6 @@ | ||
import { reader } from './utils.js'; | ||
import { createReader } from './utils/reader.js'; | ||
export function decodeMessage(buf, codec) { | ||
const r = reader(buf instanceof Uint8Array ? buf : buf.subarray()); | ||
return codec.decode(r); | ||
const reader = createReader(buf); | ||
return codec.decode(reader); | ||
} | ||
//# sourceMappingURL=decode.js.map |
@@ -1,4 +0,4 @@ | ||
import { writer } from './utils.js'; | ||
import { createWriter } from './utils/writer.js'; | ||
export function encodeMessage(message, codec) { | ||
const w = writer(); | ||
const w = createWriter(); | ||
codec.encode(message, w, { | ||
@@ -5,0 +5,0 @@ lengthDelimited: false |
@@ -13,3 +13,4 @@ import type { Codec } from './codec.js'; | ||
export { message } from './codecs/message.js'; | ||
export { reader, writer } from './utils.js'; | ||
export { createReader as reader } from './utils/reader.js'; | ||
export { createWriter as writer } from './utils/writer.js'; | ||
export type { Codec, EncodeOptions } from './codec.js'; | ||
@@ -24,59 +25,59 @@ export interface Writer { | ||
*/ | ||
uint32(value: number): Writer; | ||
uint32(value: number): this; | ||
/** | ||
* Writes a signed 32 bit value as a varint` | ||
*/ | ||
int32(value: number): Writer; | ||
int32(value: number): this; | ||
/** | ||
* Writes a 32 bit value as a varint, zig-zag encoded | ||
*/ | ||
sint32(value: number): Writer; | ||
sint32(value: number): this; | ||
/** | ||
* Writes an unsigned 64 bit value as a varint | ||
*/ | ||
uint64(value: bigint): Writer; | ||
uint64(value: bigint): this; | ||
/** | ||
* Writes a signed 64 bit value as a varint | ||
*/ | ||
int64(value: bigint): Writer; | ||
int64(value: bigint): this; | ||
/** | ||
* Writes a signed 64 bit value as a varint, zig-zag encoded | ||
*/ | ||
sint64(value: bigint): Writer; | ||
sint64(value: bigint): this; | ||
/** | ||
* Writes a boolish value as a varint | ||
*/ | ||
bool(value: boolean): Writer; | ||
bool(value: boolean): this; | ||
/** | ||
* Writes an unsigned 32 bit value as fixed 32 bits | ||
*/ | ||
fixed32(value: number): Writer; | ||
fixed32(value: number): this; | ||
/** | ||
* Writes a signed 32 bit value as fixed 32 bits | ||
*/ | ||
sfixed32(value: number): Writer; | ||
sfixed32(value: number): this; | ||
/** | ||
* Writes an unsigned 64 bit value as fixed 64 bits | ||
*/ | ||
fixed64(value: bigint): Writer; | ||
fixed64(value: bigint): this; | ||
/** | ||
* Writes a signed 64 bit value as fixed 64 bits | ||
*/ | ||
sfixed64(value: bigint): Writer; | ||
sfixed64(value: bigint): this; | ||
/** | ||
* Writes a float (32 bit) | ||
*/ | ||
float(value: number): Writer; | ||
float(value: number): this; | ||
/** | ||
* Writes a double (64 bit float) | ||
*/ | ||
double(value: number): Writer; | ||
double(value: number): this; | ||
/** | ||
* Writes a sequence of bytes | ||
*/ | ||
bytes(value: Uint8Array): Writer; | ||
bytes(value: Uint8Array): this; | ||
/** | ||
* Writes a string | ||
*/ | ||
string(value: string): Writer; | ||
string(value: string): this; | ||
/** | ||
@@ -86,11 +87,11 @@ * Forks this writer's state by pushing it to a stack. | ||
*/ | ||
fork(): Writer; | ||
fork(): this; | ||
/** | ||
* Resets this instance to the last state. | ||
*/ | ||
reset(): Writer; | ||
reset(): this; | ||
/** | ||
* Resets to the last state and appends the fork state's current write length as a varint followed by its operations. | ||
*/ | ||
ldelim(): Writer; | ||
ldelim(): this; | ||
/** | ||
@@ -97,0 +98,0 @@ * Finishes the write operation |
@@ -5,3 +5,4 @@ export { decodeMessage } from './decode.js'; | ||
export { message } from './codecs/message.js'; | ||
export { reader, writer } from './utils.js'; | ||
export { createReader as reader } from './utils/reader.js'; | ||
export { createWriter as writer } from './utils/writer.js'; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "protons-runtime", | ||
"version": "5.0.3", | ||
"version": "5.0.4", | ||
"description": "Shared code to make your bundle smaller when running protons in your app", | ||
@@ -128,11 +128,8 @@ "license": "Apache-2.0 OR MIT", | ||
"dependencies": { | ||
"protobufjs": "^7.0.0", | ||
"uint8arraylist": "^2.4.3" | ||
"uint8arraylist": "^2.4.3", | ||
"uint8arrays": "^4.0.6" | ||
}, | ||
"devDependencies": { | ||
"aegir": "^41.0.4" | ||
}, | ||
"peerDependencies": { | ||
"uint8arraylist": "^2.3.2" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { reader } from './utils.js' | ||
import { createReader } from './utils/reader.js' | ||
import type { Codec } from './codec.js' | ||
@@ -6,5 +6,5 @@ import type { Uint8ArrayList } from 'uint8arraylist' | ||
export function decodeMessage <T> (buf: Uint8Array | Uint8ArrayList, codec: Codec<T>): T { | ||
const r = reader(buf instanceof Uint8Array ? buf : buf.subarray()) | ||
const reader = createReader(buf) | ||
return codec.decode(r) | ||
return codec.decode(reader) | ||
} |
@@ -1,6 +0,6 @@ | ||
import { writer } from './utils.js' | ||
import { createWriter } from './utils/writer.js' | ||
import type { Codec } from './codec.js' | ||
export function encodeMessage <T> (message: T, codec: Codec<T>): Uint8Array { | ||
const w = writer() | ||
const w = createWriter() | ||
@@ -7,0 +7,0 @@ codec.encode(message, w, { |
@@ -21,3 +21,4 @@ import type { Codec } from './codec.js' | ||
export { message } from './codecs/message.js' | ||
export { reader, writer } from './utils.js' | ||
export { createReader as reader } from './utils/reader.js' | ||
export { createWriter as writer } from './utils/writer.js' | ||
export type { Codec, EncodeOptions } from './codec.js' | ||
@@ -34,3 +35,3 @@ | ||
*/ | ||
uint32(value: number): Writer | ||
uint32(value: number): this | ||
@@ -40,3 +41,3 @@ /** | ||
*/ | ||
int32(value: number): Writer | ||
int32(value: number): this | ||
@@ -46,3 +47,3 @@ /** | ||
*/ | ||
sint32(value: number): Writer | ||
sint32(value: number): this | ||
@@ -52,3 +53,3 @@ /** | ||
*/ | ||
uint64(value: bigint): Writer | ||
uint64(value: bigint): this | ||
@@ -58,3 +59,3 @@ /** | ||
*/ | ||
int64(value: bigint): Writer | ||
int64(value: bigint): this | ||
@@ -64,3 +65,3 @@ /** | ||
*/ | ||
sint64(value: bigint): Writer | ||
sint64(value: bigint): this | ||
@@ -70,3 +71,3 @@ /** | ||
*/ | ||
bool(value: boolean): Writer | ||
bool(value: boolean): this | ||
@@ -76,3 +77,3 @@ /** | ||
*/ | ||
fixed32(value: number): Writer | ||
fixed32(value: number): this | ||
@@ -82,3 +83,3 @@ /** | ||
*/ | ||
sfixed32(value: number): Writer | ||
sfixed32(value: number): this | ||
@@ -88,3 +89,3 @@ /** | ||
*/ | ||
fixed64(value: bigint): Writer | ||
fixed64(value: bigint): this | ||
@@ -94,3 +95,3 @@ /** | ||
*/ | ||
sfixed64(value: bigint): Writer | ||
sfixed64(value: bigint): this | ||
@@ -100,3 +101,3 @@ /** | ||
*/ | ||
float(value: number): Writer | ||
float(value: number): this | ||
@@ -106,3 +107,3 @@ /** | ||
*/ | ||
double(value: number): Writer | ||
double(value: number): this | ||
@@ -112,3 +113,3 @@ /** | ||
*/ | ||
bytes(value: Uint8Array): Writer | ||
bytes(value: Uint8Array): this | ||
@@ -118,3 +119,3 @@ /** | ||
*/ | ||
string(value: string): Writer | ||
string(value: string): this | ||
@@ -125,3 +126,3 @@ /** | ||
*/ | ||
fork(): Writer | ||
fork(): this | ||
@@ -131,3 +132,3 @@ /** | ||
*/ | ||
reset(): Writer | ||
reset(): this | ||
@@ -137,3 +138,3 @@ /** | ||
*/ | ||
ldelim(): Writer | ||
ldelim(): this | ||
@@ -140,0 +141,0 @@ /** |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
134252
2
64
2799
1
+ Addeduint8arrays@^4.0.6
+ Addedmultiformats@12.1.3(transitive)
+ Addeduint8arrays@4.0.10(transitive)
- Removedprotobufjs@^7.0.0
- Removed@protobufjs/aspromise@1.1.2(transitive)
- Removed@protobufjs/base64@1.1.2(transitive)
- Removed@protobufjs/codegen@2.0.4(transitive)
- Removed@protobufjs/eventemitter@1.1.0(transitive)
- Removed@protobufjs/fetch@1.1.0(transitive)
- Removed@protobufjs/float@1.0.2(transitive)
- Removed@protobufjs/inquire@1.1.0(transitive)
- Removed@protobufjs/path@1.1.2(transitive)
- Removed@protobufjs/pool@1.1.0(transitive)
- Removed@protobufjs/utf8@1.1.0(transitive)
- Removed@types/node@22.10.2(transitive)
- Removedlong@5.2.3(transitive)
- Removedprotobufjs@7.4.0(transitive)
- Removedundici-types@6.20.0(transitive)