/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. * * The event kinds' events on the canvas's own rows (#1192, #1541): a Plan of * event kinds lands each kind's events on the rows of the resources series or * kinds case its `resource.of` names — the record's own rows, which the root * makes wherever it makes them, inline or a window at a time — through the * payload's seam: `placed` reads the events of a range, filed by the series * they land on, and `place` joins them into any rows. * * # Read where the canvas draws * * The events 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 events again, as a new draft does. A read whose * kinds are still in flight leaves the last events 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 events move only when * they differ, so a write that changes none of them redraws nothing. * * The read runs in a component of its own, {@link PlanEventsReader}, which * hands the canvas what it read only when it moves: 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). * * # Joined into the rows * * Inline, the root's blocks are placed once, the Unassigned rows after them. * Paged, the root's source is ONE wrapper per source (a host function is * equivalent only to itself, so a new wrapper would drop the driver's windows) * that places each window the source serves — and a window standing in, as * the canvas's editing redraws it (#1599) — and names a new revision when the * events 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 the * rows draw with no events. The wrapper names the snapshot of the source's own * data apart from that revision (`snapshot`, #1199): new events over the same * data read the windows again and are no new snapshot of it, so a key search * standing stays where it is. Over rows read a page at a time no Unassigned row * is drawn: an event on no row of the canvas's is in no window (#1541). * * # 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. Over rows read a page at a time, an * event on a top-level resource is named by its resource's row id from the * events placed alone — `entry { series: , path: [key] }`, or * `.` for the further ways its kinds draw — 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 { PlanEventDraftsType, PlanEventPlacedType, PlanEventSeamType, PlanEventShadingType } 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"; import { type PlanLandingValue } from "./landings.js"; /** The payload's seam, decoded: the events of a range, filed, and how they join any rows (#1541). */ export type PlanEventSeamValue = ValueTypeOf; /** The events of a range, filed by the series they land on, the way they draw and the resource's key (#1541). */ export type PlanEventPlacedValue = ValueTypeOf; /** A series the event kinds land on, as the payload carries it (#1541): `landings.ts`'s, which every reader of one names. */ export type { PlanLandingValue }; /** What a Plan of event kinds hands its canvas (#1192, #1541). */ export interface PlanEventRows { /** The payload's seam: the events of a range, filed, and how they join the rows. */ seam: PlanEventSeamValue; /** The series the event kinds land on, in the series tree's order, a kinds block's cases in its variant's: the payload's own list. */ landings: PlanLandingValue[]; /** Whether the canvas's rows are read a page at a time: every kind is then read a cell at a time. */ paged: boolean; } /** The event kinds' events as the canvas draws them now. */ export interface PlanEventLead { /** The events of the range, filed by the series they land on — `undefined` until the first read answers. */ placed: PlanEventPlacedValue | undefined; /** The resources' shading (#1039): what a landing row draws 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 events placed do, or the shading, or what the viewer hides — from 0 before the first read * answers — the rows are placed again then, and a paged canvas reads its windows again. */ 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' events 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'. */ 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 event kinds, as the payload carries them. */ type PlanEventKinds = PlanCellsArgs["kinds"]; /** The range the canvas reads its event kinds' events 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' events 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' events 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) — 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) — filed by the series they land * on (#1541). * * @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 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 events as the canvas draws them now */ export declare function usePlanEventPlaced(events: PlanEventRows | undefined, scale: PlanScale | undefined, hidden?: readonly string[], drafts?: ValueTypeOf, cells?: ScheduleCellsRead | undefined, kinds?: PlanEventKinds): PlanEventLead; /** * The event kinds' events before their first read: none placed. * * @returns The events to stand in */ export declare function initialEventLead(): 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 event kinds, as the payload carries them (#1039): a kind read by its cells is read through its part. */ kinds: PlanCellsArgs["kinds"]; /** The canvas's own rows: what a kind read by its cells reads the resources of, and a kind past the cap shades (#1541). */ rows: PlanCellsArgs["rows"]; /** 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 canvas's paged rows in view, as it 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 events go: called only when they move. */ onLead: (lead: PlanEventLead) => void; } /** * The event kinds' events, read in a component of its own (#1343, #1344): * each search that lands re-runs it alone, and it hands the canvas what it * read only when it moves — 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 events are read over, and where they go * @returns Nothing: it reads */ export declare function PlanEventsReader({ events, scale, hidden, drafts, kinds, rows, parts, links, spans, editing, onLead }: PlanEventsReaderProps): null; /** * The root with the event kinds' events joined into its rows, and its links' * event ends named where the events draw (see the module docs). * * @param value - The latest root * @param data - Its data-stable twin * @param lead - The event kinds' events; `undefined` for a Plan with none * @param events - The Plan's event rows: the seam that places the events, and the series they land on * @param hidden - The ids the viewer hides in the library's Series tab: a further row whose kinds are all hidden is left out * @returns The two roots the canvas draws */ export declare function usePlanEventRoot(value: PlanRootValue, data: PlanRootValue, lead: PlanEventLead | undefined, events?: PlanEventRows | undefined, hidden?: readonly string[]): { value: PlanRootValue; data: PlanRootValue; }; /** * 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 — over rows read a page at a time, for an event on a row no window * holds, the resource's row by its id, from the events placed, where the * resource is an entry of the rows (see the module docs). * * @param links - The root's links * @param blocks - The rows with the events joined in, when they are all at hand * @param placed - The events placed, over rows read a page at a time * @param landings - The series they land on, 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, landings?: readonly PlanLandingValue[]): PlanRootValue["links"]; //# sourceMappingURL=events.d.ts.map