Comparing version 1.4.6-rc.1 to 1.4.6
@@ -1,2 +0,2 @@ | ||
import { EventEmitter } from "eventemitter3"; | ||
import { EventEmitter, ValidEventTypes } from "eventemitter3"; | ||
export interface UtilSupportsObj { | ||
@@ -55,10 +55,2 @@ browser: boolean; | ||
} | ||
export enum ConnectionEventType { | ||
Open = "open", | ||
Stream = "stream", | ||
Data = "data", | ||
Close = "close", | ||
Error = "error", | ||
IceStateChanged = "iceStateChanged" | ||
} | ||
export enum ConnectionType { | ||
@@ -68,3 +60,2 @@ Data = "data", | ||
} | ||
export type PeerEventType = "open" | "close" | "connection" | "call" | "disconnected" | "error"; | ||
export enum PeerErrorType { | ||
@@ -123,3 +114,11 @@ BrowserIncompatible = "browser-incompatible", | ||
} | ||
declare abstract class BaseConnection extends EventEmitter { | ||
type BaseConnectionEvents = { | ||
/** | ||
* Emitted when either you or the remote peer closes the connection. | ||
*/ | ||
close: () => void; | ||
error: (error: Error) => void; | ||
iceStateChanged: (state: RTCIceConnectionState) => void; | ||
}; | ||
declare abstract class BaseConnection<T extends ValidEventTypes> extends EventEmitter<T & BaseConnectionEvents> { | ||
readonly peer: string; | ||
@@ -138,6 +137,16 @@ provider: Peer; | ||
} | ||
type DataConnectionEvents = { | ||
/** | ||
* Emitted when data is received from the remote peer. | ||
*/ | ||
data: (data: unknown) => void; | ||
/** | ||
* Emitted when the connection is established and ready-to-use. | ||
*/ | ||
open: () => void; | ||
}; | ||
/** | ||
* Wraps a DataChannel between two Peers. | ||
*/ | ||
export class DataConnection extends BaseConnection implements DataConnection { | ||
export class DataConnection extends BaseConnection<DataConnectionEvents> implements DataConnection { | ||
readonly label: string; | ||
@@ -187,6 +196,12 @@ readonly serialization: SerializationType; | ||
} | ||
type MediaConnectionEvents = { | ||
/** | ||
* Emitted when a connection to the PeerServer is established. | ||
*/ | ||
stream: (stream: MediaStream) => void; | ||
}; | ||
/** | ||
* Wraps the streaming interface between two Peers. | ||
*/ | ||
export class MediaConnection extends BaseConnection { | ||
export class MediaConnection extends BaseConnection<MediaConnectionEvents> { | ||
get type(): ConnectionType; | ||
@@ -198,3 +213,3 @@ get localStream(): MediaStream; | ||
handleMessage(message: ServerMessage): void; | ||
answer(stream: MediaStream, options?: AnswerOption): void; | ||
answer(stream?: MediaStream, options?: AnswerOption): void; | ||
/** | ||
@@ -301,5 +316,5 @@ * Exposed functionality for users. | ||
call(peer: string, stream: MediaStream, options?: CallOption): MediaConnection; | ||
_removeConnection(connection: BaseConnection): void; | ||
_removeConnection(connection: DataConnection | MediaConnection): void; | ||
/** Retrieve a data/media connection for this peer. */ | ||
getConnection(peerId: string, connectionId: string): null | BaseConnection; | ||
getConnection(peerId: string, connectionId: string): null | DataConnection | MediaConnection; | ||
/** Emits a typed error message. */ | ||
@@ -306,0 +321,0 @@ emitError(type: PeerErrorType, err: string | Error): void; |
{ | ||
"name": "peerjs", | ||
"version": "1.4.6-rc.1", | ||
"version": "1.4.6", | ||
"keywords": [ | ||
@@ -5,0 +5,0 @@ "peerjs", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
2588115
20868