import "./boot"; import type { Client, Table, View } from "@perspective-dev/client"; import { WebGLContextManager } from "../webgl/context-manager"; import { ChartImplementation } from "../charts/chart"; import { ZoomController } from "../interaction/zoom-controller"; import type { InitMsg, InteractionEvent, LoadAndRenderMsg, WorkerMsg } from "../transport/protocol"; export declare class WorkerRenderer { chartImpl: ChartImplementation; glManager: WebGLContextManager; zoomController: ZoomController | null; gridlines: OffscreenCanvas; chrome: OffscreenCanvas; cssWidth: number; cssHeight: number; dpr: number; client: Client; view: View; /** * Source `Table` opened once at bootstrap from the host-supplied * `tableName`. Used by `loadAndRender` to fetch the source schema * for group-by level types — the worker resolves it itself so the * host's render path makes zero `Client`/`Table`/`View` awaits. * Null when the host had no table loaded at init time. */ table: Table | null; controlPort: MessagePort; /** * Monotonic counter bumped by every `loadAndRender` entry. Captured * locally as `myGen` and re-checked after each await — a stale * value means a newer call has superseded this one and we must * bail (throwing inside the `with_typed_arrays` callback so the * wasm Arrow buffer release runs cleanly). */ private _renderGen; /** * Active drag state. `pointerdown` resolves a target via the * facet grid and stores it; `pointermove` consults this until * `pointerup` clears it. Pointer capture itself is host-side. */ private _dragTarget; private _lastDragX; private _lastDragY; constructor(msg: InitMsg, client: Client, view: View, table: Table | null, controlPort: MessagePort, ImplClass: new () => ChartImplementation); setViewByName(name: string): void; /** * Full data-fetch + render pipeline. Owns every `Client`/`Table`/ * `View` await on the render path: * * 1. Resolve metadata (`view.num_rows`, `view.schema`, * `view.expression_schema`, `table.schema`) in parallel. * 2. Apply schema + viewer-config to the chart impl (replaces the * individual `setColumnTypes` / `setGroupByTypes` / * `setViewPivots` / `setColumnSlots` setters that used to * stream from the host). * 3. Compute `totalRows` from `bufferPool.maxCapacity / numCols` * and grow the buffer pool to fit. * 4. Run `view.with_typed_arrays`; the inner callback hands the * resulting `ColumnDataMap` straight to * `chartImpl.uploadAndRender` — no `postMessage`, no transfer. * * Mid-flight cancellation: each entry bumps `_renderGen` and * captures `myGen`. After the metadata await we re-check; if a * newer call has superseded this one, ack-and-return so the host * promise resolves cleanly. Inside the `with_typed_arrays` * callback the same check throws `StaleGenerationError` so the * wasm Arrow buffer release path runs (callback's promise must * reject for `with_typed_arrays` to unwind) before the next call * proceeds — caught and swallowed here. * * Always sends `loadAndRenderAck` (even on stale drop) per the * "resolve on stale" host contract. */ loadAndRender(msg: LoadAndRenderMsg): Promise; redraw(): void; resize(cssWidth: number, cssHeight: number, dpr: number): void; clear(): void; saveZoom(): any; restoreZoom(state: any): void; allZoomsDefault(): boolean; resetAllZooms(): void; resetExpandedDomain(): void; /** * Hit-test the cursor against the chart's facet grid (in faceted * mode) or its current layout (single-plot). The worker owns the * facet grid and controllers, so the resolution runs here. */ private _resolveTarget; onInteraction(event: InteractionEvent): void; /** * Read the chart impl's `TooltipController`. Charts that don't use * one (no `attachTooltip` override) yield `null` and the * mouse-event branches fall through. */ private _tooltip; /** * Composite the three layers into a single PNG `Blob`. */ snapshotPng(): Promise; destroy(): void; post(msg: WorkerMsg, transfer?: Transferable[]): void; } /** * In-process bootstrap. Used when the host loads this same module via * `await import(workerURL)` to run the renderer on the main thread — * skips the wasm / font / proxy-port plumbing because the host already * owns a live `Client` and the document's `FontFaceSet` is the active * one. */ export declare function bootstrapInProcess(opts: { msg: InitMsg; client: Client; controlPort: MessagePort; }): Promise;