@expofp/floorplan
Version:
Interactive floor plan library for expos and events
48 lines • 2.31 kB
TypeScript
import { type CameraAPI, type CameraState } from '@expofp/renderer';
/** The plan's camera, as the parts of the SDK that live outside React reach it. */
export interface MapCameraHandle {
/** Moving the camera. */
readonly api: CameraAPI;
/** Reading where it is, at the moment of asking. */
state(): CameraState;
}
/** What the mounted map holds, and hands the handle below a live view of. */
export interface MountedCamera {
/** The camera commands, as the renderer last handed them over. */
api: CameraAPI;
/** The camera reader, likewise. */
state: () => CameraState;
}
/**
* Wraps the map's live camera in a handle whose identity never changes.
*
* The renderer's hooks return a fresh object on every render, deliberately — it memoizes nothing, so
* that the cost of a settled identity is paid by whoever knows how often they render. That is this
* map: it reads them through a ref, and hands out this one object for the life of the mount, so
* nothing outside React ever holds a stale command.
* @param camera - A live view of what the mounted map holds.
* @returns The handle to publish.
*/
export declare function createMapCamera(camera: {
readonly current: MountedCamera;
}): MapCameraHandle;
/**
* Publishes the plan's camera, for as long as the map is on screen.
*
* The same inversion {@link setMarkerResolver} performs, and for the same reason: the renderer's
* camera is reached through hooks, which only resolve inside a component mounted under
* `<Renderer>` — and that is deliberate, since it is what stops anything touching the camera
* before the canvas exists. The SDK's own methods, the kiosk store and the route store are not
* components and cannot hold a hook, so `MapCamera` hands the camera out here once it is safe.
* @param camera - The camera; omitted to unpublish it as the map unmounts.
*/
export declare function setMapCamera(camera?: MapCameraHandle): void;
/**
* The plan's camera, if the map is on screen.
*
* Absent before the canvas has mounted, and in MapLibre mode, where the map is unmounted entirely
* and the imperative renderer drives the embed instead.
* @returns The camera, or `undefined`.
*/
export declare function mapCamera(): MapCameraHandle | undefined;
//# sourceMappingURL=camera.d.ts.map