/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * Where the links-focus ribbons go (R1, #818) — computed from the MODEL, never * measured from the DOM. * * A row's place is the body's own arithmetic: its top is the sum of the exact * heights of the body items above it (`usePlanBody`'s `heights`, the same * numbers the frame lays the rows out at), and its bar sits centred in its * plot cell — the row less the rule under it — at the geometry table's bar * height. A run's x is its window fraction across the plot. So the ribbons * follow the rows in the same render — a collapse, a chart toggle or a landing * window moves both at once — and they reach rows the virtualizer has not * mounted. * * A link's end meets its element where the element DRAWS (#1258): a run's bar * from its start, never narrower than the canvas's narrowest bar; a chip in * from its ends by the cell inset, never narrower than the narrowest chip; a * tile's cell in from its bucket's edges and its lane's; a mark across its * glyph, centred on its instant — each clipped to the plot as the plot clips * it. The widths are the geometry table's, the numbers the recipe draws them * at, so a tiny run's link leaves the end its bar shows, not the end its time * says. * * A bounded frame shows only part of its rows. An endpoint beyond that view * clamps to the edge it lies past and ends in a stub pointing toward its row * (`routeRibbon`); a ribbon with both ends past the same edge is not drawn. An * unbounded frame shows every row, so nothing clamps there. A row the body * does not hold is placed by the caller (`beyond`): a pinned row sits past the * rows' top, and a row in an evicted paged window sits at that window's offset * in its block's band (#823) — then clamps and stubs like any row out of view. * * Pure: no React, no DOM. * * @packageDocumentation */ import { type PlanBodyItem, type PlanLinkValue, type PlanRowValue } from "../model.js"; import type { PlanScale } from "../scale.js"; import type { PlanInstantValue } from "../instant.js"; import { type PlanGeometry } from "../geometry.js"; import type { RowKey } from "../plan-state.js"; import type { PlanWords } from "../words.js"; import { type RibbonEdgeSlot, type RibbonEnd, type RibbonOff, type RibbonPath } from "../../shared/links/geometry.js"; import { type LaidBand, type LanePlan } from "../../shared/links/lanes.js"; import type { LinkBox } from "../../shared/links/layer.js"; export { RIBBON_CAPTION_CHAR, RIBBON_CAPTION_PAD, ribbonWeight } from "../../shared/links/captions.js"; export { RIBBON_SLOT_W, type RibbonEdgeSlot } from "../../shared/links/geometry.js"; /** Where one body row sits, in the rows' own px. */ export interface RibbonSlot { /** The row's top — the heights of every body item above it. */ top: number; /** The row's height. */ height: number; /** The height of the bar its runs draw (a collapsed parent's are slimmer). */ bar: number; } /** The canvas body as the ribbons see it. */ export interface RibbonBody { /** Each body row's slot, by key. */ slots: ReadonlyMap; /** Each unloaded band's top, by `block:at` (`"0:tail"`) — where a row in * an evicted window is placed from (#823). */ bands: ReadonlyMap; /** The canvas's geometry: the rule under every row, inside its height — a * row's plot cell, where its elements centre, is the row less it — the * bar a row outside the body is drawn at, and every width an element * draws at (#1258). */ geometry: Readonly; /** The body's full height — the sum of every item's. */ height: number; /** * Where a links focus draws a row it has folded with the others while their band is folded (#1680's review): a bar * centred in that band's plot cell, its top here — what a row of a paged source's evicted window is placed at, its * own band not in the body. `undefined` while no such band is folded. */ folded?: number | undefined; /** Where each rule a links focus opens for its lanes holds its tracks (#1680's review), by the rule: a lane band, or * the middle of the role band's plot cell where the tracks stand in it. Empty with no focus. */ lanes: ReadonlyMap; /** The bands between a links focus's rows, as laid out — each role band's plot cell and each lane band: where an S's * caption sits off the rows' bars (#1680's review). Empty with no focus. */ gaps: readonly LaidBand[]; } /** Where a rule's lane tracks lie down the rows: the first track's top, and their height. */ export interface RibbonLaneBox { top: number; height: number; } /** Where a row the body does not hold is drawn: past an edge of the rows (a * pinned row is above them), or AT a place in them — a row in an evicted * paged window, at its window's offset in its block's band (#823). */ export type RibbonBeyond = { off: RibbonOff; } | { y: number; }; /** A mark's glyph: its kind's shape, or the box its icon fits in. */ export type LinkedGlyph = "dot" | "diamond" | "triangle" | "icon"; /** How the element a link's end names draws — what the end meets (#1258). */ export type LinkedDraw = /** A run's bar: from its start, at least the canvas's narrowest bar wide, at its row's bar height. */ { kind: "bar"; } /** A chip: in by the cell inset from its ends, at least the narrowest chip wide, at the chip height. */ | { kind: "chip"; } /** The cell a tile sits in: its bucket in by the cell inset, at least the narrowest cell wide; down, * `span` of the row's `lanes` from lane `lane`, in by the inset from them. */ | { kind: "cell"; lane: number; span: number; lanes: number; } /** A mark: its glyph, centred on its instant. */ | { kind: "mark"; glyph: LinkedGlyph; }; /** The element a link's end names: its instants, and how it draws. */ export interface LinkedElement { start: PlanInstantValue; end: PlanInstantValue; draw: LinkedDraw; } /** * The element a link's end meets on its row: the one its run key names — a * run, a chip, a tile (met at the cell it sits in) or a mark — and how it * draws. A link's end that names an event meets it however the event draws * (#1192). * * @param row - The end's row * @param key - The element's key * @param scale - The shared scale (a tile's bucket) * @returns The element, or `undefined` when the row has no element of that key */ export declare function linkedElement(row: PlanRowValue, key: string, scale: PlanScale): LinkedElement | undefined; /** * The body's rows as slots, and a links focus's bands as the ribbons see them. * * @param items - The body items, in order * @param heights - Each item's exact height (`usePlanBody`) * @param geometry - The canvas's geometry table * @returns The slots, the bands, and the body's height */ export declare function ribbonBody(items: readonly PlanBodyItem[], heights: readonly number[], geometry: Readonly): RibbonBody; /** * Where a row of a paged source's evicted window is drawn (#823): at its * window's offset in its block's band — or, that band folded with a links * focus's other rows, at the band they fold into (#1680's review). * * @param place - The row's place: its block's band, which end, and its window's offset in it (the paging driver's) * @param body - The canvas body as the ribbons see it * @returns Where it is drawn; `undefined` where the body holds neither — its edges are not drawn */ export declare function placedBeyond(place: { readonly block: number; readonly at: string; readonly px: number; }, body: RibbonBody): RibbonBeyond | undefined; /** The part of the rows a bounded frame shows, in the rows' own px. */ export interface RibbonViewport { top: number; bottom: number; } /** One laid-out ribbon. */ export interface LaidRibbon extends RibbonPath { /** The link's index in the root's `links` — its identity on the canvas. */ link: number; from: RibbonEnd; to: RibbonEnd; /** Its stroke's width, by its quantity ({@link ribbonWeight}). */ weight: number; /** The link's quantity caption (#824) — `undefined` for a link with no * quantity, which then shows no caption and no tooltip. */ label: string | undefined; } /** What {@link layoutRibbons} lays out from. */ export interface RibbonLayoutInput { /** The root's link graph. */ links: readonly PlanLinkValue[]; /** The rows a links focus keeps at full height (the focus and its family) — * an edge with an end outside it is not drawn. */ visibleKeys: ReadonlySet; body: RibbonBody; /** Where a row the body does not hold is drawn ({@link RibbonBeyond}); * `undefined` when it has no place — its edges are not drawn. */ beyond: (key: RowKey) => RibbonBeyond | undefined; /** The element a link's end names, by row and run key ({@link linkedElement}). */ element: (rowKey: string, runKey: string) => LinkedElement | undefined; scale: PlanScale; /** The plot column, in the rows' own px. */ plot: { left: number; width: number; }; /** What a bounded frame shows; `undefined` — the frame shows every row. */ viewport: RibbonViewport | undefined; /** The canvas's words — a caption prints the link's quantity in them (#824). */ words: PlanWords; /** A links focus's lane plan ({@link planFocusLanes}), whose rules the body opened into bands; left out, none. */ lanes?: RibbonLanes | undefined; } /** * The boxes the links stand back from (#1680's review): each bar's label in * the rows the body holds, with the room its bar pads it with — laid out from * the model as the recipe draws it (the table's widths, which a guard ties to * the recipe), never read from the page (#818): the run across the plot, its * bar down its row, its label's glyphs after its lock, cut short at the bar's * end; none where the bar is too short to show its label, or lies off the * window. * * @param body - The body as the ribbons see it * @param rowOf - A row, by its key * @param scale - The shared scale * @param plot - The plot column, in the rows' own px * @returns The boxes, in the rows' own px */ export declare function labelBoxes(body: RibbonBody, rowOf: (key: RowKey) => PlanRowValue | undefined, scale: PlanScale, plot: { left: number; width: number; }): LinkBox[]; /** A links focus's lane plan, and each planned link's place in it by its index in the root's `links`. */ export interface RibbonLanes { readonly plan: LanePlan; readonly planned: ReadonlyMap; } /** * A links focus's lane plan (#1680's review, `shared/links/lanes.ts`): the * rules between its gathered rows that its family's loopbacks run along and its * one-row links caption on, each opened into a band of tracks — planned from * where each link's elements draw across the plot, at the weights its ribbons * draw at. A link with an end the body does not gather — a pinned row's, a row * folded with the others — is not planned: its route keeps its own. * * @param input - The links, the gathered rows top to bottom (`focusGatheredKeys`), the rows the focus keeps, and how an element draws across the plot * @returns The plan, and each planned link's place in it */ export declare function planFocusLanes(input: Pick & { /** The gathered rows, top to bottom. */ order: readonly RowKey[]; geometry: Readonly; }): RibbonLanes; /** * Lay out every drawable edge of the family: each end resolved from the * model, and the family laid out by the shared links layer (`routeLinks`) — * links sharing an element's end spread there, each routed, its caption * placed. * * @param input - The model the ribbons follow * @returns The routed ribbons (in `links` order) and the off-window slots */ export declare function layoutRibbons(input: RibbonLayoutInput): { ribbons: LaidRibbon[]; edgeSlots: RibbonEdgeSlot[]; }; //# sourceMappingURL=ribbon-layout.d.ts.map