/**
* **Read-only sprite rasterizer** — engine-agnostic. Turns a {@link MarkerWidget} whose
* `static` flag is set into a bitmap that the engine adapters place as a **native icon**
* (MapLibre `addImage`, OpenLayers `Icon`, Leaflet `
`), so a non-selected cartouche
* gets the rich `WidgetBox` layout without N live DOM cards to reposition each frame.
*
* Strategy: **measure in the DOM, paint on a canvas.** We build the box-layout tree as a
* real (off-screen) DOM subtree — so the browser's own flex/text layout positions every
* node (one layout logic, shared with the live card) — then read each node's measured
* geometry back and **repaint** it onto a 2D canvas (`fillText` / rounded-rect frames /
* `drawImage` for glyph SVGs). No `foreignObject` is involved, so the canvas stays
* origin-clean and is readable as `ImageData` / `toDataURL` / a WebGL texture on **every**
* browser (incl. Safari/WebKit, where a `foreignObject` render would taint it).
*
* The DOM subtree is measured **inside the engine's own container** (off-screen) so it
* inherits the exact same font/line-height cascade as a real mounted card → pixel parity.
*
* The result is cached per `id` and only re-rasterized when the layout hash or the
* device-pixel-ratio changes — never on pan/zoom.
*/
import type { LatLng, MarkerWidget } from "./index.js";
/** Rendered size of a sprite, in **CSS px** (for placement / anchoring / collision). */
export interface WidgetSize {
width: number;
height: number;
}
/** Options shared by {@link measureWidget} / {@link rasterizeWidget}. */
export interface SpriteOptions {
/** Device pixels per CSS px the bitmap is rendered at. Default `window.devicePixelRatio` (≥1). */
dpr?: number;
/** Formatter for `coord` leaves (mirrors {@link MapAdapter.setCoordFormat}). Default decimal lat/lon. */
coordFmt?: (ll: LatLng) => string;
/** Element to measure the off-screen tree inside, so it inherits the same CSS cascade (font,
* line-height) as a real card. Pass the engine map container; defaults to `document.body`. */
container?: HTMLElement;
}
/** A rasterized sprite: a device-pixel canvas plus its CSS-px size and the dpr it was drawn at. */
export interface SpriteResult {
/** Canvas at device resolution (`width = round(cssWidth × dpr)`); origin-clean, so it can be read
* back (`getContext("2d").getImageData` / `toDataURL`) or uploaded as a texture on any browser. */
canvas: HTMLCanvasElement;
/** CSS-px width (icon display size). */
width: number;
/** CSS-px height. */
height: number;
/** The device-pixel-ratio this canvas was rendered at. */
dpr: number;
}
/** Drop cached sprite(s). Pass an `id` to evict one, or omit to clear all (engine `destroy`). */
export declare function clearSpriteCache(id?: string): void;
/**
* Measure the rendered size of a `static` widget — **CSS px** — without painting it. Used by the
* consumer's call-out placement pass so a sprite collides with its exact box (no estimate). Cheap
* and cached per `id`; in a headless DOM (jsdom, `getBoundingClientRect` ⇒ 0) it returns a zero size.
*/
export declare function measureWidget(w: MarkerWidget, opts?: SpriteOptions): WidgetSize;
/**
* Rasterize a `static` widget to a device-pixel canvas (cached per `id`; re-rendered only when the
* layout hash or `dpr` changes). Returns `null` when there is no DOM (SSR) or the measured size is
* empty (headless test env). The canvas is origin-clean — `getImageData` / `toDataURL` / texture
* upload all work on every browser.
*/
export declare function rasterizeWidget(w: MarkerWidget, opts?: SpriteOptions): Promise;
//# sourceMappingURL=sprite.d.ts.map