/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * The canvas body's items and the link graph they are gathered by (split out * of `model.ts`, #815): the R1 family closure and the gap bands that elide a * links focus, the unloaded bands of a paged source (#577), the error bands of * failed windows (#811), and each item's identity (#812). * * @packageDocumentation */ import type { PlanFocusCtx, PlanLinkValue, PlanRowIndex, VisibleRow } from "./model.js"; import type { RowKey } from "./plan-state.js"; import type { PlanRowDiagnostic } from "./derive.js"; /** Every row key any link edge touches — the rows that grow the `links` control. * A link names its ends by run ref (#824), each carrying its row's id (#822); * the graph keys by the ids' text. */ export declare function linkedRowKeys(links: readonly PlanLinkValue[]): ReadonlySet; /** One elided run in a links focus — replaces N consecutive unrelated rows. */ export interface FocusGap { /** Stable key (the first elided row's key). */ key: string; /** The first elided row — where keyboard focus lands when the gap is * opened and its rows come back (#819). */ first: RowKey; /** Data rows hidden inside the run (collapsed subtrees counted through). */ rows: number; /** Group bands hidden inside the run. */ groups: number; /** Pessimistic status tone across the hidden rows (undefined ⇒ quiet). */ tone: string | undefined; } /** * A run of source elements that is NOT resident (#577), rendered as one band. * * Its height comes from the window ledger, so the band and the rows that * replace it occupy exactly the same space — scrolling in loads content without * moving anything below it, and eviction puts the band back with nothing * shifting either. Each paged block has its own (#823): its rows' share of the * elements the band covers. */ export interface PlanBand { /** The block the band belongs to (#823). */ block: number; at: "head" | "tail"; /** First source element the band covers. */ from: number; /** Last source element the band covers (inclusive). */ to: number; /** The band's pixel height. */ px: number; /** Which of its elements are loading (#1082): from the first element of * the first window it covers that is in flight to the last element of * the last (inclusive), when any is. A band far from every window in * flight is loading nothing — it says how many elements it holds. */ loading?: { from: number; to: number; } | undefined; } /** * A resident window whose read FAILED (#811) — one error band where the * window's rows would be, carrying the reason and a Retry. * * The failure belongs to its window: every other window keeps landing and * rendering around it. One read serves every block (#823), so a failed window * is a band in each block that holds it. */ export interface PlanWindowFailure { /** The block the band stands in (#823). */ block: number; /** The window index. */ w: number; /** First source element the window covers. */ from: number; /** Last source element the window covers (inclusive). */ to: number; /** The band's pixel height — the window's ledger slot, floored so the * reason and the Retry stay legible in a short last window. */ px: number; /** Why the read failed. */ error: string; } /** One line of the canvas body: a row, the R2 developer render, an elided run * (R1), an unloaded run of the source (#577, one per paged block's end — * #823), or a window whose read failed (#811). * * The R2 developer render is NOT an item here — it renders inside the * focused row, which grows to hold it (see {@link PlanFocusCtx.renderPx}). * Expand focus still stays inside the virtualizer either way; putting the * render in the row is what lets the GUTTER grow with it. */ export type PlanBodyItem = { kind: "row"; row: VisibleRow; } | { kind: "gap"; gap: FocusGap; } | { kind: "band"; band: PlanBand; } | { kind: "failed"; failure: PlanWindowFailure; }; /** * A body item's identity (#812) — its row's key, its gap's first row, its * band's block and end, its failed window's block and window — prefixed by * kind, so no two items of a body share one. The virtualizer keys rows by it, * so a row keeps its component instance when a collapse, a focus or a landing * window moves it; keyed by index, the instance at a moved row's old index was * handed whichever row now sat there. * * @param item - The body item * @returns Its key, unique within one body */ export declare function bodyItemKey(item: PlanBodyItem): string; /** * A ROW's item key — what {@link bodyItemKey} gives its body item, and a * pinned row (which the body does not hold) goes by too (#819). * * @param key - The row key * @returns Its item key */ export declare function rowItemKey(key: RowKey): string; /** * Place each failed window's band where its rows would be (#811): after the * last row that came from an EARLIER window, or first when none did. * * @remarks * A block's windows serve its entries in key order and its rows concatenate * them in window order (#823), so a window's rows sit between its neighbours' * — its band goes in the seam. Called once per block, over that block's items. * * @param items - One block's body items, rows in visible order * @param failures - That block's failed windows * @param windowOf - Which window a resident row came from * @returns The items with a `failed` band placed per failure (the same array * when there are none) */ export declare function placeFailures(items: readonly PlanBodyItem[], failures: readonly PlanWindowFailure[], windowOf: (key: RowKey) => number | undefined): readonly PlanBodyItem[]; /** * The body item the diagnostics chip seeks to (#811): the first diagnostic * row in body order — or, when a collapsed group hides it, that group's band. * * @param items - The body items, in order * @param index - The row-tree index * @param diagnostics - The diagnostic rows (`PlanDerived.diagnostics`) * @returns The item index, or `undefined` when no diagnostic row is reachable */ export declare function firstDiagnosticItem(items: readonly PlanBodyItem[], index: PlanRowIndex, diagnostics: ReadonlyMap): number | undefined; /** * Elide a links-focus row list for scale (R1): family rows and the focus keep * full height; a group keeps its wayfinding band ONLY while its subtree holds * family; every other row is elidable. A lone elidable data row stays an 11px * rail (today's rhythm); any longer run — including family-less group bands * and their subtrees — coalesces into ONE double-height gap band, so a * thousand-tank canvas gathers to family + a handful of bands. */ export declare function elideForFocus(vis: ReadonlyArray, index: PlanRowIndex, focus: PlanFocusCtx): PlanBodyItem[]; /** A focused row's transitive family over the link graph. */ export interface LinkFamily { /** Rows reaching the focus via edges (any depth). */ upstream: ReadonlySet; /** Rows reachable from the focus via edges (any depth). */ downstream: ReadonlySet; /** Union of both (the full-height set, focus excluded). */ all: ReadonlySet; } /** * Derive the focused row's transitive upstream + downstream family — the * links-focus gather set (R1). Any depth, wherever the rows live; a row * reachable both ways lands in both sets (rendered as the `LINKED` tag). */ export declare function deriveLinkFamily(links: readonly PlanLinkValue[], key: RowKey): LinkFamily; //# sourceMappingURL=body-items.d.ts.map