Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 1 | import DependenciesProviderSingleton, { |
| 2 | AutoRefreshDependency, |
Adrià Vilanova Martínez | 6ecaa0d | 2024-10-26 17:04:32 +0200 | [diff] [blame] | 3 | OptionsProviderDependency, |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 4 | } from '../../../common/architecture/dependenciesProvider/DependenciesProvider'; |
| 5 | import { Context } from '../../../common/architecture/entrypoint/Context'; |
| 6 | import { |
| 7 | ScriptEnvironment, |
| 8 | ScriptPage, |
| 9 | ScriptRunPhase, |
| 10 | } from '../../../common/architecture/scripts/Script'; |
| 11 | import AutoRefreshThreadListHideHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListHide.handler'; |
| 12 | import AutoRefreshThreadListSetUpHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListSetUp.handler'; |
| 13 | import AutoRefreshStylesScript from '../../../features/autoRefresh/presentation/scripts/styles.script'; |
| 14 | import Features from '../../../features/Features'; |
| 15 | import { NodeWatcherAdapter } from '../../../infrastructure/presentation/nodeWatcher/NodeWatcher.adapter'; |
| 16 | import NodeWatcherScriptAdapter from '../../../infrastructure/presentation/scripts/NodeWatcherScript.adapter'; |
| 17 | import ScriptRunner from '../../../infrastructure/presentation/scripts/ScriptRunner'; |
| 18 | import ScriptSorterAdapter from '../../../infrastructure/presentation/scripts/ScriptSorter.adapter'; |
| 19 | import { SortedScriptsProviderAdapter } from '../../../infrastructure/presentation/scripts/SortedScriptsProvider.adapter'; |
| 20 | import { NodeWatcherHandler } from '../../../presentation/nodeWatcher/NodeWatcherHandler'; |
| 21 | import StandaloneScripts from '../../../scripts/Scripts'; |
| 22 | |
| 23 | // Run legacy Javascript entry point |
| 24 | import '../../../contentScripts/communityConsole/main'; |
Adrià Vilanova Martínez | 6ecaa0d | 2024-10-26 17:04:32 +0200 | [diff] [blame] | 25 | import CCDarkThemeEcAppHandler from '../../../features/ccDarkTheme/nodeWatcherHandlers/ecApp.handler'; |
| 26 | import CCDarkThemeReportDialogHandler from '../../../features/ccDarkTheme/nodeWatcherHandlers/reportDialog.handler'; |
| 27 | import CCDarkThemeUnifiedProfilesIframeHandler from '../../../features/ccDarkTheme/nodeWatcherHandlers/unifiedProfilesIframe.handler'; |
| 28 | import ReportDialogColorThemeFix from '../../../features/ccDarkTheme/core/logic/reportDialog'; |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 29 | |
| 30 | const scriptRunner = createScriptRunner(); |
| 31 | scriptRunner.run(); |
| 32 | |
| 33 | function createScriptRunner() { |
| 34 | const dependenciesProvider = DependenciesProviderSingleton.getInstance(); |
| 35 | const autoRefresh = dependenciesProvider.getDependency(AutoRefreshDependency); |
Adrià Vilanova Martínez | 6ecaa0d | 2024-10-26 17:04:32 +0200 | [diff] [blame] | 36 | const optionsProvider = dependenciesProvider.getDependency( |
| 37 | OptionsProviderDependency, |
| 38 | ); |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 39 | |
| 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ínez | 6ecaa0d | 2024-10-26 17:04:32 +0200 | [diff] [blame] | 61 | ['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ínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 73 | ]), |
| 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 | } |