UNPKG

adam-sdk

Version:

A JavaScript SDK for integrating A.D.A.M. 3D avatars into web applications.

106 lines (105 loc) 3.72 kB
/** * Configuration options for the AvatarSDK. * These options are provided during the SDK's instantiation. */ export interface AvatarSDKOptions { /** * The target origin for postMessage communication. * If not provided, it will be inferred from the iframe's src attribute. * @default new URL(iframeElement.src).origin */ targetOrigin?: string; /** * The desired level of logging for the SDK. * - `none`: No logs will be shown. * - `error`: Only error messages will be displayed. * - `warn`: Warnings and errors will be displayed. * - `info`: Informational messages, warnings, and errors will be displayed. * @default 'info' */ logLevel?: 'none' | 'error' | 'warn' | 'info'; } /** * Options for the `speak(text, options)` command form. * These options allow for customization of the avatar's speech. * Arbitrary additional key/value pairs are allowed and will be forwarded to the iframe payload. */ export interface SpeakOptions { /** * The voice to be used for the speech. * This should correspond to a voice available in the avatar's configuration. */ voice?: string | { id: string; }; /** * The rate at which the avatar speaks. * This is a number that modifies the default speech rate. * A value of 1 is the default rate. Values less than 1 are slower, and values greater than 1 are faster. */ rate?: number; /** * The pitch of the avatar's voice. * This is a number that modifies the default pitch. * A value of 1 is the default pitch. Values less than 1 are lower, and values greater than 1 are higher. */ pitch?: number; /** * An optional animation to be played while the avatar is speaking. * This should correspond to an animation available in the avatar's configuration. */ animation?: string | { name: string; }; /** * An optional expression to be set on the avatar while it is speaking. * This should correspond to an expression available in the avatar's configuration. */ expression?: string | { name: string; intensity?: number; }; /** * Any additional custom key/value pairs to forward to the iframe payload. */ [key: string]: any; } /** * Object payload for the `speak({ text, ... })` command form. * Supports known fields and allows arbitrary additional properties * such as `backgroundUrl`, `sceneId`, etc. */ export interface SpeakPayload { /** The text for the avatar to speak. */ text: string; /** Voice can be a simple id string or an object with an id */ voice?: string | { id: string; }; /** Animation can be a simple name string or an object with a name */ animation?: string | { name: string; }; /** Expression can be a simple name string or an object with a name/intensity */ expression?: string | { name: string; intensity?: number; }; /** Any additional custom key/value pairs to forward to the iframe payload. */ [key: string]: any; } /** * Union for input to `speak` when using single-argument style. */ export type SpeakArg = string | SpeakPayload; /** * A map of events that the SDK can emit. * These events can be listened to using the `on` method. */ export type AvatarEvent = 'ready' | 'speech:start' | 'speech:end' | 'command:success' | 'command:error'; /** * A generic callback function for event listeners. * This function is called when an event is emitted, and it receives a payload with event-specific data. * @param payload - The data associated with the event. */ export type EventCallback = (payload: any) => void;