1- import { Mutex , Room } from 'livekit-client' ;
1+ import { Mutex , type Room } from 'livekit-client' ;
22import { useCallback , useEffect , useMemo , useRef } from 'react' ;
33import { log } from '@livekit/components-core' ;
44
@@ -8,13 +8,14 @@ const CONNECT_DISCONNECT_WARNING_THRESHOLD_MS = 400;
88const ROOM_CHANGE_WARNING_THRESHOLD_QUANTITY = 3 ;
99const ROOM_CHANGE_WARNING_THRESHOLD_MS = 1000 ;
1010
11- type RoomConnectFn = typeof Room . prototype . connect ;
12- type RoomDisconnectFn = typeof Room . prototype . disconnect ;
13-
1411/** @public */
1512export type UseSequentialRoomConnectDisconnectResults < R extends Room | undefined > = {
16- connect : R extends undefined ? RoomConnectFn | null : RoomConnectFn ;
17- disconnect : R extends undefined ? RoomDisconnectFn | null : RoomDisconnectFn ;
13+ connect : R extends undefined
14+ ? typeof Room . prototype . connect | null
15+ : typeof Room . prototype . connect ;
16+ disconnect : R extends undefined
17+ ? typeof Room . prototype . disconnect | null
18+ : typeof Room . prototype . disconnect ;
1819} ;
1920
2021/**
@@ -44,15 +45,15 @@ export function useSequentialRoomConnectDisconnect<R extends Room | undefined>(
4445 | {
4546 type : 'connect' ;
4647 room : Room ;
47- args : Parameters < RoomConnectFn > ;
48- resolve : ( value : Awaited < ReturnType < RoomConnectFn > > ) => void ;
48+ args : Parameters < typeof Room . prototype . connect > ;
49+ resolve : ( value : Awaited < ReturnType < typeof Room . prototype . connect > > ) => void ;
4950 reject : ( err : Error ) => void ;
5051 }
5152 | {
5253 type : 'disconnect' ;
5354 room : Room ;
54- args : Parameters < RoomDisconnectFn > ;
55- resolve : ( value : Awaited < ReturnType < RoomDisconnectFn > > ) => void ;
55+ args : Parameters < typeof Room . prototype . disconnect > ;
56+ resolve : ( value : Awaited < ReturnType < typeof Room . prototype . disconnect > > ) => void ;
5657 reject : ( err : Error ) => void ;
5758 }
5859 >
@@ -136,7 +137,7 @@ export function useSequentialRoomConnectDisconnect<R extends Room | undefined>(
136137 } , [ ] ) ;
137138
138139 const connect = useCallback (
139- async ( ...args : Parameters < RoomConnectFn > ) => {
140+ async ( ...args : Parameters < typeof Room . prototype . connect > ) => {
140141 return new Promise ( ( resolve , reject ) => {
141142 if ( ! room ) {
142143 throw new Error ( 'Called connect(), but room was unset' ) ;
@@ -152,7 +153,7 @@ export function useSequentialRoomConnectDisconnect<R extends Room | undefined>(
152153 ) ;
153154
154155 const disconnect = useCallback (
155- async ( ...args : Parameters < RoomDisconnectFn > ) => {
156+ async ( ...args : Parameters < typeof Room . prototype . disconnect > ) => {
156157 return new Promise ( ( resolve , reject ) => {
157158 if ( ! room ) {
158159 throw new Error ( 'Called discconnect(), but room was unset' ) ;
0 commit comments