Prechádzať zdrojové kódy

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
Jonas Gloning 3 rokov pred
rodič
commit
979e69545c
4 zmenil súbory, kde vykonal 11 pridanie a 6 odobranie
  1. 2 0
      lib/exports.ts
  2. 5 0
      lib/optionInterfaces.ts
  3. 3 5
      lib/peer.ts
  4. 1 1
      lib/util.ts

+ 2 - 0
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";
 

+ 5 - 0
lib/optionInterfaces.ts

@@ -19,3 +19,8 @@ export interface PeerConnectOption {
 	serialization?: string;
 	reliable?: boolean;
 }
+
+export interface CallOption {
+	metadata?: any;
+	sdpTransform?: Function;
+}

+ 3 - 5
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;
 	}

+ 1 - 1
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;