Skip to content

Commit

Permalink
fix(typings): export interfaces
Browse files Browse the repository at this point in the history
In 1.3 typings have been documented by hand. Now they are auto generated and we have to export them explicitly.

Closes #953
  • Loading branch information
jonasgloning committed May 13, 2022
1 parent 29acfef commit 979e695
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions lib/exports.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
5 changes: 5 additions & 0 deletions lib/optionInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ export interface PeerConnectOption {
serialization?: string;
reliable?: boolean;
}

export interface CallOption {
metadata?: any;
sdpTransform?: Function;
}
8 changes: 3 additions & 5 deletions lib/peer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 " +
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 979e695

Please sign in to comment.