blob: 9ffdd952cca91faffb05072160ed5960bb7347af [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ínez3913f4d2024-10-26 21:16:38 +02006 OptionsProviderDependency,
7 StartupDataStorageDependency,
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +02008 WorkflowsImportDependency,
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +02009} from '../../../common/architecture/dependenciesProvider/DependenciesProvider';
10import { Context } from '../../../common/architecture/entrypoint/Context';
11import {
12 ScriptEnvironment,
13 ScriptPage,
14 ScriptRunPhase,
15} from '../../../common/architecture/scripts/Script';
16import AutoRefreshSetUpScript from '../../../features/autoRefresh/presentation/scripts/setUp.script';
Adrià Vilanova Martínezfe694782024-11-09 20:40:43 +010017import CCDarkThemeInjectAutoDarkTheme from '../../../features/ccDarkTheme/presentation/scripts/injectAutoDarkTheme.script';
18import CCDarkThemeInjectForcedDarkTheme from '../../../features/ccDarkTheme/presentation/scripts/injectForcedDarkTheme.script';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020019import Features from '../../../features/Features';
Adrià Vilanova Martínez2d035552024-10-26 20:23:34 +020020import InteropThreadPageSetupScript from '../../../features/interopThreadPage/presentation/scripts/setup.script';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020021import ScriptRunner from '../../../infrastructure/presentation/scripts/ScriptRunner';
22import ScriptSorterAdapter from '../../../infrastructure/presentation/scripts/ScriptSorter.adapter';
23import { SortedScriptsProviderAdapter } from '../../../infrastructure/presentation/scripts/SortedScriptsProvider.adapter';
24import StandaloneScripts from '../../../scripts/Scripts';
Adrià Vilanova Martínez3913f4d2024-10-26 21:16:38 +020025import LoadDraftsSetupScript from '../../../features/loadDrafts/presentation/scripts/setup.script';
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020026import WorkflowsImportSetUpScript from '../../../features/workflows/presentation/scripts/importSetUp.script';
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020027
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020028const scriptRunner = createScriptRunner();
29scriptRunner.run();
30
31function createScriptRunner() {
32 const dependenciesProvider = DependenciesProviderSingleton.getInstance();
33 const autoRefresh = dependenciesProvider.getDependency(AutoRefreshDependency);
Adrià Vilanova Martínez3913f4d2024-10-26 21:16:38 +020034 const optionsProvider = dependenciesProvider.getDependency(
35 OptionsProviderDependency,
36 );
37 const startupDataStorage = dependenciesProvider.getDependency(
38 StartupDataStorageDependency,
39 );
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020040 const workflowsImport = dependenciesProvider.getDependency(
41 WorkflowsImportDependency,
42 );
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020043
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ínez6ecaa0d2024-10-26 17:04:32 +020055 new CCDarkThemeInjectAutoDarkTheme(),
56 new CCDarkThemeInjectForcedDarkTheme(),
Adrià Vilanova Martínez2d035552024-10-26 20:23:34 +020057 new InteropThreadPageSetupScript(),
Adrià Vilanova Martínez3913f4d2024-10-26 21:16:38 +020058 new LoadDraftsSetupScript(optionsProvider, startupDataStorage),
Adrià Vilanova Martínezed1aba32024-10-26 21:23:12 +020059 new WorkflowsImportSetUpScript(workflowsImport),
Adrià Vilanova Martínezf92172f2024-10-19 15:55:15 +020060
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}