/** * The Runtime Context object (spec: "Runtime Context API") — injected into * every widget render. A stable contract that deliberately never exposes * deck.gl internals (no layerManager, no raw Deck instance) — only the * viewport (for projection) crosses that boundary, per the spec's own * rationale. */ import type { LayerIR, LayerFilter, LayerCategoryFilter } from "./ir"; import type { RuntimeCore } from "./runtime-core"; import type { Selection } from "./selection"; import { type Stats } from "./stats"; import type { LegendSpec } from "./legend-spec"; export interface LayerMetaSnapshot { id: string; label?: string; color?: string; /** Statically-derived color symbology — the legend widget's default rendering (spec: "Built-in widgets / legend"). */ legend?: LegendSpec; visible: boolean; type: string; dataUrl?: string; /** The layer's active declarative filter, if any (spec: "Filtering") — read by the built-in `filter` widget. */ filter?: LayerFilter; /** The layer's active categorical filter, if any — independent of `filter`, read by the built-in `filter` widget's categorical mode. */ categoryFilter?: LayerCategoryFilter; } export interface DataOpts { /** Set `false` to bypass the layer's active declarative filter (spec: "Filter-aware stats & data (the coherence rule)"). Default `true`. */ filtered?: boolean; } export interface RuntimeContext { layers: LayerMetaSnapshot[]; viewport: { bounds: [[number, number], [number, number]]; zoom: number; center: [number, number]; project(lngLat: [number, number]): [number, number]; }; selection: Selection | null; /** * The decoded EXT_structural_metadata property table for a `pick-features` * layer, indexed BY feature ID, or null before its first tile has loaded. * Watch the `features` token to re-render when it arrives. */ features(layerId: string): Record[] | null; /** Manifest undo/redo state (spec: "Undo / Redo — Manifest History") — drive it via emit("undo"/"redo"). Always false on the programmatic/React path (the app owns state there). */ history: { canUndo: boolean; canRedo: boolean; }; emit(event: string, payload?: Record): void; data(layerId: string, opts?: DataOpts): Promise; dataInViewport(layerId: string, opts?: DataOpts): Promise; stats(layerId: string, field: string, opts?: { scope?: "all" | "viewport"; } & DataOpts): Stats; } export interface BuildCtxDeps { layerIRs: ReadonlyMap; featureTables?: ReadonlyMap[]>; core: RuntimeCore; mapEl: Element; selection: Selection | null; history?: { canUndo: boolean; canRedo: boolean; }; } /** `ctx.viewport.bounds` / the `viewport` external-store snapshot — one bounds derivation (incl. the world-extent fallback) for both (spec: "External-Store Contract"). */ export declare function viewportBounds(viewport: ReturnType): [[number, number], [number, number]]; /** `ctx.layers` / the `layers` external store — one builder for both (spec: "External-Store Contract"). */ export declare function buildLayerMetas(layerIRs: ReadonlyMap): LayerMetaSnapshot[]; /** Built fresh on every widget-render invocation — never mutated, never reused. */ export declare function buildCtx({ layerIRs, core, mapEl, selection, history, featureTables }: BuildCtxDeps): RuntimeContext;