UNPKG

vue-persistent-storage-manager

Version:

Vue plugin that wraps the StorageManager API and provides the state of the persistent-storage permission alongside a storage estimate.

63 lines (62 loc) 1.96 kB
import { PluginFunction } from 'vue'; /** * Options for the VuePersistentStorageManager plugin. */ export interface PluginOptions { /** * If true, localStorage.setItem and localStorage.removeItem will be replaced with custom functions. */ watchStorage: boolean; } /** * Wrapper for the StorageManager API. Provides the state of the persistent-storage permission alongside a storage estimate. */ export declare class VuePersistentStorageManager { /** * Indicates that the StorageManager API is available. */ readonly isAvailable: boolean; /** * Contains storage quota and usage information. */ readonly storageEstimate: StorageEstimate; private _isPersistent; /** * Installs a VuePersistentStorageManager as a Vue plugin. */ static install: PluginFunction<PluginOptions>; /** * Creates a new VuePersistentStorageManager instance. */ constructor(); /** * Indicates that persistence of localStorage has been granted. */ get isPersistent(): boolean; /** * Requests persistence of localStorage. * @returns a Promise that resolves to true if permission has been granted. */ requestPersistentStorage(): Promise<boolean>; private _refreshIsPersistent; private _refreshStorageEstimate; private _modifyLocalStorageFunctions; } declare module 'vue/types/vue' { interface Vue { /** * Wrapper for the StorageManager API. Provides the state of the persistent-storage permission alongside a storage estimate. */ $storageManager: VuePersistentStorageManager; /** * Contains storage quota and usage information. */ $storageEstimate: StorageEstimate; } } declare global { interface Storage { originalSetItem?: ((key: string, value: string) => void) | undefined; originalRemoveItem?: ((key: string) => void) | undefined; } }