import { HsonNode } from "../../core/types.js"; import { ListenerBuilder } from "../../types/listen.types.js"; import { CssTreeHandle, StyleHandle } from "../../types/css.types.js"; import { LiveTextApi } from "./managers/text-form-values.js"; import { DataApi } from "./managers/data-manager.js"; import { FindMany } from "./methods/find.js"; import { HtmlCreateHelper } from "../../types/livetree.types.js"; import { FindWithById } from "../../types/livetree.types.js"; import { ClassApi, IdApi, LiveTreeDom } from "../../types/dom.types.js"; import { TreeEvents } from "../../types/events.types.js"; import { type ContentManager } from "./managers/content-manager.js"; import { AttrHandle, FlagHandle } from "../../types/attrs.types.js"; import { SvgApi } from "./managers/svg-api.js"; import { AppendableLiveBranch, LiveFormApi, LiveTreeApi } from "../../types/livetree-internals.types.js"; import { CanvasApi } from "./managers/canvas/canvas.types.js"; import { type AsyncLiveTree } from "./async-livetree.js"; import { LiveTreeBindApi } from "./methods/livetree.bind.js"; import type { DetachedLiveContent, LiveTreeLifecycleResult } from "../../types/lifecycle.types.js"; /** * Instrumented wrapper around a single `HsonNode`, providing a high-level API. * * Core surfaces: * - Traversal and selection (`find`, `findAll`). * - Structural editing (`append`, `empty`, `detachContents`, `detach`, `remove`). * - Attribute/flag, content/form, style/data/css, and event helpers. * - Typed element creation via `.create`. * * Instances maintain: * - nodeRef: A `NodeRef` that pins the exact current node and resolves QUID on demand. * - hostRoot: Hson node representing the historic root of the subtree. * - Lazily constructed managers for style (`StyleManager`) and dataset (`DataManager`). */ export declare class LiveTree implements LiveTreeApi { private nodeRef; private hostRoot; private styleApiInternal?; private dataApiInternal?; private contentManager?; private cssApiInternal?; private eventsInternal?; private idApi?; private classApi?; private _attrs?; private _flags?; private svgApi?; private domApiInternal?; private textApiInternal?; private formApiInternal?; private canvasApi?; private bindApiInternal?; private asyncApiInternal?; private findApiInternal?; private findAllApiInternal?; /** * Internal helper to assign `nodeRef` from either a raw `HsonNode` * or another `LiveTree`. * * Behavior: * - When given a `LiveTree`, re-wraps its `.node` in a fresh `NodeRef` * to ensure a stable QUID and consistent `resolve*` behavior. * - When given a `HsonNode`, wraps it directly via `makeRef`. * * This method centralizes creation of the `NodeRef` used by the * `node` getter and QUID-based DOM resolution. * * @param input - Either a `HsonNode` or another `LiveTree`. * @see makeRef */ private setRef; /** * Internal helper to assign the `hostRoot` for this `LiveTree`. * * Behavior: * - When given a `LiveTree`, inherits its `hostRoot` so that branches * grafted from an existing tree carry forward the same historic root. * - When given a `HsonNode`, treats that node as the root for this * instance. * * Throws if the resulting `hostRoot` is falsy, as a missing root would * break features that depend on a stable root context. * * @param input - Either a `HsonNode` or another `LiveTree`. */ private setRoot; /** * Construct a new `LiveTree` from either a raw `HsonNode` or another * `LiveTree`. * * Initialization steps: * - Derive and store the `hostRoot` via `setRoot(input)`. * - Create a `NodeRef` and QUID association via `setRef(input)`. * * When constructed from another `LiveTree`, both the root and the * referenced node are inherited so the new instance views the same * subtree within the same root context. * * @param input - A `HsonNode` to wrap, or another `LiveTree` to clone * references from. */ constructor(input: HsonNode | LiveTree); private invalidate_dom_api; /** * Resolve this tree's node to its associated DOM `Element`, if any. * * Uses the stored `NodeRef` to call `resolveElement()` and returns * the result. If the node has no mapped element, `undefined` is * returned instead of throwing. * * @returns The DOM `Element` corresponding to this tree's node, or * `undefined` if not mounted. * @see NodeRef.resolveElement */ private resolveDomElement; /*************************************** * LiveTree API ***************************************/ /*************************************** * Core tree operations * * Public branch mutation and query surface. * * @see LiveTreeContent * @see LiveTreeQuery ***************************************/ /** Append another branch into this branch's content. */ append(branch: AppendableLiveBranch, index?: number): this; /** Remove all content from this branch. */ empty(): this; /** Find the first matching descendant or helper query. */ get find(): FindWithById; /** Find all matching descendants or helper query results. */ get findAll(): FindMany; /*************************************** * DOM projection * * Access mounted DOM projection helpers. * * @see LiveTreeDomAccess ***************************************/ /** DOM helper bound to this tree's mounted element. */ get dom(): LiveTreeDom; /*************************************** * Branch removal * * Structural removal operations against the backing Hson node graph. * * @see LiveTreeContent ***************************************/ /** Identity-preserving removal of all ordered content. */ detachContents(): DetachedLiveContent; /** Identity-preserving removal of this branch from its current owner. */ detach(): LiveTreeLifecycleResult; /** Terminally remove and dispose this complete branch. */ remove(): void; /*************************************** * Child creation * * Namespace-aware child factory. * * @see LiveTreeDomAccess ***************************************/ /** Create HTML or SVG children according to the current namespace scope. */ get create(): HtmlCreateHelper; /*************************************** * Identity and host-root context * * Stable branch identity and root ownership. * * @see LiveTreeIdentity ***************************************/ /** Stable QUID for this branch. */ get quid(): string; /** Whether terminal lifecycle disposal has reached this node. */ get isDisposed(): boolean; /** Return the host root node for this branch. */ hostRootNode(): HsonNode; /** Content manager bound to this branch. */ get content(): ContentManager; /** Adopt a new host-root context for this branch. */ adoptRoots(root: HsonNode): this; /** Resolve and return the backing Hson node. */ get node(): HsonNode; private assertActive; /*************************************** * Style and CSS managers * * Inline style, scoped CSS, data, and event helper namespaces. * * @see LiveTreeStyling * @see LiveTreeData * @see LiveTreeEvents ***************************************/ /** Inline style helper bound to this branch. * * @see StyleManager * @see StyleSetter * @see StyleHandle */ get style(): StyleHandle; /** QUID-scoped stylesheet helper for this branch. * * @see CssTreeHandle */ get css(): CssTreeHandle; /** Tree-local event registry/helper surface. * * @see make_tree_events * @see TreeEvents */ get events(): TreeEvents; /** Fluent event-listener builder bound to this branch. * * @see ListenerBuilder */ get listen(): ListenerBuilder; get bind(): LiveTreeBindApi; /** Enter explicit Promise-settled exact document authoring. */ get async(): AsyncLiveTree; /*************************************** * Attribute helpers * * getters/setters for attributes and "flags" AKA boolean attributes, plus convenience wrapeprs for e.g. id, class, text * * all helpers are bound to the current LiveTree node * * @see LiveTreeAttrs ***************************************/ /** Canonical ordinary attributes. * * @see AttrHandle */ get attrs(): AttrHandle; /** "Flags" (HTML boolean attributes) - has/get/clear * * @see FlagHandle */ get flags(): FlagHandle; /*************************************** * Dataset, id, classlist * * Get/set wrappers for common attribute calls * * @see LiveTreeAttrs * @see LiveTreeData ***************************************/ /** Dataset - (get/set/drop/setMany) * * @see DataApi */ get data(): DataApi; /** ID - (get/set/clear) * * @see IdApi */ get id(): IdApi; /** Classlist - (get/has/add/set/remove/toggle/clear) * * @see ClassApi */ get classlist(): ClassApi; /*************************************** * Textcontent, Form, Value, Inputs * * get/set and handles for text nodes and common input methods * * all helpers are bound to the current LiveTree node * * @see LiveTreeText * @see LiveTreeForm ***************************************/ /** * Text-content * (set/get/add/overwrite/insert) * * @see LiveTextApi */ get text(): LiveTextApi; /** * Form * (set/get for value, checked, selected) * * @see LiveFormApi */ get form(): LiveFormApi; /*************************************** * SVG * (inScope/preserveAspectRatio/viewBox/d/fill/stroke/strokeWidth/vectorEffect/bbox/must.bbox) * * @see SvgApi ***************************************/ get svg(): SvgApi; /*************************************** * Canvas methods * * get/set convenience methods for common canvas properties and attributes * * all helpers are bound to the current LiveTree node * * @see make_canvas_api * @see CanvasApi ***************************************/ get canvas(): CanvasApi; /*************************************** * Branch cloning * * Deep branch duplication with fresh identity. * * @see clone_branch_method ***************************************/ /** Clone this branch as a new unattached LiveTree branch. */ /** Clone this branch as a new unattached branch of the same LiveTree subtype. */ cloneBranch(): this; } //# sourceMappingURL=livetree.d.ts.map