From 5677ea318e2bbb610d4bf2c5916f714a4986563c Mon Sep 17 00:00:00 2001 From: Sascha Englert Date: Tue, 21 Aug 2018 20:13:50 +0200 Subject: [PATCH] Added d.ts for socket.io-p2p --- types/socket.io-p2p/index.d.ts | 49 ++++++++++++++++++++++ types/socket.io-p2p/socket.io-p2p-tests.ts | 0 types/socket.io-p2p/tsconfig.json | 15 +++++++ types/socket.io-p2p/tslint.json | 1 + 4 files changed, 65 insertions(+) create mode 100644 types/socket.io-p2p/index.d.ts create mode 100644 types/socket.io-p2p/socket.io-p2p-tests.ts create mode 100644 types/socket.io-p2p/tsconfig.json create mode 100644 types/socket.io-p2p/tslint.json diff --git a/types/socket.io-p2p/index.d.ts b/types/socket.io-p2p/index.d.ts new file mode 100644 index 0000000000..fbeaa07c94 --- /dev/null +++ b/types/socket.io-p2p/index.d.ts @@ -0,0 +1,49 @@ +// Type definitions for socket.io-p2p 2.2 +// Project: https://github.com/socketio/socket.io-p2p +// Definitions by: Sascha Englert +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export as namespace Socketiop2p; + +export = SocketioP2PStatic; + +declare function SocketioP2PStatic( + socket: any, + opts: SocketioP2PStatic.P2POptions, + cb?: () => void +): SocketioP2PStatic.Socketiop2p; + +declare namespace SocketioP2PStatic { + export interface PeerOpts { + initiator?: boolean; // false + channelConfig?: object; // {} + channelName?: string; // random string + config?: object; // { iceServers: [{ urls: 'stun:stun.l.google.com:19302' }, { urls: 'stun:global.stun.twilio.com:3478?transport=udp' }] } + constraints?: object; // {} + offerConstraints?: object; // {} + answerConstraints?: object; // {} + sdpTransfrom?: (sdp: any) => any; // (sdp) => sdp + stream?: boolean; // false + streams?: any[]; // [] + trickle?: boolean; // true + wrtc?: RTCPeerConnection | RTCSessionDescription | RTCIceCandidate; // {} + objectMode?: boolean; // false + } + + export interface P2POptions { + numClients?: number; // 5 + autoUpgrade?: boolean; // true + peerOpts?: PeerOpts; + } + + export interface Socketiop2p { + (socket: any, opts: P2POptions, cb?: () => void): Socketiop2p; + on(event: string, callback: (data: any) => void): void; + emit(data: any, cb: () => void): void; + + upgrade(): void; + disconnect(): void; + binarySlice(arr: any[], interval: number, cb: () => void): void; + setupPeerEvents(peer: any): void; + } +} diff --git a/types/socket.io-p2p/socket.io-p2p-tests.ts b/types/socket.io-p2p/socket.io-p2p-tests.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/types/socket.io-p2p/tsconfig.json b/types/socket.io-p2p/tsconfig.json new file mode 100644 index 0000000000..cbaab55544 --- /dev/null +++ b/types/socket.io-p2p/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6", "dom"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "socket.io-p2p-tests.ts"] +} diff --git a/types/socket.io-p2p/tslint.json b/types/socket.io-p2p/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/socket.io-p2p/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }