import { clearCache } from '@chenglou/pretext'; import { type LayoutNode, type ComputedLayout } from './types.js'; /** Initialize the Yoga WASM runtime. Must be called once before computeLayout. */ export declare function init(): Promise; /** Release Yoga config. Mostly useful for tests. */ export declare function destroy(): void; /** Clear Pretext's internal measurement caches. */ export { clearCache }; export interface ComputeOptions { /** * Available width for the root container. Default: unconstrained. * * Runtime: only finite primitive numbers are forwarded to Yoga; `NaN`, `±Infinity`, negatives, and non-numbers * (e.g. corrupted JSON) are ignored per-axis, same as omitting `width`. IEEE `-0` is normalized to `+0`. */ width?: number; /** * Available height for the root container. Default: unconstrained. * * Same constraint guard as {@link ComputeOptions.width}. */ height?: number; /** * Yoga **owner** direction passed to `calculateLayout` (document / root context). It seeds inheritance * for nodes that use `dir: 'auto'` or Yoga’s default inherit behavior. * * Nodes may also set {@link FlexProps.dir} for per-subtree layout direction (mirrors flex rows, start/end). * Geometra’s `createApp` maps `AppOptions.layoutDirection` or the root element’s resolved `dir` here while * omitting `dir` on the layout-tree root so this option stays authoritative for the host root. * * Default: `'ltr'`. * * Runtime: only the exact string `'rtl'` selects RTL; any other value (including `'RTL'`, whitespace, * or corrupted deserialization) falls back to LTR — same as omitting `direction`. */ direction?: 'ltr' | 'rtl'; } /** * Compute the full layout geometry for a declarative UI tree. * * Builds a Yoga node tree, wires Pretext text measurement into leaf nodes, * runs Yoga's flexbox algorithm, and returns the computed positions and sizes. * * Combine {@link ComputeOptions.direction} with optional per-node {@link FlexProps.dir} on each * {@link LayoutNode} for mixed-direction flex subtrees. * * `children` arrays may contain `null` or `undefined` holes (sparse runtime arrays). Those indices * become Yoga `display: none` placeholders so output `children` length matches the source array, * holes yield near-zero geometry, and layout does not throw while walking siblings. * * @throws {Error} If {@link init} has not completed (`textura: call init() first`). */ export declare function computeLayout(tree: LayoutNode, options?: ComputeOptions): ComputedLayout;