import {Dispatch, SetStateAction} from 'react'; export = useChromeStorage; export as namespace useChromeStorage; declare namespace useChromeStorage { /** * Hook which will use `chrome.storage.local` to persist state. * * @param {string} key - they key name in chrome's storage. Nested keys not supported * @param {*} [initialValue] - default value to use * @returns {[any, (value: any) => void, boolean, string, boolean]} - array of * stateful `value`, * function to update this `value`, * `isPersistent` - will be `false` if error occurred during reading/writing chrome.storage, * `error` - will contain error appeared in storage. if isPersistent is true will be empty string * `isInitialStateResolved` - will set to `true` once `initialValue` will be replaced with stored in chrome.storage */ function useChromeStorageLocal(key: string, initialValue: S | (() => S)): [S, Dispatch>, boolean, string, boolean]; // convenience overload when initialValue is omitted /** * Hook which will use `chrome.storage.local` to persist state. * * @param {string} key - they key name in chrome's storage. Nested keys not supported * @param {*} [initialValue] - default value to use * @returns {[any, (value: any) => void, boolean, string, boolean]} - array of * stateful `value`, * function to update this `value`, * `isPersistent` - will be `false` if error occurred during reading/writing chrome.storage, * `error` - will contain error appeared in storage. if isPersistent is true will be empty string * `isInitialStateResolved` - will set to `true` once `initialValue` will be replaced with stored in chrome.storage */ function useChromeStorageLocal(key: string): [S | undefined, Dispatch>, boolean, string, boolean]; /** * Hook which will use `chrome.storage.sync` to persist state. * * @param {string} key - they key name in chrome's storage. Nested keys not supported * @param {*} [initialValue] - default value to use * @returns {[any, (value: any) => void, boolean, string, boolean]} - array of * stateful `value`, * function to update this `value`, * `isPersistent` - will be `false` if error occurred during reading/writing chrome.storage, * `error` - will contain error appeared in storage. if isPersistent is true will be empty string * `isInitialStateResolved` - will set to `true` once `initialValue` will be replaced with stored in chrome.storage */ function useChromeStorageSync(key: string, initialValue: S | (() => S)): [S, Dispatch>, boolean, string, boolean]; // convenience overload when initialValue is omitted /** * Hook which will use `chrome.storage.sync` to persist state. * * @param {string} key - they key name in chrome's storage. Nested keys not supported * @param {*} [initialValue] - default value to use * @returns {[any, (value: any) => void, boolean, string, boolean]} - array of * stateful `value`, * function to update this `value`, * `isPersistent` - will be `false` if error occurred during reading/writing chrome.storage, * `error` - will contain error appeared in storage. if isPersistent is true will be empty string * `isInitialStateResolved` - will set to `true` once `initialValue` will be replaced with stored in chrome.storage */ function useChromeStorageSync(key: string): [S | undefined, Dispatch>, boolean, string, boolean]; /** * Hook which will use `chrome.storage.session` to persist state. * * @param {string} key - they key name in chrome's storage. Nested keys not supported * @param {*} [initialValue] - default value to use * @returns {[any, (value: any) => void, boolean, string, boolean]} - array of * stateful `value`, * function to update this `value`, * `isPersistent` - will be `false` if error occurred during reading/writing chrome.storage, * `error` - will contain error appeared in storage. if isPersistent is true will be empty string * `isInitialStateResolved` - will set to `true` once `initialValue` will be replaced with stored in chrome.storage */ function useChromeStorageSession(key: string, initialValue: S | (() => S)): [S, Dispatch>, boolean, string, boolean]; // convenience overload when initialValue is omitted /** * Hook which will use `chrome.storage.session` to persist state. * * @param {string} key - they key name in chrome's storage. Nested keys not supported * @param {*} [initialValue] - default value to use * @returns {[any, (value: any) => void, boolean, string, boolean]} - array of * stateful `value`, * function to update this `value`, * `isPersistent` - will be `false` if error occurred during reading/writing chrome.storage, * `error` - will contain error appeared in storage. if isPersistent is true will be empty string * `isInitialStateResolved` - will set to `true` once `initialValue` will be replaced with stored in chrome.storage */ function useChromeStorageSession(key: string): [S | undefined, Dispatch>, boolean, string, boolean]; /** * Use to create state with chrome.storage.local. * Useful if you want to reuse same state across components and/or context (like in popup, content script, background pages) * * @param {string} key - they key name in chrome's storage. Nested keys not supported * @param {*} [initialValue] - default value to use * @returns {function(): [any, (value: any) => void, boolean, string, boolean]} */ function createChromeStorageStateHookLocal(key: string, initialValue: S | (() => S)): () => [S, Dispatch>, boolean, string, boolean]; // convenience overload when initialValue is omitted /** * Use to create state with chrome.storage.local. * Useful if you want to reuse same state across components and/or context (like in popup, content script, background pages) * * @param {string} key - they key name in chrome's storage. Nested keys not supported * @param {*} [initialValue] - default value to use * @returns {function(): [any, (value: any) => void, boolean, string, boolean]} */ function createChromeStorageStateHookLocal(key: string): () => [S | undefined, Dispatch>, boolean, string, boolean]; /** * Use to create state with chrome.storage.sync. * Useful if you want to reuse same state across components and/or context (like in popup, content script, background pages) * * @param {string} key - they key name in chrome's storage. Nested keys not supported * @param {*} [initialValue] - default value to use * @returns {function(): [any, (value: any) => void, boolean, string, boolean]} */ function createChromeStorageStateHookSync(key: string, initialValue: S | (() => S)): () => [S, Dispatch>, boolean, string, boolean]; // convenience overload when initialValue is omitted /** * Use to create state with chrome.storage.sync. * Useful if you want to reuse same state across components and/or context (like in popup, content script, background pages) * * @param {string} key - they key name in chrome's storage. Nested keys not supported * @param {*} [initialValue] - default value to use * @returns {function(): [any, (value: any) => void, boolean, string, boolean]} */ function createChromeStorageStateHookSync(key: string): () => [S | undefined, Dispatch>, boolean, string, boolean]; /** * Use to create state with chrome.storage.session. * Useful if you want to reuse same state across components and/or context (like in popup, content script, background pages) * * @param {string} key - they key name in chrome's storage. Nested keys not supported * @param {*} [initialValue] - default value to use * @returns {function(): [any, (value: any) => void, boolean, string, boolean]} */ function createChromeStorageStateHookSession(key: string, initialValue: S | (() => S)): () => [S, Dispatch>, boolean, string, boolean]; // convenience overload when initialValue is omitted /** * Use to create state with chrome.storage.session. * Useful if you want to reuse same state across components and/or context (like in popup, content script, background pages) * * @param {string} key - they key name in chrome's storage. Nested keys not supported * @param {*} [initialValue] - default value to use * @returns {function(): [any, (value: any) => void, boolean, string, boolean]} */ function createChromeStorageStateHookSession(key: string): () => [S | undefined, Dispatch>, boolean, string, boolean]; }