/** * The viewport Virtual DOM. * * Holds a keyed virtual mirror of **only the rows currently rendered**, and * uses it to turn a data change into the smallest possible set of DOM writes: * one `textContent` assignment per cell whose value actually changed, and * nothing at all for the rest. * * Why a viewport-scoped tree rather than a conventional one: * - **Bounded cost.** Diffing is O(rendered cells), never O(dataset). A 1 M-row * grid diffs exactly as fast as a 100-row grid. * - **Bounded memory.** The tree holds a few hundred small records that are * reused across scrolling, so a high-frequency stream produces almost no * garbage — the dominant cost of naive virtual-DOM designs. * - **No reconciliation of structure.** Row and column identity are already * stable (`nodeId`, `colId`), so there is no children-array to reconcile: * structural change is handled by the renderer, and the virtual tree only * ever answers "did this cell's value change?". * * @packageDocumentation */ import type { RowNode } from '../../types/row.types'; import type { RenderedRowRef, VDomRenderContext, VDomStats } from './vdom.types'; import type { CellPatcher } from './cell-patcher'; export declare class ViewportVDom { private readonly patcher; private readonly rows; private generation; private cellsCompared; private cellsPatched; private cellsReRendered; private cellsDeferred; private flushes; private lastFlushMs; constructor(patcher: CellPatcher); /** * Reconciles the virtual tree with the rows the renderer just painted. * * Called at the end of every render pass. Rows whose panel elements are * unchanged keep their adopted cells (the common case while scrolling stays * within already-rendered rows); rows that were rebuilt are re-adopted, and * rows that left the viewport are dropped. * * Adoption happens here rather than lazily at patch time because a freshly * rendered cell is the one moment the DOM is guaranteed to agree with the * data — recording values later could silently miss a change that landed in * between. * * @param refs - Every row currently rendered, with its per-panel elements. * @param ctx - Render context used to classify columns and derive classes. */ sync(refs: Iterable, ctx: VDomRenderContext): void; /** * Diffs the given rows against the virtual tree and patches only the cells * whose values changed. * * Rows that are not currently rendered are skipped entirely — their data has * already been updated in the model, and they will render correctly when they * scroll into view. * * @param nodeIds - Rows to diff, or `null` to diff every rendered row. * @param ctx - Render context matching the initial render. * @returns The number of cells written to the DOM. */ patchRows(nodeIds: Iterable | null, ctx: VDomRenderContext): number; /** `true` when the row is currently rendered and tracked. */ has(nodeId: string): boolean; /** * The `RowNode` for a rendered row, in O(1). * * Lets the real-time update path resolve visible rows without scanning the * dataset. */ getRow(nodeId: string): RowNode | undefined; /** * Drops rows from the virtual tree. * * Called when the renderer evicts row DOM so the tree never holds a reference * to a detached element. */ evict(nodeIds: Iterable): void; /** Drops every tracked row — used when the renderer clears the body. */ clear(): void; /** Snapshot of the counters described by {@link VDomStats}. */ getStats(): VDomStats; /** Zeroes the cumulative counters (the tracked tree is left intact). */ resetStats(): void; /** * Diffs one tracked row. * * The loop reads each cell's current value once, compares it against the last * value written to the DOM, and only then hands it to the patcher — so an * unchanged cell costs a map lookup, a value read and a comparison, with no * allocation and no DOM access whatsoever. */ private patchTracked; /** * Records the live cell elements of a freshly rendered row. * * Resolving `.pg-cell__value` here — once, at adoption — is what makes the * steady-state patch a single `textContent` write with no query at all. */ private adopt; } //# sourceMappingURL=viewport-vdom.d.ts.map