import { ResizeObserver } from '@juggle/resize-observer'; import { Scene } from './Scene'; import { ContentAwarenessObjectModel } from './models'; import { UpdateContentAwarenessRequestBody } from './websocket-message/scene'; import { Logger, LogLevel } from './utils/Logger'; /** * ContentAwareness class * * An instance of this class is used to enable CUE behaviors in the digital human. * This is achived by measuring tagged HTML elements and sending their coordinates back to the server * * See documentation on GitHub for further reference on how to use this API * https://github.com/soulmachines/smwebsdk/blob/cue-content-awareness-api/guide/content-awareness.md * * @public */ export declare class ContentAwareness { private scene; debounceTime: number; private logger; private readonly VIDEO_FRAME_STR; private readonly VIDEO_FRAME_STR_BRACKETED; private readonly CONTENT_STR; private readonly CONTENT_STR_BRACKETED; private readonly CUE_ATTRIBUTES; private readonly CUE_ATTRIBUTES_BRACKETED; private readonly RESIZE_OBSERVER_BOX_OPTIONS; private mutationObserver; resizeObserver: ResizeObserver; private callMeasure; contentCollection: Record; videoFrame: Element | null; debouncedMeasure: CallableFunction; constructor(scene: Scene, debounceTime?: number, logger?: Logger); /** * Check if the content awareness logging is enabled. * * @returns Returns true if the content awareness logging is enabled otherwise false. */ isLoggingEnabled(): boolean; /** * Enable/disable content awareness logging * @param enable - set true to enable content awareness log, false to disable */ setLogging(enable: boolean): void; /** * Check minimal log level of content awareness. * * @returns Returns minimal log setting of content awareness, type is LogLevel. */ getMinLogLevel(): "debug" | "log" | "warn" | "error"; /** * Set minimal log level of content awareness logging. * @param level - use LogLevel type to set minimal log level of content awareness logging */ setMinLogLevel(level: LogLevel): void; setupEventListeners(): void; /** * Get initial elements, future elements will be added via mutation observer */ private getInitialElements; /** * Start watching for changes in the DOM that are relevant to * ContentAwareness object tracking. * @returns The ContentAwareness MutationObserver used for all content */ private observeMutations; /** * Publicly accessible function to disconnect observers and event listeners */ disconnect(): void; /** * Publicly accessible function to reconnect observers and event listeners */ reconnect(): void; /** * Publicly accessible function to trigger measurement of CUE-relevant elements in the DOM * and send an updateContentAwareness message */ measure(): void; measureDebounced(): void; /** * measures data-sm-video and data-sm-content HTML Elements * * This is automatically called in simple scenarios but can be manually called * if the dev knows an important element has changed * * See documentation on GitHub for further reference on how to use this API * https://github.com/soulmachines/smwebsdk/blob/cue-content-awareness-api/guide/content-awareness.md * * Console logs the sent message on success or an error on failure */ private measureInternal; /** * measure elements tagged with data-videoFrame * @returns a ContentAwarenessObjectModel filled with * videoFrame coordinates on success. returns null on failure */ private measureVideoFrame; /** * measure elements tagged with data-content * @returns a ContentAwarenessObjectModel array filled with the coordinates and * ids of content tagged with the data-sm-content attribute */ private measureContent; /** * Preliminary indication of if content dimensions are valid or not. * Checks if the length and height are zero * @param contentRect - the DOMRect to check * @returns a bool indicating validity */ private invalidDimensions; /** * Preliminary indication of if content is valid or not. * Checks if the coordinates are non zero * @param contentRect - the DOMRect to check * @returns a bool indicating validity */ private invalidContent; /** * measure the browser window * @returns an object containing the window height (innerHeight) and window width (innerWidth) */ private measureWindow; /** * Builds the required UpdateContentAwareness message that gets sent to the server * * @param viewWidth - the width of the browser window * @param viewHeight - the height of the browser window * @param videoFrame - an object containing the coordinates of the video element in which the persona exists * @param content - an array of objects containing the coordinates of the content elements the persona should be aware of * @returns - UpdateContentAwarenessRequestBody the message body to send * * The return value from this function should be passed to * scene.sendRequest('updateContentAwareness', body) */ buildUpdateContentAwarenessRequest(viewWidth: number, viewHeight: number, videoFrame: ContentAwarenessObjectModel, content: Array): UpdateContentAwarenessRequestBody; private trackVideoElement; private trackContentElement; private untrackContentElement; private untrackVideoElement; /** * Takes an array of MutationRecords and measures the ones marked with content awareness attributes * @param mutations - an array of MutationRecords to check and measure */ mutationCallback(mutations: readonly MutationRecord[]): void; private trackAddedNodeWithCUE; private untrackRemovedNodeWithCUE; } //# sourceMappingURL=ContentAwareness.d.ts.map