@@ -47,23 +47,23 @@ interface Config extends LocalConfig {
4747
4848export default class ConfigManager {
4949 private static DARK_SITES_INDEX : SiteListIndex | null ;
50- static DYNAMIC_THEME_FIXES_INDEX : SitePropsIndex < DynamicThemeFix > | null ;
51- static DYNAMIC_THEME_FIXES_RAW : string | null ;
52- static INVERSION_FIXES_INDEX : SitePropsIndex < InversionFix > | null ;
53- static INVERSION_FIXES_RAW : string | null ;
54- static STATIC_THEMES_INDEX : SitePropsIndex < StaticTheme > | null ;
55- static STATIC_THEMES_RAW : string | null ;
56- static COLOR_SCHEMES_RAW : ParsedColorSchemeConfig | null ;
57-
58- static raw = {
50+ public static DYNAMIC_THEME_FIXES_INDEX : SitePropsIndex < DynamicThemeFix > | null ;
51+ public static DYNAMIC_THEME_FIXES_RAW : string | null ;
52+ public static INVERSION_FIXES_INDEX : SitePropsIndex < InversionFix > | null ;
53+ public static INVERSION_FIXES_RAW : string | null ;
54+ public static STATIC_THEMES_INDEX : SitePropsIndex < StaticTheme > | null ;
55+ public static STATIC_THEMES_RAW : string | null ;
56+ public static COLOR_SCHEMES_RAW : ParsedColorSchemeConfig | null ;
57+
58+ public static raw = {
5959 darkSites : null as string | null ,
6060 dynamicThemeFixes : null as string | null ,
6161 inversionFixes : null as string | null ,
6262 staticThemes : null as string | null ,
6363 colorSchemes : null as string | null ,
6464 } ;
6565
66- static overrides = {
66+ public static overrides = {
6767 darkSites : null as string | null ,
6868 dynamicThemeFixes : null as string | null ,
6969 inversionFixes : null as string | null ,
@@ -95,61 +95,61 @@ export default class ConfigManager {
9595 }
9696
9797 private static async loadColorSchemes ( { local} : LocalConfig ) {
98- const $config = await this . loadConfig ( {
98+ const $config = await ConfigManager . loadConfig ( {
9999 name : 'Color Schemes' ,
100100 local,
101101 localURL : CONFIG_URLs . colorSchemes . local ,
102102 remoteURL : CONFIG_URLs . colorSchemes . remote ,
103103 } ) ;
104- this . raw . colorSchemes = $config ;
105- this . handleColorSchemes ( ) ;
104+ ConfigManager . raw . colorSchemes = $config ;
105+ ConfigManager . handleColorSchemes ( ) ;
106106 }
107107
108108 private static async loadDarkSites ( { local} : LocalConfig ) {
109- const sites = await this . loadConfig ( {
109+ const sites = await ConfigManager . loadConfig ( {
110110 name : 'Dark Sites' ,
111111 local,
112112 localURL : CONFIG_URLs . darkSites . local ,
113113 remoteURL : CONFIG_URLs . darkSites . remote ,
114114 } ) ;
115- this . raw . darkSites = sites ;
116- this . handleDarkSites ( ) ;
115+ ConfigManager . raw . darkSites = sites ;
116+ ConfigManager . handleDarkSites ( ) ;
117117 }
118118
119119 private static async loadDynamicThemeFixes ( { local} : LocalConfig ) {
120- const fixes = await this . loadConfig ( {
120+ const fixes = await ConfigManager . loadConfig ( {
121121 name : 'Dynamic Theme Fixes' ,
122122 local,
123123 localURL : CONFIG_URLs . dynamicThemeFixes . local ,
124124 remoteURL : CONFIG_URLs . dynamicThemeFixes . remote ,
125125 } ) ;
126- this . raw . dynamicThemeFixes = fixes ;
127- this . handleDynamicThemeFixes ( ) ;
126+ ConfigManager . raw . dynamicThemeFixes = fixes ;
127+ ConfigManager . handleDynamicThemeFixes ( ) ;
128128 }
129129
130130 private static async loadInversionFixes ( { local} : LocalConfig ) {
131- const fixes = await this . loadConfig ( {
131+ const fixes = await ConfigManager . loadConfig ( {
132132 name : 'Inversion Fixes' ,
133133 local,
134134 localURL : CONFIG_URLs . inversionFixes . local ,
135135 remoteURL : CONFIG_URLs . inversionFixes . remote ,
136136 } ) ;
137- this . raw . inversionFixes = fixes ;
138- this . handleInversionFixes ( ) ;
137+ ConfigManager . raw . inversionFixes = fixes ;
138+ ConfigManager . handleInversionFixes ( ) ;
139139 }
140140
141141 private static async loadStaticThemes ( { local} : LocalConfig ) {
142- const themes = await this . loadConfig ( {
142+ const themes = await ConfigManager . loadConfig ( {
143143 name : 'Static Themes' ,
144144 local,
145145 localURL : CONFIG_URLs . staticThemes . local ,
146146 remoteURL : CONFIG_URLs . staticThemes . remote ,
147147 } ) ;
148- this . raw . staticThemes = themes ;
149- this . handleStaticThemes ( ) ;
148+ ConfigManager . raw . staticThemes = themes ;
149+ ConfigManager . handleStaticThemes ( ) ;
150150 }
151151
152- static async load ( config ?: LocalConfig ) {
152+ public static async load ( config ?: LocalConfig ) {
153153 if ( ! config ) {
154154 await UserStorage . loadSettings ( ) ;
155155 config = {
@@ -158,49 +158,49 @@ export default class ConfigManager {
158158 }
159159
160160 await Promise . all ( [
161- this . loadColorSchemes ( config ) ,
162- this . loadDarkSites ( config ) ,
163- this . loadDynamicThemeFixes ( config ) ,
164- this . loadInversionFixes ( config ) ,
165- this . loadStaticThemes ( config ) ,
161+ ConfigManager . loadColorSchemes ( config ) ,
162+ ConfigManager . loadDarkSites ( config ) ,
163+ ConfigManager . loadDynamicThemeFixes ( config ) ,
164+ ConfigManager . loadInversionFixes ( config ) ,
165+ ConfigManager . loadStaticThemes ( config ) ,
166166 ] ) . catch ( ( err ) => console . error ( 'Fatality' , err ) ) ;
167167 }
168168
169169 private static handleColorSchemes ( ) {
170- const $config = this . raw . colorSchemes ;
170+ const $config = ConfigManager . raw . colorSchemes ;
171171 const { result, error} = ParseColorSchemeConfig ( $config || '' ) ;
172172 if ( error ) {
173173 logWarn ( `Color Schemes parse error, defaulting to fallback. ${ error } .` ) ;
174- this . COLOR_SCHEMES_RAW = DEFAULT_COLORSCHEME ;
174+ ConfigManager . COLOR_SCHEMES_RAW = DEFAULT_COLORSCHEME ;
175175 return ;
176176 }
177- this . COLOR_SCHEMES_RAW = result ;
177+ ConfigManager . COLOR_SCHEMES_RAW = result ;
178178 }
179179
180180 private static handleDarkSites ( ) {
181- const $sites = this . overrides . darkSites || this . raw . darkSites ;
182- this . DARK_SITES_INDEX = indexSiteListConfig ( $sites || '' ) ;
181+ const $sites = ConfigManager . overrides . darkSites || ConfigManager . raw . darkSites ;
182+ ConfigManager . DARK_SITES_INDEX = indexSiteListConfig ( $sites || '' ) ;
183183 }
184184
185- static handleDynamicThemeFixes ( ) {
186- const $fixes = this . overrides . dynamicThemeFixes || this . raw . dynamicThemeFixes || '' ;
187- this . DYNAMIC_THEME_FIXES_INDEX = indexSitesFixesConfig < DynamicThemeFix > ( $fixes ) ;
188- this . DYNAMIC_THEME_FIXES_RAW = $fixes ;
185+ public static handleDynamicThemeFixes ( ) {
186+ const $fixes = ConfigManager . overrides . dynamicThemeFixes || ConfigManager . raw . dynamicThemeFixes || '' ;
187+ ConfigManager . DYNAMIC_THEME_FIXES_INDEX = indexSitesFixesConfig < DynamicThemeFix > ( $fixes ) ;
188+ ConfigManager . DYNAMIC_THEME_FIXES_RAW = $fixes ;
189189 }
190190
191- static handleInversionFixes ( ) {
192- const $fixes = this . overrides . inversionFixes || this . raw . inversionFixes || '' ;
193- this . INVERSION_FIXES_INDEX = indexSitesFixesConfig < InversionFix > ( $fixes ) ;
194- this . INVERSION_FIXES_RAW = $fixes ;
191+ public static handleInversionFixes ( ) {
192+ const $fixes = ConfigManager . overrides . inversionFixes || ConfigManager . raw . inversionFixes || '' ;
193+ ConfigManager . INVERSION_FIXES_INDEX = indexSitesFixesConfig < InversionFix > ( $fixes ) ;
194+ ConfigManager . INVERSION_FIXES_RAW = $fixes ;
195195 }
196196
197- static handleStaticThemes ( ) {
198- const $themes = this . overrides . staticThemes || this . raw . staticThemes || '' ;
199- this . STATIC_THEMES_INDEX = indexSitesFixesConfig < StaticTheme > ( $themes ) ;
200- this . STATIC_THEMES_RAW = $themes ;
197+ public static handleStaticThemes ( ) {
198+ const $themes = ConfigManager . overrides . staticThemes || ConfigManager . raw . staticThemes || '' ;
199+ ConfigManager . STATIC_THEMES_INDEX = indexSitesFixesConfig < StaticTheme > ( $themes ) ;
200+ ConfigManager . STATIC_THEMES_RAW = $themes ;
201201 }
202202
203- static isURLInDarkList ( url : string ) : boolean {
203+ public static isURLInDarkList ( url : string ) : boolean {
204204 return isURLInSiteList ( url , ConfigManager . DARK_SITES_INDEX ) ;
205205 }
206206}
0 commit comments