import { VirtualizationOptions } from "../types.js"; import { ElementContent } from "hast"; //#region src/managers/VirtualizationManager.d.ts interface VisibleRange { start: number; end: number; } /** * Monaco-style virtualized rendering manager. * * Key optimizations: * 1. Lazy HTML conversion — HAST nodes are stored raw and only converted * to HTML strings when they enter the viewport (via toHtml per-node). * This avoids the O(N) cost of toHtml on the entire 5000-node AST. * 2. Batch innerHTML — visible lines are joined and set via one innerHTML * per scroll frame. * 3. O(1) range calculation — uses scrollY math, not getBoundingClientRect. * 4. Position caching — container position measured on resize only. */ declare class VirtualizationManager { private options; private container; private contentWrapper; private spacerTop; private spacerBottom; private totalLines; /** * Per-line HTML strings. Populated eagerly (setupFromHTML/setupFromHTMLString) * or lazily from HAST nodes (setupFromHAST — null means not yet converted). */ private lineHTMLs; /** HAST nodes for lazy conversion. Only used with setupFromHAST. */ private hastNodes; private renderedRange; private isVirtualized; private totalContentHeight; private containerPageTop; private rafId; private scrollHandler; private resizeObserver; private intersectionObserver; constructor(options?: VirtualizationOptions); setOptions(options: VirtualizationOptions): void; isActive(): boolean; shouldVirtualize(lineCount: number): boolean; private measureContainerPosition; /** * Setup from pre-parsed DOM elements (legacy API). */ setup(codeElement: HTMLElement, lineElements: HTMLElement[], _scrollContainer: HTMLElement): void; /** * Setup from a concatenated HTML string — splits into per-element strings. */ setupFromHTMLString(codeElement: HTMLElement, htmlContent: string): void; /** * FAST PATH: Setup directly from HAST AST nodes. * * This skips both: * - toHtml() on the full AST (saves ~500ms for 5000 nodes) * - splitHTMLIntoElements() (saves ~200ms on 5MB string) * * HAST nodes are stored raw and converted to HTML lazily — only when * they enter the visible viewport. For 5000 lines with 60 visible, * only 60 toHtml() calls happen instead of 5000. */ setupFromHAST(codeElement: HTMLElement, hastChildren: ElementContent[]): void; /** * Core setup from an array of HTML strings (one per line/element). */ private setupFromHTML; /** * Common virtualization activation (spacers, listeners, initial render). */ private activateVirtualization; private handleScroll; private calculateVisibleRange; /** * Get the HTML string for a line, converting from HAST lazily if needed. */ private getLineHTML; /** * Batch innerHTML update — 1 DOM operation per frame. * Lazily converts HAST nodes to HTML only for visible lines. */ private updateVisibleLines; getVisibleRange(): VisibleRange; scrollToLine(lineNumber: number): void; cleanUp(): void; } /** * Split a concatenated HTML string into per-element strings. */ declare function splitHTMLIntoElements(html: string): string[]; declare function extractLineElements(htmlString: string): HTMLElement[]; interface ParsedCodeContent { lines: HTMLElement[]; separators: HTMLElement[]; allElements: HTMLElement[]; } declare function parseCodeContent(htmlString: string): ParsedCodeContent; //#endregion export { ParsedCodeContent, VirtualizationManager, extractLineElements, parseCodeContent, splitHTMLIntoElements }; //# sourceMappingURL=VirtualizationManager.d.ts.map