sandai-react
Version:
React components and utilities for the Sandai 3D AI Characters.
35 lines • 2.03 kB
TypeScript
import type { AllRpcMethods } from "ai-vrm-chat/index.rpc";
import type { AllRpcMethods as MiscRpcMethods } from "ai-vrm-chat/index-reduced.rpc";
export declare class RPCManager {
private _iframe;
private _iframeUrl;
private _listeners;
constructor(iframe: HTMLIFrameElement);
private static _collectTransferables;
/**
* Calls a method inside the iframe to control or interact with the character.
* Provides direct access to most functionality exposed by the character.
*
* This function requires that the character has been initialized successfully.
* If the character failed to load and returned a `loadError`, use `postLoadErrorCall` instead.
*
* @template P - The key of the RPC method to call.
* @param {P} path - Path through the object representing the method to call. TypeScript will infer valid options.
* @param {...AllRpcMethods[P]["args"]} args - Arguments to pass to the target method.
* @returns {Promise<AllRpcMethods[P]["return"]>} - A promise that resolves with the result of the called method.
*/
call<P extends keyof AllRpcMethods>(path: P, ...args: AllRpcMethods[P]["args"]): Promise<AllRpcMethods[P]["return"]>;
/**
* Calls a method even if the character failed to load properly.
* Use this for methods that can be invoked in error states, e.g., logging or fallback operations.
*
* @template P - The key of the miscellaneous RPC method to call.
* @param {P} path - Path through the object representing the method to call. TypeScript will infer valid options.
* @param {...MiscRpcMethods[P]["args"]} args - Arguments to pass to the target method.
* @returns {Promise<MiscRpcMethods[P]["return"]>} - A promise that resolves with the result of the called method.
*/
postLoadErrorCall<P extends keyof MiscRpcMethods>(path: P, ...args: MiscRpcMethods[P]["args"]): Promise<MiscRpcMethods[P]["return"]>;
private _call;
destroy(): void;
}
//# sourceMappingURL=RpcManager.d.ts.map