UNPKG

@mirawision/chrome-api

Version:

A comprehensive TypeScript library for Chrome Extension API, providing type-safe wrappers and utilities for bookmarks, commands, context menus, cookies, downloads, storage, notifications, runtime, scripting, and side panel functionalities.

53 lines (52 loc) 2.06 kB
interface Storage { [key: string]: any; } /** * A class that provides a type-safe wrapper around Chrome's local storage API. * This class allows you to store, retrieve, and manage data in the browser's local storage. * Local storage is persistent and can store larger amounts of data compared to session storage. */ declare class LocalStorage { /** * Retrieves a value from local storage by key. * @param key - The key to retrieve * @returns A promise that resolves to the stored value for the specified key * @throws {Error} If there's an error retrieving the data */ static get<T = any>(key: string): Promise<T>; /** * Retrieves all data from local storage. * @returns A promise that resolves to all stored data * @throws {Error} If there's an error retrieving the data */ static getAll(): Promise<Storage>; /** * Stores a value in local storage. * @param key - The key under which to store the value * @param value - The value to store * @returns A promise that resolves when the value is stored * @throws {Error} If there's an error storing the data */ static set(key: string, value: any): Promise<void>; /** * Stores multiple key-value pairs in local storage. * @param data - An object containing the key-value pairs to store * @returns A promise that resolves when all values are stored * @throws {Error} If there's an error storing the data */ static setBulk(data: Storage): Promise<void>; /** * Removes a value from local storage. * @param key - The key to remove * @returns A promise that resolves when the value is removed * @throws {Error} If there's an error removing the data */ static remove(key: string): Promise<void>; /** * Removes all data from local storage. * @returns A promise that resolves when all data is cleared * @throws {Error} If there's an error clearing the data */ static clear(): Promise<void>; } export { LocalStorage, Storage };