import { CacheableTile, CachedTile } from './CacheableTile.js'; import { FetchableTile } from './FetchableTile.js'; import { FetchFn } from '@allmaps/types'; import { CacheableTileFactory, TileCacheOptions, MapPruneInfo } from '../shared/types.js'; /** * Class that fetches and caches IIIF tiles. */ export declare class TileCache extends EventTarget { #private; cacheableTileFactory: CacheableTileFactory; fetchFn?: FetchFn; tileCacheForTilesFromSprites?: TileCache; protected tilesByTileUrl: Map>; protected mapIdsByTileUrl: Map>; protected tileUrlsByMapId: Map>; protected tilesFetchingCount: number; protected tileRemoveQueue: { tileUrl: string; mapId: string; }[]; protected fetchableTiles: FetchableTile[]; constructor(cacheableTileFactory: CacheableTileFactory, partialTileCacheOptions?: Partial>); /** * Get the tiles in this cache * * @returns */ getCacheableTiles(): IterableIterator>; /** * Get a specific tile in this cache * * @param tileUrl - the URL of the requested tile * @returns */ getCacheableTile(tileUrl: string): CacheableTile | undefined; /** * Get the tiles in this cache, corresponding to a specific map * * @param mapId - ID of the map * @returns */ getMapCacheableTiles(mapId: string): CacheableTile[]; /** * Get the tiles in this cache that have been fetched * * @returns */ getCachedTiles(): CachedTile[]; /** * Get a specific cached tile in this cache that has been fetched * * @param tileUrl - the URL of the requested tile * @returns */ getCachedTile(tileUrl: string): CachedTile | undefined; /** * Get the tiles in this cache, corresponding to a specific map, that have been fetched * * @param mapId - ID of the map * @returns */ getMapCachedTiles(mapId: string): CachedTile[]; /** * Get the URLs of tiles in this cache * * @returns */ getTileUrls(): IterableIterator; /** * Get the URLs of tiles in this cache, corresponding to a specific map * * @param mapId - ID of the map * @returns */ getMapTileUrls(mapId: string): Set; /** * Get the Tile Cache options * * @param partialTileCacheOptions - Options */ setOptions(partialTileCacheOptions?: Partial>): void; /** * Process the request for new tiles to be added to this cache * * @param fetchableTiles */ requestFetchableTiles(fetchableTiles: FetchableTile[]): void; /** * Returns a promise that resolves when all requested tiles are loaded. * This could happen immidiately, in case there are no ongoing requests and the tilesFetchingCount is zero, * or in a while, when the count reaches zero and the ALLREQUESTEDTILESLOADED event is fired. */ allRequestedTilesLoaded(): Promise; /** * Prune tiles in this cache using the provided prune info */ prune(pruneInfoByMapId: Map): void; clear(): void; destroy(): void; protected requestFetchableTile(fetchableTile: FetchableTile): void; protected addCacheableTile(cacheableTile: CacheableTile): void; addCachedTile(cachedTile: CachedTile): void; protected delayedRemoveCacheableTileForMapId(tileUrl: string, mapId: string): void; protected cancelDelayedRemoveCacheableTileForMapId(tileUrl: string, mapId: string): void; protected removeCacheableTileForMapId(tileUrl: string, mapId: string): void; protected tileFetched(event: Event): void; protected tileFetchError(event: Event): void; protected tilesFromSpriteTile(event: Event): void; protected passTilesFromSprites(tileUrl?: string): void; protected addMapIdForTileUrl(mapId: string, tileUrl: string): Set; protected removeMapIdForTileUrl(mapId: string, tileUrl: string): Set; protected addTileUrlForMapId(tileUrl: string, mapId: string): Set; protected removeTileUrlForMapId(tileUrl: string, mapId: string): Set; get finished(): boolean; protected updateTilesFetchingCount(delta: number): void; protected addEventListenersToCacheableTile(cacheableTile: CacheableTile): void; protected removeEventListenersFromCacheableTile(cacheableTile: CacheableTile): void; }