import type { BlueDot } from '../blue-dot'; import type { Asyncify, ConditionalExcept, ConditionalPick } from 'type-fest'; import type { BrowserPermissionState } from '@packages/internal/common/browser'; import type { BuiltInSensorId } from '../sensors/types'; /** * Proxy interface for a sensor accessed through the React Native bridge. * Provides async versions of sensor methods. */ export interface SensorProxy { /** Unique identifier for this sensor */ readonly id: string; /** * Enable the sensor and request permissions if needed. * @returns The permission state after enabling */ enable(): Promise; /** * Disable the sensor. */ disable(): Promise; /** * Check the current permission state for this sensor. */ checkPermission(): Promise; /** * Request permission to use this sensor. * Must be called in response to a user gesture. */ requestPermission(): Promise; /** * Check if the sensor is currently enabled. * Note: This is async in React Native as it requires a bridge call. */ getIsEnabled(): Promise; } /** * Proxy interface for the SensorRegistry accessed through the React Native bridge. * Note: `register()` is not available in React Native as custom sensors cannot be serialized. */ export interface SensorRegistryProxy { /** * Get a built-in sensor by ID. * @param sensorId The ID of the sensor to get * @returns A proxy object for interacting with the sensor */ get(sensorId: BuiltInSensorId): SensorProxy; } /** * Extension state for Blue Dot that includes the current state and position. * Excludes Sensors as it uses a special proxy type for React Native. */ export type BlueDotExtensionState = Omit any>, 'Sensors' | 'Fusion'>; /** * Helper type that asyncifies all methods from BlueDot, excluding event listener methods. */ type AsyncBlueDotMethods = { [K in keyof Omit any>, 'on' | 'off'>]: Asyncify; }; /** Filters out internal (__-prefixed) methods from the public API. */ type PublicAsyncBlueDotMethods = { [K in keyof AsyncBlueDotMethods as K extends `__${string}` ? never : K]: AsyncBlueDotMethods[K]; }; export interface UseBlueDotResult extends BlueDotExtensionState, Omit { /** * Whether the extension is ready and initialized */ isReady: boolean; /** * Proxy for the Sensors API. * Provides access to built-in sensors through the React Native bridge. */ Sensors: SensorRegistryProxy; /** @experimental Force position for a duration, overriding all sensors. */ forcePosition: (position: { latitude: number; longitude: number; heading?: number; floorLevel?: number; }, durationMs?: number) => Promise; /** @experimental Report a confidence-weighted position to the fusion engine. */ reportPosition: (options: { latitude: number; longitude: number; accuracy?: number; heading?: number; floorLevel?: number; confidence?: number; timestamp?: number; }) => Promise; /** @experimental Enable a sensor by ID. */ enableSensor: (sensorId: string) => Promise; /** @experimental Disable a sensor by ID. */ disableSensor: (sensorId: string) => Promise; /** @experimental Check the current permission state for a sensor. */ checkSensorPermission: (sensorId: string) => Promise; /** @experimental Request permission for a sensor. */ requestSensorPermission: (sensorId: string) => Promise; /** @experimental Check if a sensor is currently enabled. */ isSensorEnabled: (sensorId: string) => Promise; } /** * React hook for using BlueDot extension in React Native WebView * * This hook provides an API for interacting with the BlueDot extension: * - Uses the shared state system for automatic extension registration * - Provides methods for controlling blue dot behavior * - Handles bridge communication and error management * * @returns Hook API object with Blue Dot methods * * @example * ```tsx * import { MapView } from '@mappedin/react-native-sdk'; * import { useBlueDot } from '@mappedin/blue-dot/rn'; * * function MyComponent() { * const { enable, isReady, state, following } = useBlueDot(); * * // Use the Blue Dot API * React.useEffect(() => { * if (isReady) { * enable({ radius: 15, color: '#ff0000' }); * } * }, [isReady]); * } * ``` */ export declare function useBlueDot(): UseBlueDotResult; export {};