Socket
Socket
Sign inDemoInstall

rpc-websockets

Package Overview
Dependencies
Maintainers
1
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rpc-websockets - npm Package Compare versions

Comparing version 8.0.1 to 9.0.0

dist/index.browser.cjs.map

18

dist/index.browser-bundle.js

@@ -1,6 +0,14 @@

"use strict";var RPCWebsocket=(()=>{var et=Object.create;var je=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var nt=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty;var O=(r,e)=>()=>(r&&(e=r(r=0)),e);var N=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var it=(r,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of rt(e))!ot.call(r,s)&&s!==n&&je(r,s,{get:()=>e[s],enumerable:!(t=tt(e,s))||t.enumerable});return r};var ct=(r,e,n)=>(n=r!=null?et(nt(r)):{},it(e||!r||!r.__esModule?je(n,"default",{value:r,enumerable:!0}):n,r));function j(r){"@babel/helpers - typeof";return j=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},j(r)}var J=O(()=>{});function de(r,e){if(j(r)!="object"||!r)return r;var n=r[Symbol.toPrimitive];if(n!==void 0){var t=n.call(r,e||"default");if(j(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}var Le=O(()=>{J()});function H(r){var e=de(r,"string");return j(e)=="symbol"?e:e+""}var ve=O(()=>{J();Le()});function Se(r,e){for(var n=0;n<e.length;n++){var t=e[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,H(t.key),t)}}function C(r,e,n){return e&&Se(r.prototype,e),n&&Se(r,n),Object.defineProperty(r,"prototype",{writable:!1}),r}var Q=O(()=>{ve()});function R(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var U=O(()=>{});function ye(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}var Ce=O(()=>{});function F(r,e){if(e&&(j(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ye(r)}var ne=O(()=>{J();Ce()});function L(r){return L=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},L(r)}var oe=O(()=>{});function V(r,e){return V=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,s){return t.__proto__=s,t},V(r,e)}var Re=O(()=>{});function $(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&V(r,e)}var ie=O(()=>{Re()});function g(r,e,n){return e=H(e),e in r?Object.defineProperty(r,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[e]=n,r}var me=O(()=>{ve()});var ge=N((zt,_e)=>{"use strict";var at=Object.prototype.hasOwnProperty,k="~";function X(){}Object.create&&(X.prototype=Object.create(null),new X().__proto__||(k=!1));function ut(r,e,n){this.fn=r,this.context=e,this.once=n||!1}function qe(r,e,n,t,s){if(typeof n!="function")throw new TypeError("The listener must be a function");var o=new ut(n,t||r,s),a=k?k+e:e;return r._events[a]?r._events[a].fn?r._events[a]=[r._events[a],o]:r._events[a].push(o):(r._events[a]=o,r._eventsCount++),r}function ce(r,e){--r._eventsCount===0?r._events=new X:delete r._events[e]}function b(){this._events=new X,this._eventsCount=0}b.prototype.eventNames=function(){var e=[],n,t;if(this._eventsCount===0)return e;for(t in n=this._events)at.call(n,t)&&e.push(k?t.slice(1):t);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(n)):e};b.prototype.listeners=function(e){var n=k?k+e:e,t=this._events[n];if(!t)return[];if(t.fn)return[t.fn];for(var s=0,o=t.length,a=new Array(o);s<o;s++)a[s]=t[s].fn;return a};b.prototype.listenerCount=function(e){var n=k?k+e:e,t=this._events[n];return t?t.fn?1:t.length:0};b.prototype.emit=function(e,n,t,s,o,a){var l=k?k+e:e;if(!this._events[l])return!1;var c=this._events[l],v=arguments.length,m,y;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),v){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,n),!0;case 3:return c.fn.call(c.context,n,t),!0;case 4:return c.fn.call(c.context,n,t,s),!0;case 5:return c.fn.call(c.context,n,t,s,o),!0;case 6:return c.fn.call(c.context,n,t,s,o,a),!0}for(y=1,m=new Array(v-1);y<v;y++)m[y-1]=arguments[y];c.fn.apply(c.context,m)}else{var E=c.length,S;for(y=0;y<E;y++)switch(c[y].once&&this.removeListener(e,c[y].fn,void 0,!0),v){case 1:c[y].fn.call(c[y].context);break;case 2:c[y].fn.call(c[y].context,n);break;case 3:c[y].fn.call(c[y].context,n,t);break;case 4:c[y].fn.call(c[y].context,n,t,s);break;default:if(!m)for(S=1,m=new Array(v-1);S<v;S++)m[S-1]=arguments[S];c[y].fn.apply(c[y].context,m)}}return!0};b.prototype.on=function(e,n,t){return qe(this,e,n,t,!1)};b.prototype.once=function(e,n,t){return qe(this,e,n,t,!0)};b.prototype.removeListener=function(e,n,t,s){var o=k?k+e:e;if(!this._events[o])return this;if(!n)return ce(this,o),this;var a=this._events[o];if(a.fn)a.fn===n&&(!s||a.once)&&(!t||a.context===t)&&ce(this,o);else{for(var l=0,c=[],v=a.length;l<v;l++)(a[l].fn!==n||s&&!a[l].once||t&&a[l].context!==t)&&c.push(a[l]);c.length?this._events[o]=c.length===1?c[0]:c:ce(this,o)}return this};b.prototype.removeAllListeners=function(e){var n;return e?(n=k?k+e:e,this._events[n]&&ce(this,n)):(this._events=new X,this._eventsCount=0),this};b.prototype.off=b.prototype.removeListener;b.prototype.addListener=b.prototype.on;b.prefixed=k;b.EventEmitter=b;typeof _e<"u"&&(_e.exports=b)});var Me=N(be=>{"use strict";U();Q();ne();oe();ie();me();function st(r,e,n){return e=L(e),F(r,Te()?Reflect.construct(e,n||[],L(r).constructor):e.apply(r,n))}function Te(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Te=function(){return!!r})()}Object.defineProperty(be,"__esModule",{value:!0});var ft=ge(),lt=function(r){function e(n,t,s){var o;return R(this,e),o=st(this,e),g(o,"socket",void 0),o.socket=new window.WebSocket(n,s),o.socket.onopen=function(){return o.emit("open")},o.socket.onmessage=function(a){return o.emit("message",a.data)},o.socket.onerror=function(a){return o.emit("error",a)},o.socket.onclose=function(a){o.emit("close",a.code,a.reason)},o}return $(e,r),C(e,[{key:"send",value:function(t,s,o){var a=o||s;try{this.socket.send(t),a()}catch(l){a(l)}}},{key:"close",value:function(t,s){this.socket.close(t,s)}},{key:"addEventListener",value:function(t,s,o){this.socket.addEventListener(t,s,o)}}])}(ft.EventEmitter);function pt(r,e){return new lt(r,e)}be.default=pt});function Ie(r,e,n,t,s,o,a){try{var l=r[o](a),c=l.value}catch(v){n(v);return}l.done?e(c):Promise.resolve(c).then(t,s)}function K(r){return function(){var e=this,n=arguments;return new Promise(function(t,s){var o=r.apply(e,n);function a(c){Ie(o,t,s,a,l,"next",c)}function l(c){Ie(o,t,s,a,l,"throw",c)}a(void 0)})}}var Ne=O(()=>{});function we(r,e){if(r==null)return{};var n={},t=Object.keys(r),s,o;for(o=0;o<t.length;o++)s=t[o],!(e.indexOf(s)>=0)&&(n[s]=r[s]);return n}var De=O(()=>{});function ke(r,e){if(r==null)return{};var n=we(r,e),t,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);for(s=0;s<o.length;s++)t=o[s],!(e.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(r,t)&&(n[t]=r[t])}return n}var Ge=O(()=>{De()});var Ae=N((or,q)=>{function xe(r){"@babel/helpers - typeof";return q.exports=xe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},q.exports.__esModule=!0,q.exports.default=q.exports,xe(r)}q.exports=xe,q.exports.__esModule=!0,q.exports.default=q.exports});var Be=N((ir,T)=>{var Fe=Ae().default;function $e(){"use strict";T.exports=$e=function(){return e},T.exports.__esModule=!0,T.exports.default=T.exports;var r,e={},n=Object.prototype,t=n.hasOwnProperty,s=Object.defineProperty||function(f,i,u){f[i]=u.value},o=typeof Symbol=="function"?Symbol:{},a=o.iterator||"@@iterator",l=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function v(f,i,u){return Object.defineProperty(f,i,{value:u,enumerable:!0,configurable:!0,writable:!0}),f[i]}try{v({},"")}catch{v=function(u,p,d){return u[p]=d}}function m(f,i,u,p){var d=i&&i.prototype instanceof ue?i:ue,h=Object.create(d.prototype),_=new pe(p||[]);return s(h,"_invoke",{value:Xe(f,u,_)}),h}function y(f,i,u){try{return{type:"normal",arg:f.call(i,u)}}catch(p){return{type:"throw",arg:p}}}e.wrap=m;var E="suspendedStart",S="suspendedYield",Z="executing",B="completed",P={};function ue(){}function ee(){}function D(){}var se={};v(se,a,function(){return this});var fe=Object.getPrototypeOf,te=fe&&fe(fe(he([])));te&&te!==n&&t.call(te,a)&&(se=te);var W=D.prototype=ue.prototype=Object.create(se);function Pe(f){["next","throw","return"].forEach(function(i){v(f,i,function(u){return this._invoke(i,u)})})}function re(f,i){function u(d,h,_,w){var x=y(f[d],f,h);if(x.type!=="throw"){var G=x.arg,I=G.value;return I&&Fe(I)=="object"&&t.call(I,"__await")?i.resolve(I.__await).then(function(A){u("next",A,_,w)},function(A){u("throw",A,_,w)}):i.resolve(I).then(function(A){G.value=A,_(G)},function(A){return u("throw",A,_,w)})}w(x.arg)}var p;s(this,"_invoke",{value:function(h,_){function w(){return new i(function(x,G){u(h,_,x,G)})}return p=p?p.then(w,w):w()}})}function Xe(f,i,u){var p=E;return function(d,h){if(p===Z)throw Error("Generator is already running");if(p===B){if(d==="throw")throw h;return{value:r,done:!0}}for(u.method=d,u.arg=h;;){var _=u.delegate;if(_){var w=Ee(_,u);if(w){if(w===P)continue;return w}}if(u.method==="next")u.sent=u._sent=u.arg;else if(u.method==="throw"){if(p===E)throw p=B,u.arg;u.dispatchException(u.arg)}else u.method==="return"&&u.abrupt("return",u.arg);p=Z;var x=y(f,i,u);if(x.type==="normal"){if(p=u.done?B:S,x.arg===P)continue;return{value:x.arg,done:u.done}}x.type==="throw"&&(p=B,u.method="throw",u.arg=x.arg)}}}function Ee(f,i){var u=i.method,p=f.iterator[u];if(p===r)return i.delegate=null,u==="throw"&&f.iterator.return&&(i.method="return",i.arg=r,Ee(f,i),i.method==="throw")||u!=="return"&&(i.method="throw",i.arg=new TypeError("The iterator does not provide a '"+u+"' method")),P;var d=y(p,f.iterator,i.arg);if(d.type==="throw")return i.method="throw",i.arg=d.arg,i.delegate=null,P;var h=d.arg;return h?h.done?(i[f.resultName]=h.value,i.next=f.nextLoc,i.method!=="return"&&(i.method="next",i.arg=r),i.delegate=null,P):h:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,P)}function Ze(f){var i={tryLoc:f[0]};1 in f&&(i.catchLoc=f[1]),2 in f&&(i.finallyLoc=f[2],i.afterLoc=f[3]),this.tryEntries.push(i)}function le(f){var i=f.completion||{};i.type="normal",delete i.arg,f.completion=i}function pe(f){this.tryEntries=[{tryLoc:"root"}],f.forEach(Ze,this),this.reset(!0)}function he(f){if(f||f===""){var i=f[a];if(i)return i.call(f);if(typeof f.next=="function")return f;if(!isNaN(f.length)){var u=-1,p=function d(){for(;++u<f.length;)if(t.call(f,u))return d.value=f[u],d.done=!1,d;return d.value=r,d.done=!0,d};return p.next=p}}throw new TypeError(Fe(f)+" is not iterable")}return ee.prototype=D,s(W,"constructor",{value:D,configurable:!0}),s(D,"constructor",{value:ee,configurable:!0}),ee.displayName=v(D,c,"GeneratorFunction"),e.isGeneratorFunction=function(f){var i=typeof f=="function"&&f.constructor;return!!i&&(i===ee||(i.displayName||i.name)==="GeneratorFunction")},e.mark=function(f){return Object.setPrototypeOf?Object.setPrototypeOf(f,D):(f.__proto__=D,v(f,c,"GeneratorFunction")),f.prototype=Object.create(W),f},e.awrap=function(f){return{__await:f}},Pe(re.prototype),v(re.prototype,l,function(){return this}),e.AsyncIterator=re,e.async=function(f,i,u,p,d){d===void 0&&(d=Promise);var h=new re(m(f,i,u,p),d);return e.isGeneratorFunction(i)?h:h.next().then(function(_){return _.done?_.value:h.next()})},Pe(W),v(W,c,"Generator"),v(W,a,function(){return this}),v(W,"toString",function(){return"[object Generator]"}),e.keys=function(f){var i=Object(f),u=[];for(var p in i)u.push(p);return u.reverse(),function d(){for(;u.length;){var h=u.pop();if(h in i)return d.value=h,d.done=!1,d}return d.done=!0,d}},e.values=he,pe.prototype={constructor:pe,reset:function(i){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(le),!i)for(var u in this)u.charAt(0)==="t"&&t.call(this,u)&&!isNaN(+u.slice(1))&&(this[u]=r)},stop:function(){this.done=!0;var i=this.tryEntries[0].completion;if(i.type==="throw")throw i.arg;return this.rval},dispatchException:function(i){if(this.done)throw i;var u=this;function p(G,I){return _.type="throw",_.arg=i,u.next=G,I&&(u.method="next",u.arg=r),!!I}for(var d=this.tryEntries.length-1;d>=0;--d){var h=this.tryEntries[d],_=h.completion;if(h.tryLoc==="root")return p("end");if(h.tryLoc<=this.prev){var w=t.call(h,"catchLoc"),x=t.call(h,"finallyLoc");if(w&&x){if(this.prev<h.catchLoc)return p(h.catchLoc,!0);if(this.prev<h.finallyLoc)return p(h.finallyLoc)}else if(w){if(this.prev<h.catchLoc)return p(h.catchLoc,!0)}else{if(!x)throw Error("try statement without catch or finally");if(this.prev<h.finallyLoc)return p(h.finallyLoc)}}}},abrupt:function(i,u){for(var p=this.tryEntries.length-1;p>=0;--p){var d=this.tryEntries[p];if(d.tryLoc<=this.prev&&t.call(d,"finallyLoc")&&this.prev<d.finallyLoc){var h=d;break}}h&&(i==="break"||i==="continue")&&h.tryLoc<=u&&u<=h.finallyLoc&&(h=null);var _=h?h.completion:{};return _.type=i,_.arg=u,h?(this.method="next",this.next=h.finallyLoc,P):this.complete(_)},complete:function(i,u){if(i.type==="throw")throw i.arg;return i.type==="break"||i.type==="continue"?this.next=i.arg:i.type==="return"?(this.rval=this.arg=i.arg,this.method="return",this.next="end"):i.type==="normal"&&u&&(this.next=u),P},finish:function(i){for(var u=this.tryEntries.length-1;u>=0;--u){var p=this.tryEntries[u];if(p.finallyLoc===i)return this.complete(p.completion,p.afterLoc),le(p),P}},catch:function(i){for(var u=this.tryEntries.length-1;u>=0;--u){var p=this.tryEntries[u];if(p.tryLoc===i){var d=p.completion;if(d.type==="throw"){var h=d.arg;le(p)}return h}}throw Error("illegal catch attempt")},delegateYield:function(i,u,p){return this.delegate={iterator:he(i),resultName:u,nextLoc:p},this.method==="next"&&(this.arg=r),P}},e}T.exports=$e,T.exports.__esModule=!0,T.exports.default=T.exports});var Ke=N((cr,We)=>{var ae=Be()();We.exports=ae;try{regeneratorRuntime=ae}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=ae:Function("r","regeneratorRuntime = r")(ae)}});var Ye=N(Y=>{"use strict";U();Q();Object.defineProperty(Y,"__esModule",{value:!0});Y.createError=Y.DefaultDataPack=void 0;var ht=new Map([[-32e3,"Event not provided"],[-32600,"Invalid Request"],[-32601,"Method not found"],[-32602,"Invalid params"],[-32603,"Internal error"],[-32604,"Params not found"],[-32605,"Method forbidden"],[-32606,"Event forbidden"],[-32700,"Parse error"]]),dt=function(){function r(){R(this,r)}return C(r,[{key:"encode",value:function(n){return JSON.stringify(n)}},{key:"decode",value:function(n){return JSON.parse(n)}}])}();Y.DefaultDataPack=dt;function vt(r,e){var n={code:r,message:ht.get(r)||"Internal Server Error"};return e&&(n.data=e),n}Y.createError=vt});var Qe=N(Oe=>{"use strict";Ne();J();Ge();U();Q();ne();oe();ie();me();var M=ct(Ke()),yt=["autoconnect","reconnect","reconnect_interval","max_reconnects"];function ze(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),n.push.apply(n,t)}return n}function Je(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ze(Object(n),!0).forEach(function(t){g(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):ze(Object(n)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(n,t))})}return r}function mt(r,e,n){return e=L(e),F(r,He()?Reflect.construct(e,n||[],L(r).constructor):e.apply(r,n))}function He(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(He=function(){return!!r})()}Object.defineProperty(Oe,"__esModule",{value:!0});var _t=ge(),gt=Ye(),bt=function(r){function e(n){var t,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"ws://localhost:8080",o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=o.autoconnect,l=a===void 0?!0:a,c=o.reconnect,v=c===void 0?!0:c,m=o.reconnect_interval,y=m===void 0?1e3:m,E=o.max_reconnects,S=E===void 0?5:E,Z=ke(o,yt),B=arguments.length>3?arguments[3]:void 0,P=arguments.length>4?arguments[4]:void 0;return R(this,e),t=mt(this,e),g(t,"address",void 0),g(t,"rpc_id",void 0),g(t,"queue",void 0),g(t,"options",void 0),g(t,"autoconnect",void 0),g(t,"ready",void 0),g(t,"reconnect",void 0),g(t,"reconnect_timer_id",void 0),g(t,"reconnect_interval",void 0),g(t,"max_reconnects",void 0),g(t,"rest_options",void 0),g(t,"current_reconnects",void 0),g(t,"generate_request_id",void 0),g(t,"socket",void 0),g(t,"webSocketFactory",void 0),g(t,"dataPack",void 0),t.webSocketFactory=n,t.queue={},t.rpc_id=0,t.address=s,t.autoconnect=l,t.ready=!1,t.reconnect=v,t.reconnect_timer_id=void 0,t.reconnect_interval=y,t.max_reconnects=S,t.rest_options=Z,t.current_reconnects=0,t.generate_request_id=B||function(){return++t.rpc_id},P?t.dataPack=P:t.dataPack=new gt.DefaultDataPack,t.autoconnect&&t._connect(t.address,Je({autoconnect:t.autoconnect,reconnect:t.reconnect,reconnect_interval:t.reconnect_interval,max_reconnects:t.max_reconnects},t.rest_options)),t}return $(e,r),C(e,[{key:"connect",value:function(){this.socket||this._connect(this.address,Je({autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects},this.rest_options))}},{key:"call",value:function(t,s,o,a){var l=this;return!a&&j(o)==="object"&&(a=o,o=null),new Promise(function(c,v){if(!l.ready)return v(new Error("socket not ready"));var m=l.generate_request_id(t,s),y={jsonrpc:"2.0",method:t,params:s||void 0,id:m};l.socket.send(l.dataPack.encode(y),a,function(E){if(E)return v(E);l.queue[m]={promise:[c,v]},o&&(l.queue[m].timeout=setTimeout(function(){delete l.queue[m],v(new Error("reply timeout"))},o))})})}},{key:"login",value:function(){var n=K(M.default.mark(function s(o){var a;return M.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this.call("rpc.login",o);case 2:if(a=c.sent,a){c.next=5;break}throw new Error("authentication failed");case 5:return c.abrupt("return",a);case 6:case"end":return c.stop()}},s,this)}));function t(s){return n.apply(this,arguments)}return t}()},{key:"listMethods",value:function(){var n=K(M.default.mark(function s(){return M.default.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this.call("__listMethods");case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}},s,this)}));function t(){return n.apply(this,arguments)}return t}()},{key:"notify",value:function(t,s){var o=this;return new Promise(function(a,l){if(!o.ready)return l(new Error("socket not ready"));var c={jsonrpc:"2.0",method:t,params:s};o.socket.send(o.dataPack.encode(c),function(v){if(v)return l(v);a()})})}},{key:"subscribe",value:function(){var n=K(M.default.mark(function s(o){var a;return M.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return typeof o=="string"&&(o=[o]),c.next=3,this.call("rpc.on",o);case 3:if(a=c.sent,!(typeof o=="string"&&a[o]!=="ok")){c.next=6;break}throw new Error("Failed subscribing to an event '"+o+"' with: "+a[o]);case 6:return c.abrupt("return",a);case 7:case"end":return c.stop()}},s,this)}));function t(s){return n.apply(this,arguments)}return t}()},{key:"unsubscribe",value:function(){var n=K(M.default.mark(function s(o){var a;return M.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return typeof o=="string"&&(o=[o]),c.next=3,this.call("rpc.off",o);case 3:if(a=c.sent,!(typeof o=="string"&&a[o]!=="ok")){c.next=6;break}throw new Error("Failed unsubscribing from an event with: "+a);case 6:return c.abrupt("return",a);case 7:case"end":return c.stop()}},s,this)}));function t(s){return n.apply(this,arguments)}return t}()},{key:"close",value:function(t,s){this.socket.close(t||1e3,s)}},{key:"setAutoReconnect",value:function(t){this.reconnect=t}},{key:"setReconnectInterval",value:function(t){this.reconnect_interval=t}},{key:"setMaxReconnects",value:function(t){this.max_reconnects=t}},{key:"_connect",value:function(t,s){var o=this;clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(t,s),this.socket.addEventListener("open",function(){o.ready=!0,o.emit("open"),o.current_reconnects=0}),this.socket.addEventListener("message",function(a){var l=a.data;l instanceof ArrayBuffer&&(l=Buffer.from(l).toString());try{l=o.dataPack.decode(l)}catch{return}if(l.notification&&o.listeners(l.notification).length){if(!Object.keys(l.params).length)return o.emit(l.notification);var c=[l.notification];if(l.params.constructor===Object)c.push(l.params);else for(var v=0;v<l.params.length;v++)c.push(l.params[v]);return Promise.resolve().then(function(){o.emit.apply(o,c)})}if(!o.queue[l.id])return l.method?Promise.resolve().then(function(){var m;o.emit(l.method,(m=l)===null||m===void 0?void 0:m.params)}):void 0;"error"in l=="result"in l&&o.queue[l.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),o.queue[l.id].timeout&&clearTimeout(o.queue[l.id].timeout),l.error?o.queue[l.id].promise[1](l.error):o.queue[l.id].promise[0](l.result),delete o.queue[l.id]}),this.socket.addEventListener("error",function(a){return o.emit("error",a)}),this.socket.addEventListener("close",function(a){var l=a.code,c=a.reason;o.ready&&setTimeout(function(){return o.emit("close",l,c)},0),o.ready=!1,o.socket=void 0,l!==1e3&&(o.current_reconnects++,o.reconnect&&(o.max_reconnects>o.current_reconnects||o.max_reconnects===0)&&(o.reconnect_timer_id=setTimeout(function(){return o._connect(t,s)},o.reconnect_interval)))})}}])}(_t.EventEmitter);Oe.default=bt});var Pt=N(z=>{Q();U();ne();oe();ie();function wt(r,e,n){return e=L(e),F(r,Ue()?Reflect.construct(e,n||[],L(r).constructor):e.apply(r,n))}function Ue(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ue=function(){return!!r})()}var Ve=z&&z.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(z,"__esModule",{value:!0});z.Client=void 0;var kt=Ve(Me()),xt=Ve(Qe()),Ot=function(r){function e(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"ws://localhost:8080",t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=t.autoconnect,o=s===void 0?!0:s,a=t.reconnect,l=a===void 0?!0:a,c=t.reconnect_interval,v=c===void 0?1e3:c,m=t.max_reconnects,y=m===void 0?5:m,E=arguments.length>2?arguments[2]:void 0;return R(this,e),wt(this,e,[kt.default,n,{autoconnect:o,reconnect:l,reconnect_interval:v,max_reconnects:y},E])}return $(e,r),C(e)}(xt.default);z.Client=Ot});return Pt();})();
/*! Bundled license information:
var RPCWebSocket = (function (exports) {
'use strict';
@babel/runtime/helpers/regeneratorRuntime.js:
(*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE *)
*/
var Rr=Object.create;var at=Object.defineProperty;var Pr=Object.getOwnPropertyDescriptor;var Lr=Object.getOwnPropertyNames,ct=Object.getOwnPropertySymbols,Nr=Object.getPrototypeOf,It=Object.prototype.hasOwnProperty,qt=Object.prototype.propertyIsEnumerable;var Bt=(h,u,c)=>u in h?at(h,u,{enumerable:!0,configurable:!0,writable:!0,value:c}):h[u]=c,_t=(h,u)=>{for(var c in u||(u={}))It.call(u,c)&&Bt(h,c,u[c]);if(ct)for(var c of ct(u))qt.call(u,c)&&Bt(h,c,u[c]);return h};var Dt=(h,u)=>{var c={};for(var l in h)It.call(h,l)&&u.indexOf(l)<0&&(c[l]=h[l]);if(h!=null&&ct)for(var l of ct(h))u.indexOf(l)<0&&qt.call(h,l)&&(c[l]=h[l]);return c};var it=(h,u)=>()=>(h&&(u=h(h=0)),u);var Wr=(h,u)=>()=>(u||h((u={exports:{}}).exports,u),u.exports),Mr=(h,u)=>{for(var c in u)at(h,c,{get:u[c],enumerable:!0});},Or=(h,u,c,l)=>{if(u&&typeof u=="object"||typeof u=="function")for(let p of Lr(u))!It.call(h,p)&&p!==c&&at(h,p,{get:()=>u[p],enumerable:!(l=Pr(u,p))||l.enumerable});return h};var jt=(h,u,c)=>(c=h!=null?Rr(Nr(h)):{},Or(!h||!h.__esModule?at(c,"default",{value:h,enumerable:!0}):c,h));var U=(h,u,c)=>Bt(h,typeof u!="symbol"?u+"":u,c);var T=it(()=>{});var j={};Mr(j,{_debugEnd:()=>Ce,_debugProcess:()=>Te,_events:()=>Ke,_eventsCount:()=>Xe,_exiting:()=>pe,_fatalExceptions:()=>xe,_getActiveHandles:()=>ye,_getActiveRequests:()=>de,_kill:()=>we,_linkedBinding:()=>ae,_maxListeners:()=>He,_preload_modules:()=>je,_rawDebug:()=>ue,_startProfilerIdleNotifier:()=>Re,_stopProfilerIdleNotifier:()=>Pe,_tickCallback:()=>Ue,abort:()=>Me,addListener:()=>Je,allowedNodeEnvironmentFlags:()=>be,arch:()=>Xt,argv:()=>Vt,argv0:()=>De,assert:()=>Ae,binding:()=>re,chdir:()=>oe,config:()=>le,cpuUsage:()=>lt,cwd:()=>ie,debugPort:()=>qe,default:()=>ir,dlopen:()=>fe,domain:()=>he,emit:()=>tr,emitWarning:()=>ee,env:()=>Qt,execArgv:()=>zt,execPath:()=>Fe,exit:()=>Ie,features:()=>ke,hasUncaughtExceptionCaptureCallback:()=>Se,hrtime:()=>pt,kill:()=>Be,listeners:()=>nr,memoryUsage:()=>Ee,moduleLoadList:()=>ce,nextTick:()=>Gt,off:()=>Ve,on:()=>K,once:()=>Qe,openStdin:()=>_e,pid:()=>Oe,platform:()=>Jt,ppid:()=>$e,prependListener:()=>er,prependOnceListener:()=>rr,reallyExit:()=>me,release:()=>se,removeAllListeners:()=>Ze,removeListener:()=>ze,resourceUsage:()=>ge,setSourceMapsEnabled:()=>Ye,setUncaughtExceptionCaptureCallback:()=>ve,stderr:()=>Ne,stdin:()=>We,stdout:()=>Le,title:()=>Kt,umask:()=>ne,uptime:()=>Ge,version:()=>Zt,versions:()=>te});function kt(h){throw new Error("Node.js process "+h+" is not supported by JSPM core outside of Node.js")}function $r(){!rt||!V||(rt=!1,V.length?H=V.concat(H):ht=-1,H.length&&Yt());}function Yt(){if(!rt){var h=setTimeout($r,0);rt=!0;for(var u=H.length;u;){for(V=H,H=[];++ht<u;)V&&V[ht].run();ht=-1,u=H.length;}V=null,rt=!1,clearTimeout(h);}}function Gt(h){var u=new Array(arguments.length-1);if(arguments.length>1)for(var c=1;c<arguments.length;c++)u[c-1]=arguments[c];H.push(new Ht(h,u)),H.length===1&&!rt&&setTimeout(Yt,0);}function Ht(h,u){this.fun=h,this.array=u;}function N(){}function ae(h){kt("_linkedBinding");}function fe(h){kt("dlopen");}function de(){return []}function ye(){return []}function Ae(h,u){if(!h)throw new Error(u||"assertion error")}function Se(){return !1}function Ge(){return J.now()/1e3}function pt(h){var u=Math.floor((Date.now()-J.now())*.001),c=J.now()*.001,l=Math.floor(c)+u,p=Math.floor(c%1*1e9);return h&&(l=l-h[0],p=p-h[1],p<0&&(l--,p+=At)),[l,p]}function K(){return ir}function nr(h){return []}var H,rt,V,ht,Kt,Xt,Jt,Qt,Vt,zt,Zt,te,ee,re,ne,ie,oe,se,ue,ce,he,pe,le,me,we,lt,ge,Ee,Be,Ie,_e,be,ke,xe,ve,Ue,Te,Ce,Re,Pe,Le,Ne,We,Me,Oe,$e,Fe,qe,De,je,Ye,J,bt,At,He,Ke,Xe,Je,Qe,Ve,ze,Ze,tr,er,rr,ir,or=it(()=>{T();R();C();H=[],rt=!1,ht=-1;Ht.prototype.run=function(){this.fun.apply(null,this.array);};Kt="browser",Xt="x64",Jt="browser",Qt={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},Vt=["/usr/bin/node"],zt=[],Zt="v16.8.0",te={},ee=function(h,u){console.warn((u?u+": ":"")+h);},re=function(h){kt("binding");},ne=function(h){return 0},ie=function(){return "/"},oe=function(h){},se={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};ue=N,ce=[];he={},pe=!1,le={};me=N,we=N,lt=function(){return {}},ge=lt,Ee=lt,Be=N,Ie=N,_e=N,be={};ke={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},xe=N,ve=N;Ue=N,Te=N,Ce=N,Re=N,Pe=N,Le=void 0,Ne=void 0,We=void 0,Me=N,Oe=2,$e=1,Fe="/bin/usr/node",qe=9229,De="node",je=[],Ye=N,J={now:typeof performance!="undefined"?performance.now.bind(performance):void 0,timing:typeof performance!="undefined"?performance.timing:void 0};J.now===void 0&&(bt=Date.now(),J.timing&&J.timing.navigationStart&&(bt=J.timing.navigationStart),J.now=()=>Date.now()-bt);At=1e9;pt.bigint=function(h){var u=pt(h);return typeof BigInt=="undefined"?u[0]*At+u[1]:BigInt(u[0]*At)+BigInt(u[1])};He=10,Ke={},Xe=0;Je=K,Qe=K,Ve=K,ze=K,Ze=K,tr=N,er=K,rr=K;ir={version:Zt,versions:te,arch:Xt,platform:Jt,release:se,_rawDebug:ue,moduleLoadList:ce,binding:re,_linkedBinding:ae,_events:Ke,_eventsCount:Xe,_maxListeners:He,on:K,addListener:Je,once:Qe,off:Ve,removeListener:ze,removeAllListeners:Ze,emit:tr,prependListener:er,prependOnceListener:rr,listeners:nr,domain:he,_exiting:pe,config:le,dlopen:fe,uptime:Ge,_getActiveRequests:de,_getActiveHandles:ye,reallyExit:me,_kill:we,cpuUsage:lt,resourceUsage:ge,memoryUsage:Ee,kill:Be,exit:Ie,openStdin:_e,allowedNodeEnvironmentFlags:be,assert:Ae,features:ke,_fatalExceptions:xe,setUncaughtExceptionCaptureCallback:ve,hasUncaughtExceptionCaptureCallback:Se,emitWarning:ee,nextTick:Gt,_tickCallback:Ue,_debugProcess:Te,_debugEnd:Ce,_startProfilerIdleNotifier:Re,_stopProfilerIdleNotifier:Pe,stdout:Le,stdin:We,stderr:Ne,abort:Me,umask:ne,chdir:oe,cwd:ie,env:Qt,title:Kt,argv:Vt,execArgv:zt,pid:Oe,ppid:$e,execPath:Fe,debugPort:qe,hrtime:pt,argv0:De,_preload_modules:je,setSourceMapsEnabled:Ye};});var C=it(()=>{or();});function Fr(){if(sr)return ot;sr=!0,ot.byteLength=E,ot.toByteArray=b,ot.fromByteArray=L;for(var h=[],u=[],c=typeof Uint8Array!="undefined"?Uint8Array:Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,f=l.length;p<f;++p)h[p]=l[p],u[l.charCodeAt(p)]=p;u[45]=62,u[95]=63;function i(y){var g=y.length;if(g%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var _=y.indexOf("=");_===-1&&(_=g);var S=_===g?0:4-_%4;return [_,S]}function E(y){var g=i(y),_=g[0],S=g[1];return (_+S)*3/4-S}function d(y,g,_){return (g+_)*3/4-_}function b(y){var g,_=i(y),S=_[0],$=_[1],v=new c(d(y,S,$)),F=0,D=$>0?S-4:S,M;for(M=0;M<D;M+=4)g=u[y.charCodeAt(M)]<<18|u[y.charCodeAt(M+1)]<<12|u[y.charCodeAt(M+2)]<<6|u[y.charCodeAt(M+3)],v[F++]=g>>16&255,v[F++]=g>>8&255,v[F++]=g&255;return $===2&&(g=u[y.charCodeAt(M)]<<2|u[y.charCodeAt(M+1)]>>4,v[F++]=g&255),$===1&&(g=u[y.charCodeAt(M)]<<10|u[y.charCodeAt(M+1)]<<4|u[y.charCodeAt(M+2)]>>2,v[F++]=g>>8&255,v[F++]=g&255),v}function B(y){return h[y>>18&63]+h[y>>12&63]+h[y>>6&63]+h[y&63]}function m(y,g,_){for(var S,$=[],v=g;v<_;v+=3)S=(y[v]<<16&16711680)+(y[v+1]<<8&65280)+(y[v+2]&255),$.push(B(S));return $.join("")}function L(y){for(var g,_=y.length,S=_%3,$=[],v=16383,F=0,D=_-S;F<D;F+=v)$.push(m(y,F,F+v>D?D:F+v));return S===1?(g=y[_-1],$.push(h[g>>2]+h[g<<4&63]+"==")):S===2&&(g=(y[_-2]<<8)+y[_-1],$.push(h[g>>10]+h[g>>4&63]+h[g<<2&63]+"=")),$.join("")}return ot}function qr(){if(ur)return ft;ur=!0;return ft.read=function(h,u,c,l,p){var f,i,E=p*8-l-1,d=(1<<E)-1,b=d>>1,B=-7,m=c?p-1:0,L=c?-1:1,y=h[u+m];for(m+=L,f=y&(1<<-B)-1,y>>=-B,B+=E;B>0;f=f*256+h[u+m],m+=L,B-=8);for(i=f&(1<<-B)-1,f>>=-B,B+=l;B>0;i=i*256+h[u+m],m+=L,B-=8);if(f===0)f=1-b;else {if(f===d)return i?NaN:(y?-1:1)*(1/0);i=i+Math.pow(2,l),f=f-b;}return (y?-1:1)*i*Math.pow(2,f-l)},ft.write=function(h,u,c,l,p,f){var i,E,d,b=f*8-p-1,B=(1<<b)-1,m=B>>1,L=p===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=l?0:f-1,g=l?1:-1,_=u<0||u===0&&1/u<0?1:0;for(u=Math.abs(u),isNaN(u)||u===1/0?(E=isNaN(u)?1:0,i=B):(i=Math.floor(Math.log(u)/Math.LN2),u*(d=Math.pow(2,-i))<1&&(i--,d*=2),i+m>=1?u+=L/d:u+=L*Math.pow(2,1-m),u*d>=2&&(i++,d/=2),i+m>=B?(E=0,i=B):i+m>=1?(E=(u*d-1)*Math.pow(2,p),i=i+m):(E=u*Math.pow(2,m-1)*Math.pow(2,p),i=0));p>=8;h[c+y]=E&255,y+=g,E/=256,p-=8);for(i=i<<p|E,b+=p;b>0;h[c+y]=i&255,y+=g,i/=256,b-=8);h[c+y-g]|=_*128;},ft}function Dr(){if(cr)return z;cr=!0;let h=Fr(),u=qr(),c=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;z.Buffer=i,z.SlowBuffer=$,z.INSPECT_MAX_BYTES=50;let l=2147483647;z.kMaxLength=l,i.TYPED_ARRAY_SUPPORT=p(),!i.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function p(){try{let r=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(r,t),r.foo()===42}catch(r){return !1}}Object.defineProperty(i.prototype,"parent",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.buffer}}),Object.defineProperty(i.prototype,"offset",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.byteOffset}});function f(r){if(r>l)throw new RangeError('The value "'+r+'" is invalid for option "size"');let t=new Uint8Array(r);return Object.setPrototypeOf(t,i.prototype),t}function i(r,t,e){if(typeof r=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return B(r)}return E(r,t,e)}i.poolSize=8192;function E(r,t,e){if(typeof r=="string")return m(r,t);if(ArrayBuffer.isView(r))return y(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(Y(r,ArrayBuffer)||r&&Y(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(Y(r,SharedArrayBuffer)||r&&Y(r.buffer,SharedArrayBuffer)))return g(r,t,e);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return i.from(n,t,e);let o=_(r);if(o)return o;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return i.from(r[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}i.from=function(r,t,e){return E(r,t,e)},Object.setPrototypeOf(i.prototype,Uint8Array.prototype),Object.setPrototypeOf(i,Uint8Array);function d(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function b(r,t,e){return d(r),r<=0?f(r):t!==void 0?typeof e=="string"?f(r).fill(t,e):f(r).fill(t):f(r)}i.alloc=function(r,t,e){return b(r,t,e)};function B(r){return d(r),f(r<0?0:S(r)|0)}i.allocUnsafe=function(r){return B(r)},i.allocUnsafeSlow=function(r){return B(r)};function m(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!i.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let e=v(r,t)|0,n=f(e),o=n.write(r,t);return o!==e&&(n=n.slice(0,o)),n}function L(r){let t=r.length<0?0:S(r.length)|0,e=f(t);for(let n=0;n<t;n+=1)e[n]=r[n]&255;return e}function y(r){if(Y(r,Uint8Array)){let t=new Uint8Array(r);return g(t.buffer,t.byteOffset,t.byteLength)}return L(r)}function g(r,t,e){if(t<0||r.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&e===void 0?n=new Uint8Array(r):e===void 0?n=new Uint8Array(r,t):n=new Uint8Array(r,t,e),Object.setPrototypeOf(n,i.prototype),n}function _(r){if(i.isBuffer(r)){let t=S(r.length)|0,e=f(t);return e.length===0||r.copy(e,0,0,t),e}if(r.length!==void 0)return typeof r.length!="number"||Et(r.length)?f(0):L(r);if(r.type==="Buffer"&&Array.isArray(r.data))return L(r.data)}function S(r){if(r>=l)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+l.toString(16)+" bytes");return r|0}function $(r){return +r!=r&&(r=0),i.alloc(+r)}i.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==i.prototype},i.compare=function(t,e){if(Y(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),Y(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),!i.isBuffer(t)||!i.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,o=e.length;for(let s=0,a=Math.min(n,o);s<a;++s)if(t[s]!==e[s]){n=t[s],o=e[s];break}return n<o?-1:o<n?1:0},i.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return !0;default:return !1}},i.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return i.alloc(0);let n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;let o=i.allocUnsafe(e),s=0;for(n=0;n<t.length;++n){let a=t[n];if(Y(a,Uint8Array))s+a.length>o.length?(i.isBuffer(a)||(a=i.from(a)),a.copy(o,s)):Uint8Array.prototype.set.call(o,a,s);else if(i.isBuffer(a))a.copy(o,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=a.length;}return o};function v(r,t){if(i.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||Y(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let e=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&e===0)return 0;let o=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return gt(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Ft(r).length;default:if(o)return n?-1:gt(r).length;t=(""+t).toLowerCase(),o=!0;}}i.byteLength=v;function F(r,t,e){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return "";for(r||(r="utf8");;)switch(r){case"hex":return br(this,t,e);case"utf8":case"utf-8":return Ct(this,t,e);case"ascii":return Ir(this,t,e);case"latin1":case"binary":return _r(this,t,e);case"base64":return Er(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ar(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0;}}i.prototype._isBuffer=!0;function D(r,t,e){let n=r[t];r[t]=r[e],r[e]=n;}i.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)D(this,e,e+1);return this},i.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)D(this,e,e+3),D(this,e+1,e+2);return this},i.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)D(this,e,e+7),D(this,e+1,e+6),D(this,e+2,e+5),D(this,e+3,e+4);return this},i.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?Ct(this,0,t):F.apply(this,arguments)},i.prototype.toLocaleString=i.prototype.toString,i.prototype.equals=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:i.compare(this,t)===0},i.prototype.inspect=function(){let t="",e=z.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},c&&(i.prototype[c]=i.prototype.inspect),i.prototype.compare=function(t,e,n,o,s){if(Y(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),o===void 0&&(o=0),s===void 0&&(s=this.length),e<0||n>t.length||o<0||s>this.length)throw new RangeError("out of range index");if(o>=s&&e>=n)return 0;if(o>=s)return -1;if(e>=n)return 1;if(e>>>=0,n>>>=0,o>>>=0,s>>>=0,this===t)return 0;let a=s-o,w=n-e,k=Math.min(a,w),A=this.slice(o,s),x=t.slice(e,n);for(let I=0;I<k;++I)if(A[I]!==x[I]){a=A[I],w=x[I];break}return a<w?-1:w<a?1:0};function M(r,t,e,n,o){if(r.length===0)return -1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Et(e)&&(e=o?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(o)return -1;e=r.length-1;}else if(e<0)if(o)e=0;else return -1;if(typeof t=="string"&&(t=i.from(t,n)),i.isBuffer(t))return t.length===0?-1:Tt(r,t,e,n,o);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):Tt(r,[t],e,n,o);throw new TypeError("val must be string, number or Buffer")}function Tt(r,t,e,n,o){let s=1,a=r.length,w=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||t.length<2)return -1;s=2,a/=2,w/=2,e/=2;}function k(x,I){return s===1?x[I]:x.readUInt16BE(I*s)}let A;if(o){let x=-1;for(A=e;A<a;A++)if(k(r,A)===k(t,x===-1?0:A-x)){if(x===-1&&(x=A),A-x+1===w)return x*s}else x!==-1&&(A-=A-x),x=-1;}else for(e+w>a&&(e=a-w),A=e;A>=0;A--){let x=!0;for(let I=0;I<w;I++)if(k(r,A+I)!==k(t,I)){x=!1;break}if(x)return A}return -1}i.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1},i.prototype.indexOf=function(t,e,n){return M(this,t,e,n,!0)},i.prototype.lastIndexOf=function(t,e,n){return M(this,t,e,n,!1)};function dr(r,t,e,n){e=Number(e)||0;let o=r.length-e;n?(n=Number(n),n>o&&(n=o)):n=o;let s=t.length;n>s/2&&(n=s/2);let a;for(a=0;a<n;++a){let w=parseInt(t.substr(a*2,2),16);if(Et(w))return a;r[e+a]=w;}return a}function yr(r,t,e,n){return ut(gt(t,r.length-e),r,e,n)}function mr(r,t,e,n){return ut(Sr(t),r,e,n)}function wr(r,t,e,n){return ut(Ft(t),r,e,n)}function gr(r,t,e,n){return ut(Ur(t,r.length-e),r,e,n)}i.prototype.write=function(t,e,n,o){if(e===void 0)o="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")o=e,n=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(n)?(n=n>>>0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-e;if((n===void 0||n>s)&&(n=s),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let a=!1;for(;;)switch(o){case"hex":return dr(this,t,e,n);case"utf8":case"utf-8":return yr(this,t,e,n);case"ascii":case"latin1":case"binary":return mr(this,t,e,n);case"base64":return wr(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return gr(this,t,e,n);default:if(a)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),a=!0;}},i.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Er(r,t,e){return t===0&&e===r.length?h.fromByteArray(r):h.fromByteArray(r.slice(t,e))}function Ct(r,t,e){e=Math.min(r.length,e);let n=[],o=t;for(;o<e;){let s=r[o],a=null,w=s>239?4:s>223?3:s>191?2:1;if(o+w<=e){let k,A,x,I;switch(w){case 1:s<128&&(a=s);break;case 2:k=r[o+1],(k&192)===128&&(I=(s&31)<<6|k&63,I>127&&(a=I));break;case 3:k=r[o+1],A=r[o+2],(k&192)===128&&(A&192)===128&&(I=(s&15)<<12|(k&63)<<6|A&63,I>2047&&(I<55296||I>57343)&&(a=I));break;case 4:k=r[o+1],A=r[o+2],x=r[o+3],(k&192)===128&&(A&192)===128&&(x&192)===128&&(I=(s&15)<<18|(k&63)<<12|(A&63)<<6|x&63,I>65535&&I<1114112&&(a=I));}}a===null?(a=65533,w=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),o+=w;}return Br(n)}let Rt=4096;function Br(r){let t=r.length;if(t<=Rt)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=Rt));return e}function Ir(r,t,e){let n="";e=Math.min(r.length,e);for(let o=t;o<e;++o)n+=String.fromCharCode(r[o]&127);return n}function _r(r,t,e){let n="";e=Math.min(r.length,e);for(let o=t;o<e;++o)n+=String.fromCharCode(r[o]);return n}function br(r,t,e){let n=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);let o="";for(let s=t;s<e;++s)o+=Tr[r[s]];return o}function Ar(r,t,e){let n=r.slice(t,e),o="";for(let s=0;s<n.length-1;s+=2)o+=String.fromCharCode(n[s]+n[s+1]*256);return o}i.prototype.slice=function(t,e){let n=this.length;t=~~t,e=e===void 0?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);let o=this.subarray(t,e);return Object.setPrototypeOf(o,i.prototype),o};function P(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}i.prototype.readUintLE=i.prototype.readUIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||P(t,e,this.length);let o=this[t],s=1,a=0;for(;++a<e&&(s*=256);)o+=this[t+a]*s;return o},i.prototype.readUintBE=i.prototype.readUIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||P(t,e,this.length);let o=this[t+--e],s=1;for(;e>0&&(s*=256);)o+=this[t+--e]*s;return o},i.prototype.readUint8=i.prototype.readUInt8=function(t,e){return t=t>>>0,e||P(t,1,this.length),this[t]},i.prototype.readUint16LE=i.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||P(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUint16BE=i.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||P(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUint32LE=i.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||P(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},i.prototype.readUint32BE=i.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||P(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readBigUInt64LE=X(function(t){t=t>>>0,et(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&nt(t,this.length-8);let o=e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,s=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(o)+(BigInt(s)<<BigInt(32))}),i.prototype.readBigUInt64BE=X(function(t){t=t>>>0,et(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&nt(t,this.length-8);let o=e*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],s=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return (BigInt(o)<<BigInt(32))+BigInt(s)}),i.prototype.readIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||P(t,e,this.length);let o=this[t],s=1,a=0;for(;++a<e&&(s*=256);)o+=this[t+a]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*e)),o},i.prototype.readIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||P(t,e,this.length);let o=e,s=1,a=this[t+--o];for(;o>0&&(s*=256);)a+=this[t+--o]*s;return s*=128,a>=s&&(a-=Math.pow(2,8*e)),a},i.prototype.readInt8=function(t,e){return t=t>>>0,e||P(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},i.prototype.readInt16LE=function(t,e){t=t>>>0,e||P(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n},i.prototype.readInt16BE=function(t,e){t=t>>>0,e||P(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n},i.prototype.readInt32LE=function(t,e){return t=t>>>0,e||P(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return t=t>>>0,e||P(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readBigInt64LE=X(function(t){t=t>>>0,et(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&nt(t,this.length-8);let o=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return (BigInt(o)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)}),i.prototype.readBigInt64BE=X(function(t){t=t>>>0,et(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&nt(t,this.length-8);let o=(e<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return (BigInt(o)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)}),i.prototype.readFloatLE=function(t,e){return t=t>>>0,e||P(t,4,this.length),u.read(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t=t>>>0,e||P(t,4,this.length),u.read(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||P(t,8,this.length),u.read(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||P(t,8,this.length),u.read(this,t,!1,52,8)};function q(r,t,e,n,o,s){if(!i.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<s)throw new RangeError('"value" argument is out of bounds');if(e+n>r.length)throw new RangeError("Index out of range")}i.prototype.writeUintLE=i.prototype.writeUIntLE=function(t,e,n,o){if(t=+t,e=e>>>0,n=n>>>0,!o){let w=Math.pow(2,8*n)-1;q(this,t,e,n,w,0);}let s=1,a=0;for(this[e]=t&255;++a<n&&(s*=256);)this[e+a]=t/s&255;return e+n},i.prototype.writeUintBE=i.prototype.writeUIntBE=function(t,e,n,o){if(t=+t,e=e>>>0,n=n>>>0,!o){let w=Math.pow(2,8*n)-1;q(this,t,e,n,w,0);}let s=n-1,a=1;for(this[e+s]=t&255;--s>=0&&(a*=256);)this[e+s]=t/a&255;return e+n},i.prototype.writeUint8=i.prototype.writeUInt8=function(t,e,n){return t=+t,e=e>>>0,n||q(this,t,e,1,255,0),this[e]=t&255,e+1},i.prototype.writeUint16LE=i.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||q(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},i.prototype.writeUint16BE=i.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||q(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},i.prototype.writeUint32LE=i.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||q(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4},i.prototype.writeUint32BE=i.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||q(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function Pt(r,t,e,n,o){$t(t,n,o,r,e,7);let s=Number(t&BigInt(4294967295));r[e++]=s,s=s>>8,r[e++]=s,s=s>>8,r[e++]=s,s=s>>8,r[e++]=s;let a=Number(t>>BigInt(32)&BigInt(4294967295));return r[e++]=a,a=a>>8,r[e++]=a,a=a>>8,r[e++]=a,a=a>>8,r[e++]=a,e}function Lt(r,t,e,n,o){$t(t,n,o,r,e,7);let s=Number(t&BigInt(4294967295));r[e+7]=s,s=s>>8,r[e+6]=s,s=s>>8,r[e+5]=s,s=s>>8,r[e+4]=s;let a=Number(t>>BigInt(32)&BigInt(4294967295));return r[e+3]=a,a=a>>8,r[e+2]=a,a=a>>8,r[e+1]=a,a=a>>8,r[e]=a,e+8}i.prototype.writeBigUInt64LE=X(function(t,e=0){return Pt(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),i.prototype.writeBigUInt64BE=X(function(t,e=0){return Lt(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),i.prototype.writeIntLE=function(t,e,n,o){if(t=+t,e=e>>>0,!o){let k=Math.pow(2,8*n-1);q(this,t,e,n,k-1,-k);}let s=0,a=1,w=0;for(this[e]=t&255;++s<n&&(a*=256);)t<0&&w===0&&this[e+s-1]!==0&&(w=1),this[e+s]=(t/a>>0)-w&255;return e+n},i.prototype.writeIntBE=function(t,e,n,o){if(t=+t,e=e>>>0,!o){let k=Math.pow(2,8*n-1);q(this,t,e,n,k-1,-k);}let s=n-1,a=1,w=0;for(this[e+s]=t&255;--s>=0&&(a*=256);)t<0&&w===0&&this[e+s+1]!==0&&(w=1),this[e+s]=(t/a>>0)-w&255;return e+n},i.prototype.writeInt8=function(t,e,n){return t=+t,e=e>>>0,n||q(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},i.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||q(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||q(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},i.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||q(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},i.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||q(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4},i.prototype.writeBigInt64LE=X(function(t,e=0){return Pt(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),i.prototype.writeBigInt64BE=X(function(t,e=0){return Lt(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Nt(r,t,e,n,o,s){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Wt(r,t,e,n,o){return t=+t,e=e>>>0,o||Nt(r,t,e,4),u.write(r,t,e,n,23,4),e+4}i.prototype.writeFloatLE=function(t,e,n){return Wt(this,t,e,!0,n)},i.prototype.writeFloatBE=function(t,e,n){return Wt(this,t,e,!1,n)};function Mt(r,t,e,n,o){return t=+t,e=e>>>0,o||Nt(r,t,e,8),u.write(r,t,e,n,52,8),e+8}i.prototype.writeDoubleLE=function(t,e,n){return Mt(this,t,e,!0,n)},i.prototype.writeDoubleBE=function(t,e,n){return Mt(this,t,e,!1,n)},i.prototype.copy=function(t,e,n,o){if(!i.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!o&&o!==0&&(o=this.length),e>=t.length&&(e=t.length),e||(e=0),o>0&&o<n&&(o=n),o===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),t.length-e<o-n&&(o=t.length-e+n);let s=o-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,n,o):Uint8Array.prototype.set.call(t,this.subarray(n,o),e),s},i.prototype.fill=function(t,e,n,o){if(typeof t=="string"){if(typeof e=="string"?(o=e,e=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!i.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(t.length===1){let a=t.charCodeAt(0);(o==="utf8"&&a<128||o==="latin1")&&(t=a);}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let s;if(typeof t=="number")for(s=e;s<n;++s)this[s]=t;else {let a=i.isBuffer(t)?t:i.from(t,o),w=a.length;if(w===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<n-e;++s)this[s+e]=a[s%w];}return this};let tt={};function wt(r,t,e){tt[r]=class extends e{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name;}get code(){return r}set code(o){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:o,writable:!0});}toString(){return `${this.name} [${r}]: ${this.message}`}};}wt("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),wt("ERR_INVALID_ARG_TYPE",function(r,t){return `The "${r}" argument must be of type number. Received type ${typeof t}`},TypeError),wt("ERR_OUT_OF_RANGE",function(r,t,e){let n=`The value of "${r}" is out of range.`,o=e;return Number.isInteger(e)&&Math.abs(e)>2**32?o=Ot(String(e)):typeof e=="bigint"&&(o=String(e),(e>BigInt(2)**BigInt(32)||e<-(BigInt(2)**BigInt(32)))&&(o=Ot(o)),o+="n"),n+=` It must be ${t}. Received ${o}`,n},RangeError);function Ot(r){let t="",e=r.length,n=r[0]==="-"?1:0;for(;e>=n+4;e-=3)t=`_${r.slice(e-3,e)}${t}`;return `${r.slice(0,e)}${t}`}function kr(r,t,e){et(t,"offset"),(r[t]===void 0||r[t+e]===void 0)&&nt(t,r.length-(e+1));}function $t(r,t,e,n,o,s){if(r>e||r<t){let a=typeof t=="bigint"?"n":"",w;throw t===0||t===BigInt(0)?w=`>= 0${a} and < 2${a} ** ${(s+1)*8}${a}`:w=`>= -(2${a} ** ${(s+1)*8-1}${a}) and < 2 ** ${(s+1)*8-1}${a}`,new tt.ERR_OUT_OF_RANGE("value",w,r)}kr(n,o,s);}function et(r,t){if(typeof r!="number")throw new tt.ERR_INVALID_ARG_TYPE(t,"number",r)}function nt(r,t,e){throw Math.floor(r)!==r?(et(r,e),new tt.ERR_OUT_OF_RANGE("offset","an integer",r)):t<0?new tt.ERR_BUFFER_OUT_OF_BOUNDS:new tt.ERR_OUT_OF_RANGE("offset",`>= ${0} and <= ${t}`,r)}let xr=/[^+/0-9A-Za-z-_]/g;function vr(r){if(r=r.split("=")[0],r=r.trim().replace(xr,""),r.length<2)return "";for(;r.length%4!==0;)r=r+"=";return r}function gt(r,t){t=t||1/0;let e,n=r.length,o=null,s=[];for(let a=0;a<n;++a){if(e=r.charCodeAt(a),e>55295&&e<57344){if(!o){if(e>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(a+1===n){(t-=3)>-1&&s.push(239,191,189);continue}o=e;continue}if(e<56320){(t-=3)>-1&&s.push(239,191,189),o=e;continue}e=(o-55296<<10|e-56320)+65536;}else o&&(t-=3)>-1&&s.push(239,191,189);if(o=null,e<128){if((t-=1)<0)break;s.push(e);}else if(e<2048){if((t-=2)<0)break;s.push(e>>6|192,e&63|128);}else if(e<65536){if((t-=3)<0)break;s.push(e>>12|224,e>>6&63|128,e&63|128);}else if(e<1114112){if((t-=4)<0)break;s.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128);}else throw new Error("Invalid code point")}return s}function Sr(r){let t=[];for(let e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function Ur(r,t){let e,n,o,s=[];for(let a=0;a<r.length&&!((t-=2)<0);++a)e=r.charCodeAt(a),n=e>>8,o=e%256,s.push(o),s.push(n);return s}function Ft(r){return h.toByteArray(vr(r))}function ut(r,t,e,n){let o;for(o=0;o<n&&!(o+e>=t.length||o>=r.length);++o)t[o+e]=r[o];return o}function Y(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function Et(r){return r!==r}let Tr=function(){let r="0123456789abcdef",t=new Array(256);for(let e=0;e<16;++e){let n=e*16;for(let o=0;o<16;++o)t[n+o]=r[e]+r[o];}return t}();function X(r){return typeof BigInt=="undefined"?Cr:r}function Cr(){throw new Error("BigInt not supported")}return z}var ot,sr,ft,ur,z,cr,Z,G,ar=it(()=>{T();R();C();ot={},sr=!1;ft={},ur=!1;z={},cr=!1;Z=Dr();Z.Buffer;Z.SlowBuffer;Z.INSPECT_MAX_BYTES;Z.kMaxLength;G=Z.Buffer,Z.INSPECT_MAX_BYTES,Z.kMaxLength;});var R=it(()=>{ar();});var vt=Wr((un,xt)=>{T();R();C();var jr=Object.prototype.hasOwnProperty,O="~";function st(){}Object.create&&(st.prototype=Object.create(null),new st().__proto__||(O=!1));function Yr(h,u,c){this.fn=h,this.context=u,this.once=c||!1;}function hr(h,u,c,l,p){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new Yr(c,l||h,p),i=O?O+u:u;return h._events[i]?h._events[i].fn?h._events[i]=[h._events[i],f]:h._events[i].push(f):(h._events[i]=f,h._eventsCount++),h}function dt(h,u){--h._eventsCount===0?h._events=new st:delete h._events[u];}function W(){this._events=new st,this._eventsCount=0;}W.prototype.eventNames=function(){var u=[],c,l;if(this._eventsCount===0)return u;for(l in c=this._events)jr.call(c,l)&&u.push(O?l.slice(1):l);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(c)):u};W.prototype.listeners=function(u){var c=O?O+u:u,l=this._events[c];if(!l)return [];if(l.fn)return [l.fn];for(var p=0,f=l.length,i=new Array(f);p<f;p++)i[p]=l[p].fn;return i};W.prototype.listenerCount=function(u){var c=O?O+u:u,l=this._events[c];return l?l.fn?1:l.length:0};W.prototype.emit=function(u,c,l,p,f,i){var E=O?O+u:u;if(!this._events[E])return !1;var d=this._events[E],b=arguments.length,B,m;if(d.fn){switch(d.once&&this.removeListener(u,d.fn,void 0,!0),b){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,c),!0;case 3:return d.fn.call(d.context,c,l),!0;case 4:return d.fn.call(d.context,c,l,p),!0;case 5:return d.fn.call(d.context,c,l,p,f),!0;case 6:return d.fn.call(d.context,c,l,p,f,i),!0}for(m=1,B=new Array(b-1);m<b;m++)B[m-1]=arguments[m];d.fn.apply(d.context,B);}else {var L=d.length,y;for(m=0;m<L;m++)switch(d[m].once&&this.removeListener(u,d[m].fn,void 0,!0),b){case 1:d[m].fn.call(d[m].context);break;case 2:d[m].fn.call(d[m].context,c);break;case 3:d[m].fn.call(d[m].context,c,l);break;case 4:d[m].fn.call(d[m].context,c,l,p);break;default:if(!B)for(y=1,B=new Array(b-1);y<b;y++)B[y-1]=arguments[y];d[m].fn.apply(d[m].context,B);}}return !0};W.prototype.on=function(u,c,l){return hr(this,u,c,l,!1)};W.prototype.once=function(u,c,l){return hr(this,u,c,l,!0)};W.prototype.removeListener=function(u,c,l,p){var f=O?O+u:u;if(!this._events[f])return this;if(!c)return dt(this,f),this;var i=this._events[f];if(i.fn)i.fn===c&&(!p||i.once)&&(!l||i.context===l)&&dt(this,f);else {for(var E=0,d=[],b=i.length;E<b;E++)(i[E].fn!==c||p&&!i[E].once||l&&i[E].context!==l)&&d.push(i[E]);d.length?this._events[f]=d.length===1?d[0]:d:dt(this,f);}return this};W.prototype.removeAllListeners=function(u){var c;return u?(c=O?O+u:u,this._events[c]&&dt(this,c)):(this._events=new st,this._eventsCount=0),this};W.prototype.off=W.prototype.removeListener;W.prototype.addListener=W.prototype.on;W.prefixed=O;W.EventEmitter=W;typeof xt!="undefined"&&(xt.exports=W);});T();R();C();T();R();C();T();R();C();var pr=jt(vt());var St=class extends pr.EventEmitter{constructor(c,l,p){super();U(this,"socket");this.socket=new window.WebSocket(c,p),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=f=>this.emit("message",f.data),this.socket.onerror=f=>this.emit("error",f),this.socket.onclose=f=>{this.emit("close",f.code,f.reason);};}send(c,l,p){let f=p||l;try{this.socket.send(c),f();}catch(i){f(i);}}close(c,l){this.socket.close(c,l);}addEventListener(c,l,p){this.socket.addEventListener(c,l,p);}};function lr(h,u){return new St(h,u)}T();R();C();var fr=jt(vt());T();R();C();var yt=class{encode(u){return JSON.stringify(u)}decode(u){return JSON.parse(u)}};var mt=class extends fr.EventEmitter{constructor(c,l="ws://localhost:8080",m={},b,B){var L=m,{autoconnect:p=!0,reconnect:f=!0,reconnect_interval:i=1e3,max_reconnects:E=5}=L,d=Dt(L,["autoconnect","reconnect","reconnect_interval","max_reconnects"]);super();U(this,"address");U(this,"rpc_id");U(this,"queue");U(this,"options");U(this,"autoconnect");U(this,"ready");U(this,"reconnect");U(this,"reconnect_timer_id");U(this,"reconnect_interval");U(this,"max_reconnects");U(this,"rest_options");U(this,"current_reconnects");U(this,"generate_request_id");U(this,"socket");U(this,"webSocketFactory");U(this,"dataPack");this.webSocketFactory=c,this.queue={},this.rpc_id=0,this.address=l,this.autoconnect=p,this.ready=!1,this.reconnect=f,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=E,this.rest_options=d,this.current_reconnects=0,this.generate_request_id=b||(()=>++this.rpc_id),B?this.dataPack=B:this.dataPack=new yt,this.autoconnect&&this._connect(this.address,_t({autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects},this.rest_options));}connect(){this.socket||this._connect(this.address,_t({autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects},this.rest_options));}call(c,l,p,f){return !f&&typeof p=="object"&&(f=p,p=null),new Promise((i,E)=>{if(!this.ready)return E(new Error("socket not ready"));let d=this.generate_request_id(c,l),b={jsonrpc:"2.0",method:c,params:l||void 0,id:d};this.socket.send(this.dataPack.encode(b),f,B=>{if(B)return E(B);this.queue[d]={promise:[i,E]},p&&(this.queue[d].timeout=setTimeout(()=>{delete this.queue[d],E(new Error("reply timeout"));},p));});})}async login(c){let l=await this.call("rpc.login",c);if(!l)throw new Error("authentication failed");return l}async listMethods(){return await this.call("__listMethods")}notify(c,l){return new Promise((p,f)=>{if(!this.ready)return f(new Error("socket not ready"));let i={jsonrpc:"2.0",method:c,params:l};this.socket.send(this.dataPack.encode(i),E=>{if(E)return f(E);p();});})}async subscribe(c){typeof c=="string"&&(c=[c]);let l=await this.call("rpc.on",c);if(typeof c=="string"&&l[c]!=="ok")throw new Error("Failed subscribing to an event '"+c+"' with: "+l[c]);return l}async unsubscribe(c){typeof c=="string"&&(c=[c]);let l=await this.call("rpc.off",c);if(typeof c=="string"&&l[c]!=="ok")throw new Error("Failed unsubscribing from an event with: "+l);return l}close(c,l){this.socket.close(c||1e3,l);}setAutoReconnect(c){this.reconnect=c;}setReconnectInterval(c){this.reconnect_interval=c;}setMaxReconnects(c){this.max_reconnects=c;}_connect(c,l){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(c,l),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0;}),this.socket.addEventListener("message",({data:p})=>{p instanceof ArrayBuffer&&(p=G.from(p).toString());try{p=this.dataPack.decode(p);}catch(f){return}if(p.notification&&this.listeners(p.notification).length){if(!Object.keys(p.params).length)return this.emit(p.notification);let f=[p.notification];if(p.params.constructor===Object)f.push(p.params);else for(let i=0;i<p.params.length;i++)f.push(p.params[i]);return Promise.resolve().then(()=>{this.emit.apply(this,f);})}if(!this.queue[p.id])return p.method?Promise.resolve().then(()=>{this.emit(p.method,p==null?void 0:p.params);}):void 0;"error"in p=="result"in p&&this.queue[p.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[p.id].timeout&&clearTimeout(this.queue[p.id].timeout),p.error?this.queue[p.id].promise[1](p.error):this.queue[p.id].promise[0](p.result),delete this.queue[p.id];}),this.socket.addEventListener("error",p=>this.emit("error",p)),this.socket.addEventListener("close",({code:p,reason:f})=>{this.ready&&setTimeout(()=>this.emit("close",p,f),0),this.ready=!1,this.socket=void 0,p!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(c,l),this.reconnect_interval)));});}};T();R();C();var Ut=class extends mt{constructor(u="ws://localhost:8080",{autoconnect:c=!0,reconnect:l=!0,reconnect_interval:p=1e3,max_reconnects:f=5}={},i){super(lr,u,{autoconnect:c,reconnect:l,reconnect_interval:p,max_reconnects:f},i);}};/*! Bundled license information:
@jspm/core/nodelibs/browser/buffer.js:
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
*/
exports.Client = Ut;
return exports;
})({});
{
"name": "rpc-websockets",
"version": "8.0.1",
"version": "9.0.0",
"description": "JSON-RPC 2.0 implementation over WebSockets for Node.js",
"exports": {
"browser": {
"import": "./dist/index.browser.mjs",
"require": "./dist/index.browser.cjs",
"types": "./dist/index.browser.d.ts"
},
"node": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
},
"types": "./dist/index.d.ts"
},
"browser": {
"./dist/index.cjs": "./dist/index.browser.cjs",
"./dist/index.mjs": "./dist/index.browser.mjs"
},
"main": "./dist/index.cjs",
"types": "./dist/index.d.cts",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"type": "commonjs",
"files": [
"dist/"
],
"scripts": {
"build": "tsc && mkdir -p ./dist && eslint --fix -c ./.eslintrc './src/**/*.cts' && ./build-browser-bundle.mjs",
"build": "npm run typecheck && mkdir -p ./dist && eslint --fix -c ./.eslintrc './src/**/*.ts' && tsup",
"typecheck": "tsc",
"pretest": "npm run-script build",

@@ -21,2 +44,6 @@ "test": "mocha --exit test/*spec.js",

"dependencies": {
"@swc/helpers": "^0.5.11",
"@types/uuid": "^8.3.4",
"@types/ws": "^8.2.2",
"buffer": "^6.0.3",
"eventemitter3": "^4.0.7",

@@ -31,15 +58,9 @@ "uuid": "^8.3.2",

"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/plugin-transform-runtime": "^7.17.0",
"@babel/preset-env": "^7.16.11",
"@types/uuid": "^8.3.4",
"@types/ws": "^8.2.2",
"@microsoft/api-extractor": "^7.47.0",
"@typescript-eslint/eslint-plugin": "^5.11.0",
"@typescript-eslint/parser": "^5.11.0",
"async": "^3.2.3",
"babel-eslint": "^10.1.0",
"chai": "^4.3.6",
"coveralls": "^3.1.1",
"esbuild": "^0.20.2",
"esbuild-plugin-babel": "^0.2.3",
"esbuild-plugin-polyfill-node": "^0.3.0",
"eslint": "^8.8.0",

@@ -49,5 +70,6 @@ "istanbul": "^0.4.5",

"mocha-lcov-reporter": "^1.3.0",
"typescript": "^4.5.5"
"tsup": "^8.1.0",
"typescript": "^4.5.5",
"url": "^0.11.3"
},
"browser": "./dist/index.browser.cjs",
"keywords": [

@@ -54,0 +76,0 @@ "json",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc