blob: fb6fa17a0535019afbc7530704da8920cc826615 [file] [log] [blame]
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +02001import DependenciesProviderSingleton, {
2 AutoRefreshDependency,
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +02003 OptionsProviderDependency,
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +02004} from '../../../common/architecture/dependenciesProvider/DependenciesProvider';
5import { Context } from '../../../common/architecture/entrypoint/Context';
6import {
7 ScriptEnvironment,
8 ScriptPage,
9 ScriptRunPhase,
10} from '../../../common/architecture/scripts/Script';
11import AutoRefreshThreadListHideHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListHide.handler';
12import AutoRefreshThreadListSetUpHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListSetUp.handler';
13import AutoRefreshStylesScript from '../../../features/autoRefresh/presentation/scripts/styles.script';
14import Features from '../../../features/Features';
15import { NodeWatcherAdapter } from '../../../infrastructure/presentation/nodeWatcher/NodeWatcher.adapter';
16import NodeWatcherScriptAdapter from '../../../infrastructure/presentation/scripts/NodeWatcherScript.adapter';
17import ScriptRunner from '../../../infrastructure/presentation/scripts/ScriptRunner';
18import ScriptSorterAdapter from '../../../infrastructure/presentation/scripts/ScriptSorter.adapter';
19import { SortedScriptsProviderAdapter } from '../../../infrastructure/presentation/scripts/SortedScriptsProvider.adapter';
20import { NodeWatcherHandler } from '../../../presentation/nodeWatcher/NodeWatcherHandler';
21import StandaloneScripts from '../../../scripts/Scripts';
22
23// Run legacy Javascript entry point
24import '../../../contentScripts/communityConsole/main';
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +020025import CCDarkThemeEcAppHandler from '../../../features/ccDarkTheme/nodeWatcherHandlers/ecApp.handler';
26import CCDarkThemeReportDialogHandler from '../../../features/ccDarkTheme/nodeWatcherHandlers/reportDialog.handler';
27import CCDarkThemeUnifiedProfilesIframeHandler from '../../../features/ccDarkTheme/nodeWatcherHandlers/unifiedProfilesIframe.handler';
28import ReportDialogColorThemeFix from '../../../features/ccDarkTheme/core/logic/reportDialog';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020029
30const scriptRunner = createScriptRunner();
31scriptRunner.run();
32
33function createScriptRunner() {
34 const dependenciesProvider = DependenciesProviderSingleton.getInstance();
35 const autoRefresh = dependenciesProvider.getDependency(AutoRefreshDependency);
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +020036 const optionsProvider = dependenciesProvider.getDependency(
37 OptionsProviderDependency,
38 );
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020039
40 const context: Context = {
41 page: ScriptPage.CommunityConsole,
42 environment: ScriptEnvironment.ContentScript,
43 runPhase: ScriptRunPhase.Main,
44 };
45
46 return new ScriptRunner(
47 new SortedScriptsProviderAdapter(
48 [
49 // Node watcher script with handlers
50 new NodeWatcherScriptAdapter(
51 new NodeWatcherAdapter(),
52 new Map<string, NodeWatcherHandler>([
53 [
54 'autoRefreshThreadListSetUp',
55 new AutoRefreshThreadListSetUpHandler(autoRefresh),
56 ],
57 [
58 'autoRefreshThreadListHide',
59 new AutoRefreshThreadListHideHandler(autoRefresh),
60 ],
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +020061 ['ccDarkThemeEcApp', new CCDarkThemeEcAppHandler(optionsProvider)],
62 [
63 'ccDarkThemeReportDialog',
64 new CCDarkThemeReportDialogHandler(
65 optionsProvider,
66 new ReportDialogColorThemeFix(),
67 ),
68 ],
69 [
70 'ccDarkThemeUnifiedProfilesIframe',
71 new CCDarkThemeUnifiedProfilesIframeHandler(optionsProvider),
72 ],
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020073 ]),
74 ),
75
76 // Individual feature scripts
77 new AutoRefreshStylesScript(),
78
79 // Non-DI scripts (legacy, should be migrated to use a DI approach)
80 ...new Features().getScripts(context),
81 ...new StandaloneScripts().getScripts(context),
82 ],
83 new ScriptSorterAdapter(),
84 ).getScripts(),
85 );
86}