UNPKG

s2maps-gpu

Version:

S2 Maps GPU - An open source, high-performance, and GPU-accelerated map engine for rendering large-scale, interactive maps.

61 lines (60 loc) 2.06 kB
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<string, SessionKey>; workers: Array<MessageChannel['port2']>; currWorker: number; totalWorkers: number; sessionPromise?: Promise<SessionKey | undefined>; /** * 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<void>; /** * 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<string | undefined | 'failed'>; } export {};