@libp2p/interface
Advanced tools
Comparing version 1.6.3 to 1.7.0-359265a3a
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PInterface = factory()}(typeof self !== 'undefined' ? self : this, function () { | ||
"use strict";var Libp2PInterface=(()=>{var n=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var g=(e,t)=>{for(var o in t)n(e,o,{get:t[o],enumerable:!0})},v=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of L(t))!_.call(e,r)&&r!==o&&n(e,r,{get:()=>t[r],enumerable:!(s=I(t,r))||s.enumerable});return e};var N=e=>v(n({},"__esModule",{value:!0}),e);var J={};g(J,{AbortError:()=>p,AggregateCodeError:()=>l,CodeError:()=>a,CustomEvent:()=>y,ERR_INVALID_MESSAGE:()=>Y,ERR_INVALID_PARAMETERS:()=>j,ERR_NOT_FOUND:()=>X,ERR_TIMEOUT:()=>G,Ed25519:()=>P,FaultTolerance:()=>c,InvalidCryptoExchangeError:()=>x,InvalidCryptoTransmissionError:()=>m,KEEP_ALIVE:()=>V,RSA:()=>D,StrictNoSign:()=>B,StrictSign:()=>k,TopicValidatorResult:()=>i,TypedEventEmitter:()=>d,UnexpectedPeerError:()=>f,connectionSymbol:()=>R,contentRoutingSymbol:()=>w,isConnection:()=>T,isPeerId:()=>C,isStartable:()=>S,isTransport:()=>F,peerDiscoverySymbol:()=>O,peerIdSymbol:()=>b,peerRoutingSymbol:()=>U,secp256k1:()=>M,serviceCapabilities:()=>q,serviceDependencies:()=>z,setMaxListeners:()=>u,start:()=>H,stop:()=>K,transportSymbol:()=>h});var R=Symbol.for("@libp2p/connection");function T(e){return e!=null&&!!e[R]}var w=Symbol.for("@libp2p/content-routing");var P="Ed25519",D="RSA",M="secp256k1";var O=Symbol.for("@libp2p/peer-discovery");var b=Symbol.for("@libp2p/peer-id");function C(e){return e!=null&&!!e[b]}var U=Symbol.for("@libp2p/peer-routing");var V="keep-alive";var k="StrictSign",B="StrictNoSign",i;(function(e){e.Accept="accept",e.Ignore="ignore",e.Reject="reject"})(i||(i={}));var h=Symbol.for("@libp2p/transport");function F(e){return e!=null&&!!e[h]}var c;(function(e){e[e.FATAL_ALL=0]="FATAL_ALL",e[e.NO_FATAL=1]="NO_FATAL"})(c||(c={}));var p=class e extends Error{code;type;constructor(t="The operation was aborted"){super(t),this.name="AbortError",this.code=e.code,this.type=e.type}static code="ABORT_ERR";static type="aborted"},a=class extends Error{code;props;constructor(t,o,s){super(t),this.code=o,this.name=s?.name??"CodeError",this.props=s??{}}},l=class extends AggregateError{code;props;constructor(t,o,s,r){super(t,o),this.code=s,this.name=r?.name??"AggregateCodeError",this.props=r??{}}},f=class e extends Error{code;constructor(t="Unexpected Peer"){super(t),this.name="UnexpectedPeerError",this.code=e.code}static code="ERR_UNEXPECTED_PEER"},x=class e extends Error{code;constructor(t="Invalid crypto exchange"){super(t),this.name="InvalidCryptoExchangeError",this.code=e.code}static code="ERR_INVALID_CRYPTO_EXCHANGE"},m=class e extends Error{code;constructor(t="Invalid crypto transmission"){super(t),this.name="InvalidCryptoTransmissionError",this.code=e.code}static code="ERR_INVALID_CRYPTO_TRANSMISSION"},G="ERR_TIMEOUT",j="ERR_INVALID_PARAMETERS",X="ERR_NOT_FOUND",Y="ERR_INVALID_MESSAGE";var u=(e,...t)=>{try{[...t]}catch{}};var d=class extends EventTarget{#t=new Map;constructor(){super(),u(1/0,this)}listenerCount(t){let o=this.#t.get(t);return o==null?0:o.length}addEventListener(t,o,s){super.addEventListener(t,o,s);let r=this.#t.get(t);r==null&&(r=[],this.#t.set(t,r)),r.push({callback:o,once:(s!==!0&&s!==!1&&s?.once)??!1})}removeEventListener(t,o,s){super.removeEventListener(t.toString(),o??null,s);let r=this.#t.get(t);r!=null&&(r=r.filter(({callback:A})=>A!==o),this.#t.set(t,r))}dispatchEvent(t){let o=super.dispatchEvent(t),s=this.#t.get(t.type);return s==null||(s=s.filter(({once:r})=>!r),this.#t.set(t.type,s)),o}safeDispatchEvent(t,o={}){return this.dispatchEvent(new y(t,o))}},E=class extends Event{detail;constructor(t,o){super(t,o),this.detail=o?.detail}},y=globalThis.CustomEvent??E;function S(e){return e!=null&&typeof e.start=="function"&&typeof e.stop=="function"}async function H(...e){let t=[];for(let o of e)S(o)&&t.push(o);await Promise.all(t.map(async o=>{o.beforeStart!=null&&await o.beforeStart()})),await Promise.all(t.map(async o=>{await o.start()})),await Promise.all(t.map(async o=>{o.afterStart!=null&&await o.afterStart()}))}async function K(...e){let t=[];for(let o of e)S(o)&&t.push(o);await Promise.all(t.map(async o=>{o.beforeStop!=null&&await o.beforeStop()})),await Promise.all(t.map(async o=>{await o.stop()})),await Promise.all(t.map(async o=>{o.afterStop!=null&&await o.afterStop()}))}var q=Symbol.for("@libp2p/service-capabilities"),z=Symbol.for("@libp2p/service-dependencies");return N(J);})(); | ||
"use strict";var Libp2PInterface=(()=>{var n=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var _=(e,t)=>{for(var o in t)n(e,o,{get:t[o],enumerable:!0})},g=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of I(t))!L.call(e,r)&&r!==o&&n(e,r,{get:()=>t[r],enumerable:!(s=A(t,r))||s.enumerable});return e};var v=e=>g(n({},"__esModule",{value:!0}),e);var z={};_(z,{AbortError:()=>c,AggregateCodeError:()=>l,CodeError:()=>a,CustomEvent:()=>h,ERR_INVALID_MESSAGE:()=>X,ERR_INVALID_PARAMETERS:()=>G,ERR_NOT_FOUND:()=>j,ERR_TIMEOUT:()=>F,Ed25519:()=>w,FaultTolerance:()=>p,InvalidCryptoExchangeError:()=>x,InvalidCryptoTransmissionError:()=>m,KEEP_ALIVE:()=>U,RSA:()=>P,StrictNoSign:()=>k,StrictSign:()=>V,TopicValidatorResult:()=>i,TypedEventEmitter:()=>E,UnexpectedPeerError:()=>f,connectionSymbol:()=>S,contentRoutingSymbol:()=>T,isConnection:()=>N,isPeerId:()=>O,isStartable:()=>d,isTransport:()=>B,peerDiscoverySymbol:()=>M,peerIdSymbol:()=>R,peerRoutingSymbol:()=>C,secp256k1:()=>D,serviceCapabilities:()=>K,serviceDependencies:()=>q,setMaxListeners:()=>u,start:()=>Y,stop:()=>H,transportSymbol:()=>b});var S=Symbol.for("@libp2p/connection");function N(e){return e!=null&&!!e[S]}var T=Symbol.for("@libp2p/content-routing");var w="Ed25519",P="RSA",D="secp256k1";var M=Symbol.for("@libp2p/peer-discovery");var R=Symbol.for("@libp2p/peer-id");function O(e){return e!=null&&!!e[R]}var C=Symbol.for("@libp2p/peer-routing");var U="keep-alive";var V="StrictSign",k="StrictNoSign",i;(function(e){e.Accept="accept",e.Ignore="ignore",e.Reject="reject"})(i||(i={}));var b=Symbol.for("@libp2p/transport");function B(e){return e!=null&&!!e[b]}var p;(function(e){e[e.FATAL_ALL=0]="FATAL_ALL",e[e.NO_FATAL=1]="NO_FATAL"})(p||(p={}));var c=class e extends Error{code;type;constructor(t="The operation was aborted"){super(t),this.name="AbortError",this.code=e.code,this.type=e.type}static code="ABORT_ERR";static type="aborted"},a=class extends Error{code;props;constructor(t,o,s){super(t),this.code=o,this.name=s?.name??"CodeError",this.props=s??{}}},l=class extends AggregateError{code;props;constructor(t,o,s,r){super(t,o),this.code=s,this.name=r?.name??"AggregateCodeError",this.props=r??{}}},f=class e extends Error{code;constructor(t="Unexpected Peer"){super(t),this.name="UnexpectedPeerError",this.code=e.code}static code="ERR_UNEXPECTED_PEER"},x=class e extends Error{code;constructor(t="Invalid crypto exchange"){super(t),this.name="InvalidCryptoExchangeError",this.code=e.code}static code="ERR_INVALID_CRYPTO_EXCHANGE"},m=class e extends Error{code;constructor(t="Invalid crypto transmission"){super(t),this.name="InvalidCryptoTransmissionError",this.code=e.code}static code="ERR_INVALID_CRYPTO_TRANSMISSION"},F="ERR_TIMEOUT",G="ERR_INVALID_PARAMETERS",j="ERR_NOT_FOUND",X="ERR_INVALID_MESSAGE";var u=(e,...t)=>{try{[...t]}catch{}};var E=class extends EventTarget{#t=new Map;constructor(){super(),u(1/0,this)}listenerCount(t){let o=this.#t.get(t);return o==null?0:o.length}addEventListener(t,o,s){super.addEventListener(t,o,s);let r=this.#t.get(t);r==null&&(r=[],this.#t.set(t,r)),r.push({callback:o,once:(s!==!0&&s!==!1&&s?.once)??!1})}removeEventListener(t,o,s){super.removeEventListener(t.toString(),o??null,s);let r=this.#t.get(t);r!=null&&(r=r.filter(({callback:y})=>y!==o),this.#t.set(t,r))}dispatchEvent(t){let o=super.dispatchEvent(t),s=this.#t.get(t.type);return s==null||(s=s.filter(({once:r})=>!r),this.#t.set(t.type,s)),o}safeDispatchEvent(t,o={}){return this.dispatchEvent(new h(t,o))}},h=globalThis.CustomEvent;function d(e){return e!=null&&typeof e.start=="function"&&typeof e.stop=="function"}async function Y(...e){let t=[];for(let o of e)d(o)&&t.push(o);await Promise.all(t.map(async o=>{o.beforeStart!=null&&await o.beforeStart()})),await Promise.all(t.map(async o=>{await o.start()})),await Promise.all(t.map(async o=>{o.afterStart!=null&&await o.afterStart()}))}async function H(...e){let t=[];for(let o of e)d(o)&&t.push(o);await Promise.all(t.map(async o=>{o.beforeStop!=null&&await o.beforeStop()})),await Promise.all(t.map(async o=>{await o.stop()})),await Promise.all(t.map(async o=>{o.afterStop!=null&&await o.afterStop()}))}var K=Symbol.for("@libp2p/service-capabilities"),q=Symbol.for("@libp2p/service-dependencies");return v(z);})(); | ||
return Libp2PInterface})); |
@@ -249,2 +249,8 @@ import type { AbortOptions, Logger } from '../index.js'; | ||
/** | ||
* The time in milliseconds it takes to make a round trip to the remote peer. | ||
* | ||
* This is updated periodically by the connection monitor. | ||
*/ | ||
rtt?: number; | ||
/** | ||
* Create a new stream on this connection and negotiate one of the passed protocols | ||
@@ -251,0 +257,0 @@ */ |
@@ -56,19 +56,3 @@ import { setMaxListeners } from './events.js'; | ||
} | ||
/** | ||
* CustomEvent is a standard event but it's not supported by node. | ||
* | ||
* Remove this when https://github.com/nodejs/node/issues/40678 is closed. | ||
* | ||
* Ref: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent | ||
*/ | ||
class CustomEventPolyfill extends Event { | ||
/** Returns any custom data event was created with. Typically used for synthetic events. */ | ||
detail; | ||
constructor(message, data) { | ||
super(message, data); | ||
// @ts-expect-error could be undefined | ||
this.detail = data?.detail; | ||
} | ||
} | ||
export const CustomEvent = globalThis.CustomEvent ?? CustomEventPolyfill; | ||
export const CustomEvent = globalThis.CustomEvent; | ||
//# sourceMappingURL=event-target.js.map |
{ | ||
"name": "@libp2p/interface", | ||
"version": "1.6.3", | ||
"version": "1.7.0-359265a3a", | ||
"description": "The interface implemented by a libp2p node", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0 OR MIT", |
@@ -291,2 +291,9 @@ import type { AbortOptions, Logger } from '../index.js' | ||
/** | ||
* The time in milliseconds it takes to make a round trip to the remote peer. | ||
* | ||
* This is updated periodically by the connection monitor. | ||
*/ | ||
rtt?: number | ||
/** | ||
* Create a new stream on this connection and negotiate one of the passed protocols | ||
@@ -293,0 +300,0 @@ */ |
@@ -108,20 +108,2 @@ import { setMaxListeners } from './events.js' | ||
/** | ||
* CustomEvent is a standard event but it's not supported by node. | ||
* | ||
* Remove this when https://github.com/nodejs/node/issues/40678 is closed. | ||
* | ||
* Ref: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent | ||
*/ | ||
class CustomEventPolyfill<T = any> extends Event { | ||
/** Returns any custom data event was created with. Typically used for synthetic events. */ | ||
public detail: T | ||
constructor (message: string, data?: EventInit & { detail: T }) { | ||
super(message, data) | ||
// @ts-expect-error could be undefined | ||
this.detail = data?.detail | ||
} | ||
} | ||
export const CustomEvent = globalThis.CustomEvent ?? CustomEventPolyfill | ||
export const CustomEvent = globalThis.CustomEvent |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
234738
124
5717
1