Adrià Vilanova Martínez | 2d03555 | 2024-10-26 20:23:34 +0200 | [diff] [blame] | 1 | // Run legacy Javascript entry point |
| 2 | import '../../../contentScripts/communityConsole/start'; |
| 3 | |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 4 | import DependenciesProviderSingleton, { |
| 5 | AutoRefreshDependency, |
Adrià Vilanova Martínez | cb12c59 | 2024-11-09 20:46:03 +0100 | [diff] [blame^] | 6 | ExtraInfoDependency, |
Adrià Vilanova Martínez | 3913f4d | 2024-10-26 21:16:38 +0200 | [diff] [blame] | 7 | OptionsProviderDependency, |
| 8 | StartupDataStorageDependency, |
Adrià Vilanova Martínez | ed1aba3 | 2024-10-26 21:23:12 +0200 | [diff] [blame] | 9 | WorkflowsImportDependency, |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 10 | } from '../../../common/architecture/dependenciesProvider/DependenciesProvider'; |
| 11 | import { Context } from '../../../common/architecture/entrypoint/Context'; |
| 12 | import { |
| 13 | ScriptEnvironment, |
| 14 | ScriptPage, |
| 15 | ScriptRunPhase, |
| 16 | } from '../../../common/architecture/scripts/Script'; |
| 17 | import AutoRefreshSetUpScript from '../../../features/autoRefresh/presentation/scripts/setUp.script'; |
Adrià Vilanova Martínez | fe69478 | 2024-11-09 20:40:43 +0100 | [diff] [blame] | 18 | import CCDarkThemeInjectAutoDarkTheme from '../../../features/ccDarkTheme/presentation/scripts/injectAutoDarkTheme.script'; |
| 19 | import CCDarkThemeInjectForcedDarkTheme from '../../../features/ccDarkTheme/presentation/scripts/injectForcedDarkTheme.script'; |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 20 | import Features from '../../../features/Features'; |
Adrià Vilanova Martínez | 2d03555 | 2024-10-26 20:23:34 +0200 | [diff] [blame] | 21 | import InteropThreadPageSetupScript from '../../../features/interopThreadPage/presentation/scripts/setup.script'; |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 22 | import ScriptRunner from '../../../infrastructure/presentation/scripts/ScriptRunner'; |
| 23 | import ScriptSorterAdapter from '../../../infrastructure/presentation/scripts/ScriptSorter.adapter'; |
| 24 | import { SortedScriptsProviderAdapter } from '../../../infrastructure/presentation/scripts/SortedScriptsProvider.adapter'; |
| 25 | import StandaloneScripts from '../../../scripts/Scripts'; |
Adrià Vilanova Martínez | 3913f4d | 2024-10-26 21:16:38 +0200 | [diff] [blame] | 26 | import LoadDraftsSetupScript from '../../../features/loadDrafts/presentation/scripts/setup.script'; |
Adrià Vilanova Martínez | ed1aba3 | 2024-10-26 21:23:12 +0200 | [diff] [blame] | 27 | import WorkflowsImportSetUpScript from '../../../features/workflows/presentation/scripts/importSetUp.script'; |
Adrià Vilanova Martínez | cb12c59 | 2024-11-09 20:46:03 +0100 | [diff] [blame^] | 28 | import CCExtraInfoSetUpScript from '../../../features/extraInfo/presentation/scripts/ccExtraInfoSetUp.script'; |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 29 | |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 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 | cb12c59 | 2024-11-09 20:46:03 +0100 | [diff] [blame^] | 36 | const extraInfo = dependenciesProvider.getDependency(ExtraInfoDependency); |
Adrià Vilanova Martínez | 3913f4d | 2024-10-26 21:16:38 +0200 | [diff] [blame] | 37 | const optionsProvider = dependenciesProvider.getDependency( |
| 38 | OptionsProviderDependency, |
| 39 | ); |
| 40 | const startupDataStorage = dependenciesProvider.getDependency( |
| 41 | StartupDataStorageDependency, |
| 42 | ); |
Adrià Vilanova Martínez | ed1aba3 | 2024-10-26 21:23:12 +0200 | [diff] [blame] | 43 | const workflowsImport = dependenciesProvider.getDependency( |
| 44 | WorkflowsImportDependency, |
| 45 | ); |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 46 | |
| 47 | const context: Context = { |
| 48 | page: ScriptPage.CommunityConsole, |
| 49 | environment: ScriptEnvironment.ContentScript, |
| 50 | runPhase: ScriptRunPhase.Start, |
| 51 | }; |
| 52 | |
| 53 | return new ScriptRunner( |
| 54 | new SortedScriptsProviderAdapter( |
| 55 | [ |
| 56 | // Individual feature scripts |
| 57 | new AutoRefreshSetUpScript(autoRefresh), |
Adrià Vilanova Martínez | 6ecaa0d | 2024-10-26 17:04:32 +0200 | [diff] [blame] | 58 | new CCDarkThemeInjectAutoDarkTheme(), |
| 59 | new CCDarkThemeInjectForcedDarkTheme(), |
Adrià Vilanova Martínez | cb12c59 | 2024-11-09 20:46:03 +0100 | [diff] [blame^] | 60 | new CCExtraInfoSetUpScript(extraInfo), |
Adrià Vilanova Martínez | 2d03555 | 2024-10-26 20:23:34 +0200 | [diff] [blame] | 61 | new InteropThreadPageSetupScript(), |
Adrià Vilanova Martínez | 3913f4d | 2024-10-26 21:16:38 +0200 | [diff] [blame] | 62 | new LoadDraftsSetupScript(optionsProvider, startupDataStorage), |
Adrià Vilanova Martínez | ed1aba3 | 2024-10-26 21:23:12 +0200 | [diff] [blame] | 63 | new WorkflowsImportSetUpScript(workflowsImport), |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 64 | |
| 65 | // Non-DI scripts (legacy, should be migrated to use a DI approach) |
| 66 | ...new Features().getScripts(context), |
| 67 | ...new StandaloneScripts().getScripts(context), |
| 68 | ], |
| 69 | new ScriptSorterAdapter(), |
| 70 | ).getScripts(), |
| 71 | ); |
| 72 | } |