import { Api } from './api'; import { Unsubscribe } from './socket'; /** GPS connection options */ export type GpsOptions = false | { /** * Start browser GPS automatically after a token is available. * Set false when an app already owns GPS collection and only wants api.gps.send(...). */ autoStart?: boolean; /** Dedicated GPS socket URL override. Defaults to the standard socket-server URL */ socketUrl?: string; /** Slice used by socket-server GPS storage */ slice: number | string; /** Field key used by socket-server GPS storage. Default is coords */ field?: string; /** * Stable tracking ID for the object/person/vehicle being tracked. * * If omitted, datalynk-client generates a unique tracker ID for this Gps * instance. The default tracking ID is intentionally not based on sessionId, * because one logged-in session/device may start more than one active tracker. */ trackingId?: string; /** Stable device ID. Default is stored in localStorage */ deviceId?: string; /** Human-readable label passed through to listeners */ label?: string; /** Source/app label passed through to listeners */ source?: string; /** Send a heartbeat even when the GPS position has not changed. Default is 5000 */ heartbeatMs?: number; /** Minimum movement before sending a non-heartbeat update. Default is 3 */ minDistanceMeters?: number; /** Do not send non-heartbeat positions worse than this accuracy. Default is 200 */ maxAccuracyMeters?: number; /** Use browser high-accuracy GPS. Default is true */ highAccuracy?: boolean; /** Browser geolocation timeout. Default is 10000 */ timeoutMs?: number; /** Reject GPS fixes older than this. Default is 4000 */ maxStaleMs?: number; /** Restart watchPosition if no fresh fix arrives. Default is 60000 */ watchdogMs?: number; /** Wait for socket-server ack on manual send(). Default is false */ waitForAck?: boolean; /** Ack wait timeout when waitForAck is true. Default is 15000 */ ackTimeoutMs?: number; }; export type GpsPositionPayload = { lat: number; lng: number; accuracy: number | null; altitude: number | null; altitudeAccuracy: number | null; heading: number | null; speed: number | null; timestamp: string; timestampMs: number; }; export type GpsManualPositionPayload = Omit, 'lat' | 'lng' | 'timestampMs'> & { lat?: number | string; lng?: number | string; lon?: number | string; latitude?: number | string; longitude?: number | string; timestampMs?: number | string; }; export type GpsListenOptions = { slice?: number | string; field?: string; includeTrails?: boolean; trailLimit?: number; }; export type GpsListener = (event: any) => any; /** Server response body inside `{ gps: ... }` */ export type GpsAck = { ok: boolean; seq?: number | null; error?: string; stage?: string; slice?: number | string; field?: string; trackingId?: string; liveKey?: string; dirtyKey?: string; activeKey?: string; trailKey?: string; sessionId?: string | null; deviceId?: string | null; pending?: boolean; }; export type GpsSendOptions = { /** When true, wait for matching socket-server ack (matched by seq). Default false */ waitForAck?: boolean; }; /** Browser/manual GPS sender backed by socket-server Redis GPS storage */ export declare class Gps { private readonly api; private static readonly GPS_ACK_TIMEOUT_MS; private ackResolvers; private deviceId; private heartbeat?; private lastFixAt; private lastPosition?; private lastSentAt; private lastSentPosition?; private pendingPayloads; private retryWatchdog?; private seq; private sessionId; private socket?; private trackerId; private started; private unsubs; private watchId?; private watchStartedAt; readonly options?: Exclude; constructor(api: Api, options?: GpsOptions); /** Start sharing browser GPS to socket-server */ start(): void; /** Stop sharing GPS and close the dedicated GPS socket */ stop(): void; /** * Send a position from an app-owned GPS engine. * By default returns after the message is queued/sent; set `waitForAck` to await server confirmation. */ send(position: GpsManualPositionPayload, extra?: any, options?: GpsSendOptions): Promise; /** Listen to GPS updates for the configured slice/field */ listen(callback: GpsListener, options?: GpsListenOptions): Unsubscribe; private bindResumeEvents; private clearAckResolvers; private connectSocket; private onSocketMessage; private createId; private flushPendingPayloads; private getClientDetails; private getOrCreateDeviceId; private getTrackingId; private isFresh; private metersBetween; private normalizeNullableNumber; private normalizeOptionalNumber; private normalizePosition; private onPosition; private onPositionError; private restartWatch; private sendPayload; private sendPosition; private serializePosition; private shouldSendPosition; private startHeartbeat; private startWatch; private startWatchdog; private startWhenAuthenticated; } //# sourceMappingURL=gps.d.ts.map