From 979e69545cc2fe10c60535ac9793140ef8dba4ec Mon Sep 17 00:00:00 2001 From: Jonas Gloning <34194370+jonasgloning@users.noreply.github.com> Date: Fri, 13 May 2022 11:29:38 +0200 Subject: [PATCH] fix(typings): export interfaces In 1.3 typings have been documented by hand. Now they are auto generated and we have to export them explicitly. Closes #953 --- lib/exports.ts | 2 ++ lib/optionInterfaces.ts | 5 +++++ lib/peer.ts | 8 +++----- lib/util.ts | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/exports.ts b/lib/exports.ts index 829cd4802..17cd7fb06 100644 --- a/lib/exports.ts +++ b/lib/exports.ts @@ -1,6 +1,8 @@ import { util } from "./util"; import { Peer } from "./peer"; +export type { PeerJSOption, PeerConnectOption, AnswerOption, CallOption } from "./optionInterfaces" +export type {UtilSupportsObj} from "./util" export type { DataConnection } from "./dataconnection"; export type { MediaConnection } from "./mediaconnection"; diff --git a/lib/optionInterfaces.ts b/lib/optionInterfaces.ts index d6d8e09ab..ee91885cd 100644 --- a/lib/optionInterfaces.ts +++ b/lib/optionInterfaces.ts @@ -19,3 +19,8 @@ export interface PeerConnectOption { serialization?: string; reliable?: boolean; } + +export interface CallOption { + metadata?: any; + sdpTransform?: Function; +} diff --git a/lib/peer.ts b/lib/peer.ts index b685b2165..b7a994a6f 100644 --- a/lib/peer.ts +++ b/lib/peer.ts @@ -14,7 +14,7 @@ import { import { BaseConnection } from "./baseconnection"; import { ServerMessage } from "./servermessage"; import { API } from "./api"; -import type { PeerConnectOption, PeerJSOption } from "./optionInterfaces"; +import type { PeerConnectOption, PeerJSOption, CallOption } from "./optionInterfaces"; class PeerOptions implements PeerJSOption { debug?: LogLevel; // 1: Errors, 2: Warnings, 3: All logs @@ -373,7 +373,7 @@ export class Peer extends EventEmitter { * Returns a MediaConnection to the specified peer. See documentation for a * complete list of options. */ - call(peer: string, stream: MediaStream, options: any = {}): MediaConnection { + call(peer: string, stream: MediaStream, options: CallOption = {}): MediaConnection { if (this.disconnected) { logger.warn( "You cannot connect to a new Peer because you called " + @@ -394,9 +394,7 @@ export class Peer extends EventEmitter { return; } - options._stream = stream; - - const mediaConnection = new MediaConnection(peer, this, options); + const mediaConnection = new MediaConnection(peer, this, {...options, _stream:stream}); this._addConnection(peer, mediaConnection); return mediaConnection; } diff --git a/lib/util.ts b/lib/util.ts index a62d1b886..644630f56 100644 --- a/lib/util.ts +++ b/lib/util.ts @@ -3,7 +3,7 @@ import BinaryPack from "peerjs-js-binarypack"; import { Supports } from "./supports"; -interface UtilSupportsObj { +export interface UtilSupportsObj { browser: boolean; webRTC: boolean; audioVideo: boolean;