import type { TileSource } from "./tile-source"; /** * Async tile fetcher with in-flight dedup and abort-on-zoom-change. * * Runs inside the renderer worker (the chart's host process). `fetch` * and `createImageBitmap` are both available in workers, and the * resulting `ImageBitmap` can be uploaded straight to a WebGL2 texture * via `gl.texImage2D(..., ImageBitmap)` — no main-thread bounce. * * The loader does not own GPU resources. Upload to texture happens in * the tile layer once an `ImageBitmap` resolves; the layer then drops * the bitmap (calling `close()` to free the decoded pixels). */ export declare class TileLoader { private _inFlight; private _onLoad; /** * Register the "tile arrived" callback. The layer wires this to * `chart.requestRender(glManager)` so a newly-loaded tile triggers * exactly one extra frame. */ setOnLoad(cb: () => void): void; /** * Kick off a fetch (or return the in-flight one). The same * (source.id, z, x, y) tuple only ever has one outstanding * fetch; multiple callers share the result. Rejected fetches * (network error, abort) resolve to `null` so callers can skip * the tile without try/catch noise on every miss. */ load(source: TileSource, z: number, x: number, y: number): Promise; /** * Abort every in-flight fetch. Called on view teardown / chart * destroy. Fetches whose `Response` has already arrived but * haven't yet decoded will still complete the decode and resolve * to `null` (because `_onLoad` is replaced or the cache is gone) * — harmless, no resource leak. */ cancelAll(): void; /** * Abort just the fetches whose key isn't in the supplied set. * The layer calls this on every render with the currently-visible * tile set so old-zoom requests don't keep arriving and triggering * spurious re-renders after the user has moved on. */ cancelExcept(liveKeys: Set): void; private _fetchAndDecode; } /** * Stable cache key for a tile under a given source. Embedded source id * so swapping sources (light/dark) doesn't surface stale tiles. */ export declare function tileKey(sourceId: string, z: number, x: number, y: number): string;