-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.d.ts
156 lines (143 loc) · 9.22 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
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<S>(key: string, initialValue: S | (() => S)): [S, Dispatch<SetStateAction<S>>, 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<S = undefined>(key: string): [S | undefined, Dispatch<SetStateAction<S | undefined>>, 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<S>(key: string, initialValue: S | (() => S)): [S, Dispatch<SetStateAction<S>>, 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<S = undefined>(key: string): [S | undefined, Dispatch<SetStateAction<S | undefined>>, 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<S>(key: string, initialValue: S | (() => S)): [S, Dispatch<SetStateAction<S>>, 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<S = undefined>(key: string): [S | undefined, Dispatch<SetStateAction<S | undefined>>, 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<S>(key: string, initialValue: S | (() => S)): () => [S, Dispatch<SetStateAction<S>>, 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<S = undefined>(key: string): () => [S | undefined, Dispatch<SetStateAction<S | undefined>>, 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<S>(key: string, initialValue: S | (() => S)): () => [S, Dispatch<SetStateAction<S>>, 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<S = undefined>(key: string): () => [S | undefined, Dispatch<SetStateAction<S | undefined>>, 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<S>(key: string, initialValue: S | (() => S)): () => [S, Dispatch<SetStateAction<S>>, 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<S = undefined>(key: string): () => [S | undefined, Dispatch<SetStateAction<S | undefined>>, boolean, string, boolean];
}