blob: 4cbfd9dbbabfcdb0e0d0ebb00658c8a5baad7491 [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';
25import StandaloneScripts from '../../../scripts/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ínezf92172f2024-10-19 15:55:15 +020029
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020030const scriptRunner = createScriptRunner();
31scriptRunner.run();
32
33function createScriptRunner() {
34 const dependenciesProvider = DependenciesProviderSingleton.getInstance();
35 const autoRefresh = dependenciesProvider.getDependency(AutoRefreshDependency);
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +010036 const extraInfo = dependenciesProvider.getDependency(ExtraInfoDependency);
Adrià Vilanova Martínez3913f4d2024-10-26 21:16:38 +020037 const optionsProvider = dependenciesProvider.getDependency(
38 OptionsProviderDependency,
39 );
40 const startupDataStorage = dependenciesProvider.getDependency(
41 StartupDataStorageDependency,
42 );
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020043 const workflowsImport = dependenciesProvider.getDependency(
44 WorkflowsImportDependency,
45 );
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020046
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ínez6ecaa0d2024-10-26 17:04:32 +020058 new CCDarkThemeInjectAutoDarkTheme(),
59 new CCDarkThemeInjectForcedDarkTheme(),
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +010060 new CCExtraInfoSetUpScript(extraInfo),
Adrià Vilanova Martínez2d035552024-10-26 20:23:34 +020061 new InteropThreadPageSetupScript(),
Adrià Vilanova Martínez3913f4d2024-10-26 21:16:38 +020062 new LoadDraftsSetupScript(optionsProvider, startupDataStorage),
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020063 new WorkflowsImportSetUpScript(workflowsImport),
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020064
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}