2022-08-09 02:04:37 +00:00
|
|
|
/// <reference types="react-scripts" />
|
2022-08-13 17:11:59 +00:00
|
|
|
|
2022-08-14 18:18:27 +00:00
|
|
|
// TODO: Contribute this to DefinitelyTyped
|
2022-08-13 17:11:59 +00:00
|
|
|
declare module 'trystero' {
|
2022-08-14 18:18:27 +00:00
|
|
|
export interface RoomConfig {}
|
|
|
|
|
|
|
|
export type PeerActionData = any
|
|
|
|
|
|
|
|
export interface Room {
|
|
|
|
makeAction: (
|
|
|
|
namespace: string
|
|
|
|
) => [
|
|
|
|
(
|
|
|
|
data: PeerActionData,
|
|
|
|
targetPeers?: string[],
|
|
|
|
metadata?: Record,
|
|
|
|
progress: (percent: number, peerId: string) => void
|
|
|
|
) => void,
|
|
|
|
|
|
|
|
(data: PeerActionData, peerId: string, metadata?: Record) => void,
|
|
|
|
|
|
|
|
(percent: number, peerId: string, metadata?: Record) => void
|
|
|
|
]
|
|
|
|
|
|
|
|
ping: (id: string) => Promise<number>
|
|
|
|
|
|
|
|
leave: () => void
|
|
|
|
|
|
|
|
getPeers: () => string[]
|
|
|
|
|
|
|
|
addStream: (
|
|
|
|
stream: MediaStream,
|
|
|
|
peerId?: string,
|
|
|
|
metadata?: Record
|
|
|
|
) => Promise<void>[]
|
|
|
|
|
|
|
|
removeStream: (stream: MediaStream, peerId?: string) => void
|
|
|
|
|
|
|
|
addTrack: (
|
|
|
|
track: MediaStreamTrack,
|
|
|
|
stream: MediaStream,
|
|
|
|
peerId?: string,
|
|
|
|
metadata?: Record
|
|
|
|
) => Promise<void>[]
|
|
|
|
|
|
|
|
removeTrack: (
|
|
|
|
track: MediaStreamTrack,
|
|
|
|
stream: MediaStream,
|
|
|
|
peerId?: string
|
|
|
|
) => void
|
|
|
|
|
|
|
|
replaceTrack: (
|
|
|
|
oldTrack: MediaStreamTrack,
|
|
|
|
newTrack: MediaStreamTrack,
|
|
|
|
stream: MediaStream,
|
|
|
|
peerId?: string
|
|
|
|
) => Promise<void>[]
|
|
|
|
|
|
|
|
onPeerJoin: (fn: (peerId: string) => void) => void
|
|
|
|
|
|
|
|
onPeerLeave: (fn: (peerId: string) => void) => void
|
|
|
|
|
|
|
|
onPeerStream: (fn: (stream: MediaStream, peerId: string) => void) => void
|
|
|
|
|
|
|
|
onPeerTrack: (
|
|
|
|
fn: (track: MediaStreamTrack, stream: MediaStream, peerId: string) => void
|
|
|
|
) => void
|
|
|
|
}
|
|
|
|
|
|
|
|
export function joinRoom(config: RoomConfig, roomId: string): Room
|
2022-08-13 17:11:59 +00:00
|
|
|
}
|