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