import { Messaging, SdkMessage } from './base_sdk'; import { ColorValueHex, EyeColorType, SdkIncomingMessages, SdkMessageResponseType } from './message_types'; import { InitParams, SdkCallback, EditableBodyProportions } from './types'; declare global { interface Window { avaturnSDKEnvironment?: any; } } /** * Main SDK class */ export declare class AvaturnSDK extends Messaging { private _version; private defaultAssets?; /** Constructor does not perform actual initialization. After creating object use {@link AvaturnSDK.init} to actually initialize SDK. */ constructor(); private sceneRef; private callbacks; private suppressCallbacks?; private applyStyles; private validateDefaultAssets; private setupDOM; /** * TODO: create types for the data incoming with messages */ protected handleMessage(message: SdkMessage): void; /** Initializes SDK, creates DOM elements for Avaturn. Returns a promise that resolves when Avaturn inside iframe is initialized. @example ``` sdk.init(containerRef, { url: "" iframeClassName: 'sdk-iframe', disableUi: true, }) ``` @param container DOM element that will be parent for all DOM elements created by SDK. @param config Config for initialization. @returns */ init(container: HTMLElement | Element | null, { url, iframeClassName, disableUi, defaultAssets }: InitParams): Promise; /** * Destructs the SDK, cleans up data, removes the listeners. */ destroy(): void; /** * Set callback to receive particular events. * @example ``` sdk.on('load', () => { console.log('[callback] Avaturn loaded'); }) ``` * {@link SdkCallback} * @event */ on(event: T, callback: SdkCallback[T]): this; /** * Gets a list of available assets. * @group Asset */ getAssetList(): Promise; /** * Sets a list of available assets. * @example * ``` sdk.getAssetList().then((list) => { const filteredList = list.slice(0, 3).map((x) => x.id); return sdk.setAvailableAssets(filteredList); }) ``` * @group Asset */ setAvailableAssets(assets: string[]): Promise; /** * Gets a list of active assets for Avaturn in a form of dictionary {category: assetId }. If some category does not have an active item, empty string instead of asset id is returned. * It's best to Avaturn state as source of truth because Avaturn automatically fixes inconsistencies such as when a developer calls `.setActiveAsset()` with incorrect id or when activating one asset leads to deactivating another one. * @group Asset */ getActiveAssets(): Promise<{ eyewear: string; hairAndHeadwear: string; clothing: string; footwear: string; }>; /** * Сhanges the current active asset to the specified one. * @group Asset */ setActiveAsset(id: string): Promise; /** * Changes the current active body to the specified one. * @param id Body id, one of ids returned by {@link getBodyList} * @returns Promise which resolves once the body is changed. * @group Body */ setActiveBody(id: string): Promise; /** * Gets a list of available bodies and their preview urls. * @group Body */ getBodyList(): Promise; /** * Gets information about the current body. * @group Body */ getActiveBody(): Promise<{ id: string; }>; /** * Changes the current active animation to the specified one. * @param id Animation id, one of ids returned by {@link getAnimationList} * @returns Promise which resolves once the animation is changed. * @group Animation */ setActiveAnimation(id: string): Promise; /** * Gets information about the current animation. * @group Animation */ getActiveAnimation(): Promise<{ id: string; }>; /** * Gets a list of available animations and their preview urls. * @group Animation */ getAnimationList(): Promise; /** * Initiates avatar export. * @group Export */ exportAvatar(): Promise; /** Sets eye color. @param value string, see EyeColorType @group Options */ setEyeColor(value: EyeColorType): Promise; /** Sets hair color. @param value hex string with leading `#` (e.g. `'#ffffff'`, `'#b32973'`) @group Options */ setHairColor(value: ColorValueHex): Promise; /** Sets eyewear lens color. @param value hex string with leading `#` (e.g. `'#ffffff'`, `'#b32973'`), or "transparent" @group Options */ setEyewearColor(value: ColorValueHex | 'transparent'): Promise; /** Sets body proportions. @param key one of **head** | **arms** | **chest** @param value Number from -100 to 100. 0 = no correction. @group Options */ setBodyProportions(key: EditableBodyProportions, value: number): Promise; /** * Sets skin tone correction coefficient. * @param value Number from -50 to 50. 0 = no correction. * @group Options */ setSkinToneCorrection(value: number): Promise; /** * Gets information about the current eye color (only for T2 avatars). * @group Options */ getEyeColor(): Promise; /** * Gets information about the current hair color. * @group Options */ getHairColor(): Promise<`#${string}`>; /** * Gets information about the current eyewear color. * @group Options */ getEyewearColor(): Promise<`#${string}` | "transparent">; /** * Gets information about the current proportions. * @group Options */ getBodyProportions(): Promise>; /** * Gets information about the current skin tone correction coefficient. * @group Options */ getSkinToneCorrection(): Promise; getAvatarId(): Promise<{ id: string | null; }>; }