import { SyncAuth } from './client.ts'; import type { SyncAuthOptions } from './types.ts'; export { SyncAuth } from './client.ts'; export * from './types.ts'; /** The subset of MapLibre's / Mapbox GL's `RequestTransformFunction` we implement — no dependency on either lib. */ export type TransformRequest = (url: string, resourceType?: string) => { url: string; headers?: Record; }; /** Minimal shape of a MapLibre / Mapbox source we know how to refresh. */ export type RefreshableSource = { type: 'geojson'; setData(data: unknown): unknown; _data?: unknown; } | { type: 'vector'; tiles?: string[]; setTiles(tiles: string[]): unknown; } | { type: string; }; /** * A `SyncAuth` with MapLibre GL / Mapbox GL conveniences attached. * * ```js * const auth = createSyncAuth({ server }); * const map = new maplibregl.Map({ container, style, transformRequest: auth.transformRequest }); * ``` */ export declare class MapLibreSyncAuth extends SyncAuth { /** * Hand this to `new Map({ transformRequest })`. Adds `?token=` to every request * aimed at Sync Server and leaves other URLs (basemap, glyphs, sprites) alone. * Reads the token per request, so sign-in/out is picked up automatically. * * `transformRequest` is synchronous and cannot wait for a popup — call * `await auth.ensureSignedIn()` before creating the map. */ transformRequest: TransformRequest; /** * Like `transformRequest` but sends `Authorization: Bearer` instead of `?token=`. * Headers force XHR fetches and CORS preflights for tiles, so prefer the default. */ transformRequestWithHeader: TransformRequest; /** * Re-fetch a source after an edit or a re-authentication. GeoJSON sources are * re-set from their URL; vector sources get a cache-busting `v=` on their tile * URLs so tiles are re-requested with fresh data and a fresh token. */ refreshSource(source: RefreshableSource, stamp?: string | number): void; } /** Create a Sync Server client with MapLibre / Mapbox GL helpers attached. */ export declare function createSyncAuth(options: SyncAuthOptions): MapLibreSyncAuth; //# sourceMappingURL=maplibre.d.ts.map