blob: e7023a2732bb41c88579968b58cea6f9ce3b873f [file] [log] [blame]
Adrià Vilanova Martínez2d035552024-10-26 20:23:34 +02001// Run legacy Javascript entry point
2import '../../../contentScripts/communityConsole/start';
3
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +02004import DependenciesProviderSingleton, {
5 AutoRefreshDependency,
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +01006 ExtraInfoDependency,
Adrià Vilanova Martínez3913f4d2024-10-26 21:16:38 +02007 OptionsProviderDependency,
8 StartupDataStorageDependency,
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +02009 WorkflowsImportDependency,
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020010} from '../../../common/architecture/dependenciesProvider/DependenciesProvider';
11import { Context } from '../../../common/architecture/entrypoint/Context';
12import {
13 ScriptEnvironment,
14 ScriptPage,
15 ScriptRunPhase,
16} from '../../../common/architecture/scripts/Script';
17import AutoRefreshSetUpScript from '../../../features/autoRefresh/presentation/scripts/setUp.script';
Adrià Vilanova Martínezfe694782024-11-09 20:40:43 +010018import CCDarkThemeInjectAutoDarkTheme from '../../../features/ccDarkTheme/presentation/scripts/injectAutoDarkTheme.script';
19import CCDarkThemeInjectForcedDarkTheme from '../../../features/ccDarkTheme/presentation/scripts/injectForcedDarkTheme.script';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020020import Features from '../../../features/Features';
Adrià Vilanova Martínez2d035552024-10-26 20:23:34 +020021import InteropThreadPageSetupScript from '../../../features/interopThreadPage/presentation/scripts/setup.script';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020022import ScriptRunner from '../../../infrastructure/presentation/scripts/ScriptRunner';
23import ScriptSorterAdapter from '../../../infrastructure/presentation/scripts/ScriptSorter.adapter';
24import { SortedScriptsProviderAdapter } from '../../../infrastructure/presentation/scripts/SortedScriptsProvider.adapter';
Adrià Vilanova Martínez33a009c2024-11-09 22:41:56 +010025import StandaloneScripts from '../../../presentation/standaloneScripts/Scripts';
Adrià Vilanova Martínez3913f4d2024-10-26 21:16:38 +020026import LoadDraftsSetupScript from '../../../features/loadDrafts/presentation/scripts/setup.script';
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020027import WorkflowsImportSetUpScript from '../../../features/workflows/presentation/scripts/importSetUp.script';
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +010028import CCExtraInfoSetUpScript from '../../../features/extraInfo/presentation/scripts/ccExtraInfoSetUp.script';
Adrià Vilanova Martínez33a009c2024-11-09 22:41:56 +010029import MWI18nServerScript from '../../../presentation/standaloneScripts/mainWorldServers/MWI18nServerScript.script';
30import MWOptionsWatcherServerScript from '../../../presentation/standaloneScripts/mainWorldServers/MWOptionsWatcherServerScript.script';
31import ApplyStartupDataModificationsOnStartScript from '../../../presentation/standaloneScripts/startupDataStorage/applyStartupDataModificationsOnStart.script';
32import XHRInterceptorScript from '../../../presentation/standaloneScripts/xhrInterceptor/xhrInterceptor.script';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020033
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020034const scriptRunner = createScriptRunner();
35scriptRunner.run();
36
37function createScriptRunner() {
38 const dependenciesProvider = DependenciesProviderSingleton.getInstance();
39 const autoRefresh = dependenciesProvider.getDependency(AutoRefreshDependency);
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +010040 const extraInfo = dependenciesProvider.getDependency(ExtraInfoDependency);
Adrià Vilanova Martínez3913f4d2024-10-26 21:16:38 +020041 const optionsProvider = dependenciesProvider.getDependency(
42 OptionsProviderDependency,
43 );
44 const startupDataStorage = dependenciesProvider.getDependency(
45 StartupDataStorageDependency,
46 );
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020047 const workflowsImport = dependenciesProvider.getDependency(
48 WorkflowsImportDependency,
49 );
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020050
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ínez6ecaa0d2024-10-26 17:04:32 +020062 new CCDarkThemeInjectAutoDarkTheme(),
63 new CCDarkThemeInjectForcedDarkTheme(),
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +010064 new CCExtraInfoSetUpScript(extraInfo),
Adrià Vilanova Martínez2d035552024-10-26 20:23:34 +020065 new InteropThreadPageSetupScript(),
Adrià Vilanova Martínez3913f4d2024-10-26 21:16:38 +020066 new LoadDraftsSetupScript(optionsProvider, startupDataStorage),
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020067 new WorkflowsImportSetUpScript(workflowsImport),
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020068
Adrià Vilanova Martínez33a009c2024-11-09 22:41:56 +010069 // Standalone scripts
70 new ApplyStartupDataModificationsOnStartScript(startupDataStorage),
71 new MWI18nServerScript(),
72 new MWOptionsWatcherServerScript(),
73 new XHRInterceptorScript(),
74
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020075 // 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}