GeoLeaf Core API - v3.0.0
    Preparing search index...
    CacheStorage: {
        loadProfileConfig(profileId: string): Promise<Record<string, unknown>>;
        loadLayerSelection(profileId: string): Promise<LayerSelection | null>;
        saveLayerSelection(
            profileId: string,
            selection: LayerSelection,
        ): Promise<void>;
        saveManifest(profileId: string, results: ManifestResults): Promise<void>;
        getManifest(profileId: string): Promise<Record<string, unknown> | null>;
        deleteManifest(profileId: string): Promise<void>;
        getCacheStatus(profileId: string): Promise<Record<string, unknown> | null>;
        getCachedProfiles(): Promise<string[]>;
        getCachedUrls(profileId: string): Promise<Set<string>>;
        clearCache(profileId: string): Promise<number>;
    } = ...

    Type Declaration

    • loadProfileConfig: function
      • Loads a profile's configuration from its profile.json.

        Parameters

        • profileId: string

          Profile ID

        Returns Promise<Record<string, unknown>>

        Profile configuration

        If the profile does not exist or cannot be loaded

        const profile = await GeoLeaf.Storage.Cache.Storage.loadProfileConfig('tourism');
        
    • loadLayerSelection: function
      • Loads the layer-selection preferences from IndexedDB. Tells the enumerator which layers and basemaps are to be cached.

        Parameters

        • profileId: string

          Profile ID

        Returns Promise<LayerSelection | null>

        Layer selection {layers: [], basemaps: [], layerStyles: {}, timestamp: number}

        const selection = await GeoLeaf.Storage.Cache.Storage.loadLayerSelection('tourism');
        if (selection) {
        console.log(`Selected layers: ${selection.layers.join(', ')}`);
        }
    • saveLayerSelection: function
      • Saves the layer-selection preferences into IndexedDB.

        Parameters

        • profileId: string

          Profile ID

        • selection: LayerSelection

          Selection to persist

          • layers

            IDs of the selected layers

          • basemaps

            IDs of the selected basemaps

          • layerStyles

            Selected style per layer

        Returns Promise<void>

        await GeoLeaf.Storage.Cache.Storage.saveLayerSelection('tourism', {
        layers: ['layer1', 'layer2'],
        basemaps: ['osm'],
        layerStyles: { 'layer1': 'default' }
        });
    • saveManifest: function
      • Saves the cache manifest into IndexedDB. The manifest holds the list of cached resources plus the run's metadata.

        Parameters

        • profileId: string

          Profile ID

        • results: ManifestResults

          Cache run results

          • cached

            URLs of the cached resources

          • failed

            Resources that failed

          • totalSize

            Total size in bytes

          • resourcesCount

            Resource count

          • duration

            Download duration in ms

        Returns Promise<void>

        await GeoLeaf.Storage.Cache.Storage.saveManifest('tourism', {
        cached: ['url1', 'url2'],
        failed: [],
        totalSize: 1024000,
        resourcesCount: 10,
        duration: 5000
        });
    • getManifest: function
      • Retrieves a profile's cache manifest.

        Parameters

        • profileId: string

          Profile ID

        Returns Promise<Record<string, unknown> | null>

        The manifest, or null when absent

        const manifest = await GeoLeaf.Storage.Cache.Storage.getManifest('tourism');
        if (manifest) {
        console.log(`Cached at: ${manifest.generatedAt}`);
        }
    • deleteManifest: function
      • Deletes a profile's cache manifest.

        Parameters

        • profileId: string

          Profile ID

        Returns Promise<void>

        await GeoLeaf.Storage.Cache.Storage.deleteManifest('tourism');
        
    • getCacheStatus: function
      • Returns a profile's cache status, i.e. its manifest (date, size, resource count).

        Parameters

        • profileId: string

          Profile ID

        Returns Promise<Record<string, unknown> | null>

        Cache status, or null when the profile is not cached

        const status = await GeoLeaf.Storage.Cache.Storage.getCacheStatus('tourism');
        if (status) {
        console.log(`Cached at: ${status.generatedAt}, ${status.resourcesCount} resources`);
        }
    • getCachedProfiles: function
      • Lists every cached profile.

        Returns Promise<string[]>

        IDs of the cached profiles

        const profiles = await GeoLeaf.Storage.Cache.Storage.getCachedProfiles();
        console.log(`Cached profiles: ${profiles.join(', ')}`);
    • getCachedUrls: function
      • Returns the URLs already cached for a profile. Walks the "layers" object store to build the Set.

        Parameters

        • profileId: string

          Profile ID

        Returns Promise<Set<string>>

        Set of cached URLs

        const urls = await GeoLeaf.Storage.Cache.Storage.getCachedUrls('tourism');
        console.log(`${urls.size} URLs in cache`);
    • clearCache: function
      • Clears a profile's cache: its layers in IndexedDB, its manifest, and its Service Worker Cache API buckets.

        Parameters

        • profileId: string

          Profile ID

        Returns Promise<number>

        Number of deleted resources

        const deleted = await GeoLeaf.Storage.Cache.Storage.clearCache('tourism');
        console.log(`Deleted ${deleted} cached resources`);