mediasfu-reactnative-expo
Version:
mediasfu-reactnative-expo – Expo-managed React Native WebRTC SDK for video conferencing, webinars, live streaming, broadcast, screen sharing, whiteboard, chat, recording, live subtitles, translation, and AI agent rooms on iOS, Android, and web. Prebuilt r
88 lines (87 loc) • 2.71 kB
TypeScript
/**
* Override helper utilities for MediaSFU React Native Expo
*
* These utilities enable flexible component and function overrides
* while maintaining React Native compatibility (no DOM APIs).
*/
import { ComponentType, ReactNode } from 'react';
/**
* Component override type - supports both full replacement and render wrapping
*/
export interface CustomComponentOverride<Props> {
/**
* Completely replace the default component
*/
component?: ComponentType<Props>;
/**
* Wrap or augment the default component's render
*/
render?: (props: Props) => ReactNode;
}
/**
* Function override type - supports both full replacement and wrapping
*/
export interface CustomFunctionOverride<Fn extends (...args: any[]) => any> {
/**
* Completely replace the default implementation
*/
implementation?: Fn;
/**
* Wrap the default implementation (before/after logic)
*/
wrap?: (defaultImplementation: Fn) => Fn;
}
/**
* Applies a component override, returning the appropriate component to render
*
* @param override - The override configuration (component or render function)
* @param DefaultComponent - The default component to use if no override is provided
* @returns The component to render (either overridden or default)
*
* @example
* ```tsx
* const MyComponent = withOverride(
* uiOverrides?.mainContainer,
* MainContainerComponent
* );
*
* // Later in JSX:
* <MyComponent {...props} />
* ```
*/
export declare function withOverride<Props>(override: CustomComponentOverride<Props> | undefined, DefaultComponent: ComponentType<Props>): ComponentType<Props>;
/**
* Applies a function override, returning the appropriate function to use
*
* @param override - The override configuration (implementation or wrap function)
* @param defaultFn - The default function to use if no override is provided
* @returns The function to use (either overridden or default)
*
* @example
* ```tsx
* const customConsumerResume = withFunctionOverride(
* uiOverrides?.consumerResume,
* consumerResume
* );
*
* // Later in code:
* await customConsumerResume(params);
* ```
*
* @example
* // Wrapping with analytics
* ```tsx
* const override = {
* wrap: (original) => async (params) => {
* const start = performance.now();
* const result = await original(params);
* analytics.track('consumer_resume', {
* duration: performance.now() - start,
* consumerId: params?.consumer?.id
* });
* return result;
* }
* };
* ```
*/
export declare function withFunctionOverride<Fn extends (...args: any[]) => any>(override: CustomFunctionOverride<Fn> | undefined, defaultFn: Fn): Fn;