import { default as React } from 'react'; import { BuiltinActionType, BuiltinEventType, KeyframeEventType, LiveConnectOptions, LiveEventType, LiveOptions, MicroStatus, RTCEventType, RTCType, UserInfo } from '../typings'; import { LiveState } from '../typings/live/LiveState'; import { Live } from './live'; /** * LiveProvider 组件的属性类型 * * @template KeyframesSnapshot 帧数据快照类型 */ export type LiveProviderPropTypes> = { /** * 子组件 */ children?: React.ReactNode; /** * 自定义 Live 实例(可选,默认使用内部创建的实例) */ live?: Live; }; /** * 创建 LiveReact 实例,并提供 React 技术栈相关工具链 * * 这个函数会创建一个 Live 实例和一系列 React Hooks,用于在 React 组件中方便地使用带看功能。 * 返回的对象包含 LiveProvider 组件和各种 Hooks。 * * @template KeyframesSnapshot 帧数据快照类型,必须是一个对象类型 * @param options 带看配置选项,详见 {@link LiveOptions} * @returns 包含 LiveProvider 组件和各种 Hooks 的对象 * @example * ```typescript * // 定义帧数据类型 * interface MyKeyframes { * camera: { position: [number, number, number] } * annotation: { text: string; position: [number, number] } * } * * // 创建 LiveReact 实例 * const { LiveProvider, useLiveAction, useKeyframe } = createLiveReact({ * url: 'wss://example.com/live', * getTicket: async () => 'ticket', * getVoiceSign: async (params) => ({ sdkAppId: 0, userId: '', userSig: '', roomId: '' }), * useBuiltInRTC: true * }) * * // 在组件中使用 * function App() { * return ( * * * * ) * } * * function MyComponent() { * const { connect, sendKeyframe } = useLiveAction() * const [camera, setCamera] = useKeyframe('camera') * * // 使用带看功能... * } * ``` */ export declare function createLiveReact>(options: LiveOptions): { live: Live; jsBridge: import('@realsee/jsbridge-x').JSBridgeProtocol; LiveProvider: (props: LiveProviderPropTypes) => React.FunctionComponentElement | null>>; unsafe__useLiveInstance: () => Live; unsafe__useRTCInstance: () => import('../typings').RTCProtocol; useConnect: () => (options: LiveConnectOptions) => Promise; useKeyframe: (key: K) => (KeyframesSnapshot[K] | ((frame: KeyframesSnapshot[K]) => boolean | Error) | undefined)[]; useKeyframeUpdateCallback: >(key: KeyOfKeyframe, callback: (...args: Parameters[KeyOfKeyframe]>) => ReturnType[KeyOfKeyframe]>, deps?: React.DependencyList) => () => void; useLiveAction: () => { connect: (options: LiveConnectOptions) => Promise; broadcast: (data: Record, toUserIds: string | string[], timeout?: number) => Promise; exit: () => Promise; kick: (toUserIds: string | string[]) => Promise; toggleMicro: (microStatus: boolean) => void; forbidMicro: (micro: MicroStatus, toUserIds?: string | string[]) => Promise; forbidSync: (sync: boolean, toUserIds?: string | string[]) => void; sendKeyframe: (key: keyof KeyframesSnapshot, frame: KeyframesSnapshot[keyof KeyframesSnapshot]) => void; getFramesByKey: (key: keyof KeyframesSnapshot) => Partial[keyof KeyframesSnapshot] | undefined; setSelfInfo: (userInfo: Partial) => void; updateStatus: (evtType: BuiltinEventType, atnType: BuiltinActionType, status: Record, toUserIds?: string | string[]) => void; }; useLiveEventCallback: >(name: K, callback: (...args: Parameters[K]>) => ReturnType[K]>, deps?: React.DependencyList) => () => void; useLiveState: () => LiveState; useRTCAction: () => { join: (options: { voiceId: string; userId: string; roomId: string; type: RTCType; }) => Promise; quit: () => Promise; shock: () => void | undefined; toggleMicro: (flag?: boolean | undefined) => Promise; detectMicro: () => Promise; }; useRTCEventCallback: (name: K, callback: (...args: Parameters) => ReturnType, deps?: React.DependencyList) => () => void; useSelfInfo: () => (Partial | ((userInfo: Partial) => Promise))[]; useKeyframesSnapshot: () => Partial; useUserList: () => UserInfo[]; };