/** * A callback to call when a realm changes. */ type RealmChangeCallback = (childNodes: Node[]) => void; /** * Get the owner realm instance for a node. * @param node The child node. * @returns The owner realm instance or null. */ export declare function getParentRealm(node: Node): Realm | null; /** * The realm class. */ export declare class Realm { /** * The root node of the realm. */ readonly node: HTMLElement; /** * The child nodes of the realm. */ readonly childNodes: Node[]; /** * The fragment used to temporary store nodes. */ readonly fragment: DocumentFragment; /** * The callbacks to call when the realm changes. */ protected callbacks: Set; /** * The position of the virtual iterator. */ protected virtualCurrentNode: Node | null; /** * Whether the realm is initialized. */ protected _active: boolean; /** * Whether the realm is open. */ protected _open: boolean; /** * Setup the realm. * @param node The root node of the realm. */ constructor(node: HTMLElement); /** * Whether the realm is initialized. */ get active(): boolean; /** * Whether the realm is open. */ get open(): boolean; /** * Initialize the realm. */ initialize(): void; /** * Restore the slot child nodes. */ restore(): void; /** * Get the child nodes assigned to a slot. * @deprecated This method is now part of the component class. * @param name The slot name, or null for the default slot. * @returns The list of child nodes assigned to the slot. */ childNodesBySlot(name?: string | null): Node[]; /** * Add a callback to call when the realm changes. * @param callback The callback to invoke. */ observe(callback: RealmChangeCallback): void; /** * Remove a registered callback. * @param callback The callback to remove. */ unobserve(callback: RealmChangeCallback): void; /** * Open the realm. * When using this method, you must call `dangerouslyClose` when you are done, * or things will get unstable. * @return Whether the realm was successfully opened. */ dangerouslyOpen(): boolean; /** * Close the realm. */ dangerouslyClose(): void; /** * Request an update of the realm. * @param callback The callback to invoke. * @returns The result of the callback. */ requestUpdate any>(callback: T): ReturnType; /** * Notifiy a realm update * @param mutations The list of mutations that triggered the update. */ protected notify(): void; /** * Check if a node should use the virtual iterator to get the next or previous sibling. * @param node The node to check. * @returns Whether the node should use the virtual iterator. */ shouldUseVirtualIterator(node: Node): boolean; /** * Get the previous sibling of a node in the realm. * @param node The node to get the previous sibling of. * @returns The previous sibling of the node. */ getPreviousSibling(node: ChildNode | null): Node | null; /** * Get the next sibling of a node in the realm. * @param node The node to get the next sibling of. * @returns The next sibling of the node. */ getNextSibling(node: Node | null): Node | null; /** * Set the owner realm for a node. * @param node The node to set the owner realm for. */ own(node: Node): void; /** * Adopt a node to a realm. * @param realm The realm to adopt the node to. * @param node The node to adopt. */ protected adoptNode(node: Node): void; /** * Release a node from the realm. * @param node The node to release. */ protected releaseNode(node: Node): void; /** * Normalize nodes list. * @param nodes The nodes to normalize. * @param acc The accumulator. * @returns The normalized nodes. */ protected importNodes(nodes: (Node | string)[], acc?: Node[]): Node[]; /** * Adopt nodes to the realm. * @param nodes Nodes to adopt. */ protected adoptNodes(nodes: Node[]): void; /** * Insert nodes before a reference node in the slot child nodes array. * @param nodes The nodes to insert. * @param referenceNode The reference node to insert before. */ protected insertNodesBefore(nodes: Node[], referenceNode: Node | null): void; /** * Append nodes to the realm. * @param nodes The nodes to append. */ append(...nodes: (Node | string)[]): void; /** * Prepend nodes to the realm. * @param nodes The nodes to prepend. */ prepend(...nodes: (Node | string)[]): void; /** * Remove nodes from the realm. * @param node The node to remove. */ removeChild(node: Node): void; /** * Replaces a realm node with nodes, while replacing strings in nodes with equivalent Text nodes. * @param nodes The nodes or strings to replace node with. Strings are replaced with equivalent Text nodes. * @param referenceNode The node to replace. */ replaceChild(nodes: (string | Node)[], referenceNode: Node): void; /** * Inserts nodes or contents in the realm before node. * @param nodes The nodes to be inserted. * @param referenceNode The node before which new nodes are to be inserted. */ insertBefore(nodes: (string | Node)[], referenceNode: Node | null): void; /** * Check if a realm is contained in this realm. * @param realm The child realm. * @returns Whether the realm is contained in this realm. */ contains(realm: Realm): boolean; } export {};