Extend libp2p-{webrtc,websocket}-star

This commit is contained in:
Jaco Greeff 2019-03-05 14:03:52 +01:00
parent 41e0c84dd3
commit a2fc36efe5
10 changed files with 54 additions and 9 deletions

View File

@ -16,6 +16,6 @@
},
"devDependencies": {
"@babel/core": "^7.2.2",
"@polkadot/dev": "^0.25.11"
"@polkadot/dev": "^0.25.12"
}
}

View File

@ -4,6 +4,7 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="peer-info"/>
/// <reference types="libp2p-bootstrap"/>
declare namespace LibP2pMdns {
type Options = {
@ -17,7 +18,7 @@ declare namespace LibP2pMdns {
type Events = 'peer';
}
declare class LibP2pMdns {
declare class LibP2pMdns extends LibP2pBootstrap {
constructor (options: LibP2pMdns.Options);
on (event: LibP2pMdns.Events, cb: (peerInfo: PeerInfo) => any): void;

View File

@ -4,9 +4,12 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="interface-transport"/>
/// <reference types="libp2p-bootstrap"/>
declare class LibP2pWebRtcStar implements LibP2pTransport {
constructor(config?: any);
discovery: LibP2pBootstrap;
}
declare module 'libp2p-webrtc-star' {

View File

@ -12,5 +12,5 @@
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "bn.js-tests.ts"]
"files": ["index.d.ts", "libp2p-swbsocket-star-tests.ts"]
}

17
types/libp2p-websocket-star/index.d.ts vendored Normal file
View File

@ -0,0 +1,17 @@
// Type definitions for libp2p-websocket-star 0.15.3
// Project: https://github.com/libp2p/js-libp2p-websocket-star
// Definitions by: Jaco Greeff <https://github.com/jacogr>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="interface-transport"/>
/// <reference types="libp2p-bootstrap"/>
declare class LibP2pWebsocketStar implements LibP2pTransport {
constructor(config?: any);
discovery: LibP2pBootstrap;
}
declare module 'libp2p-websocket-star' {
export default LibP2pWebsocketStar;
}

View File

@ -0,0 +1,4 @@
// @ts-ignore
import T from 'libp2p-websocket-star';
new T();

View File

@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "libp2p-swbsocket-star-tests.ts"]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@ -29,9 +29,12 @@ declare namespace LibP2p {
interval?: number
enabled?: boolean
},
webrtcStar?: {
webRTCStar?: {
interval?: number
enabled?: boolean
},
websocketStar?: {
enabled?: boolean
}
},
peerRouting?: {},
@ -49,7 +52,7 @@ declare namespace LibP2p {
connEncryption: Array<LibP2pSecio>,
streamMuxer: Array<LibP2pMplex | LibP2pSpdy | PullMplex>,
dht?: typeof LibP2pKadDht,
peerDiscovery: Array<LibP2pBootstrap | LibP2pMdns>,
peerDiscovery: Array<LibP2pBootstrap>,
transport: LibP2pTransport[]
};

View File

@ -1499,10 +1499,10 @@
universal-user-agent "^2.0.0"
url-template "^2.0.8"
"@polkadot/dev@^0.25.11":
version "0.25.11"
resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.25.11.tgz#73235add1eb0c86257ed8f1ab60e213be79a93f1"
integrity sha512-Fs9VFlwwZVKtk+J9kjNG0lWDpTYvcVXOksMXJ1lQLnf2YhqFILsq8kETfoXWbDbusgcok69hoA4YcNtwiEAGWg==
"@polkadot/dev@^0.25.12":
version "0.25.12"
resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.25.12.tgz#de440a96dba3c9b4a92e6be0f0276b8c1f4daf24"
integrity sha512-pISn6l4+brHCE04jjqSc7j7V63QmuhFykJFV2WejZHvUtKzBJa35C1ps+U9iKfa5Ma2gFyjyvlQOOvAKRwuKrA==
dependencies:
"@babel/cli" "^7.2.3"
"@babel/core" "^7.3.4"