/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. * * The canvas body as the virtualizer sees it: the items (rows, a links focus's * bands, the unloaded runs of a paged source, failed windows), their exact * heights and identities, where a search or the diagnostics chip asks it to * scroll, and the viewport reported back to the paging driver. * * @packageDocumentation */ import { type PlanBodyItem, type PlanDerived, type PlanFocusCtx, type PlanRowIndex, type VisibleRow } from "../model.js"; import type { RowKey } from "../plan-state.js"; import type { PlanController, PlanNavAlign, PlanPagingSnapshot, PlanScrollTarget } from "../controller/index.js"; import type { PlanPagedBlock, PlanRowOrigin } from "../controller/paging.js"; /** The body items, and what the frame measures and keys them by. */ export interface PlanBody { items: readonly PlanBodyItem[]; /** The exact height of every item — the frame's sizes AND what each item * renders at (#812). */ heights: readonly number[]; /** Each item's identity, so a row keeps its instance wherever it moves. */ itemKey: (i: number) => string; } /** * The body's items — BLOCK AFTER BLOCK (#823), each block's rows in stream * order: a paged block's resident windows as one slab between its bands, with * each failed window's band in its seam, and a fixed block's rows once. * * @remarks * A paged block's bands stand for its unloaded windows, sized by its own * ledger, so the rows that replace one occupy the same space and nothing below * it moves (#577). A block nested under a section's header draws nothing — * no rows, no bands — while that header is collapsed or hidden, as its rows * would not. * * A links focus (#1680's review) gathers its family under its role bands, and * folds every other row into one band after them ({@link focusBodyItems}): * opened, it holds the body as it draws with no focus, less the rows gathered. * * @param visible - The visible rows * @param index - The row index * @param blocks - A paged canvas's blocks (`[]` inline — nothing unloaded) * @param origin - Which block and window each paged row came from * @param focusCtx - Which row is focused * @param placed - Whether the canvas has placed a row it does not hold (a paged source's evicted window's) * @param lanes - The rules a links focus opens for its lanes, and their tracks' heights ({@link focusBodyItems}) * @returns The items */ export declare function planBodyItems(visible: readonly VisibleRow[], index: PlanRowIndex, blocks: readonly PlanPagedBlock[], origin: ReadonlyMap, focusCtx: PlanFocusCtx | undefined, placed?: (key: RowKey) => boolean, lanes?: ReadonlyMap): PlanBodyItem[]; /** * The rows that close an open group — each the last visible member of a * parent drawn open (#949): it carries the group's closing rule, so the rows * after it read as outside it. * * @remarks * Walks the body in order with the depths of the parents still open. A row at * or above an open parent's depth ends that parent at the row before it — * when that row is one of its members (a parent with nothing visible under it * closes nothing). An unloaded band or a failed window breaks the walk: a * group whose members run into a band has no end on the canvas yet. A links * focus's band (#1680's review) closes the band before it at its last row, and * a role's band opens over the rows it gathers, one level in; the others' * opens over nothing, its rows at their own levels. A lane band between two * rows it gathers is room between them, and changes nothing. The last row * closes every parent still open. * * @param items - The body items, in order * @returns The keys of the rows that end a group */ export declare function groupEndsOf(items: readonly PlanBodyItem[]): ReadonlySet; /** * The body items and their geometry. * * @param visible - The visible rows * @param index - The row index * @param derived - The derivations (heights read them) * @param paging - The paged source's blocks and where each row came from (inline: idle) * @param focusCtx - Which row is focused * @param heightCtx - The same, with the expand clamp * @param dense - The declared density * @param chartsExpanded - The user's expanded chart rows * @param placed - Whether the canvas has placed a row it does not hold — read as the paging moves, which renews the items * @param lanes - The rules a links focus opens for its lanes, and their tracks' heights ({@link focusBodyItems}) * @returns The body */ export declare function usePlanBody(visible: readonly VisibleRow[], index: PlanRowIndex, derived: PlanDerived, paging: PlanPagingSnapshot, focusCtx: PlanFocusCtx | undefined, heightCtx: PlanFocusCtx | undefined, dense: boolean, chartsExpanded: ReadonlySet, placed?: (key: RowKey) => boolean, lanes?: ReadonlyMap): PlanBody; /** * Where the frame is asked to scroll: a key search's target row — resolved * against the VISIBLE body (a match inside a collapsed group has no row to * scroll to), and only once it has loaded — the first skipped row the * diagnostics chip seeks (#811), or the item a keyboard move went to (#819). * The latest request wins: a new search takes the viewport back, and each * search, chip click or keyboard move carries a nonce, so it scrolls there * again after the user has moved away. * * Every request names its ROW, which the frame serves once per nonce — a row * whose index moves as windows land above it is not a new request. So the * chip's row is the first skipped row AT the click: a window that lands later * with an earlier skipped row does not take the view there. * * @param items - The body items * @param index - The row index * @param derived - The derivations (their diagnostic rows) * @param scroll - Who owns the request, and its target * @returns The item to scroll to, how to align it, the re-request nonce, and the first skipped item */ export declare function usePlanScrollTarget(items: readonly PlanBodyItem[], index: PlanRowIndex, derived: PlanDerived, scroll: PlanScrollTarget): { toIndex: number | undefined; align: PlanNavAlign | "center"; nonce: number | undefined; firstSkipped: number | undefined; }; /** * The frame's range signal, in the paging driver's terms: which ROW (or which * band) the viewport sits on. The item under the viewport CENTER when the * frame can resolve one (the live scroll offset — inside one huge band item * only the center pixel can say where the thumb is, #612), else the middle of * the mounted range — with the windows the mounted range shows (#1398): each * row's, a run's nearest its rows and a failed window's, which the footer's * loading line and the frame's busy follow. No body-layout knowledge crosses * into the driver. * * @param items - The body items * @param controller - Where the viewport is reported * @param origin - Which block and window each paged row came from * @returns The frame's `onRangeChange` */ export declare function usePlanRangeReport(items: readonly PlanBodyItem[], controller: PlanController, origin: ReadonlyMap): (range: { startIndex: number; endIndex: number; }, isScrolling: boolean, center?: { index: number; withinPx: number; }) => void; //# sourceMappingURL=body.d.ts.map