UNPKG

@independo/leaflet-independo-maps

Version:

Leaflet plugin for displaying points of interest as pictograms.

72 lines (71 loc) 2.72 kB
import { Pictogram } from "../../models/pictogram"; import { PointOfInterest } from "../../models/point-of-interest"; import { PictogramService } from "../pictogram-service"; /** * @description Options for configuring the GlobalSymbolsPictogramService. * @see https://globalsymbols.com/api/docs Global Symbols API documentation */ export interface GlobalSymbolsPictogramServiceOptions { /** * @description The base URL of the Global Symbols API endpoint. * @default "https://globalsymbols.com/api/v1/concepts/suggest". */ apiUrl?: string; /** * @description The symbol set the pictogram should be fetched from. * @default "arasaac" * @remarks Examples: `"arasaac"`, `"sclera"`, `"blissymbols"`, etc. * @see https://globalsymbols.com/api/docs Global Symbols API documentation * @see https://globalsymbols.com/api/v1/symbolsets GET all available symbol sets */ symbolSet?: string; /** * @description Include the type of the point of interest in the display text of the pictogram. * @default false */ includeTypeInDisplayText?: boolean; /** * @description Include the type of the point of interest in the aria label of the pictogram. * @default true */ includeTypeInAriaLabel?: boolean; /** * @description Cache strategy: "in-memory" (in-memory caching) or "local-storage" (persistent caching). * @default "local-storage" */ cacheStrategy?: "in-memory" | "local-storage"; /** * @description Cache expiration time in milliseconds. * @default 604800000 (1 week) */ cacheExpiration?: number; /** * @description Cache prefix for the local storage cache. * @default "global-symbols-pictogram-service" * @remarks This is used to avoid conflicts with other local storage items. */ cachePrefix?: string; } export declare class GlobalSymbolsPictogramService implements PictogramService { private readonly apiUrl; private readonly symbolSet; private readonly includeTypeInDisplayText; private readonly includeTypeInAriaLabel; private readonly cacheStrategy; private readonly cacheExpiration; private readonly cachePrefix; private memoryCache; constructor(options?: GlobalSymbolsPictogramServiceOptions); /** @inheritDoc */ getPictogram(poi: PointOfInterest): Promise<Pictogram | undefined>; private constructPictogram; private getCacheKey; private getFromCache; private saveToCache; /** * Cleans up expired items in `localStorage`. * * This method iterates over all keys in `localStorage` and removes any expired cache entries. */ private cleanupLocalStorage; }