Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 1 | import DependenciesProviderSingleton, { |
| 2 | AutoRefreshDependency, |
| 3 | } from '../../../common/architecture/dependenciesProvider/DependenciesProvider'; |
| 4 | import { Context } from '../../../common/architecture/entrypoint/Context'; |
| 5 | import { |
| 6 | ScriptEnvironment, |
| 7 | ScriptPage, |
| 8 | ScriptRunPhase, |
| 9 | } from '../../../common/architecture/scripts/Script'; |
| 10 | import AutoRefreshSetUpScript from '../../../features/autoRefresh/presentation/scripts/setUp.script'; |
| 11 | import Features from '../../../features/Features'; |
| 12 | import ScriptRunner from '../../../infrastructure/presentation/scripts/ScriptRunner'; |
| 13 | import ScriptSorterAdapter from '../../../infrastructure/presentation/scripts/ScriptSorter.adapter'; |
| 14 | import { SortedScriptsProviderAdapter } from '../../../infrastructure/presentation/scripts/SortedScriptsProvider.adapter'; |
| 15 | import StandaloneScripts from '../../../scripts/Scripts'; |
| 16 | |
| 17 | // Run legacy Javascript entry point |
| 18 | import '../../../contentScripts/communityConsole/start'; |
Adrià Vilanova Martínez | 6ecaa0d | 2024-10-26 17:04:32 +0200 | [diff] [blame^] | 19 | import CCDarkThemeInjectAutoDarkTheme from '../../../features/ccDarkTheme/scripts/injectAutoDarkTheme.script'; |
| 20 | import CCDarkThemeInjectForcedDarkTheme from '../../../features/ccDarkTheme/scripts/injectForcedDarkTheme.script'; |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 21 | |
| 22 | const scriptRunner = createScriptRunner(); |
| 23 | scriptRunner.run(); |
| 24 | |
| 25 | function createScriptRunner() { |
| 26 | const dependenciesProvider = DependenciesProviderSingleton.getInstance(); |
| 27 | const autoRefresh = dependenciesProvider.getDependency(AutoRefreshDependency); |
| 28 | |
| 29 | const context: Context = { |
| 30 | page: ScriptPage.CommunityConsole, |
| 31 | environment: ScriptEnvironment.ContentScript, |
| 32 | runPhase: ScriptRunPhase.Start, |
| 33 | }; |
| 34 | |
| 35 | return new ScriptRunner( |
| 36 | new SortedScriptsProviderAdapter( |
| 37 | [ |
| 38 | // Individual feature scripts |
| 39 | new AutoRefreshSetUpScript(autoRefresh), |
Adrià Vilanova Martínez | 6ecaa0d | 2024-10-26 17:04:32 +0200 | [diff] [blame^] | 40 | new CCDarkThemeInjectAutoDarkTheme(), |
| 41 | new CCDarkThemeInjectForcedDarkTheme(), |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 42 | |
| 43 | // Non-DI scripts (legacy, should be migrated to use a DI approach) |
| 44 | ...new Features().getScripts(context), |
| 45 | ...new StandaloneScripts().getScripts(context), |
| 46 | ], |
| 47 | new ScriptSorterAdapter(), |
| 48 | ).getScripts(), |
| 49 | ); |
| 50 | } |