import { FusedPosition } from '../fusion/types'; import type { BrowserPermissionState } from '@packages/internal/common/browser'; import { SensorEventPayloads } from './types'; import { PubSub } from '@packages/internal/common/pubsub'; /** * Options for setting an anchor from a sensor. */ export interface SetAnchorOptions { /** Latitude in degrees */ latitude: number; /** Longitude in degrees */ longitude: number; /** Heading in degrees (0-360, clockwise from north) */ heading?: number; /** Floor level (elevation) */ floorLevel?: number; /** * How long the anchor remains valid in milliseconds. * @default 30000 (30 seconds) */ ttl?: number; /** * Confidence score (0-1) for this anchor. * @default 1.0 */ confidence?: number; /** * Duration in ms where this anchor is exclusive (GPS rejected). * If not specified, uses the FusionEngine's default anchorOnlyPeriodMs. */ anchorOnlyPeriodMs?: number; } /** * Abstract base class for all position sources. * Extend this class to create custom position sources (e.g., IPS, BLE beacons). */ export declare abstract class BaseSensor extends PubSub { /** Unique identifier for this sensor */ abstract readonly id: string; /** Whether this sensor requires browser/device permission to operate */ abstract readonly requiresPermission: boolean; /** Whether this source is currently running */ protected enabled: boolean; constructor(); /** * Whether this source is currently running and producing updates. */ get isEnabled(): boolean; /** * Start receiving position updates from this source. * This is called automatically when the source is enabled. */ protected abstract start(): Promise; /** * Stop receiving position updates from this source. * This is called automatically when the source is disabled. */ protected abstract stop(): void; /** * Check the current permission state for this source. * @returns The current permission state */ abstract checkPermission(): Promise; /** * Request permission to use this source. * Must be called in response to a user gesture (click, tap, etc.). * @returns true if permission was granted, false otherwise */ abstract requestPermission(): Promise; /** * Called when the fusion engine produces a new fused position. * Override this method to receive fused positions for calibration or anchoring. * @param position The fused position from all sources */ onFusedPosition(position: FusedPosition): void; /** * Set a position anchor from this sensor. * * Use this when your sensor has a high-confidence absolute position * (e.g., VPS localization, QR code scan, beacon detection). * The anchor will be used as the reference point for position fusion. * * @param options - Anchor position and configuration * * @example * ```typescript * // In your custom sensor after successful localization: * this.setAnchor({ * latitude: 43.4723, * longitude: -80.5449, * heading: 90, * floorLevel: 2, * ttl: 30000, * }); * ``` */ protected setAnchor(options: SetAnchorOptions): void; /** * Clear the anchor set by this sensor. * * After clearing, the FusionEngine will fall back to other position sources. */ protected clearAnchor(): void; enable(): Promise; disable(): void; }