import type { UrlMap } from 'util/index.js'; import type { Analytics } from 'style/style.spec.js'; /** A Session manager object */ interface SessionKey { apiKey?: string; token?: string; exp?: number; } /** * Session Manager * * Keep up to date with API keys and session tokens */ export default class Session { analytics?: Analytics; sessionKeys: Record; workers: Array; currWorker: number; totalWorkers: number; sessionPromise?: Promise; /** * Load a style via a URL, sending off analytics and utilizing the apiKey if needed * @param mapID - the id of the map * @param analytics - basic analytics about the GPU and screen dimensions * @param apiKey - the api key if needed */ loadStyle(mapID: string, analytics: Analytics, apiKey?: string): void; /** * Load a worker * @param _messagePort - unused * @param postPort - the port for a worker to send session messages to * @param id - the id of the worker */ loadWorker(_messagePort: MessageChannel['port1'], postPort: MessageChannel['port2'], id: number): void; /** * Request a worker to process data * @returns the port for the worker */ requestWorker(): MessagePort; /** * Check if the map has an API key * @param mapID - the id of the map * @returns true if the map has an API key */ hasAPIKey(mapID: string): boolean; /** * Request a style from the server * @param mapID - the id of the map * @param style - the style url * @param urlMap - the url map to properly modify and resolve urls */ requestStyle(mapID: string, style: string, urlMap?: UrlMap): Promise; /** * Request a session token from the server to start fetching data * @param mapID - the id of the map * @returns the session token if available and/or successful */ requestSessionToken(mapID: string): Promise; } export {};