@libp2p/perf 1.1.5-a6be8f0f → 1.1.6-10cbc8fa

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,3 +1,3 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PPerf = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PPerf=(()=>{var ae=Object.create;var N=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var L=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ue=(e,t)=>{for(var r in t)N(e,r,{get:t[r],enumerable:!0})},V=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ce(t))!le.call(e,s)&&s!==r&&N(e,s,{get:()=>t[s],enumerable:!(o=ie(t,s))||o.enumerable});return e};var de=(e,t,r)=>(r=e!=null?ae(fe(e)):{},V(t||!e||!e.__esModule?N(r,"default",{value:e,enumerable:!0}):r,e)),pe=e=>V(N({},"__esModule",{value:!0}),e);var Z=L((Re,q)=>{var B=1e3,O=B*60,I=O*60,S=I*24,he=S*7,be=S*365.25;q.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return Ce(e);if(r==="number"&&isFinite(e))return t.long?ge(e):me(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Ce(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),o=(t[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return r*be;case"weeks":case"week":case"w":return r*he;case"days":case"day":case"d":return r*S;case"hours":case"hour":case"hrs":case"hr":case"h":return r*I;case"minutes":case"minute":case"mins":case"min":case"m":return r*O;case"seconds":case"second":case"secs":case"sec":case"s":return r*B;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function me(e){var t=Math.abs(e);return t>=S?Math.round(e/S)+"d":t>=I?Math.round(e/I)+"h":t>=O?Math.round(e/O)+"m":t>=B?Math.round(e/B)+"s":e+"ms"}function ge(e){var t=Math.abs(e);return t>=S?P(e,t,S,"day"):t>=I?P(e,t,I,"hour"):t>=O?P(e,t,O,"minute"):t>=B?P(e,t,B,"second"):e+" ms"}function P(e,t,r,o){var s=t>=r*1.5;return Math.round(e/r)+" "+o+(s?"s":"")}});var G=L((Le,K)=>{function we(e){r.debug=r,r.default=r,r.coerce=b,r.disable=d,r.enable=s,r.enabled=f,r.humanize=Z(),r.destroy=k,Object.keys(e).forEach(n=>{r[n]=e[n]}),r.names=[],r.skips=[],r.formatters={};function t(n){let a=0;for(let u=0;u<n.length;u++)a=(a<<5)-a+n.charCodeAt(u),a|=0;return r.colors[Math.abs(a)%r.colors.length]}r.selectColor=t;function r(n){let a,u=null,U,i;function c(...p){if(!c.enabled)return;let h=c,m=Number(new Date),F=m-(a||m);h.diff=F,h.prev=a,h.curr=m,a=m,p[0]=r.coerce(p[0]),typeof p[0]!="string"&&p.unshift("%O");let C=0;p[0]=p[0].replace(/%([a-zA-Z%])/g,(v,w)=>{if(v==="%%")return"%";C++;let A=r.formatters[w];if(typeof A=="function"){let z=p[C];v=A.call(h,z),p.splice(C,1),C--}return v}),r.formatArgs.call(h,p),(h.log||r.log).apply(h,p)}return c.namespace=n,c.useColors=r.useColors(),c.color=r.selectColor(n),c.extend=o,c.destroy=r.destroy,Object.defineProperty(c,"enabled",{enumerable:!0,configurable:!1,get:()=>u!==null?u:(U!==r.namespaces&&(U=r.namespaces,i=r.enabled(n)),i),set:p=>{u=p}}),typeof r.init=="function"&&r.init(c),c}function o(n,a){let u=r(this.namespace+(typeof a>"u"?":":a)+n);return u.log=this.log,u}function s(n){r.save(n),r.namespaces=n,r.names=[],r.skips=[];let a,u=(typeof n=="string"?n:"").split(/[\s,]+/),U=u.length;for(a=0;a<U;a++)u[a]&&(n=u[a].replace(/\*/g,".*?"),n[0]==="-"?r.skips.push(new RegExp("^"+n.slice(1)+"$")):r.names.push(new RegExp("^"+n+"$")))}function d(){let n=[...r.names.map(l),...r.skips.map(l).map(a=>"-"+a)].join(",");return r.enable(""),n}function f(n){if(n[n.length-1]==="*")return!0;let a,u;for(a=0,u=r.skips.length;a<u;a++)if(r.skips[a].test(n))return!1;for(a=0,u=r.names.length;a<u;a++)if(r.names[a].test(n))return!0;return!1}function l(n){return n.toString().substring(2,n.toString().length-2).replace(/\.\*\?$/,"*")}function b(n){return n instanceof Error?n.stack||n.message:n}function k(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}K.exports=we});var W=L((y,R)=>{y.formatArgs=xe;y.save=Fe;y.load=ve;y.useColors=ye;y.storage=Ae();y.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();y.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function ye(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function xe(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+R.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,s=>{s!=="%%"&&(r++,s==="%c"&&(o=r))}),e.splice(o,0,t)}y.log=console.debug||console.log||(()=>{});function Fe(e){try{e?y.storage.setItem("debug",e):y.storage.removeItem("debug")}catch{}}function ve(){let e;try{e=y.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function Ae(){try{return localStorage}catch{}}R.exports=G()(y);var{formatters:Ee}=R.exports;Ee.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Ne={};ue(Ne,{defaultInit:()=>Ie,perfService:()=>Me});var x=de(W(),1);function Se(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),o=0;o<r.length;o++)r[o]=255;for(var s=0;s<e.length;s++){var d=e.charAt(s),f=d.charCodeAt(0);if(r[f]!==255)throw new TypeError(d+" is ambiguous");r[f]=s}var l=e.length,b=e.charAt(0),k=Math.log(l)/Math.log(256),n=Math.log(256)/Math.log(l);function a(i){if(i instanceof Uint8Array||(ArrayBuffer.isView(i)?i=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):Array.isArray(i)&&(i=Uint8Array.from(i))),!(i instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(i.length===0)return"";for(var c=0,p=0,h=0,m=i.length;h!==m&&i[h]===0;)h++,c++;for(var F=(m-h)*n+1>>>0,C=new Uint8Array(F);h!==m;){for(var E=i[h],v=0,w=F-1;(E!==0||v<p)&&w!==-1;w--,v++)E+=256*C[w]>>>0,C[w]=E%l>>>0,E=E/l>>>0;if(E!==0)throw new Error("Non-zero carry");p=v,h++}for(var A=F-p;A!==F&&C[A]===0;)A++;for(var z=b.repeat(c);A<F;++A)z+=e.charAt(C[A]);return z}function u(i){if(typeof i!="string")throw new TypeError("Expected String");if(i.length===0)return new Uint8Array;var c=0;if(i[c]!==" "){for(var p=0,h=0;i[c]===b;)p++,c++;for(var m=(i.length-c)*k+1>>>0,F=new Uint8Array(m);i[c];){var C=r[i.charCodeAt(c)];if(C===255)return;for(var E=0,v=m-1;(C!==0||E<h)&&v!==-1;v--,E++)C+=l*F[v]>>>0,F[v]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");h=E,c++}if(i[c]!==" "){for(var w=m-h;w!==m&&F[w]===0;)w++;for(var A=new Uint8Array(p+(m-w)),z=p;w!==m;)A[z++]=F[w++];return A}}}function U(i){var c=u(i);if(c)return c;throw new Error(`Non-${t} character`)}return{encode:a,decodeUnsafe:u,decode:U}}var ke=Se,Ue=ke,X=Ue;var $e=new Uint8Array(0);var Q=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};var T=class{constructor(t,r,o){this.name=t,this.prefix=r,this.baseEncode=o}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},$=class{constructor(t,r,o){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=o}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Y(this,t)}},j=class{constructor(t){this.decoders=t}or(t){return Y(this,t)}decode(t){let r=t[0],o=this.decoders[r];if(o)return o.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Y=(e,t)=>new j({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}}),D=class{constructor(t,r,o,s){this.name=t,this.prefix=r,this.baseEncode=o,this.baseDecode=s,this.encoder=new T(t,r,o),this.decoder=new $(t,r,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},H=({name:e,prefix:t,encode:r,decode:o})=>new D(e,t,r,o),_=({prefix:e,name:t,alphabet:r})=>{let{encode:o,decode:s}=X(r,t);return H({prefix:e,name:t,encode:o,decode:d=>Q(s(d))})},ze=(e,t,r,o)=>{let s={};for(let n=0;n<t.length;++n)s[t[n]]=n;let d=e.length;for(;e[d-1]==="=";)--d;let f=new Uint8Array(d*r/8|0),l=0,b=0,k=0;for(let n=0;n<d;++n){let a=s[e[n]];if(a===void 0)throw new SyntaxError(`Non-${o} character`);b=b<<r|a,l+=r,l>=8&&(l-=8,f[k++]=255&b>>l)}if(l>=r||255&b<<8-l)throw new SyntaxError("Unexpected end of data");return f},Be=(e,t,r)=>{let o=t[t.length-1]==="=",s=(1<<r)-1,d="",f=0,l=0;for(let b=0;b<e.length;++b)for(l=l<<8|e[b],f+=8;f>r;)f-=r,d+=t[s&l>>f];if(f&&(d+=t[s&l<<r-f]),o)for(;d.length*r&7;)d+="=";return d},g=({name:e,prefix:t,bitsPerChar:r,alphabet:o})=>H({prefix:t,name:e,encode(s){return Be(s,o,r)},decode(s){return ze(s,o,r,e)}});var ee=g({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),qe=g({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ze=g({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ke=g({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ge=g({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),We=g({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Xe=g({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Qe=g({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ye=g({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var re=_({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),rr=_({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var te=g({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),or=g({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),sr=g({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ar=g({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});x.default.formatters.b=e=>e==null?"undefined":re.baseEncode(e);x.default.formatters.t=e=>e==null?"undefined":ee.baseEncode(e);x.default.formatters.m=e=>e==null?"undefined":te.baseEncode(e);x.default.formatters.p=e=>e==null?"undefined":e.toString();x.default.formatters.c=e=>e==null?"undefined":e.toString();x.default.formatters.k=e=>e==null?"undefined":e.toString();x.default.formatters.a=e=>e==null?"undefined":e.toString();function Oe(e){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}function ne(e){let t=Oe(`${e}:trace`);return x.default.enabled(`${e}:trace`)&&x.default.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=(0,x.default)(`${e}:trace`)),Object.assign((0,x.default)(e),{error:(0,x.default)(`${e}:error`),trace:t})}var oe="/perf/1.0.0",se=BigInt(65536);var M=ne("libp2p:perf"),Ie={protocolName:"/perf/1.0.0",writeBlockSize:BigInt(65536)},J=class{protocol;components;started;databuf;writeBlockSize;constructor(t,r){this.components=t,this.started=!1,this.protocol=r.protocolName??oe,this.writeBlockSize=r.writeBlockSize??se,this.databuf=new ArrayBuffer(Number(r.writeBlockSize))}async start(){await this.components.registrar.handle(this.protocol,t=>{this.handleMessage(t).catch(r=>{M.error("error handling perf protocol message",r)})}),this.started=!0}async stop(){await this.components.registrar.unhandle(this.protocol),this.started=!1}isStarted(){return this.started}async handleMessage(t){let{stream:r}=t,o=this.writeBlockSize,s=null;for await(let f of r.source)s===null&&(s=BigInt(f.getBigUint64(0,!1)));let d=new Uint8Array(this.databuf);if(s===null)throw new Error("bytesToSendBack was not set");await r.sink(async function*(){for(;s>0n;){let f=o;f>s&&(f=s),s=s-f,yield d.subarray(0,Number(f))}}())}async measurePerformance(t,r,o,s,d={}){M("opening stream on protocol %s to %p",this.protocol,r.remotePeer);let f=new Uint8Array(this.databuf),l=this.writeBlockSize,b=await r.newStream([this.protocol]);new DataView(this.databuf).setBigInt64(0,s,!1),M("sending %i bytes to %p",o,r.remotePeer);try{await b.sink(async function*(){for(yield f.subarray(0,8);o>0n;){let a=l;a>o&&(a=o),o=o-a,yield f.subarray(0,Number(a))}}());let n=BigInt(0);for await(let a of b.source)n+=BigInt(a.length);if(n!==s)throw new Error(`Expected to receive ${s} bytes, but received ${n}`)}catch(n){throw M("error sending %i bytes to %p: %s",o,r.remotePeer,n),n}finally{M("performed %s to %p",this.protocol,r.remotePeer),await b.close()}return Date.now()-t}};function Me(e={}){return t=>new J(t,e)}return pe(Ne);})();
2
+ "use strict";var Libp2PPerf=(()=>{var ae=Object.create;var N=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var L=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ue=(e,t)=>{for(var r in t)N(e,r,{get:t[r],enumerable:!0})},V=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ce(t))!le.call(e,s)&&s!==r&&N(e,s,{get:()=>t[s],enumerable:!(o=ie(t,s))||o.enumerable});return e};var de=(e,t,r)=>(r=e!=null?ae(fe(e)):{},V(t||!e||!e.__esModule?N(r,"default",{value:e,enumerable:!0}):r,e)),pe=e=>V(N({},"__esModule",{value:!0}),e);var Z=L((Re,q)=>{var B=1e3,O=B*60,I=O*60,S=I*24,he=S*7,be=S*365.25;q.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return Ce(e);if(r==="number"&&isFinite(e))return t.long?ge(e):me(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Ce(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),o=(t[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return r*be;case"weeks":case"week":case"w":return r*he;case"days":case"day":case"d":return r*S;case"hours":case"hour":case"hrs":case"hr":case"h":return r*I;case"minutes":case"minute":case"mins":case"min":case"m":return r*O;case"seconds":case"second":case"secs":case"sec":case"s":return r*B;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function me(e){var t=Math.abs(e);return t>=S?Math.round(e/S)+"d":t>=I?Math.round(e/I)+"h":t>=O?Math.round(e/O)+"m":t>=B?Math.round(e/B)+"s":e+"ms"}function ge(e){var t=Math.abs(e);return t>=S?P(e,t,S,"day"):t>=I?P(e,t,I,"hour"):t>=O?P(e,t,O,"minute"):t>=B?P(e,t,B,"second"):e+" ms"}function P(e,t,r,o){var s=t>=r*1.5;return Math.round(e/r)+" "+o+(s?"s":"")}});var G=L((Le,K)=>{function we(e){r.debug=r,r.default=r,r.coerce=b,r.disable=d,r.enable=s,r.enabled=f,r.humanize=Z(),r.destroy=k,Object.keys(e).forEach(n=>{r[n]=e[n]}),r.names=[],r.skips=[],r.formatters={};function t(n){let a=0;for(let u=0;u<n.length;u++)a=(a<<5)-a+n.charCodeAt(u),a|=0;return r.colors[Math.abs(a)%r.colors.length]}r.selectColor=t;function r(n){let a,u=null,U,i;function c(...p){if(!c.enabled)return;let h=c,m=Number(new Date),F=m-(a||m);h.diff=F,h.prev=a,h.curr=m,a=m,p[0]=r.coerce(p[0]),typeof p[0]!="string"&&p.unshift("%O");let C=0;p[0]=p[0].replace(/%([a-zA-Z%])/g,(v,w)=>{if(v==="%%")return"%";C++;let A=r.formatters[w];if(typeof A=="function"){let z=p[C];v=A.call(h,z),p.splice(C,1),C--}return v}),r.formatArgs.call(h,p),(h.log||r.log).apply(h,p)}return c.namespace=n,c.useColors=r.useColors(),c.color=r.selectColor(n),c.extend=o,c.destroy=r.destroy,Object.defineProperty(c,"enabled",{enumerable:!0,configurable:!1,get:()=>u!==null?u:(U!==r.namespaces&&(U=r.namespaces,i=r.enabled(n)),i),set:p=>{u=p}}),typeof r.init=="function"&&r.init(c),c}function o(n,a){let u=r(this.namespace+(typeof a>"u"?":":a)+n);return u.log=this.log,u}function s(n){r.save(n),r.namespaces=n,r.names=[],r.skips=[];let a,u=(typeof n=="string"?n:"").split(/[\s,]+/),U=u.length;for(a=0;a<U;a++)u[a]&&(n=u[a].replace(/\*/g,".*?"),n[0]==="-"?r.skips.push(new RegExp("^"+n.slice(1)+"$")):r.names.push(new RegExp("^"+n+"$")))}function d(){let n=[...r.names.map(l),...r.skips.map(l).map(a=>"-"+a)].join(",");return r.enable(""),n}function f(n){if(n[n.length-1]==="*")return!0;let a,u;for(a=0,u=r.skips.length;a<u;a++)if(r.skips[a].test(n))return!1;for(a=0,u=r.names.length;a<u;a++)if(r.names[a].test(n))return!0;return!1}function l(n){return n.toString().substring(2,n.toString().length-2).replace(/\.\*\?$/,"*")}function b(n){return n instanceof Error?n.stack||n.message:n}function k(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}K.exports=we});var W=L((y,R)=>{y.formatArgs=xe;y.save=Fe;y.load=ve;y.useColors=ye;y.storage=Ae();y.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();y.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function ye(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function xe(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+R.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,s=>{s!=="%%"&&(r++,s==="%c"&&(o=r))}),e.splice(o,0,t)}y.log=console.debug||console.log||(()=>{});function Fe(e){try{e?y.storage.setItem("debug",e):y.storage.removeItem("debug")}catch{}}function ve(){let e;try{e=y.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function Ae(){try{return localStorage}catch{}}R.exports=G()(y);var{formatters:Ee}=R.exports;Ee.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Ne={};ue(Ne,{defaultInit:()=>Ie,perfService:()=>Me});var x=de(W(),1);function Se(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),o=0;o<r.length;o++)r[o]=255;for(var s=0;s<e.length;s++){var d=e.charAt(s),f=d.charCodeAt(0);if(r[f]!==255)throw new TypeError(d+" is ambiguous");r[f]=s}var l=e.length,b=e.charAt(0),k=Math.log(l)/Math.log(256),n=Math.log(256)/Math.log(l);function a(i){if(i instanceof Uint8Array||(ArrayBuffer.isView(i)?i=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):Array.isArray(i)&&(i=Uint8Array.from(i))),!(i instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(i.length===0)return"";for(var c=0,p=0,h=0,m=i.length;h!==m&&i[h]===0;)h++,c++;for(var F=(m-h)*n+1>>>0,C=new Uint8Array(F);h!==m;){for(var E=i[h],v=0,w=F-1;(E!==0||v<p)&&w!==-1;w--,v++)E+=256*C[w]>>>0,C[w]=E%l>>>0,E=E/l>>>0;if(E!==0)throw new Error("Non-zero carry");p=v,h++}for(var A=F-p;A!==F&&C[A]===0;)A++;for(var z=b.repeat(c);A<F;++A)z+=e.charAt(C[A]);return z}function u(i){if(typeof i!="string")throw new TypeError("Expected String");if(i.length===0)return new Uint8Array;var c=0;if(i[c]!==" "){for(var p=0,h=0;i[c]===b;)p++,c++;for(var m=(i.length-c)*k+1>>>0,F=new Uint8Array(m);i[c];){var C=r[i.charCodeAt(c)];if(C===255)return;for(var E=0,v=m-1;(C!==0||E<h)&&v!==-1;v--,E++)C+=l*F[v]>>>0,F[v]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");h=E,c++}if(i[c]!==" "){for(var w=m-h;w!==m&&F[w]===0;)w++;for(var A=new Uint8Array(p+(m-w)),z=p;w!==m;)A[z++]=F[w++];return A}}}function U(i){var c=u(i);if(c)return c;throw new Error(`Non-${t} character`)}return{encode:a,decodeUnsafe:u,decode:U}}var ke=Se,Ue=ke,X=Ue;var $e=new Uint8Array(0);var Q=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};var T=class{constructor(t,r,o){this.name=t,this.prefix=r,this.baseEncode=o}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},$=class{constructor(t,r,o){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=o}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Y(this,t)}},j=class{constructor(t){this.decoders=t}or(t){return Y(this,t)}decode(t){let r=t[0],o=this.decoders[r];if(o)return o.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Y=(e,t)=>new j({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}}),D=class{constructor(t,r,o,s){this.name=t,this.prefix=r,this.baseEncode=o,this.baseDecode=s,this.encoder=new T(t,r,o),this.decoder=new $(t,r,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},H=({name:e,prefix:t,encode:r,decode:o})=>new D(e,t,r,o),_=({prefix:e,name:t,alphabet:r})=>{let{encode:o,decode:s}=X(r,t);return H({prefix:e,name:t,encode:o,decode:d=>Q(s(d))})},ze=(e,t,r,o)=>{let s={};for(let n=0;n<t.length;++n)s[t[n]]=n;let d=e.length;for(;e[d-1]==="=";)--d;let f=new Uint8Array(d*r/8|0),l=0,b=0,k=0;for(let n=0;n<d;++n){let a=s[e[n]];if(a===void 0)throw new SyntaxError(`Non-${o} character`);b=b<<r|a,l+=r,l>=8&&(l-=8,f[k++]=255&b>>l)}if(l>=r||255&b<<8-l)throw new SyntaxError("Unexpected end of data");return f},Be=(e,t,r)=>{let o=t[t.length-1]==="=",s=(1<<r)-1,d="",f=0,l=0;for(let b=0;b<e.length;++b)for(l=l<<8|e[b],f+=8;f>r;)f-=r,d+=t[s&l>>f];if(f&&(d+=t[s&l<<r-f]),o)for(;d.length*r&7;)d+="=";return d},g=({name:e,prefix:t,bitsPerChar:r,alphabet:o})=>H({prefix:t,name:e,encode(s){return Be(s,o,r)},decode(s){return ze(s,o,r,e)}});var ee=g({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),qe=g({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ze=g({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ke=g({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ge=g({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),We=g({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Xe=g({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Qe=g({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ye=g({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var re=_({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),rr=_({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var te=g({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),or=g({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),sr=g({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ar=g({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});x.default.formatters.b=e=>e==null?"undefined":re.baseEncode(e);x.default.formatters.t=e=>e==null?"undefined":ee.baseEncode(e);x.default.formatters.m=e=>e==null?"undefined":te.baseEncode(e);x.default.formatters.p=e=>e==null?"undefined":e.toString();x.default.formatters.c=e=>e==null?"undefined":e.toString();x.default.formatters.k=e=>e==null?"undefined":e.toString();x.default.formatters.a=e=>e==null?"undefined":e.toString();function Oe(e){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}function ne(e){let t=Oe(`${e}:trace`);return x.default.enabled(`${e}:trace`)&&x.default.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=(0,x.default)(`${e}:trace`)),Object.assign((0,x.default)(e),{error:(0,x.default)(`${e}:error`),trace:t})}var oe="/perf/1.0.0",se=BigInt(65536);var M=ne("libp2p:perf"),Ie={protocolName:"/perf/1.0.0",writeBlockSize:BigInt(65536)},J=class{protocol;components;started;databuf;writeBlockSize;constructor(t,r){this.components=t,this.started=!1,this.protocol=r.protocolName??oe,this.writeBlockSize=r.writeBlockSize??se,this.databuf=new ArrayBuffer(Number(r.writeBlockSize))}async start(){await this.components.registrar.handle(this.protocol,t=>{this.handleMessage(t).catch(r=>{M.error("error handling perf protocol message",r)})}),this.started=!0}async stop(){await this.components.registrar.unhandle(this.protocol),this.started=!1}isStarted(){return this.started}async handleMessage(t){let{stream:r}=t,o=this.writeBlockSize,s=null;for await(let f of r.source)s===null&&(s=BigInt(f.getBigUint64(0,!1)));let d=new Uint8Array(this.databuf);if(s===null)throw new Error("bytesToSendBack was not set");await r.sink(async function*(){for(;s>0n;){let f=o;f>s&&(f=s),s=s-f,yield d.subarray(0,Number(f))}}())}async measurePerformance(t,r,o,s,d={}){M("opening stream on protocol %s to %p",this.protocol,r.remotePeer);let f=new Uint8Array(this.databuf),l=this.writeBlockSize,b=await r.newStream([this.protocol],d);new DataView(this.databuf).setBigInt64(0,s,!1),M("sending %i bytes to %p",o,r.remotePeer);try{await b.sink(async function*(){for(yield f.subarray(0,8);o>0n;){let a=l;a>o&&(a=o),o=o-a,yield f.subarray(0,Number(a))}}());let n=BigInt(0);for await(let a of b.source)n+=BigInt(a.length);if(n!==s)throw new Error(`Expected to receive ${s} bytes, but received ${n}`)}catch(n){throw M("error sending %i bytes to %p: %s",o,r.remotePeer,n),n}finally{M("performed %s to %p",this.protocol,r.remotePeer),await b.close()}return Date.now()-t}};function Me(e={}){return t=>new J(t,e)}return pe(Ne);})();
3
3
  return Libp2PPerf}));
package/dist/src/index.js CHANGED
@@ -104,7 +104,7 @@ class DefaultPerfService {
104
104
  log('opening stream on protocol %s to %p', this.protocol, connection.remotePeer);
105
105
  const uint8Buf = new Uint8Array(this.databuf);
106
106
  const writeBlockSize = this.writeBlockSize;
107
- const stream = await connection.newStream([this.protocol]);
107
+ const stream = await connection.newStream([this.protocol], options);
108
108
  // Convert sendBytes to uint64 big endian buffer
109
109
  const view = new DataView(this.databuf);
110
110
  view.setBigInt64(0, recvBytes, false);
@@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AAC,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,CAAA;YAC/D,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;SACrB;QAED,qBAAqB;QACrB,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAA;IAC/B,CAAC;CACF;AAED,MAAM,UAAU,WAAW,CAAE,OAAwB,EAAE;IACrD,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AACjE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/perf",
3
- "version": "1.1.5-a6be8f0f",
3
+ "version": "1.1.6-10cbc8fa",
4
4
  "description": "Implementation of Perf Protocol",
5
5
  "author": "@maschad / @marcopolo",
6
6
  "license": "Apache-2.0 OR MIT",
@@ -49,16 +49,16 @@
49
49
  "dependencies": {
50
50
  "@chainsafe/libp2p-noise": "^13.0.0",
51
51
  "@chainsafe/libp2p-yamux": "^5.0.0",
52
- "@libp2p/crypto": "2.0.3-a6be8f0f",
53
- "@libp2p/interface": "0.1.2-a6be8f0f",
54
- "@libp2p/interface-compliance-tests": "4.0.5-a6be8f0f",
55
- "@libp2p/interface-internal": "0.1.4-a6be8f0f",
52
+ "@libp2p/crypto": "2.0.3-10cbc8fa",
53
+ "@libp2p/interface": "0.1.2-10cbc8fa",
54
+ "@libp2p/interface-compliance-tests": "4.0.5-10cbc8fa",
55
+ "@libp2p/interface-internal": "0.1.4-10cbc8fa",
56
56
  "@libp2p/interfaces": "3.3.2",
57
- "@libp2p/logger": "3.0.2-a6be8f0f",
58
- "@libp2p/peer-id-factory": "3.0.3-a6be8f0f",
59
- "@libp2p/tcp": "8.0.5-a6be8f0f",
57
+ "@libp2p/logger": "3.0.2-10cbc8fa",
58
+ "@libp2p/peer-id-factory": "3.0.3-10cbc8fa",
59
+ "@libp2p/tcp": "8.0.5-10cbc8fa",
60
60
  "@multiformats/multiaddr": "^12.1.5",
61
- "libp2p": "0.46.8-a6be8f0f",
61
+ "libp2p": "0.46.9-10cbc8fa",
62
62
  "uint8arrays": "^4.0.6",
63
63
  "yargs": "^17.7.2"
64
64
  },
package/src/index.ts CHANGED
@@ -145,7 +145,7 @@ class DefaultPerfService implements Startable, PerfService {
145
145
 
146
146
  const writeBlockSize = this.writeBlockSize
147
147
 
148
- const stream = await connection.newStream([this.protocol])
148
+ const stream = await connection.newStream([this.protocol], options)
149
149
 
150
150
  // Convert sendBytes to uint64 big endian buffer
151
151
  const view = new DataView(this.databuf)