/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. * * The event kinds' rows on the canvas (#1192): a Plan of event kinds draws its * resources' rows — read through the payload's `blocks` over the range the * canvas draws — ahead of every other row, as fixed blocks. * * # Read where the canvas draws * * The rows are read over the scale's window and the periods it lays out * beyond each edge (#619), so a pan reveals the events there, with every * kind's drafts in place (#1194), so a draft draws as Save would leave it. The * read is a tracked evaluation: the records it reads are listened to, and a * commit to one reads the rows again, as a new draft does. A read whose kinds are still in flight leaves the * last rows standing; one that throws leaves them too, and says why — and * which kinds' own events it could not read, each kind read alone in the read * that failed (#1398): what the footer's line names the failure by, and what * its Retry asks again. A kind read a window at a time is read by the shared * reader (#1599), which keeps its window's rows standing while they are read * again and names the kind whose window it could not read: said the same way. * The rows * move only when they differ, so a write that changes none of them redraws * nothing. A resource kind the rail narrows draws the resources its source * shows (#1344). * * The read runs in a component of its own, {@link PlanEventsReader}, which * hands the canvas its rows only when they move: a kind narrowed through an * interval index lands some fifty-five key searches a window, and each would * otherwise render the whole canvas (#1343, #1344). * * # Ahead of every other row * * Inline, the rows lead the canvas's blocks. Paged, they ride the source's * windows: ONE wrapper per source (a host function is equivalent only to * itself, so a new wrapper would drop the driver's windows) serves them ahead * of every window's blocks, and names a new revision when they move, so the * driver reads its windows again and keeps the rows it has standing in until * they land (#821). Until the first read answers, as many empty fixed blocks * stand in for them, so the canvas's blocks are laid out alike from the * first window. The wrapper names the snapshot of the source's own data apart * from that revision (`snapshot`, #1199): new rows over the same data read the * windows again and are no new snapshot of it, so a key search standing stays * where it is. * * # A paged resource kind (#1199) * * A resource kind with a `window` pages the canvas over its resources, as a * paged `data` does (PB55): the canvas's source is ONE wrapper over the * payload's `paged`, its size and key search the kind's window's, and each of * its windows the event kinds' blocks with the kind's place — the one block * that is not fixed — filled by that window of its resources, the events * placed on them, and the root's own rows after, fixed. The events placed on * the kind's resources are read with the rest of the rows, so they move the * same version, and a new version, a new set of what the viewer hides or new * rows of the root's are a new revision: the driver reads its windows again, * the rows it has standing in until they land — over the same snapshot of the * kind's resources, which only their window's own revision moves. Until the * events are placed, a window is in flight. A canvas pages one source, so * `data` beside a paged kind is inline (the Plan refuses it paged). * * A paged kind its source of the slice narrows (#1344) is paged from the * narrowing's rows themselves: the wrapper is a live source, as the rail's * `rows` source is, naming the narrowing its windows belong to (`query`), so a * choice is a new result — the view the last narrowing drew stands in until * the new one's first window lands — and the snapshot of its resources is * their revision and the narrowing together. It has no key search. * * # A link's event end * * A link may name an event (`Plan.eventRef(kind, key)`): a run ref at the * kind's slot with no path, whose run is the event's key. The canvas finds the * event's element where it draws — its key is the event's ref as East prints * it — and names that row and element instead, so the links focus gathers the * row and a ribbon meets the element. An event on a paged kind's resource is * named by its resource's row id, `entry { series: ".", path: * [key] }`, from the events placed on the kind's resources — never looked for * in a window (#1199): the row is the one the window holding that resource * draws, whether or not it has landed. An event the rows do not draw keeps its * end, which no row has, and its ribbon is not drawn. * * @packageDocumentation */ import { type ValueTypeOf } from "@elaraai/east"; import { PlanEventBlocksType, PlanEventDraftsType, PlanEventPagedType, PlanEventPlacedType, PlanEventShadingType, PlanEventShownType } from "@elaraai/e3-ui/internal"; import type { PlanRootValue, PlanWireBlock } from "../model.js"; import type { PlanScale } from "../scale.js"; import type { ScheduleCellsRead } from "../../shared/schedule/cells.js"; import { type PlanCellSpanStore, type PlanCellsArgs } from "./cells.js"; /** The payload's `blocks` seam, decoded: the resources' rows over a window, every kind's drafts in place. */ export type PlanEventBlocksValue = ValueTypeOf; /** The payload's `paged` seam, decoded: a paged resource kind's rows, a window of its resources at a time (#1199). */ export type PlanEventPagedValue = ValueTypeOf; /** The events placed on a paged resource kind's resources, by way of drawing and by the resource's key (#1199). */ export type PlanEventPlacedValue = ValueTypeOf; /** The resources the rail shows (#1344): by a resource kind's slot, the keys of those its source shows. */ export type PlanEventShownValue = ValueTypeOf; /** What a Plan of event kinds hands its canvas (#1192). */ export interface PlanEventRows { /** The resources' rows over a window — the payload's `blocks`. */ blocks: PlanEventBlocksValue; /** How many blocks it answers: one per resource kind, then the Unassigned rows'. */ count: number; /** A paged resource kind's rows, a window of its resources at a time — the payload's `paged` (#1199); none when no kind pages. */ paged?: PlanEventPagedValue | undefined; } /** The event kinds' rows as the canvas draws them now. */ export interface PlanEventLead { /** The blocks, laid out first — empty fixed blocks until the first read answers. */ blocks: readonly PlanWireBlock[]; /** The events placed on a paged kind's resources (#1199): what each of its windows draws — `undefined` until the * first read answers, and for a Plan whose kinds page none. */ placed: PlanEventPlacedValue | undefined; /** The resources' shading (#1039): what a paged kind's windows draw in place of its events past the budget. */ shading: PlanEventShadingValue; /** The kinds' cells and counts (#1039): what a kind read by them draws from, every kind's drafts as the seams take * them, the rows each kind's cells hold, and the counted kinds read over the range; `undefined` before the reader * hands them on — every kind is counted, so a Plan of event kinds has them once it has read. */ cells: ScheduleCellsRead | undefined; /** Moves each time the blocks do, or the events placed on a paged kind's resources, or its shading, or what the * viewer hides of a paged kind — from 0 before the first read answers — a paged canvas reads its windows again then. */ version: number; /** The last read's failure, when it failed: why, and the kinds whose own events it could not read (#1398). */ error: PlanEventFailure | undefined; } /** * A read of the event kinds' rows that failed (#1398): why, and the kinds whose * own events over the range it could not read — what the footer's loading line * names the failure by, and what its Retry asks again; none where the failure * was no kind's own events' — a resource's row's, a measure's. */ export interface PlanEventFailure { /** Why it failed, in the read's own words. */ readonly reason: string; /** The slots of the kinds whose own events could not be read, in the kinds' order. */ readonly kinds: readonly string[]; } /** The resources' shading (#1039), decoded. */ export type PlanEventShadingValue = ValueTypeOf; /** The rail narrows no resource kind: each draws every resource. */ export declare const ALL_SHOWN: PlanEventShownValue; /** The event kinds, as the payload carries them. */ type PlanEventKinds = PlanCellsArgs["kinds"]; /** The range the canvas reads its event kinds' rows over. */ export interface PlanEventRange { /** Its start: the scale's window less the periods laid out before it. */ readonly from: Date; /** Its end, exclusive: the window and the periods laid out after it. */ readonly to: Date; } /** * The range the canvas reads its event kinds' rows over (#619): the scale's * window and the periods it lays out beyond each edge. A kind read a window * at a time (#1199) holds there every event the canvas draws, so a gesture on * one reads it from what the windows hold, with no read of its own. * * @param scale - The shared scale * @returns The range; `undefined` with no scale, or one whose instants are not times */ export declare function eventReadRange(scale: PlanScale | undefined): PlanEventRange | undefined; /** * The event kinds' rows over the range the canvas draws: the scale's window * and the periods laid out beyond each edge, what the viewer hides left out, * every kind's drafts in place (#1194, PB17) — and, beside a paged resource * kind, the events placed on its resources, read with them (#1199); a kind * read by its cells drawn from what they hold, a kind counted past the cap * drawn from none, and the resources' shading in their place (#1039). * * @param events - The Plan's event rows, when it has event kinds * @param scale - The shared scale — a time scale, beside event kinds * @param hidden - The ids the viewer hides in the library's Series tab (#1195) * @param drafts - Every kind's drafts, by kind then by entry id — the same object while they hold * @param shown - The resources the rail shows, by resource kind (#1344) — the same object while they hold * @param cells - The kinds' cells and counts, when the reader decides a kind (#1039): each kind's cells it gives — none past the cap — every kind's drafts as the seams take them, the shading * @param kinds - The event kinds, as the payload carries them: a read that fails names those whose own events it could not read (#1398) * @returns The rows as the canvas draws them now */ export declare function usePlanEventBlocks(events: PlanEventRows | undefined, scale: PlanScale | undefined, hidden?: readonly string[], drafts?: ValueTypeOf, shown?: PlanEventShownValue, cells?: ScheduleCellsRead | undefined, kinds?: PlanEventKinds): PlanEventLead; /** * The event kinds' rows before their first read: as many empty fixed blocks as * the read answers, so the canvas's blocks are laid out alike from the first * window. * * @param events - The Plan's event rows, when it has event kinds * @returns The rows to stand in */ export declare function initialEventLead(events: PlanEventRows | undefined): PlanEventLead; /** Props of {@link PlanEventsReader}. */ export interface PlanEventsReaderProps { /** The Plan's event rows, when it has event kinds. */ events: PlanEventRows | undefined; /** The shared scale. */ scale: PlanScale | undefined; /** The ids the viewer hides in the library's Series tab. */ hidden: readonly string[] | undefined; /** Every kind's drafts. */ drafts: ValueTypeOf; /** The resources the rail shows, by resource kind. */ shown: PlanEventShownValue; /** The event kinds, as the payload carries them (#1039): a kind read by its cells is read through its part. */ kinds: PlanCellsArgs["kinds"]; /** The resource kinds, as the payload carries them: a kind read whole shades over their rows. */ resources: PlanCellsArgs["resources"]; /** The event kinds narrowed through their sources of the slice, and their parts. */ parts: PlanCellsArgs["parts"]; /** The canvas's links: an event end its kind's cells do not hold is read by its key. */ links: PlanCellsArgs["links"]; /** The paged kind's rows in view, as the canvas reports them. */ spans: PlanCellSpanStore; /** What confirmed Saves landed of the kinds read by their cells, and how it is let go: drawn until the cells are read again. */ editing: PlanCellsArgs["editing"]; /** Where the rows go: called only when they move. */ onLead: (lead: PlanEventLead) => void; } /** * The event kinds' rows, read in a component of its own (#1343, #1344): each * search that lands re-runs it alone, and it hands the canvas its rows only * when they move — a kind narrowed through an interval index lands some * fifty-five searches before its window is read, and each would otherwise * render the whole canvas. A kind read by its cells (#1039) is read here too, * every cell it wants in one request a read, and every other kind counted * before one of its events is read; the rows the canvas reports in view are * read here alone. What a Save landed of a kind read by its cells draws as the * Save left it until they are read again: its confirmation reads its events by * their keys, never the cells. * * @param props - What the rows are read over, and where they go * @returns Nothing: it reads */ export declare function PlanEventsReader({ events, scale, hidden, drafts, shown, kinds, resources, parts, links, spans, editing, onLead }: PlanEventsReaderProps): null; /** * The root with the event kinds' rows ahead of its own, and its links' event * ends named where the events draw — over a paged resource kind's windows * when a kind pages (#1199, see the module docs). * * @param value - The latest root * @param data - Its data-stable twin * @param lead - The event kinds' rows; `undefined` for a Plan with none * @param pagedKind - A paged resource kind's rows, when a kind pages * @param hidden - The ids the viewer hides in the library's Series tab: what a paged kind's windows leave out * @returns The two roots the canvas draws, and the version of a paged kind's windows — it moves when they are * to be read again (0 when no kind pages) */ export declare function usePlanEventRoot(value: PlanRootValue, data: PlanRootValue, lead: PlanEventLead | undefined, pagedKind?: PlanEventPagedValue | undefined, hidden?: readonly string[]): { value: PlanRootValue; data: PlanRootValue; version: number; }; /** * A root's links with each event end named where its event draws: the row * holding the element whose key is the event's ref as East prints it, and * that key — on a paged kind's resource, that resource's row by its id * (#1199), wherever the window that draws it is. * * @param links - The root's links * @param blocks - The event kinds' rows * @param placed - The events placed on a paged kind's resources, by way of drawing and by resource, when a kind pages * @param pagedSlot - The paged kind's slot, beside `placed` * @returns The links — the same array when none names an event */ export declare function resolveEventLinks(links: PlanRootValue["links"], blocks: readonly PlanWireBlock[], placed?: PlanEventPlacedValue, pagedSlot?: string): PlanRootValue["links"]; export {}; //# sourceMappingURL=events.d.ts.map