/** * The slice of MapLibre GL JS the adapter uses, derived from MapLibre's own types (type-only import: no * runtime cost, and the slice cannot drift from the real API). Tests drive a fake that fits this slice, * because jsdom has no WebGL. */ import type * as GeoJSON from 'geojson'; import type { Map as MapLibreMap, MapOptions } from 'maplibre-gl'; export type MapLike = Pick; /** What the adapter needs from the `maplibre-gl` module: just the Map constructor. */ export interface MapLibreModuleLike { Map: new (options: MapOptions) => MapLike; /** Where MapLibre loads its web worker from (v6). Optional so older modules and fakes still fit. */ setWorkerUrl?: (url: string) => void; /** Custom URL schemes (pmtiles://, contour tiles). Optional so fakes without it still fit. */ addProtocol?: (id: string, handler: never) => void; } /** An image source (MapLibre places a picture by four corners). */ export interface ImageSourceLike { updateImage(options: { url: string; coordinates?: Array<[number, number]>; }): unknown; setCoordinates(coordinates: Array<[number, number]>): unknown; } /** The GeoJSON source methods the adapter calls (MapLibre's `getSource` returns a generic Source). */ export interface GeoJSONSourceLike { setData(data: GeoJSON.FeatureCollection): Promise | unknown; updateData?(diff: { removeAll?: boolean; remove?: Array; add?: GeoJSON.Feature[]; }): Promise | unknown; getClusterExpansionZoom?(clusterId: number): Promise; } /** Fields the adapter reads from MapLibre mouse events and rendered features. */ export interface MapMouseEventLike { point: { x: number; y: number; }; lngLat: { lng: number; lat: number; }; } export interface RenderedFeatureLike { id?: string | number; properties: Record; layer: { id: string; }; geometry?: { type: string; coordinates: unknown; }; }