blob: e9be92c58c0e2410136c3c62dc1548147d85c1c7 [file] [log] [blame]
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +02001import DependenciesProviderSingleton, {
2 AutoRefreshDependency,
3} from '../../../common/architecture/dependenciesProvider/DependenciesProvider';
4import { Context } from '../../../common/architecture/entrypoint/Context';
5import {
6 ScriptEnvironment,
7 ScriptPage,
8 ScriptRunPhase,
9} from '../../../common/architecture/scripts/Script';
10import AutoRefreshSetUpScript from '../../../features/autoRefresh/presentation/scripts/setUp.script';
11import Features from '../../../features/Features';
12import ScriptRunner from '../../../infrastructure/presentation/scripts/ScriptRunner';
13import ScriptSorterAdapter from '../../../infrastructure/presentation/scripts/ScriptSorter.adapter';
14import { SortedScriptsProviderAdapter } from '../../../infrastructure/presentation/scripts/SortedScriptsProvider.adapter';
15import StandaloneScripts from '../../../scripts/Scripts';
16
17// Run legacy Javascript entry point
18import '../../../contentScripts/communityConsole/start';
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +020019import CCDarkThemeInjectAutoDarkTheme from '../../../features/ccDarkTheme/scripts/injectAutoDarkTheme.script';
20import CCDarkThemeInjectForcedDarkTheme from '../../../features/ccDarkTheme/scripts/injectForcedDarkTheme.script';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020021
22const scriptRunner = createScriptRunner();
23scriptRunner.run();
24
25function 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ínez6ecaa0d2024-10-26 17:04:32 +020040 new CCDarkThemeInjectAutoDarkTheme(),
41 new CCDarkThemeInjectForcedDarkTheme(),
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020042
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}