@libp2p/interface 1.0.1 → 1.0.2-742915567
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 +1 -1
- package/dist/src/event-target.d.ts +39 -0
- package/dist/src/event-target.d.ts.map +1 -0
- package/dist/src/event-target.js +66 -0
- package/dist/src/event-target.js.map +1 -0
- package/dist/src/events.d.ts +0 -38
- package/dist/src/events.d.ts.map +1 -1
- package/dist/src/events.js +0 -65
- package/dist/src/events.js.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/peer-discovery/index.d.ts +1 -1
- package/dist/src/peer-discovery/index.d.ts.map +1 -1
- package/dist/src/pubsub/index.d.ts +1 -1
- package/dist/src/pubsub/index.d.ts.map +1 -1
- package/dist/src/transport/index.d.ts +1 -1
- package/dist/src/transport/index.d.ts.map +1 -1
- package/package.json +4 -1
- package/src/event-target.ts +116 -0
- package/src/events.ts +0 -117
- package/src/index.ts +2 -1
- package/src/peer-discovery/index.ts +1 -1
- package/src/pubsub/index.ts +1 -1
- package/src/transport/index.ts +1 -1
- package/dist/typedoc-urls.json +0 -152
package/dist/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PInterface = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PInterface=(()=>{var n=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var _=(e,t)=>{for(var o in t)n(e,o,{get:t[o],enumerable:!0})},I=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of y(t))!L.call(e,s)&&s!==o&&n(e,s,{get:()=>t[s],enumerable:!(r=h(t,s))||r.enumerable});return e};var g=e=>I(n({},"__esModule",{value:!0}),e);var K={};_(K,{AbortError:()=>i,CodeError:()=>a,CustomEvent:()=>b,ERR_INVALID_MESSAGE:()=>j,ERR_INVALID_PARAMETERS:()=>F,ERR_NOT_FOUND:()=>G,ERR_TIMEOUT:()=>B,Ed25519:()=>v,FaultTolerance:()=>c,InvalidCryptoExchangeError:()=>x,InvalidCryptoTransmissionError:()=>f,KEEP_ALIVE:()=>V,RSA:()=>w,StrictNoSign:()=>U,StrictSign:()=>C,TopicValidatorResult:()=>p,TypedEventEmitter:()=>u,UnexpectedPeerError:()=>l,connectionSymbol:()=>S,contentRoutingSymbol:()=>T,isConnection:()=>N,isPeerId:()=>O,isStartable:()=>E,isTransport:()=>k,peerDiscoverySymbol:()=>M,peerIdSymbol:()=>d,peerRoutingSymbol:()=>D,secp256k1:()=>P,setMaxListeners:()=>X,start:()=>Y,stop:()=>H,transportSymbol:()=>R});var S=Symbol.for("@libp2p/connection");function N(e){return e!=null&&!!e[S]}var T=Symbol.for("@libp2p/content-routing");var v="Ed25519",w="RSA",P="secp256k1";var M=Symbol.for("@libp2p/peer-discovery");var d=Symbol.for("@libp2p/peer-id");function O(e){return e!=null&&!!e[d]}var D=Symbol.for("@libp2p/peer-routing");var V="keep-alive";var C="StrictSign",U="StrictNoSign",p;(function(e){e.Accept="accept",e.Ignore="ignore",e.Reject="reject"})(p||(p={}));var R=Symbol.for("@libp2p/transport");function k(e){return e!=null&&!!e[R]}var c;(function(e){e[e.FATAL_ALL=0]="FATAL_ALL",e[e.NO_FATAL=1]="NO_FATAL"})(c||(c={}));var i=class e extends Error{code;type;constructor(t="The operation was aborted"){super(t),this.code=e.code,this.type=e.type}static code="ABORT_ERR";static type="aborted"},a=class extends Error{code;props;constructor(t,o,r){super(t),this.code=o,this.name=r?.name??"CodeError",this.props=r??{}}},l=class e extends Error{code;constructor(t="Unexpected Peer"){super(t),this.code=e.code}static code="ERR_UNEXPECTED_PEER"},x=class e extends Error{code;constructor(t="Invalid crypto exchange"){super(t),this.code=e.code}static code="ERR_INVALID_CRYPTO_EXCHANGE"},f=class e extends Error{code;constructor(t="Invalid crypto transmission"){super(t),this.code=e.code}static code="ERR_INVALID_CRYPTO_TRANSMISSION"},B="ERR_TIMEOUT",F="ERR_INVALID_PARAMETERS",G="ERR_NOT_FOUND",j="ERR_INVALID_MESSAGE";var u=class extends EventTarget{#t=new Map;listenerCount(t){let o=this.#t.get(t);return o==null?0:o.length}addEventListener(t,o,r){super.addEventListener(t,o,r);let s=this.#t.get(t);s==null&&(s=[],this.#t.set(t,s)),s.push({callback:o,once:(r!==!0&&r!==!1&&r?.once)??!1})}removeEventListener(t,o,r){super.removeEventListener(t.toString(),o??null,r);let s=this.#t.get(t);s!=null&&(s=s.filter(({callback:A})=>A!==o),this.#t.set(t,s))}dispatchEvent(t){let o=super.dispatchEvent(t),r=this.#t.get(t.type);return r==null||(r=r.filter(({once:s})=>!s),this.#t.set(t.type,r)),o}safeDispatchEvent(t,o){return this.dispatchEvent(new b(t,o))}},m=class extends Event{detail;constructor(t,o){super(t,o),this.detail=o?.detail}},b=globalThis.CustomEvent??m
|
|
2
|
+
"use strict";var Libp2PInterface=(()=>{var n=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var _=(e,t)=>{for(var o in t)n(e,o,{get:t[o],enumerable:!0})},I=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of y(t))!L.call(e,s)&&s!==o&&n(e,s,{get:()=>t[s],enumerable:!(r=h(t,s))||r.enumerable});return e};var g=e=>I(n({},"__esModule",{value:!0}),e);var K={};_(K,{AbortError:()=>i,CodeError:()=>a,CustomEvent:()=>b,ERR_INVALID_MESSAGE:()=>j,ERR_INVALID_PARAMETERS:()=>F,ERR_NOT_FOUND:()=>G,ERR_TIMEOUT:()=>B,Ed25519:()=>v,FaultTolerance:()=>c,InvalidCryptoExchangeError:()=>x,InvalidCryptoTransmissionError:()=>f,KEEP_ALIVE:()=>V,RSA:()=>w,StrictNoSign:()=>U,StrictSign:()=>C,TopicValidatorResult:()=>p,TypedEventEmitter:()=>u,UnexpectedPeerError:()=>l,connectionSymbol:()=>S,contentRoutingSymbol:()=>T,isConnection:()=>N,isPeerId:()=>O,isStartable:()=>E,isTransport:()=>k,peerDiscoverySymbol:()=>M,peerIdSymbol:()=>d,peerRoutingSymbol:()=>D,secp256k1:()=>P,setMaxListeners:()=>X,start:()=>Y,stop:()=>H,transportSymbol:()=>R});var S=Symbol.for("@libp2p/connection");function N(e){return e!=null&&!!e[S]}var T=Symbol.for("@libp2p/content-routing");var v="Ed25519",w="RSA",P="secp256k1";var M=Symbol.for("@libp2p/peer-discovery");var d=Symbol.for("@libp2p/peer-id");function O(e){return e!=null&&!!e[d]}var D=Symbol.for("@libp2p/peer-routing");var V="keep-alive";var C="StrictSign",U="StrictNoSign",p;(function(e){e.Accept="accept",e.Ignore="ignore",e.Reject="reject"})(p||(p={}));var R=Symbol.for("@libp2p/transport");function k(e){return e!=null&&!!e[R]}var c;(function(e){e[e.FATAL_ALL=0]="FATAL_ALL",e[e.NO_FATAL=1]="NO_FATAL"})(c||(c={}));var i=class e extends Error{code;type;constructor(t="The operation was aborted"){super(t),this.code=e.code,this.type=e.type}static code="ABORT_ERR";static type="aborted"},a=class extends Error{code;props;constructor(t,o,r){super(t),this.code=o,this.name=r?.name??"CodeError",this.props=r??{}}},l=class e extends Error{code;constructor(t="Unexpected Peer"){super(t),this.code=e.code}static code="ERR_UNEXPECTED_PEER"},x=class e extends Error{code;constructor(t="Invalid crypto exchange"){super(t),this.code=e.code}static code="ERR_INVALID_CRYPTO_EXCHANGE"},f=class e extends Error{code;constructor(t="Invalid crypto transmission"){super(t),this.code=e.code}static code="ERR_INVALID_CRYPTO_TRANSMISSION"},B="ERR_TIMEOUT",F="ERR_INVALID_PARAMETERS",G="ERR_NOT_FOUND",j="ERR_INVALID_MESSAGE";var u=class extends EventTarget{#t=new Map;listenerCount(t){let o=this.#t.get(t);return o==null?0:o.length}addEventListener(t,o,r){super.addEventListener(t,o,r);let s=this.#t.get(t);s==null&&(s=[],this.#t.set(t,s)),s.push({callback:o,once:(r!==!0&&r!==!1&&r?.once)??!1})}removeEventListener(t,o,r){super.removeEventListener(t.toString(),o??null,r);let s=this.#t.get(t);s!=null&&(s=s.filter(({callback:A})=>A!==o),this.#t.set(t,s))}dispatchEvent(t){let o=super.dispatchEvent(t),r=this.#t.get(t.type);return r==null||(r=r.filter(({once:s})=>!s),this.#t.set(t.type,r)),o}safeDispatchEvent(t,o){return this.dispatchEvent(new b(t,o))}},m=class extends Event{detail;constructor(t,o){super(t,o),this.detail=o?.detail}},b=globalThis.CustomEvent??m;var X=(e,...t)=>{try{[...t]}catch{}};function E(e){return e!=null&&typeof e.start=="function"&&typeof e.stop=="function"}async function Y(...e){let t=[];for(let o of e)E(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)E(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()}))}return g(K);})();
|
|
3
3
|
return Libp2PInterface}));
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface EventCallback<EventType> {
|
|
2
|
+
(evt: EventType): void;
|
|
3
|
+
}
|
|
4
|
+
export interface EventObject<EventType> {
|
|
5
|
+
handleEvent: EventCallback<EventType>;
|
|
6
|
+
}
|
|
7
|
+
export type EventHandler<EventType> = EventCallback<EventType> | EventObject<EventType>;
|
|
8
|
+
/**
|
|
9
|
+
* Adds types to the EventTarget class. Hopefully this won't be necessary forever.
|
|
10
|
+
*
|
|
11
|
+
* https://github.com/microsoft/TypeScript/issues/28357
|
|
12
|
+
* https://github.com/microsoft/TypeScript/issues/43477
|
|
13
|
+
* https://github.com/microsoft/TypeScript/issues/299
|
|
14
|
+
* etc
|
|
15
|
+
*/
|
|
16
|
+
export interface TypedEventTarget<EventMap extends Record<string, any>> extends EventTarget {
|
|
17
|
+
addEventListener<K extends keyof EventMap>(type: K, listener: EventHandler<EventMap[K]> | null, options?: boolean | AddEventListenerOptions): void;
|
|
18
|
+
listenerCount(type: string): number;
|
|
19
|
+
removeEventListener<K extends keyof EventMap>(type: K, listener?: EventHandler<EventMap[K]> | null, options?: boolean | EventListenerOptions): void;
|
|
20
|
+
removeEventListener(type: string, listener?: EventHandler<Event>, options?: boolean | EventListenerOptions): void;
|
|
21
|
+
safeDispatchEvent<Detail>(type: keyof EventMap, detail: CustomEventInit<Detail>): boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* An implementation of a typed event target
|
|
25
|
+
* etc
|
|
26
|
+
*/
|
|
27
|
+
export declare class TypedEventEmitter<EventMap extends Record<string, any>> extends EventTarget implements TypedEventTarget<EventMap> {
|
|
28
|
+
#private;
|
|
29
|
+
listenerCount(type: string): number;
|
|
30
|
+
addEventListener<K extends keyof EventMap>(type: K, listener: EventHandler<EventMap[K]> | null, options?: boolean | AddEventListenerOptions): void;
|
|
31
|
+
removeEventListener<K extends keyof EventMap>(type: K, listener?: EventHandler<EventMap[K]> | null, options?: boolean | EventListenerOptions): void;
|
|
32
|
+
dispatchEvent(event: Event): boolean;
|
|
33
|
+
safeDispatchEvent<Detail>(type: keyof EventMap, detail: CustomEventInit<Detail>): boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare const CustomEvent: {
|
|
36
|
+
new <T>(type: string, eventInitDict?: CustomEventInit<T> | undefined): CustomEvent<T>;
|
|
37
|
+
prototype: CustomEvent<any>;
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=event-target.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-target.d.ts","sourceRoot":"","sources":["../../src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AS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAE,SAAQ,WAAY,YAAW,gBAAgB,CAAC,QAAQ,CAAC;;IAG5H,aAAa,CAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAUpC,gBAAgB,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAAG,IAAI;IAiBlJ,mBAAmB,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,oBAAoB,GAAG,IAAI;IAcnJ,aAAa,CAAE,KAAK,EAAE,KAAK,GAAG,OAAO;IAerC,iBAAiB,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,EAAE,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,GAAG,OAAO;CAG1F;AAoBD,eAAO,MAAM,WAAW;;;CAAgD,CAAA"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An implementation of a typed event target
|
|
3
|
+
* etc
|
|
4
|
+
*/
|
|
5
|
+
export class TypedEventEmitter extends EventTarget {
|
|
6
|
+
#listeners = new Map();
|
|
7
|
+
listenerCount(type) {
|
|
8
|
+
const listeners = this.#listeners.get(type);
|
|
9
|
+
if (listeners == null) {
|
|
10
|
+
return 0;
|
|
11
|
+
}
|
|
12
|
+
return listeners.length;
|
|
13
|
+
}
|
|
14
|
+
addEventListener(type, listener, options) {
|
|
15
|
+
super.addEventListener(type, listener, options);
|
|
16
|
+
let list = this.#listeners.get(type);
|
|
17
|
+
if (list == null) {
|
|
18
|
+
list = [];
|
|
19
|
+
this.#listeners.set(type, list);
|
|
20
|
+
}
|
|
21
|
+
list.push({
|
|
22
|
+
callback: listener,
|
|
23
|
+
once: (options !== true && options !== false && options?.once) ?? false
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
removeEventListener(type, listener, options) {
|
|
27
|
+
super.removeEventListener(type.toString(), listener ?? null, options);
|
|
28
|
+
let list = this.#listeners.get(type);
|
|
29
|
+
if (list == null) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
list = list.filter(({ callback }) => callback !== listener);
|
|
33
|
+
this.#listeners.set(type, list);
|
|
34
|
+
}
|
|
35
|
+
dispatchEvent(event) {
|
|
36
|
+
const result = super.dispatchEvent(event);
|
|
37
|
+
let list = this.#listeners.get(event.type);
|
|
38
|
+
if (list == null) {
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
list = list.filter(({ once }) => !once);
|
|
42
|
+
this.#listeners.set(event.type, list);
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
safeDispatchEvent(type, detail) {
|
|
46
|
+
return this.dispatchEvent(new CustomEvent(type, detail));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* CustomEvent is a standard event but it's not supported by node.
|
|
51
|
+
*
|
|
52
|
+
* Remove this when https://github.com/nodejs/node/issues/40678 is closed.
|
|
53
|
+
*
|
|
54
|
+
* Ref: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent
|
|
55
|
+
*/
|
|
56
|
+
class CustomEventPolyfill extends Event {
|
|
57
|
+
/** Returns any custom data event was created with. Typically used for synthetic events. */
|
|
58
|
+
detail;
|
|
59
|
+
constructor(message, data) {
|
|
60
|
+
super(message, data);
|
|
61
|
+
// @ts-expect-error could be undefined
|
|
62
|
+
this.detail = data?.detail;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export const CustomEvent = globalThis.CustomEvent ?? CustomEventPolyfill;
|
|
66
|
+
//# sourceMappingURL=event-target.js.map
|
|
@@ -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ED
|
@@ -1,42 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { setMaxListeners as nodeSetMaxListeners } from 'events';
|
|
3
|
-
export interface EventCallback<EventType> {
|
|
4
|
-
(evt: EventType): void;
|
|
5
|
-
}
|
|
6
|
-
export interface EventObject<EventType> {
|
|
7
|
-
handleEvent: EventCallback<EventType>;
|
|
8
|
-
}
|
|
9
|
-
export type EventHandler<EventType> = EventCallback<EventType> | EventObject<EventType>;
|
|
10
|
-
/**
|
|
11
|
-
* Adds types to the EventTarget class. Hopefully this won't be necessary forever.
|
|
12
|
-
*
|
|
13
|
-
* https://github.com/microsoft/TypeScript/issues/28357
|
|
14
|
-
* https://github.com/microsoft/TypeScript/issues/43477
|
|
15
|
-
* https://github.com/microsoft/TypeScript/issues/299
|
|
16
|
-
* etc
|
|
17
|
-
*/
|
|
18
|
-
export interface TypedEventTarget<EventMap extends Record<string, any>> extends EventTarget {
|
|
19
|
-
addEventListener<K extends keyof EventMap>(type: K, listener: EventHandler<EventMap[K]> | null, options?: boolean | AddEventListenerOptions): void;
|
|
20
|
-
listenerCount(type: string): number;
|
|
21
|
-
removeEventListener<K extends keyof EventMap>(type: K, listener?: EventHandler<EventMap[K]> | null, options?: boolean | EventListenerOptions): void;
|
|
22
|
-
removeEventListener(type: string, listener?: EventHandler<Event>, options?: boolean | EventListenerOptions): void;
|
|
23
|
-
safeDispatchEvent<Detail>(type: keyof EventMap, detail: CustomEventInit<Detail>): boolean;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* An implementation of a typed event target
|
|
27
|
-
* etc
|
|
28
|
-
*/
|
|
29
|
-
export declare class TypedEventEmitter<EventMap extends Record<string, any>> extends EventTarget implements TypedEventTarget<EventMap> {
|
|
30
|
-
#private;
|
|
31
|
-
listenerCount(type: string): number;
|
|
32
|
-
addEventListener<K extends keyof EventMap>(type: K, listener: EventHandler<EventMap[K]> | null, options?: boolean | AddEventListenerOptions): void;
|
|
33
|
-
removeEventListener<K extends keyof EventMap>(type: K, listener?: EventHandler<EventMap[K]> | null, options?: boolean | EventListenerOptions): void;
|
|
34
|
-
dispatchEvent(event: Event): boolean;
|
|
35
|
-
safeDispatchEvent<Detail>(type: keyof EventMap, detail: CustomEventInit<Detail>): boolean;
|
|
36
|
-
}
|
|
37
|
-
export declare const CustomEvent: {
|
|
38
|
-
new <T>(type: string, eventInitDict?: CustomEventInit<T> | undefined): CustomEvent<T>;
|
|
39
|
-
prototype: CustomEvent<any>;
|
|
40
|
-
};
|
|
41
3
|
export declare const setMaxListeners: typeof nodeSetMaxListeners;
|
|
42
4
|
//# sourceMappingURL=events.d.ts.map
|
package/dist/src/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,IAAI,mBAAmB,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,IAAI,mBAAmB,EAAE,MAAM,QAAQ,CAAA;AAG/D,eAAO,MAAM,eAAe,EAAE,OAAO,mBAMpC,CAAA"}
|
package/dist/src/events.js
CHANGED
|
@@ -1,69 +1,4 @@
|
|
|
1
1
|
import { setMaxListeners as nodeSetMaxListeners } from 'events';
|
|
2
|
-
/**
|
|
3
|
-
* An implementation of a typed event target
|
|
4
|
-
* etc
|
|
5
|
-
*/
|
|
6
|
-
export class TypedEventEmitter extends EventTarget {
|
|
7
|
-
#listeners = new Map();
|
|
8
|
-
listenerCount(type) {
|
|
9
|
-
const listeners = this.#listeners.get(type);
|
|
10
|
-
if (listeners == null) {
|
|
11
|
-
return 0;
|
|
12
|
-
}
|
|
13
|
-
return listeners.length;
|
|
14
|
-
}
|
|
15
|
-
addEventListener(type, listener, options) {
|
|
16
|
-
super.addEventListener(type, listener, options);
|
|
17
|
-
let list = this.#listeners.get(type);
|
|
18
|
-
if (list == null) {
|
|
19
|
-
list = [];
|
|
20
|
-
this.#listeners.set(type, list);
|
|
21
|
-
}
|
|
22
|
-
list.push({
|
|
23
|
-
callback: listener,
|
|
24
|
-
once: (options !== true && options !== false && options?.once) ?? false
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
removeEventListener(type, listener, options) {
|
|
28
|
-
super.removeEventListener(type.toString(), listener ?? null, options);
|
|
29
|
-
let list = this.#listeners.get(type);
|
|
30
|
-
if (list == null) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
list = list.filter(({ callback }) => callback !== listener);
|
|
34
|
-
this.#listeners.set(type, list);
|
|
35
|
-
}
|
|
36
|
-
dispatchEvent(event) {
|
|
37
|
-
const result = super.dispatchEvent(event);
|
|
38
|
-
let list = this.#listeners.get(event.type);
|
|
39
|
-
if (list == null) {
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
list = list.filter(({ once }) => !once);
|
|
43
|
-
this.#listeners.set(event.type, list);
|
|
44
|
-
return result;
|
|
45
|
-
}
|
|
46
|
-
safeDispatchEvent(type, detail) {
|
|
47
|
-
return this.dispatchEvent(new CustomEvent(type, detail));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* CustomEvent is a standard event but it's not supported by node.
|
|
52
|
-
*
|
|
53
|
-
* Remove this when https://github.com/nodejs/node/issues/40678 is closed.
|
|
54
|
-
*
|
|
55
|
-
* Ref: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent
|
|
56
|
-
*/
|
|
57
|
-
class CustomEventPolyfill extends Event {
|
|
58
|
-
/** Returns any custom data event was created with. Typically used for synthetic events. */
|
|
59
|
-
detail;
|
|
60
|
-
constructor(message, data) {
|
|
61
|
-
super(message, data);
|
|
62
|
-
// @ts-expect-error could be undefined
|
|
63
|
-
this.detail = data?.detail;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
export const CustomEvent = globalThis.CustomEvent ?? CustomEventPolyfill;
|
|
67
2
|
// create a setMaxListeners that doesn't break browser usage
|
|
68
3
|
export const setMaxListeners = (n, ...eventTargets) => {
|
|
69
4
|
try {
|
package/dist/src/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,mBAAmB,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,mBAAmB,EAAE,MAAM,QAAQ,CAAA;AAE/D,4DAA4D;AAC5D,MAAM,CAAC,MAAM,eAAe,GAA+B,CAAC,CAAC,EAAE,GAAG,YAAY,EAAE,EAAE;IAChF,IAAI,CAAC;QACH,mBAAmB,CAAC,CAAC,EAAE,GAAG,YAAY,CAAC,CAAA;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,sBAAsB;IACxB,CAAC;AACH,CAAC,CAAA"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { Connection, NewStreamOptions, Stream } from './connection/index.js';
|
|
17
17
|
import type { ContentRouting } from './content-routing/index.js';
|
|
18
|
-
import type { TypedEventTarget } from './
|
|
18
|
+
import type { TypedEventTarget } from './event-target.js';
|
|
19
19
|
import type { Metrics } from './metrics/index.js';
|
|
20
20
|
import type { PeerId } from './peer-id/index.js';
|
|
21
21
|
import type { PeerInfo } from './peer-info/index.js';
|
|
@@ -628,6 +628,7 @@ export * from './stream-muxer/index.js';
|
|
|
628
628
|
export * from './topology/index.js';
|
|
629
629
|
export * from './transport/index.js';
|
|
630
630
|
export * from './errors.js';
|
|
631
|
+
export * from './event-target.js';
|
|
631
632
|
export * from './events.js';
|
|
632
633
|
export * from './startable.js';
|
|
633
634
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACpF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,EAAE,SAA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
|
@@ -32,6 +32,7 @@ export * from './stream-muxer/index.js';
|
|
|
32
32
|
export * from './topology/index.js';
|
|
33
33
|
export * from './transport/index.js';
|
|
34
34
|
export * from './errors.js';
|
|
35
|
+
export * from './event-target.js';
|
|
35
36
|
export * from './events.js';
|
|
36
37
|
export * from './startable.js';
|
|
37
38
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAmpBH,cAAc,uBAAuB,CAAA;AACrC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,2BAA2B,CAAA;AACzC,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA;AACvC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,2BAA2B,CAAA;AACzC,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAmpBH,cAAc,uBAAuB,CAAA;AACrC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,2BAA2B,CAAA;AACzC,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA;AACvC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,2BAA2B,CAAA;AACzC,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/peer-discovery/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/peer-discovery/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAErD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,mBAAmB,eAAuC,CAAA;AAEvE,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;CAC9B;AAED,MAAM,WAAW,aAAc,SAAQ,gBAAgB,CAAC,mBAAmB,CAAC;CAAG"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Stream } from '../connection/index.js';
|
|
2
|
-
import type { TypedEventTarget } from '../
|
|
2
|
+
import type { TypedEventTarget } from '../event-target.js';
|
|
3
3
|
import type { PeerId } from '../peer-id/index.js';
|
|
4
4
|
import type { Pushable } from 'it-pushable';
|
|
5
5
|
import type { Uint8ArrayList } from 'uint8arraylist';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pubsub/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pubsub/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,eAAe,CAAA;AAEtC;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,iBAAiB,CAAA;AAE1C,MAAM,MAAM,eAAe,GAAG,OAAO,UAAU,GAAG,OAAO,YAAY,CAAA;AAErE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,UAAU,CAAA;IAChB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,UAAU,CAAA;IACrB,GAAG,EAAE,UAAU,CAAA;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,UAAU,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,UAAU,CAAA;CACjB;AAED,MAAM,MAAM,OAAO,GAAG,aAAa,GAAG,eAAe,CAAA;AAErD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,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I,CAAA;IAE9B;;;;;;;;;;;;;;OAcG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAEhC;;;;;;;;OAQG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAEvC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;CACjE;AAED,MAAM,WAAW,gBAAgB;IAC/B,gBAAgB,EAAE,WAAW,CAAC,KAAK,CAAC,CAAA;IACpC,iBAAiB,EAAE,WAAW,CAAC,KAAK,CAAC,CAAA;IACrC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAA;CAC5B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Connection, MultiaddrConnection } from '../connection/index.js';
|
|
2
|
-
import type { TypedEventTarget } from '../
|
|
2
|
+
import type { TypedEventTarget } from '../event-target.js';
|
|
3
3
|
import type { AbortOptions } from '../index.js';
|
|
4
4
|
import type { StreamMuxerFactory } from '../stream-muxer/index.js';
|
|
5
5
|
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transport/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transport/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AA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;IACH,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,QAAQ,CAAA;IAExD;;OAEG;IACH,MAAM,EAAE,eAAe,CAAA;CACxB;AAED,wBAAgB,WAAW,CAAE,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,SAAS,CAE3D;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB;;OAEG;IACH,SAAS,IAAI;IAEb;;OAEG;IACH,QAAQ,IAAA;CACT;AAED,MAAM,WAAW,eAAe;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,YAAY,CAAC,EAAE,kBAAkB,CAAA;IAEjC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,eAAe,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IAEzF;;OAEG;IACH,cAAc,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CACzF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/interface",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2-742915567",
|
|
4
4
|
"description": "The interface implemented by a libp2p node",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/interface#readme",
|
|
@@ -74,5 +74,8 @@
|
|
|
74
74
|
},
|
|
75
75
|
"browser": {
|
|
76
76
|
"events": "./dist/src/events.browser.js"
|
|
77
|
+
},
|
|
78
|
+
"react-native": {
|
|
79
|
+
"./dist/src/events.js": "./dist/src/events.browser.js"
|
|
77
80
|
}
|
|
78
81
|
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
export interface EventCallback<EventType> { (evt: EventType): void }
|
|
2
|
+
export interface EventObject<EventType> { handleEvent: EventCallback<EventType> }
|
|
3
|
+
export type EventHandler<EventType> = EventCallback<EventType> | EventObject<EventType>
|
|
4
|
+
|
|
5
|
+
interface Listener {
|
|
6
|
+
once: boolean
|
|
7
|
+
callback: any
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Adds types to the EventTarget class. Hopefully this won't be necessary forever.
|
|
12
|
+
*
|
|
13
|
+
* https://github.com/microsoft/TypeScript/issues/28357
|
|
14
|
+
* https://github.com/microsoft/TypeScript/issues/43477
|
|
15
|
+
* https://github.com/microsoft/TypeScript/issues/299
|
|
16
|
+
* etc
|
|
17
|
+
*/
|
|
18
|
+
export interface TypedEventTarget <EventMap extends Record<string, any>> extends EventTarget {
|
|
19
|
+
addEventListener<K extends keyof EventMap>(type: K, listener: EventHandler<EventMap[K]> | null, options?: boolean | AddEventListenerOptions): void
|
|
20
|
+
|
|
21
|
+
listenerCount (type: string): number
|
|
22
|
+
|
|
23
|
+
removeEventListener<K extends keyof EventMap>(type: K, listener?: EventHandler<EventMap[K]> | null, options?: boolean | EventListenerOptions): void
|
|
24
|
+
|
|
25
|
+
removeEventListener (type: string, listener?: EventHandler<Event>, options?: boolean | EventListenerOptions): void
|
|
26
|
+
|
|
27
|
+
safeDispatchEvent<Detail>(type: keyof EventMap, detail: CustomEventInit<Detail>): boolean
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* An implementation of a typed event target
|
|
32
|
+
* etc
|
|
33
|
+
*/
|
|
34
|
+
export class TypedEventEmitter<EventMap extends Record<string, any>> extends EventTarget implements TypedEventTarget<EventMap> {
|
|
35
|
+
#listeners = new Map<any, Listener[]>()
|
|
36
|
+
|
|
37
|
+
listenerCount (type: string): number {
|
|
38
|
+
const listeners = this.#listeners.get(type)
|
|
39
|
+
|
|
40
|
+
if (listeners == null) {
|
|
41
|
+
return 0
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return listeners.length
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
addEventListener<K extends keyof EventMap>(type: K, listener: EventHandler<EventMap[K]> | null, options?: boolean | AddEventListenerOptions): void
|
|
48
|
+
addEventListener (type: string, listener: EventHandler<Event>, options?: boolean | AddEventListenerOptions): void {
|
|
49
|
+
super.addEventListener(type, listener, options)
|
|
50
|
+
|
|
51
|
+
let list = this.#listeners.get(type)
|
|
52
|
+
|
|
53
|
+
if (list == null) {
|
|
54
|
+
list = []
|
|
55
|
+
this.#listeners.set(type, list)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
list.push({
|
|
59
|
+
callback: listener,
|
|
60
|
+
once: (options !== true && options !== false && options?.once) ?? false
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
removeEventListener<K extends keyof EventMap>(type: K, listener?: EventHandler<EventMap[K]> | null, options?: boolean | EventListenerOptions): void
|
|
65
|
+
removeEventListener (type: string, listener?: EventHandler<Event>, options?: boolean | EventListenerOptions): void {
|
|
66
|
+
super.removeEventListener(type.toString(), listener ?? null, options)
|
|
67
|
+
|
|
68
|
+
let list = this.#listeners.get(type)
|
|
69
|
+
|
|
70
|
+
if (list == null) {
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
list = list.filter(({ callback }) => callback !== listener)
|
|
75
|
+
this.#listeners.set(type, list)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
dispatchEvent (event: Event): boolean {
|
|
79
|
+
const result = super.dispatchEvent(event)
|
|
80
|
+
|
|
81
|
+
let list = this.#listeners.get(event.type)
|
|
82
|
+
|
|
83
|
+
if (list == null) {
|
|
84
|
+
return result
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
list = list.filter(({ once }) => !once)
|
|
88
|
+
this.#listeners.set(event.type, list)
|
|
89
|
+
|
|
90
|
+
return result
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
safeDispatchEvent<Detail>(type: keyof EventMap, detail: CustomEventInit<Detail>): boolean {
|
|
94
|
+
return this.dispatchEvent(new CustomEvent<Detail>(type as string, detail))
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* CustomEvent is a standard event but it's not supported by node.
|
|
100
|
+
*
|
|
101
|
+
* Remove this when https://github.com/nodejs/node/issues/40678 is closed.
|
|
102
|
+
*
|
|
103
|
+
* Ref: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent
|
|
104
|
+
*/
|
|
105
|
+
class CustomEventPolyfill<T = any> extends Event {
|
|
106
|
+
/** Returns any custom data event was created with. Typically used for synthetic events. */
|
|
107
|
+
public detail: T
|
|
108
|
+
|
|
109
|
+
constructor (message: string, data?: EventInit & { detail: T }) {
|
|
110
|
+
super(message, data)
|
|
111
|
+
// @ts-expect-error could be undefined
|
|
112
|
+
this.detail = data?.detail
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export const CustomEvent = globalThis.CustomEvent ?? CustomEventPolyfill
|
package/src/events.ts
CHANGED
|
@@ -1,122 +1,5 @@
|
|
|
1
1
|
import { setMaxListeners as nodeSetMaxListeners } from 'events'
|
|
2
2
|
|
|
3
|
-
export interface EventCallback<EventType> { (evt: EventType): void }
|
|
4
|
-
export interface EventObject<EventType> { handleEvent: EventCallback<EventType> }
|
|
5
|
-
export type EventHandler<EventType> = EventCallback<EventType> | EventObject<EventType>
|
|
6
|
-
|
|
7
|
-
interface Listener {
|
|
8
|
-
once: boolean
|
|
9
|
-
callback: any
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Adds types to the EventTarget class. Hopefully this won't be necessary forever.
|
|
14
|
-
*
|
|
15
|
-
* https://github.com/microsoft/TypeScript/issues/28357
|
|
16
|
-
* https://github.com/microsoft/TypeScript/issues/43477
|
|
17
|
-
* https://github.com/microsoft/TypeScript/issues/299
|
|
18
|
-
* etc
|
|
19
|
-
*/
|
|
20
|
-
export interface TypedEventTarget <EventMap extends Record<string, any>> extends EventTarget {
|
|
21
|
-
addEventListener<K extends keyof EventMap>(type: K, listener: EventHandler<EventMap[K]> | null, options?: boolean | AddEventListenerOptions): void
|
|
22
|
-
|
|
23
|
-
listenerCount (type: string): number
|
|
24
|
-
|
|
25
|
-
removeEventListener<K extends keyof EventMap>(type: K, listener?: EventHandler<EventMap[K]> | null, options?: boolean | EventListenerOptions): void
|
|
26
|
-
|
|
27
|
-
removeEventListener (type: string, listener?: EventHandler<Event>, options?: boolean | EventListenerOptions): void
|
|
28
|
-
|
|
29
|
-
safeDispatchEvent<Detail>(type: keyof EventMap, detail: CustomEventInit<Detail>): boolean
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* An implementation of a typed event target
|
|
34
|
-
* etc
|
|
35
|
-
*/
|
|
36
|
-
export class TypedEventEmitter<EventMap extends Record<string, any>> extends EventTarget implements TypedEventTarget<EventMap> {
|
|
37
|
-
#listeners = new Map<any, Listener[]>()
|
|
38
|
-
|
|
39
|
-
listenerCount (type: string): number {
|
|
40
|
-
const listeners = this.#listeners.get(type)
|
|
41
|
-
|
|
42
|
-
if (listeners == null) {
|
|
43
|
-
return 0
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return listeners.length
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
addEventListener<K extends keyof EventMap>(type: K, listener: EventHandler<EventMap[K]> | null, options?: boolean | AddEventListenerOptions): void
|
|
50
|
-
addEventListener (type: string, listener: EventHandler<Event>, options?: boolean | AddEventListenerOptions): void {
|
|
51
|
-
super.addEventListener(type, listener, options)
|
|
52
|
-
|
|
53
|
-
let list = this.#listeners.get(type)
|
|
54
|
-
|
|
55
|
-
if (list == null) {
|
|
56
|
-
list = []
|
|
57
|
-
this.#listeners.set(type, list)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
list.push({
|
|
61
|
-
callback: listener,
|
|
62
|
-
once: (options !== true && options !== false && options?.once) ?? false
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
removeEventListener<K extends keyof EventMap>(type: K, listener?: EventHandler<EventMap[K]> | null, options?: boolean | EventListenerOptions): void
|
|
67
|
-
removeEventListener (type: string, listener?: EventHandler<Event>, options?: boolean | EventListenerOptions): void {
|
|
68
|
-
super.removeEventListener(type.toString(), listener ?? null, options)
|
|
69
|
-
|
|
70
|
-
let list = this.#listeners.get(type)
|
|
71
|
-
|
|
72
|
-
if (list == null) {
|
|
73
|
-
return
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
list = list.filter(({ callback }) => callback !== listener)
|
|
77
|
-
this.#listeners.set(type, list)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
dispatchEvent (event: Event): boolean {
|
|
81
|
-
const result = super.dispatchEvent(event)
|
|
82
|
-
|
|
83
|
-
let list = this.#listeners.get(event.type)
|
|
84
|
-
|
|
85
|
-
if (list == null) {
|
|
86
|
-
return result
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
list = list.filter(({ once }) => !once)
|
|
90
|
-
this.#listeners.set(event.type, list)
|
|
91
|
-
|
|
92
|
-
return result
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
safeDispatchEvent<Detail>(type: keyof EventMap, detail: CustomEventInit<Detail>): boolean {
|
|
96
|
-
return this.dispatchEvent(new CustomEvent<Detail>(type as string, detail))
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* CustomEvent is a standard event but it's not supported by node.
|
|
102
|
-
*
|
|
103
|
-
* Remove this when https://github.com/nodejs/node/issues/40678 is closed.
|
|
104
|
-
*
|
|
105
|
-
* Ref: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent
|
|
106
|
-
*/
|
|
107
|
-
class CustomEventPolyfill<T = any> extends Event {
|
|
108
|
-
/** Returns any custom data event was created with. Typically used for synthetic events. */
|
|
109
|
-
public detail: T
|
|
110
|
-
|
|
111
|
-
constructor (message: string, data?: EventInit & { detail: T }) {
|
|
112
|
-
super(message, data)
|
|
113
|
-
// @ts-expect-error could be undefined
|
|
114
|
-
this.detail = data?.detail
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export const CustomEvent = globalThis.CustomEvent ?? CustomEventPolyfill
|
|
119
|
-
|
|
120
3
|
// create a setMaxListeners that doesn't break browser usage
|
|
121
4
|
export const setMaxListeners: typeof nodeSetMaxListeners = (n, ...eventTargets) => {
|
|
122
5
|
try {
|
package/src/index.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import type { Connection, NewStreamOptions, Stream } from './connection/index.js'
|
|
18
18
|
import type { ContentRouting } from './content-routing/index.js'
|
|
19
|
-
import type { TypedEventTarget } from './
|
|
19
|
+
import type { TypedEventTarget } from './event-target.js'
|
|
20
20
|
import type { Metrics } from './metrics/index.js'
|
|
21
21
|
import type { PeerId } from './peer-id/index.js'
|
|
22
22
|
import type { PeerInfo } from './peer-info/index.js'
|
|
@@ -690,5 +690,6 @@ export * from './stream-muxer/index.js'
|
|
|
690
690
|
export * from './topology/index.js'
|
|
691
691
|
export * from './transport/index.js'
|
|
692
692
|
export * from './errors.js'
|
|
693
|
+
export * from './event-target.js'
|
|
693
694
|
export * from './events.js'
|
|
694
695
|
export * from './startable.js'
|
package/src/pubsub/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Stream } from '../connection/index.js'
|
|
2
|
-
import type { TypedEventTarget } from '../
|
|
2
|
+
import type { TypedEventTarget } from '../event-target.js'
|
|
3
3
|
import type { PeerId } from '../peer-id/index.js'
|
|
4
4
|
import type { Pushable } from 'it-pushable'
|
|
5
5
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
package/src/transport/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Connection, MultiaddrConnection } from '../connection/index.js'
|
|
2
|
-
import type { TypedEventTarget } from '../
|
|
2
|
+
import type { TypedEventTarget } from '../event-target.js'
|
|
3
3
|
import type { AbortOptions } from '../index.js'
|
|
4
4
|
import type { StreamMuxerFactory } from '../stream-muxer/index.js'
|
|
5
5
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"Connection": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.connection.Connection.html",
|
|
3
|
-
"ConnectionProtector": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.connection.ConnectionProtector.html",
|
|
4
|
-
"ConnectionTimeline": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.connection.ConnectionTimeline.html",
|
|
5
|
-
"MultiaddrConnection": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.connection.MultiaddrConnection.html",
|
|
6
|
-
"MultiaddrConnectionTimeline": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.connection.MultiaddrConnectionTimeline.html",
|
|
7
|
-
"NewStreamOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.connection.NewStreamOptions.html",
|
|
8
|
-
"Stream": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.connection.Stream.html",
|
|
9
|
-
"StreamTimeline": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.connection.StreamTimeline.html",
|
|
10
|
-
"ConnectionStatus": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.connection.ConnectionStatus.html",
|
|
11
|
-
"Direction": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.connection.Direction.html",
|
|
12
|
-
"ReadStatus": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.connection.ReadStatus.html",
|
|
13
|
-
"StreamStatus": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.connection.StreamStatus.html",
|
|
14
|
-
"WriteStatus": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.connection.WriteStatus.html",
|
|
15
|
-
"connectionSymbol": "https://libp2p.github.io/js-libp2p/variables/_libp2p_interface.connection.connectionSymbol.html",
|
|
16
|
-
"isConnection": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface.connection.isConnection.html",
|
|
17
|
-
"ConnectionEncrypter": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.connection_encrypter.ConnectionEncrypter.html",
|
|
18
|
-
"SecuredConnection": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.connection_encrypter.SecuredConnection.html",
|
|
19
|
-
"ConnectionGater": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.connection_gater.ConnectionGater.html",
|
|
20
|
-
"ContentRouting": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.content_routing.ContentRouting.html",
|
|
21
|
-
"contentRoutingSymbol": "https://libp2p.github.io/js-libp2p/variables/_libp2p_interface.content_routing.contentRoutingSymbol.html",
|
|
22
|
-
"AbortError": "https://libp2p.github.io/js-libp2p/classes/_libp2p_interface.errors.AbortError.html",
|
|
23
|
-
"CodeError": "https://libp2p.github.io/js-libp2p/classes/_libp2p_interface.errors.CodeError.html",
|
|
24
|
-
"InvalidCryptoExchangeError": "https://libp2p.github.io/js-libp2p/classes/_libp2p_interface.errors.InvalidCryptoExchangeError.html",
|
|
25
|
-
"InvalidCryptoTransmissionError": "https://libp2p.github.io/js-libp2p/classes/_libp2p_interface.errors.InvalidCryptoTransmissionError.html",
|
|
26
|
-
"UnexpectedPeerError": "https://libp2p.github.io/js-libp2p/classes/_libp2p_interface.errors.UnexpectedPeerError.html",
|
|
27
|
-
"ERR_INVALID_MESSAGE": "https://libp2p.github.io/js-libp2p/variables/_libp2p_interface.errors.ERR_INVALID_MESSAGE.html",
|
|
28
|
-
"ERR_INVALID_PARAMETERS": "https://libp2p.github.io/js-libp2p/variables/_libp2p_interface.errors.ERR_INVALID_PARAMETERS.html",
|
|
29
|
-
"ERR_NOT_FOUND": "https://libp2p.github.io/js-libp2p/variables/_libp2p_interface.errors.ERR_NOT_FOUND.html",
|
|
30
|
-
"ERR_TIMEOUT": "https://libp2p.github.io/js-libp2p/variables/_libp2p_interface.errors.ERR_TIMEOUT.html",
|
|
31
|
-
"TypedEventEmitter": "https://libp2p.github.io/js-libp2p/classes/_libp2p_interface.events.TypedEventEmitter.html",
|
|
32
|
-
"EventCallback": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.events.EventCallback.html",
|
|
33
|
-
"EventObject": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.events.EventObject.html",
|
|
34
|
-
"TypedEventTarget": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.events.TypedEventTarget.html",
|
|
35
|
-
"EventHandler": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.events.EventHandler.html",
|
|
36
|
-
"CustomEvent": "https://libp2p.github.io/js-libp2p/variables/_libp2p_interface.events.CustomEvent.html",
|
|
37
|
-
"setMaxListeners": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface.events.setMaxListeners.html",
|
|
38
|
-
"AbortOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.AbortOptions.html",
|
|
39
|
-
".:AbortOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.AbortOptions.html",
|
|
40
|
-
"AddressSorter": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.AddressSorter.html",
|
|
41
|
-
".:AddressSorter": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.AddressSorter.html",
|
|
42
|
-
"ComponentLogger": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.ComponentLogger.html",
|
|
43
|
-
".:ComponentLogger": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.ComponentLogger.html",
|
|
44
|
-
"IdentifyResult": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.IdentifyResult.html",
|
|
45
|
-
".:IdentifyResult": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.IdentifyResult.html",
|
|
46
|
-
"Libp2p": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.Libp2p.html",
|
|
47
|
-
".:Libp2p": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.Libp2p.html",
|
|
48
|
-
"Libp2pEvents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.Libp2pEvents.html",
|
|
49
|
-
".:Libp2pEvents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.Libp2pEvents.html",
|
|
50
|
-
"Logger": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.Logger.html",
|
|
51
|
-
".:Logger": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.Logger.html",
|
|
52
|
-
"LoggerOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.LoggerOptions.html",
|
|
53
|
-
".:LoggerOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.LoggerOptions.html",
|
|
54
|
-
"NodeInfo": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.NodeInfo.html",
|
|
55
|
-
".:NodeInfo": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.NodeInfo.html",
|
|
56
|
-
"PeerUpdate": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.PeerUpdate.html",
|
|
57
|
-
".:PeerUpdate": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.PeerUpdate.html",
|
|
58
|
-
"PendingDial": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.PendingDial.html",
|
|
59
|
-
".:PendingDial": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.PendingDial.html",
|
|
60
|
-
"SignedPeerRecord": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.SignedPeerRecord.html",
|
|
61
|
-
".:SignedPeerRecord": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.SignedPeerRecord.html",
|
|
62
|
-
"Topology": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.index.Topology.html",
|
|
63
|
-
"Libp2pStatus": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.index.Libp2pStatus.html",
|
|
64
|
-
".:Libp2pStatus": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.index.Libp2pStatus.html",
|
|
65
|
-
"PendingDialStatus": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.index.PendingDialStatus.html",
|
|
66
|
-
".:PendingDialStatus": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.index.PendingDialStatus.html",
|
|
67
|
-
"RecursivePartial": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.index.RecursivePartial.html",
|
|
68
|
-
".:RecursivePartial": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.index.RecursivePartial.html",
|
|
69
|
-
"ServiceMap": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.index.ServiceMap.html",
|
|
70
|
-
".:ServiceMap": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.index.ServiceMap.html",
|
|
71
|
-
"PrivateKey": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.keys.PrivateKey.html",
|
|
72
|
-
"PublicKey": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.keys.PublicKey.html",
|
|
73
|
-
"KeyType": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.keys.KeyType.html",
|
|
74
|
-
"Ed25519": "https://libp2p.github.io/js-libp2p/variables/_libp2p_interface.keys.Ed25519.html",
|
|
75
|
-
"RSA": "https://libp2p.github.io/js-libp2p/variables/_libp2p_interface.keys.RSA.html",
|
|
76
|
-
"secp256k1": "https://libp2p.github.io/js-libp2p/variables/_libp2p_interface.keys.secp256k1.html",
|
|
77
|
-
"CalculatedMetricOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.metrics.CalculatedMetricOptions.html",
|
|
78
|
-
"Counter": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.metrics.Counter.html",
|
|
79
|
-
"CounterGroup": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.metrics.CounterGroup.html",
|
|
80
|
-
"Metric": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.metrics.Metric.html",
|
|
81
|
-
"MetricGroup": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.metrics.MetricGroup.html",
|
|
82
|
-
"MetricOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.metrics.MetricOptions.html",
|
|
83
|
-
"Metrics": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.metrics.Metrics.html",
|
|
84
|
-
"StopTimer": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.metrics.StopTimer.html",
|
|
85
|
-
"CalculateMetric": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.metrics.CalculateMetric.html",
|
|
86
|
-
"PeerDiscovery": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.peer_discovery.PeerDiscovery.html",
|
|
87
|
-
"PeerDiscoveryEvents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.peer_discovery.PeerDiscoveryEvents.html",
|
|
88
|
-
"peerDiscoverySymbol": "https://libp2p.github.io/js-libp2p/variables/_libp2p_interface.peer_discovery.peerDiscoverySymbol.html",
|
|
89
|
-
"Ed25519PeerId": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.peer_id.Ed25519PeerId.html",
|
|
90
|
-
"RSAPeerId": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.peer_id.RSAPeerId.html",
|
|
91
|
-
"Secp256k1PeerId": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.peer_id.Secp256k1PeerId.html",
|
|
92
|
-
"PeerId": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.peer_id.PeerId.html",
|
|
93
|
-
"PeerIdType": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.peer_id.PeerIdType.html",
|
|
94
|
-
"peerIdSymbol": "https://libp2p.github.io/js-libp2p/variables/_libp2p_interface.peer_id.peerIdSymbol.html",
|
|
95
|
-
"isPeerId": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface.peer_id.isPeerId.html",
|
|
96
|
-
"PeerInfo": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.peer_info.PeerInfo.html",
|
|
97
|
-
"PeerRouting": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.peer_routing.PeerRouting.html",
|
|
98
|
-
"peerRoutingSymbol": "https://libp2p.github.io/js-libp2p/variables/_libp2p_interface.peer_routing.peerRoutingSymbol.html",
|
|
99
|
-
"Address": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.peer_store.Address.html",
|
|
100
|
-
"Peer": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.peer_store.Peer.html",
|
|
101
|
-
"PeerData": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.peer_store.PeerData.html",
|
|
102
|
-
"PeerQuery": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.peer_store.PeerQuery.html",
|
|
103
|
-
"PeerQueryFilter": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.peer_store.PeerQueryFilter.html",
|
|
104
|
-
"PeerQueryOrder": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.peer_store.PeerQueryOrder.html",
|
|
105
|
-
"PeerStore": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.peer_store.PeerStore.html",
|
|
106
|
-
"Tag": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.peer_store.Tag.html",
|
|
107
|
-
"TagOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.peer_store.TagOptions.html",
|
|
108
|
-
"KEEP_ALIVE": "https://libp2p.github.io/js-libp2p/variables/_libp2p_interface.peer_store_tags.KEEP_ALIVE.html",
|
|
109
|
-
"TopicValidatorResult": "https://libp2p.github.io/js-libp2p/enums/_libp2p_interface.pubsub.TopicValidatorResult.html",
|
|
110
|
-
"PeerStreamEvents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.pubsub.PeerStreamEvents.html",
|
|
111
|
-
"PeerStreams": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.pubsub.PeerStreams.html",
|
|
112
|
-
"PubSub": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.pubsub.PubSub.html",
|
|
113
|
-
"PubSubEvents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.pubsub.PubSubEvents.html",
|
|
114
|
-
"PubSubInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.pubsub.PubSubInit.html",
|
|
115
|
-
"PubSubRPC": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.pubsub.PubSubRPC.html",
|
|
116
|
-
"PubSubRPCMessage": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.pubsub.PubSubRPCMessage.html",
|
|
117
|
-
"PubSubRPCSubscription": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.pubsub.PubSubRPCSubscription.html",
|
|
118
|
-
"PublishResult": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.pubsub.PublishResult.html",
|
|
119
|
-
"SignedMessage": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.pubsub.SignedMessage.html",
|
|
120
|
-
"SubscriptionChangeData": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.pubsub.SubscriptionChangeData.html",
|
|
121
|
-
"TopicValidatorFn": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.pubsub.TopicValidatorFn.html",
|
|
122
|
-
"UnsignedMessage": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.pubsub.UnsignedMessage.html",
|
|
123
|
-
"Message": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.pubsub.Message.html",
|
|
124
|
-
"SignaturePolicy": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.pubsub.SignaturePolicy.html",
|
|
125
|
-
"StrictNoSign": "https://libp2p.github.io/js-libp2p/variables/_libp2p_interface.pubsub.StrictNoSign.html",
|
|
126
|
-
"StrictSign": "https://libp2p.github.io/js-libp2p/variables/_libp2p_interface.pubsub.StrictSign.html",
|
|
127
|
-
"Envelope": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.record.Envelope.html",
|
|
128
|
-
"Record": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.record.Record.html",
|
|
129
|
-
"Startable": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.startable.Startable.html",
|
|
130
|
-
"isStartable": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface.startable.isStartable.html",
|
|
131
|
-
"start": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface.startable.start.html",
|
|
132
|
-
"stop": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface.startable.stop.html",
|
|
133
|
-
"IncomingStreamData": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.stream_handler.IncomingStreamData.html",
|
|
134
|
-
"StreamHandler": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.stream_handler.StreamHandler.html",
|
|
135
|
-
"StreamHandlerOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.stream_handler.StreamHandlerOptions.html",
|
|
136
|
-
"StreamHandlerRecord": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.stream_handler.StreamHandlerRecord.html",
|
|
137
|
-
"StreamMuxer": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.stream_muxer.StreamMuxer.html",
|
|
138
|
-
"StreamMuxerFactory": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.stream_muxer.StreamMuxerFactory.html",
|
|
139
|
-
"StreamMuxerInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.stream_muxer.StreamMuxerInit.html",
|
|
140
|
-
"FaultTolerance": "https://libp2p.github.io/js-libp2p/enums/_libp2p_interface.transport.FaultTolerance.html",
|
|
141
|
-
"ConnectionHandler": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.transport.ConnectionHandler.html",
|
|
142
|
-
"CreateListenerOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.transport.CreateListenerOptions.html",
|
|
143
|
-
"DialOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.transport.DialOptions.html",
|
|
144
|
-
"Listener": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.transport.Listener.html",
|
|
145
|
-
"ListenerEvents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.transport.ListenerEvents.html",
|
|
146
|
-
"MultiaddrFilter": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.transport.MultiaddrFilter.html",
|
|
147
|
-
"Transport": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.transport.Transport.html",
|
|
148
|
-
"Upgrader": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.transport.Upgrader.html",
|
|
149
|
-
"UpgraderOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.transport.UpgraderOptions.html",
|
|
150
|
-
"transportSymbol": "https://libp2p.github.io/js-libp2p/variables/_libp2p_interface.transport.transportSymbol.html",
|
|
151
|
-
"isTransport": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface.transport.isTransport.html"
|
|
152
|
-
}
|