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 AutoRefreshThreadListHideHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListHide.handler'; |
| 11 | import AutoRefreshThreadListSetUpHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListSetUp.handler'; |
| 12 | import AutoRefreshStylesScript from '../../../features/autoRefresh/presentation/scripts/styles.script'; |
| 13 | import Features from '../../../features/Features'; |
| 14 | import { NodeWatcherAdapter } from '../../../infrastructure/presentation/nodeWatcher/NodeWatcher.adapter'; |
| 15 | import NodeWatcherScriptAdapter from '../../../infrastructure/presentation/scripts/NodeWatcherScript.adapter'; |
| 16 | import ScriptRunner from '../../../infrastructure/presentation/scripts/ScriptRunner'; |
| 17 | import ScriptSorterAdapter from '../../../infrastructure/presentation/scripts/ScriptSorter.adapter'; |
| 18 | import { SortedScriptsProviderAdapter } from '../../../infrastructure/presentation/scripts/SortedScriptsProvider.adapter'; |
| 19 | import { NodeWatcherHandler } from '../../../presentation/nodeWatcher/NodeWatcherHandler'; |
| 20 | import StandaloneScripts from '../../../scripts/Scripts'; |
| 21 | |
| 22 | // Run legacy Javascript entry point |
| 23 | import '../../../contentScripts/communityConsole/main'; |
| 24 | |
| 25 | const scriptRunner = createScriptRunner(); |
| 26 | scriptRunner.run(); |
| 27 | |
| 28 | function createScriptRunner() { |
| 29 | const dependenciesProvider = DependenciesProviderSingleton.getInstance(); |
| 30 | const autoRefresh = dependenciesProvider.getDependency(AutoRefreshDependency); |
| 31 | |
| 32 | const context: Context = { |
| 33 | page: ScriptPage.CommunityConsole, |
| 34 | environment: ScriptEnvironment.ContentScript, |
| 35 | runPhase: ScriptRunPhase.Main, |
| 36 | }; |
| 37 | |
| 38 | return new ScriptRunner( |
| 39 | new SortedScriptsProviderAdapter( |
| 40 | [ |
| 41 | // Node watcher script with handlers |
| 42 | new NodeWatcherScriptAdapter( |
| 43 | new NodeWatcherAdapter(), |
| 44 | new Map<string, NodeWatcherHandler>([ |
| 45 | [ |
| 46 | 'autoRefreshThreadListSetUp', |
| 47 | new AutoRefreshThreadListSetUpHandler(autoRefresh), |
| 48 | ], |
| 49 | [ |
| 50 | 'autoRefreshThreadListHide', |
| 51 | new AutoRefreshThreadListHideHandler(autoRefresh), |
| 52 | ], |
| 53 | ]), |
| 54 | ), |
| 55 | |
| 56 | // Individual feature scripts |
| 57 | new AutoRefreshStylesScript(), |
| 58 | |
| 59 | // Non-DI scripts (legacy, should be migrated to use a DI approach) |
| 60 | ...new Features().getScripts(context), |
| 61 | ...new StandaloneScripts().getScripts(context), |
| 62 | ], |
| 63 | new ScriptSorterAdapter(), |
| 64 | ).getScripts(), |
| 65 | ); |
| 66 | } |