import { Call } from '@azure/communication-calling' ; import { CallContext } from './CallContext' ; private export interface DeclarativeCall extends Call { /**
     * Stop any declarative specific subscriptions and remove declarative subscribers.
     */ unsubscribe ( ) : void ; } class ProxyCall implements ProxyHandler < Call > { private _context : CallContext ; constructor ( context ) { this . _context = context ; } public unsubscribe ( ) { } public get < P extends keyof Call > ( target , prop ) { switch ( prop ) { case 'mute' : { return this . _context . withAsyncErrorTeedToState ( async function ( ... args ) { return await target . mute ( ... args ) ; } , 'Call.mute' ) ; } case 'unmute' : { return this . _context . withAsyncErrorTeedToState ( async function ( ... args ) { return await target . unmute ( ... args ) ; } , 'Call.unmute' ) ; } case 'startVideo' : { return this . _context . withAsyncErrorTeedToState ( async function ( ... args ) { return await target . startVideo ( ... args ) ; } , 'Call.startVideo' ) ; } case 'stopVideo' : { return this . _context . withAsyncErrorTeedToState ( async function ( ... args ) { return await target . stopVideo ( ... args ) ; } , 'Call.stopVideo' ) ; } case 'startScreenSharing' : { return this . _context . withAsyncErrorTeedToState ( async function ( ... args ) { return await target . startScreenSharing ( ... args ) ; } , 'Call.startScreenSharing' ) ; } case 'stopScreenSharing' : { return this . _context . withAsyncErrorTeedToState ( async function ( ... args ) { return await target . stopScreenSharing ( ... args ) ; } , 'Call.stopScreenSharing' ) ; } default : return Reflect . get ( target , prop ) ; } } } param call param context export const callDeclaratify = ( call , context ) : DeclarativeCall => { const proxyCall = new ProxyCall ( context ) ; Object . defineProperty ( call , 'unsubscribe' , { configurable : false , value : ( ) => proxyCall . unsubscribe ( ) } ) ; return new Proxy ( call , proxyCall ) as DeclarativeCall ; } ;