1+ import type { Theme } from '~types/types' ;
2+
13export const SETTINGS = 'devtools-settings' ;
24export const DEVTOOLS_THEME = 'devtools-theme' ;
35export const DEVTOOLS_FONT = 'devtools-font' ;
@@ -7,9 +9,18 @@ export const DEVTOOLS_ACCENT_COLOR = 'devtools-accent-color';
79export const DEVTOOLS_SCROLLBARS = 'devtools-scrollbars' ;
810
911const chromeStorage = chrome . storage && chrome . storage . sync ;
10- const fakeStorage = {
1112
12- async get ( property , fn = ( ) => { } ) {
13+ export type DevtoolsSettings = {
14+ [ DEVTOOLS_THEME ] ?: string ;
15+ [ DEVTOOLS_FONT ] ?: string ;
16+ [ DEVTOOLS_SIZE ] ?: number ;
17+ [ DEVTOOLS_CURRENT ] ?: Theme ;
18+ [ DEVTOOLS_ACCENT_COLOR ] ?: string ;
19+ [ DEVTOOLS_SCROLLBARS ] ?: boolean ;
20+ } ;
21+
22+ const fakeStorage = {
23+ async get ( property : string , fn = ( object : DevtoolsSettings ) => { } ) {
1324 let item = await localStorage . getItem ( SETTINGS ) ;
1425 try {
1526 const settings = item ? JSON . parse ( item ) : { } ;
@@ -19,14 +30,14 @@ const fakeStorage = {
1930 }
2031 } ,
2132
22- set ( settings , fn = ( ) => { } ) {
33+ set ( settings : DevtoolsSettings , fn = ( object : DevtoolsSettings ) => { } ) {
2334 let oldItem = localStorage . getItem ( SETTINGS ) || '{}' ;
2435 try {
2536 const oldSettings = JSON . parse ( oldItem ) ;
26- const newSettings = { ...oldSettings , ...settings } ;
37+ const newSettings = { ...oldSettings , ...settings } ;
2738
2839 if ( chromeStorage ) {
29- chromeStorage . set ( { [ SETTINGS ] : JSON . stringify ( newSettings ) } , ( ) => { } ) ;
40+ chromeStorage . set ( { [ SETTINGS ] : JSON . stringify ( newSettings ) } , ( ) => { } ) ;
3041 }
3142 localStorage . setItem ( SETTINGS , JSON . stringify ( newSettings ) ) ;
3243 fn ( settings ) ;
0 commit comments