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'; |
Adrià Vilanova Martínez | 33a009c | 2024-11-09 22:41:56 +0100 | [diff] [blame^] | 25 | import StandaloneScripts from '../../../presentation/standaloneScripts/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 | 33a009c | 2024-11-09 22:41:56 +0100 | [diff] [blame^] | 29 | import MWI18nServerScript from '../../../presentation/standaloneScripts/mainWorldServers/MWI18nServerScript.script'; |
| 30 | import MWOptionsWatcherServerScript from '../../../presentation/standaloneScripts/mainWorldServers/MWOptionsWatcherServerScript.script'; |
| 31 | import ApplyStartupDataModificationsOnStartScript from '../../../presentation/standaloneScripts/startupDataStorage/applyStartupDataModificationsOnStart.script'; |
| 32 | import XHRInterceptorScript from '../../../presentation/standaloneScripts/xhrInterceptor/xhrInterceptor.script'; |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 33 | |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 34 | const scriptRunner = createScriptRunner(); |
| 35 | scriptRunner.run(); |
| 36 | |
| 37 | function createScriptRunner() { |
| 38 | const dependenciesProvider = DependenciesProviderSingleton.getInstance(); |
| 39 | const autoRefresh = dependenciesProvider.getDependency(AutoRefreshDependency); |
Adrià Vilanova Martínez | cb12c59 | 2024-11-09 20:46:03 +0100 | [diff] [blame] | 40 | const extraInfo = dependenciesProvider.getDependency(ExtraInfoDependency); |
Adrià Vilanova Martínez | 3913f4d | 2024-10-26 21:16:38 +0200 | [diff] [blame] | 41 | const optionsProvider = dependenciesProvider.getDependency( |
| 42 | OptionsProviderDependency, |
| 43 | ); |
| 44 | const startupDataStorage = dependenciesProvider.getDependency( |
| 45 | StartupDataStorageDependency, |
| 46 | ); |
Adrià Vilanova Martínez | ed1aba3 | 2024-10-26 21:23:12 +0200 | [diff] [blame] | 47 | const workflowsImport = dependenciesProvider.getDependency( |
| 48 | WorkflowsImportDependency, |
| 49 | ); |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 50 | |
| 51 | const context: Context = { |
| 52 | page: ScriptPage.CommunityConsole, |
| 53 | environment: ScriptEnvironment.ContentScript, |
| 54 | runPhase: ScriptRunPhase.Start, |
| 55 | }; |
| 56 | |
| 57 | return new ScriptRunner( |
| 58 | new SortedScriptsProviderAdapter( |
| 59 | [ |
| 60 | // Individual feature scripts |
| 61 | new AutoRefreshSetUpScript(autoRefresh), |
Adrià Vilanova Martínez | 6ecaa0d | 2024-10-26 17:04:32 +0200 | [diff] [blame] | 62 | new CCDarkThemeInjectAutoDarkTheme(), |
| 63 | new CCDarkThemeInjectForcedDarkTheme(), |
Adrià Vilanova Martínez | cb12c59 | 2024-11-09 20:46:03 +0100 | [diff] [blame] | 64 | new CCExtraInfoSetUpScript(extraInfo), |
Adrià Vilanova Martínez | 2d03555 | 2024-10-26 20:23:34 +0200 | [diff] [blame] | 65 | new InteropThreadPageSetupScript(), |
Adrià Vilanova Martínez | 3913f4d | 2024-10-26 21:16:38 +0200 | [diff] [blame] | 66 | new LoadDraftsSetupScript(optionsProvider, startupDataStorage), |
Adrià Vilanova Martínez | ed1aba3 | 2024-10-26 21:23:12 +0200 | [diff] [blame] | 67 | new WorkflowsImportSetUpScript(workflowsImport), |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 68 | |
Adrià Vilanova Martínez | 33a009c | 2024-11-09 22:41:56 +0100 | [diff] [blame^] | 69 | // Standalone scripts |
| 70 | new ApplyStartupDataModificationsOnStartScript(startupDataStorage), |
| 71 | new MWI18nServerScript(), |
| 72 | new MWOptionsWatcherServerScript(), |
| 73 | new XHRInterceptorScript(), |
| 74 | |
Adrià Vilanova Martínez | f92172f | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 75 | // Non-DI scripts (legacy, should be migrated to use a DI approach) |
| 76 | ...new Features().getScripts(context), |
| 77 | ...new StandaloneScripts().getScripts(context), |
| 78 | ], |
| 79 | new ScriptSorterAdapter(), |
| 80 | ).getScripts(), |
| 81 | ); |
| 82 | } |