import { type Styles } from "./styles.js"; import { type OutputTransformer } from "./render-node-to-output.js"; import { TaffyNode } from "./taffy-node.js"; import { type SizeObserver } from "./size-observer.js"; /** * Interface representing a node in the Tinky tree. */ export interface TinkyNode { /** Parent DOM element in the tree. */ parentNode: DOMElement | undefined; /** Taffy layout node for computing dimensions. */ taffyNode?: TaffyNode; /** Whether this node is inside a Static component. */ internal_static?: boolean; /** Styles applied to this node. */ style: Styles; } /** * Type representing a text node name. */ export type TextName = "#text"; /** * Type representing element names in the Tinky DOM. */ export type ElementNames = "tinky-root" | "tinky-box" | "tinky-text" | "tinky-virtual-text" | "tinky-separator" | "tinky-raw"; /** * Union type of all possible node names. */ export type NodeNames = ElementNames | TextName; /** * Interface representing a DOM element in Tinky. */ export type DOMElement = { /** Name of the element type. */ nodeName: ElementNames; /** Key-value pairs of element attributes. */ attributes: Record; /** Array of child nodes. */ childNodes: DOMNode[]; /** Function to transform the output of this element. */ internal_transform?: OutputTransformer; /** Accessibility attributes for screen readers. */ internal_accessibility?: { /** ARIA role for the element. */ role?: "button" | "checkbox" | "combobox" | "list" | "listbox" | "listitem" | "menu" | "menuitem" | "option" | "progressbar" | "radio" | "radiogroup" | "tab" | "tablist" | "table" | "textbox" | "timer" | "toolbar"; /** ARIA state values for the element. */ state?: { /** Whether the element is busy. */ busy?: boolean; /** Whether the element is checked. */ checked?: boolean; /** Whether the element is disabled. */ disabled?: boolean; /** Whether the element is expanded. */ expanded?: boolean; /** Whether the element accepts multiline input. */ multiline?: boolean; /** Whether multiple items can be selected. */ multiselectable?: boolean; /** Whether the element is read-only. */ readonly?: boolean; /** Whether the element is required. */ required?: boolean; /** Whether the element is selected. */ selected?: boolean; }; }; /** Whether static nodes need to be re-rendered. */ isStaticDirty?: boolean; /** Reference to the Static component node. */ staticNode?: DOMElement; /** Callback to compute layout before rendering. */ onComputeLayout?: () => void; /** Callback to trigger a render. */ onRender?: () => void; /** Callback to trigger an immediate render. */ onImmediateRender?: () => void; /** Set of resize observers attached to this element. */ resizeObservers?: Set; } & TinkyNode; /** * Interface representing a text node in Tinky. */ export type TextNode = { /** Text node identifier. */ nodeName: TextName; /** Text content of the node. */ nodeValue: string; } & TinkyNode; /** * Union type representing either a DOM element or a text node. */ export type DOMNode = T extends { nodeName: infer U; } ? U extends "#text" ? TextNode : DOMElement : never; /** * Type representing possible types for DOM node attributes. */ export type DOMNodeAttribute = boolean | string | number; /** * Creates a new DOM element. * * @param nodeName - The name of the node to create. * @returns The created DOM element. */ export declare const createNode: (nodeName: ElementNames) => DOMElement; /** * Appends a child node to a parent node. * * @param node - The parent node. * @param childNode - The child node to append. */ export declare const appendChildNode: (node: DOMElement, childNode: DOMElement) => void; /** * Inserts a new child node before a reference node. * * @param node - The parent node. * @param newChildNode - The new child node to insert. * @param beforeChildNode - The reference node before which to insert the new node. */ export declare const insertBeforeNode: (node: DOMElement, newChildNode: DOMNode, beforeChildNode: DOMNode) => void; /** * Removes a child node from a parent node. * * @param node - The parent node. * @param removeNode - The child node to remove. */ export declare const removeChildNode: (node: DOMElement, removeNode: DOMNode) => void; /** * Sets an attribute on a DOM element. * * @param node - The DOM element. * @param key - The attribute key. * @param value - The attribute value. */ export declare const setAttribute: (node: DOMElement, key: string, value: DOMNodeAttribute) => void; /** * Sets the style of a DOM node. * * @param node - The DOM node. * @param style - The style object. */ export declare const setStyle: (node: DOMNode, style: Styles) => void; /** * Creates a text node. * * @param text - The text content. * @returns The created text node. */ export declare const createTextNode: (text: string) => TextNode; /** * Sets the value of a text node. * * @param node - The text node. * @param text - The new text value. */ export declare const setTextNodeValue: (node: TextNode, text: string) => void;