import { HsonNode } from "../../../core/types.js"; import { HsonQuery } from "../../../types/livetree.types.js"; /** * Apply query-specific text matching to a node. * * Behavior: * - If `query.text` is `null`/`undefined`, returns `true` (no text * constraint). * - Otherwise: * - Computes `t = nodeText(node)`. * - If `query.text` is a `RegExp`, tests `t` against it. * - If `query.text` is a string, checks `t.includes(query.text)`. * - If `query.text` is a function, calls it with `t` and coerces * the result to boolean. * - For any other type, falls back to `true`. * * @param node - The node to test. * @param query - The `HsonQuery` object, optionally containing a `text` * field in one of the supported forms. * @returns `true` if the node passes the text constraint, `false` otherwise. * @see nodeText */ export declare function matchText(node: HsonNode, query: HsonQuery): boolean; /** * Apply attribute-based matching rules from a query to a node. * * Behavior: * - If `query.attrs` is absent or falsy, returns `true` (no constraint). * - Otherwise, for each `[key, qv]` in `query.attrs`: * - Let `nv = node.$_attrs[key]`. * - If `qv` is a `RegExp`: * - Requires `nv` to be a string that passes `qv.test(nv)`. * - If `qv` is a non-null object: * - Requires `nv` to be a non-null object and to match all * sub-keys `sk` with strictly equal values `sv`. * - If `qv === true`: * - Interpreted as a flag-style attribute; requires that `key` * exists in `node.$_attrs`. * - Otherwise: * - Requires strict equality `nv === qv`. * - Returns `false` on the first mismatch; `true` if all attributes match. * * @param node - The `HsonNode` whose attributes will be tested. * @param query - The `HsonQuery` providing an `attrs` constraint. * @returns `true` if the node matches all attribute rules, else `false`. */ export declare function matchAttrs(node: HsonNode, query: HsonQuery): boolean; /** * Apply meta-field matching rules from a query to a node. * * Behavior: * - If `query.meta` is absent or falsy, returns `true` (no constraint). * - Otherwise, for each `[key, qv]` in `query.meta`: * - Let `nv = node.$_meta[key]`. * - If `qv` is a `RegExp`: * - Requires `nv` to be a string that passes `qv.test(nv)`. * - Otherwise: * - Requires strict equality `nv === qv`. * - Returns `false` on the first mismatch; `true` if all meta entries match. * * @param node - The `HsonNode` whose `$_meta` object will be tested. * @param query - The `HsonQuery` providing a `meta` constraint. * @returns `true` if the node satisfies all meta rules, else `false`. */ export declare function matchMeta(node: HsonNode, query: HsonQuery): boolean; /** * Depth-first search over a set of Hson nodes using a structured query. * * Matching: * - A node is considered a match if all of the following pass: * - Tag: `query.tag` is absent, or equals `node.$_tag` (case-insensitive). * - Attributes: `matchAttrs(node, query)` is `true`. * - Meta: `matchMeta(node, query)` is `true`. * - Text: `matchText(node, query)` is `true`. * * Traversal: * - Walks the tree in depth-first order starting from the `nodes` array, * descending via `$_content` and filtering children with `is_Node`. * - If `options.findFirst` is `true`, traversal stops as soon as a * match is found and only the first matching node is returned * (wrapped in a single-element array). * - Otherwise, collects *all* matching nodes in document order. * * @param nodes - Root nodes to search from. * @param query - Query object describing tag, attrs, meta, and optional * text constraints. * @param options - Search options: * - `findFirst`: when `true`, stop after the first match and return * at most one node. * @returns An array of matching nodes; either all matches or at most one * when `findFirst` is enabled. * @see matchAttrs * @see matchMeta * @see matchText */ export declare function search_nodes(nodes: HsonNode[], query: HsonQuery, options: { findFirst: boolean; }): HsonNode[]; //# sourceMappingURL=search.d.ts.map