/** * Which form a message uses. Also drives the `data-content` attribute, because * plain text is the one form whose whitespace has to survive. * * @param {Message} message * @returns {'text' | 'html' | 'template' | 'element' | 'component'} */ export function contentField(message: Message): "text" | "html" | "template" | "element" | "component"; /** * The value a message's content is built from. Used to decide whether a * message actually changed, so `chat-message-render` does not fire on every * unrelated update. * * @param {Message} message * @returns {unknown} */ export function contentKey(message: Message): unknown; /** * Build (or reuse) an element for a component reference and write its props. * * The instance is kept across renders so the component keeps its own state; a * changed reference replaces it, and changed props are assigned one by one so * the component's own setters see each change. * * @param {ChitUI} host * @param {string} key Cache key. * @param {(new () => HTMLElement) | string} source * @param {Record} [props] * @returns {HTMLElement} */ export function resolveComponent(host: ChitUI, key: string, source: (new () => HTMLElement) | string, props?: Record): HTMLElement; /** * Drop cached instances for messages that are gone, so a long conversation * does not hold on to elements it will never show again. Non-message entries, * such as the launcher's, are left alone. * * @param {ChitUI} host * @param {Set} liveIds */ export function pruneComponents(host: ChitUI, liveIds: Set): void; /** * The component instance backing a message, when it has one. * * @param {ChitUI} host * @param {string} id * @returns {HTMLElement | undefined} */ export function componentInstance(host: ChitUI, id: string): HTMLElement | undefined; /** * Turn a message's content into something Lit can render as a child value. * * All four shapes collapse here: an HTML string becomes an `unsafeHTML` * directive, a Lit template passes straight through, and an element or a * component becomes a Node, which Lit inserts as-is. * * @param {ChitUI} host * @param {Message} message * @returns {unknown} */ export function renderContent(host: ChitUI, message: Message): unknown; /** The cache key for the closed-state component. */ export const LAUNCHER_KEY: "launcher"; export type ComponentEntry = { /** * What `component` held when this was built. */ source: (new () => HTMLElement) | string; element: HTMLElement; /** * Last props written to the element. */ props: Record; }; import type { Message } from '../types.js'; import type { ChitUI } from '../chit-ui.js';