UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

63 lines • 3.34 kB
import { type ViewportAPI } from '@expofp/renderer'; import { type FloorPlanGetCoordsEvent } from '../../types'; /** * What the mounted map holds, and hands the handle below a live view of. * * The renderer's conversions themselves, unwrapped: unlike the camera, there is nothing to publish * here *besides* them — no reader to pair with the commands — so the handle is the same shape as * what it forwards to. */ export interface MountedViewport { /** The conversions, as the renderer last handed them over. */ api: ViewportAPI; } /** * Wraps the map's live coordinate conversions in a handle whose identity never changes. * * The same inversion `createMapCamera` performs, and for the same reason: the renderer's hooks * return a fresh object on every render — they memoize nothing, so that the cost of a settled * identity is paid by whoever knows how often they render. That is this map, which reads them * through a ref and hands out this one object for the life of the mount. * @param viewport - A live view of what the mounted map holds. * @returns The handle to publish. */ export declare function createMapViewport(viewport: { readonly current: MountedViewport; }): ViewportAPI; /** * Publishes the plan's coordinate conversions, for as long as the map is on screen. * * The same inversion `setMapCamera` performs: the renderer's viewport is reached through a * hook, which only resolves inside a component mounted under `<Renderer>` — deliberately, since that * is what stops anything measuring the plan before the canvas exists. The SDK's own methods and the * kiosk store are not components and cannot hold a hook, so the map hands the conversions out here * once it is safe. * @param viewport - The conversions; omitted to unpublish them as the map unmounts. */ export declare function setMapViewport(viewport?: ViewportAPI): void; /** * The plan's coordinate conversions, if the plan is on screen. * * Absent only before the canvas has mounted. Present in MapLibre mode as much as on the standalone * plan: the conversions read the scene's space and the camera three draws with, and in external mode * that camera is the one MapLibre's matrix is decomposed onto — so `canvasToPlan` casts its ray * through the venue exactly as it does when this renderer owns the camera. * @returns The conversions, or `undefined`. */ export declare function mapViewport(): ViewportAPI | undefined; /** * What the middle of the canvas is looking at, which is what the SDK's `getCenterCoordinates` * reports. * * The canvas center rather than the camera's own target, and the two are not the same point: a * `visibleRect` moves where the camera looks without moving the canvas under it. This is what the * imperative map converted through `viewport.canvasToSvg`. * * Shared by both views. Each passes the canvas it owns — the plan's own, or the one MapLibre draws * on — and the answer comes back in plan coordinates either way, so the SDK's method means the same * thing in map mode as on the plan. * @param canvas - The canvas the plan is drawn on, once it has mounted. * @returns The plan coordinates, and the floor they are on. */ export declare function centerCoordinates(canvas: HTMLCanvasElement | null): FloorPlanGetCoordsEvent; //# sourceMappingURL=viewport.d.ts.map