/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. * * A Plan's paged rows' collections, read a cell at a time through their * nested series index (#1438): the reader beside the canvas's paging, in a * component of its own as the event kinds' is (`events.ts`), and the wrapper * that draws each window of lean rows with what it read. * * # What it reads * * The canvas's rows in view and 25 either side (`SCHEDULE_CELL_MARGIN`), in * blocks of {@link SCHEDULE_CELL_BLOCK} of its rows — top rows and child rows * alike, in the canvas's order. A folded row's children are no rows of it, and * their items are not read. For each row, each collection its series reads * (the seam's `uses`) and each level the collection's items are filed at, one * range over that level's run of tiles (#1433): `[place, row, path, .items, * level, from]` to `[…, to]`, every literal as the index's key prints it. A row * with children whose series subtotals them reads its subtotals too, one range * at the resolution's level, and never its descendants' cells for them; one * whose children's span series rolls them up into bands reads its subtree's * items, one range a level — which e3's fill puts back in the descendants that * hold them, so the bands roll up from them as over rows read whole. * * Every search it does not hold goes in one request, which counts each one's * entries first; the entries it does not hold go in one more. What it holds is * kept at the record's revision: a pan or a scroll within what it holds reads * nothing, and a commit reads what is wanted again, the last standing in until * it lands. * * # The cap * * While a collection's items in the cells wanted are at most * {@link SCHEDULE_EVENT_CAP}, they draw. Past it, no item of it is read, and the * rows of the series reading it shade from their totals — a parent rolling it * up into bands from its subtree's — at the summary tile, where that divides the * canvas's bucket: the share of each bucket booked, how many items touch it, or * its values folded as the series folds them. Where no summary divides it, the * rows are hatched, and the reader names the collection among its notices, with * how many items there are. * * # What it hands on * * The cells, encoded as the binding's fill takes them; the shading; each * parent's subtotals by its row's key, which the derivation draws in place of * its children's (`derivePlan`); and a version that moves when any of them * does, so the canvas's paged source, which draws each window through the * seam's `rows`, is read again. Beside them, while a read is in flight, the * rows waiting on it — each row with a run of tiles not held, as a pan, a * zoom, a scroll or a commit asks — which wash as a paged kind's unread rows * do (#1398, CL2) until their cells land. * * @packageDocumentation */ import { type ValueTypeOf, type option } from "@elaraai/east"; import { PlanNestedShadingType, type PlanNestedType } from "@elaraai/e3-ui/internal"; import { type PreviewedRow, type RecordDraftsSession } from "../../shared/records/drafts.js"; import type { EditSession } from "@elaraai/east-ui-components"; import { type ScheduleCellBucket } from "../../shared/schedule/cells.js"; import { type PlanParentSubtotals, type PlanRootValue, type PlanRowIndex, type PlanRowValue } from "../model.js"; import type { PlanResolution, PlanScale } from "../scale.js"; /** The seam a Plan's root carries over paged rows beside their nested series index, decoded. */ export type PlanNestedValue = ValueTypeOf; /** The rows' shading past the cap, as the seam's window takes it. */ export type PlanNestedShadingValue = ValueTypeOf; /** A collection past the cap that no totals shade at this resolution. */ export interface PlanNestedNotice { /** Its place: its field names from the row down. */ readonly place: readonly string[]; /** How many of its items the cells wanted hold. */ readonly items: number; } /** What the reader hands the canvas (see the module docs). */ export interface PlanNestedLead { /** The items read, encoded as the binding's fill takes them: a beast2 Array of the index's `{ ik, value }` entries. */ readonly cells: Uint8Array; /** The rows' shading past the cap: by series, then by the row's path as East prints it, its buckets. */ readonly shading: PlanNestedShadingValue; /** Each parent's subtotals as e3 keeps them, by its row's key. */ readonly parents: PlanParentSubtotals; /** The collections past the cap that no totals shade at this resolution. */ readonly notices: readonly PlanNestedNotice[]; /** Moves each time the cells, the shading or the subtotals do: the canvas reads its windows again then. */ readonly version: number; /** Whether a read is in flight: what stands was read before it. */ readonly reading: boolean; } /** The rows the view shows as its scroll rests: the first and the last, by their keys. */ export interface PlanNestedView { readonly first: string; readonly last: string; } /** Where the canvas's rows in view are, as it reports them to the reader: a store of one view. */ export interface PlanNestedViewStore { /** The view last reported; `undefined` before any is. */ get(): PlanNestedView | undefined; /** Reports the rows in view: a view the store holds already moves nothing. */ set(view: PlanNestedView | undefined): void; /** Listens for a view that moves; returns the unsubscribe. */ subscribe(listener: () => void): () => void; } /** * A store of the canvas's rows in view: the canvas writes it as its scroll * comes to rest, and the reader, a component of its own, reads it. * * @returns The store */ export declare function createNestedViewStore(): PlanNestedViewStore; /** What the reader reads over, as the canvas gives it. */ export interface PlanNestedArgs { /** The seam. */ readonly seam: PlanNestedValue; /** The canvas's rows the body lays out, in order: a folded row's children are none of them. */ readonly visible: readonly PlanRowValue[]; /** Every row the canvas holds, by key, with each one's children. */ readonly index: PlanRowIndex; /** The rows in view, as the canvas reports them at rest; `undefined` before it does, for the first block. */ readonly view: PlanNestedView | undefined; /** The range the canvas reads: its window and the periods laid out beyond it. */ readonly range: { readonly from: Date; readonly to: Date; } | undefined; /** The canvas's buckets over the range. */ readonly buckets: readonly ScheduleCellBucket[] | undefined; /** The canvas's resolution. */ readonly resolution: PlanResolution | undefined; /** Each drafted row's Save, previewed (#1437): what it changes in the index, put into what is held. */ readonly previews?: ReadonlyMap | undefined; } /** What the reader hands on: what it read, and the rows waiting on a read in flight. */ export interface PlanNestedCells { /** What it read; `undefined` before the first read lands. */ readonly lead: PlanNestedLead | undefined; /** The rows waiting on a read in flight, by their keys: the same set while they are the same rows. */ readonly waiting: ReadonlySet; } /** * The rows' collections, read a cell at a time (see the module docs), in a * tracked evaluation: a search that lands reads again. A read in flight * leaves the last standing, and says which rows wait on it; one that throws * leaves it too, and says why. * * @param args - What it reads over * @returns What it read, and the rows waiting on a read in flight */ export declare function usePlanNestedCells(args: PlanNestedArgs): PlanNestedCells; /** Props of {@link PlanNestedReader}. */ export interface PlanNestedReaderProps { /** The seam. */ seam: PlanNestedValue; /** The canvas's rows the body lays out, in order. */ visible: readonly PlanRowValue[]; /** Every row the canvas holds. */ index: PlanRowIndex; /** The shared scale. */ scale: PlanScale | undefined; /** The rows in view, as the canvas reports them at rest. */ views: PlanNestedViewStore; /** The canvas's editing session, when it edits: each drafted row's Save previewed in what is read (#1437). */ session?: (RecordDraftsSession & Pick, "subscribe" | "getSnapshot">) | undefined; /** Where what it read goes: called only when it moves. */ onLead: (lead: PlanNestedLead | undefined) => void; /** Where the rows waiting on a read in flight go, by their keys: called only when they move, and with none as it unmounts. */ onWaiting: (rows: ReadonlySet) => void; /** Where the span of the collections the series shown read, and their months' counts, go (#1438): called only when they move. */ onSpan: (span: PlanNestedSpanRead | typeof SPAN_READING | undefined) => void; } /** * The rows' collections, read in a component of its own: each search that * lands re-runs it alone, and it hands the canvas what it read, and the rows * waiting on a read in flight, only when they move. * * @param props - What it reads over, and where it goes * @returns Nothing: it reads */ export declare function PlanNestedReader({ seam, visible, index, scale, views, session, onLead, onWaiting, onSpan }: PlanNestedReaderProps): null; /** The span of the collections a Plan's series read (#1438): `[from, to)`, in ms. */ export type PlanNestedSpan = readonly [number, number]; /** * How much the collections a Plan's series read hold in each month (#1438), * as e3 keeps it in the index's span: each month's start, in ms, and the items * and values touching it across the rows, in order — what the horizon's bars * count. */ export type PlanNestedMonths = readonly (readonly [number, number])[]; /** * The span's read (#1438): the span of what every series reads — the horizon, * whichever are shown (#1440) — and the months' counts of what the series * shown read. */ export interface PlanNestedSpanRead { /** `[from, to)`, in ms: from the first month any collection of any series touches to the end of the last. */ readonly span: PlanNestedSpan; /** Each month's count across the series shown, in order: none while none is shown. */ readonly months: PlanNestedMonths; } /** A span whose read is in flight. */ export declare const SPAN_READING = "reading"; /** * The span of what every series the canvas lays out reads — the horizon, * whichever are shown — and the months' counts of what the series shown read * (#1438, #1440), read again at each revision. Every series' collections are * read once, so switching a series asks nothing: its collections leave the * bars, and with none shown the strip still spans what they hold, its bars * empty, where it once fell back to the window alone and moved with every * drag. While a read again is in flight it is the last read, so the horizon * and its bars hold still until the new counts land. * * @param seam - The root's seam * @param index - Every row the canvas holds: its rows' series are the ones shown * @returns The span and its months; {@link SPAN_READING} while the first read is in flight; undefined where no collection holds an item */ export declare function usePlanNestedSpan(seam: PlanNestedValue, index: PlanRowIndex): PlanNestedSpanRead | typeof SPAN_READING | undefined; /** * Rows read whole by their keys (#1438): what a gesture drafts — a row read * whole once, on its first change — and what a Save is confirmed by. */ export interface PlanWholeRows { /** * A row whole, encoded as the record holds it, by its id, at the record's * revision: `some(some(bytes))`, `some(none)` for a key the record holds no * row under, `none` while it is read — asked with every row asked and not * yet read, in one request. A tracked read: an evaluation that reads it * runs again when it lands. */ read(id: string): option>; /** * Several rows whole, each as {@link PlanWholeRows.read} answers it, every * one not yet read asked in one request: `none` while any of them is read. * A tracked read. */ readAll(ids: readonly string[]): option>>; } /** * The rows a Plan over paged rows beside their nested series index reads * whole (#1438): what its editing session drafts from. * * @param seam - The root's seam; `undefined` for a root reading no nested series index * @returns The rows read whole; `undefined` without a seam */ export declare function usePlanWholeRows(seam: PlanNestedValue | undefined): PlanWholeRows | undefined; /** * The root with its paged rows drawn through the seam (#1438): ONE wrapper per * source, as the event kinds' is, each window its lean rows filled with the * cells read and the series run over them, the shading in place — its * revision naming the reader's version beside the source's own, so the driver * reads its windows again when what was read moves, the rows it holds * standing in. A window carries no entries (`CarriedWindowType`): its rows are * lean, and a gesture drafts from the row read whole by its key * ({@link usePlanWholeRows}). * * @param value - The latest root * @param data - Its data-stable twin * @param lead - What the reader read; `undefined` before it first lands, or for a root reading no nested series index * @param drafted - The session's drafted rows, whole, by id, and their version: each draws in its lean row's place * @param readWhole - Rows read whole for the link ends the cells do not hold, by id: each draws whole in its lean * row's place, its runs where their times put them — a drafted row before it * @returns The two roots the canvas draws */ export declare function usePlanNestedRoot(value: PlanRootValue, data: PlanRootValue, lead: PlanNestedLead | undefined, drafted?: { readonly drafts: ReadonlyMap; readonly version: number; }, readWhole?: ReadonlyMap): { value: PlanRootValue; data: PlanRootValue; }; //# sourceMappingURL=nested.d.ts.map