refactor: delete now outdated "new architecture" code

The previous architecture that we used to call the "new architecture" is
no longer used. Thus, this commit removes all remanents from that era.

Fixed: twpowertools:226
Change-Id: I5c7c509dc135b7b2dd675dd6d94693b02e74e1b1
diff --git a/src/common/architecture/entrypoint/EntrypointScriptRunner.ts b/src/common/architecture/entrypoint/EntrypointScriptRunner.ts
deleted file mode 100644
index f4d5f5c..0000000
--- a/src/common/architecture/entrypoint/EntrypointScriptRunner.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import Features from '../../../features/Features';
-import StandaloneScripts from '../../../presentation/standaloneScripts/Scripts';
-import ScriptProvider from '../scripts/ScriptProvider';
-import LegacyScriptRunner from '../scripts/LegacyScriptRunner';
-import { Context } from './Context';
-
-/**
- * @deprecated
- */
-export default class EntrypointScriptRunner {
-  private scriptRunner: LegacyScriptRunner;
-
-  constructor(public context: Context) {
-    this.scriptRunner = new LegacyScriptRunner();
-    this.addScriptProvider(new Features());
-    this.addScriptProvider(new StandaloneScripts());
-  }
-
-  addScriptProvider(scriptProvider: ScriptProvider): EntrypointScriptRunner {
-    const scripts = scriptProvider.getScripts(this.context);
-    this.scriptRunner.add(...scripts);
-    return this;
-  }
-
-  run() {
-    this.scriptRunner.run();
-  }
-}
diff --git a/src/common/architecture/features/Feature.ts b/src/common/architecture/features/Feature.ts
deleted file mode 100644
index 5f0cfa0..0000000
--- a/src/common/architecture/features/Feature.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { OptionCodename } from '../../options/optionsPrototype';
-import Script, { ConcreteScript } from '../scripts/Script';
-
-/**
- * @deprecated
- */
-export default abstract class Feature {
-  /**
-   * Internal codename used for the feature.
-   *
-   * It will be used for i18n translations, shown in log messages, etc.
-   */
-  abstract readonly codename: string;
-
-  /**
-   * Options which control the behavior of this feature.
-   */
-  abstract readonly relatedOptions: OptionCodename[];
-
-  /**
-   * Uninitialized scripts which are associated with the feature.
-   */
-  abstract readonly scripts: ConcreteScript[];
-
-  private initializedScripts: Script[];
-
-  public getScripts() {
-    if (this.initializedScripts === undefined) {
-      this.initializedScripts = this.scripts.map((script) => new script());
-    }
-    return this.initializedScripts;
-  }
-}
diff --git a/src/common/architecture/scripts/LegacyScriptRunner.test.ts b/src/common/architecture/scripts/LegacyScriptRunner.test.ts
deleted file mode 100644
index 1ae8f72..0000000
--- a/src/common/architecture/scripts/LegacyScriptRunner.test.ts
+++ /dev/null
@@ -1,83 +0,0 @@
-import Script, {
-  ScriptEnvironment,
-  ScriptPage,
-  ScriptRunPhase,
-} from './Script';
-import { beforeEach, expect, it, jest } from '@jest/globals';
-import LegacyScriptRunner from './LegacyScriptRunner';
-
-interface FakeScriptOptions {
-  id: string;
-  priority: number;
-}
-
-class FakeScript extends Script {
-  id: string;
-  priority: number;
-  page: ScriptPage.CommunityConsole;
-  environment: ScriptEnvironment.ContentScript;
-  runPhase: ScriptRunPhase.Main;
-
-  constructor(options: FakeScriptOptions) {
-    super();
-    this.id = options.id;
-    this.priority = options.priority;
-  }
-
-  execute() {}
-}
-
-const fakeScriptMock = jest
-  .spyOn(FakeScript.prototype, 'execute')
-  .mockImplementation(function() {
-    return (this as FakeScript).id;
-  });
-
-beforeEach(() => {
-  jest.clearAllMocks();
-});
-
-it('scripts run in the correct order based on priority', () => {
-  const scriptsConfig = [
-    {
-      script: new FakeScript({
-        id: '1',
-        priority: 1,
-      }),
-      expectedRunPosition: 2,
-    },
-    {
-      script: new FakeScript({
-        id: '2',
-        priority: 1000,
-      }),
-      expectedRunPosition: 3,
-    },
-    {
-      script: new FakeScript({
-        id: '3',
-        priority: 0,
-      }),
-      expectedRunPosition: 1,
-    },
-    {
-      script: new FakeScript({
-        id: '4',
-        priority: 2 ** 31,
-      }),
-      expectedRunPosition: 4,
-    },
-  ];
-
-  const scriptRunner = new LegacyScriptRunner();
-  scriptRunner.add(...scriptsConfig.map((config) => config.script));
-  scriptRunner.run();
-
-  expect(fakeScriptMock).toHaveBeenCalledTimes(scriptsConfig.length);
-  for (const config of scriptsConfig) {
-    expect(fakeScriptMock).toHaveNthReturnedWith(
-      config.expectedRunPosition,
-      config.script.id,
-    );
-  }
-});
diff --git a/src/common/architecture/scripts/LegacyScriptRunner.ts b/src/common/architecture/scripts/LegacyScriptRunner.ts
deleted file mode 100644
index f7b3e82..0000000
--- a/src/common/architecture/scripts/LegacyScriptRunner.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import Script from './Script';
-
-export default class LegacyScriptRunner {
-  private scripts: Script[] = [];
-
-  add(...scripts: Script[]) {
-    this.scripts.push(...scripts);
-  }
-
-  run() {
-    this.scripts.sort((a, b) => {
-      if (a.priority < b.priority) return -1;
-      if (a.priority > b.priority) return 1;
-      return 0;
-    });
-    for (const script of this.scripts) {
-      script.execute();
-    }
-  }
-}
diff --git a/src/common/architecture/scripts/ScriptFilterListProvider.ts b/src/common/architecture/scripts/ScriptFilterListProvider.ts
deleted file mode 100644
index db2610f..0000000
--- a/src/common/architecture/scripts/ScriptFilterListProvider.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { Context } from '../entrypoint/Context';
-import Script from './Script';
-import ScriptProvider from './ScriptProvider';
-
-/**
- * @deprecated
- */
-export default abstract class ScriptFilterListProvider
-  implements ScriptProvider
-{
-  protected abstract getUnfilteredScriptsList(): Script[];
-
-  getScripts(context: Context) {
-    const scripts = this.getUnfilteredScriptsList();
-    return scripts.filter(
-      (script) =>
-        script.page === context.page &&
-        script.environment === context.environment &&
-        script.runPhase === context.runPhase,
-    );
-  }
-}
diff --git a/src/common/architecture/scripts/ScriptProvider.ts b/src/common/architecture/scripts/ScriptProvider.ts
deleted file mode 100644
index 63b896e..0000000
--- a/src/common/architecture/scripts/ScriptProvider.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { Context } from "../entrypoint/Context";
-import Script from "./Script";
-
-/**
- * @deprecated
- */
-export default interface ScriptProvider {
-  getScripts(context: Context): Script[];
-}
diff --git a/src/common/architecture/scripts/nodeWatcher/LegacyNodeWatcherScript.ts b/src/common/architecture/scripts/nodeWatcher/LegacyNodeWatcherScript.ts
deleted file mode 100644
index 211210d..0000000
--- a/src/common/architecture/scripts/nodeWatcher/LegacyNodeWatcherScript.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-import NodeWatcherSingleton, { NodeWatcherAdapter } from '../../../../infrastructure/presentation/nodeWatcher/NodeWatcher.adapter';
-import { ConcreteNodeWatcherScriptHandler } from './handlers/NodeWatcherScriptHandler';
-import Script from '../Script';
-
-/**
- * @deprecated
- */
-export default abstract class LegacyNodeWatcherScript<Options> extends Script {
-  public abstract handlers: Map<
-    string,
-    ConcreteNodeWatcherScriptHandler<Options>
-  >;
-
-  private nodeWatcher: NodeWatcherAdapter;
-
-  constructor() {
-    super();
-
-    // TODO(https://iavm.xyz/b/226): Retrieve this via constructor injection.
-    this.nodeWatcher = NodeWatcherSingleton.getInstance();
-  }
-
-  /**
-   * Resolves to the options when the script is executed.
-   *
-   */
-  protected abstract optionsFactory(): Options;
-
-  execute() {
-    const options = this.optionsFactory();
-
-    this.nodeWatcher.start();
-    for (const [key, handlerClass] of this.handlers) {
-      const handler = new handlerClass(options);
-      this.nodeWatcher.setHandler(key, handler);
-    }
-  }
-}
diff --git a/src/common/architecture/scripts/nodeWatcher/handlers/CssSelectorNodeWatcherScriptHandler.ts b/src/common/architecture/scripts/nodeWatcher/handlers/CssSelectorNodeWatcherScriptHandler.ts
deleted file mode 100644
index 8756b72..0000000
--- a/src/common/architecture/scripts/nodeWatcher/handlers/CssSelectorNodeWatcherScriptHandler.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { NodeWatcherScriptHandler } from './NodeWatcherScriptHandler';
-import { NodeMutation, NodeMutationType } from '../../../../../presentation/nodeWatcher/NodeWatcherHandler';
-
-/**
- * @deprecated
- */
-export default abstract class CssSelectorNodeWatcherScriptHandler<
-  Options,
-> extends NodeWatcherScriptHandler<Options> {
-  readonly mutationTypesProcessed: NodeMutationType[] = [
-    NodeMutationType.InitialDiscovery,
-    NodeMutationType.NewNode,
-  ];
-
-  abstract readonly cssSelector: string;
-
-  nodeFilter(nodeMutation: NodeMutation): boolean {
-    if (
-      !this.mutationTypesProcessed.includes(nodeMutation.type) ||
-      !(nodeMutation.node instanceof Element)
-    ) {
-      return false;
-    }
-    return nodeMutation.node.matches(this.cssSelector);
-  }
-
-  get initialDiscoverySelector() {
-    return this.cssSelector;
-  }
-}
diff --git a/src/common/architecture/scripts/nodeWatcher/handlers/NodeWatcherScriptHandler.ts b/src/common/architecture/scripts/nodeWatcher/handlers/NodeWatcherScriptHandler.ts
deleted file mode 100644
index 712f533..0000000
--- a/src/common/architecture/scripts/nodeWatcher/handlers/NodeWatcherScriptHandler.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { NodeMutation, NodeWatcherHandler } from "../../../../../presentation/nodeWatcher/NodeWatcherHandler";
-
-export abstract class NodeWatcherScriptHandler<Options>
-  implements NodeWatcherHandler
-{
-  abstract initialDiscoverySelector?: string;
-  constructor(protected options: Options) {}
-  abstract nodeFilter(nodeMutation: NodeMutation): boolean;
-  abstract onMutatedNode(nodeMutation: NodeMutation): void;
-}
-
-export type ConcreteNodeWatcherScriptHandler<Options> = {
-  new (options: Options): NodeWatcherScriptHandler<Options>;
-};
diff --git a/src/common/architecture/scripts/setUpDependencies/SetUpDependenciesScript.ts b/src/common/architecture/scripts/setUpDependencies/SetUpDependenciesScript.ts
deleted file mode 100644
index 1774a58..0000000
--- a/src/common/architecture/scripts/setUpDependencies/SetUpDependenciesScript.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import DependenciesProviderSingleton, { Dependency } from "../../dependenciesProvider/DependenciesProvider";
-import Script from "../Script";
-
-/**
- * @deprecated
- */
-export default abstract class SetUpDependenciesScript extends Script {
-  abstract dependencies: Dependency[];
-
-  execute() {
-    const dependenciesProvider = DependenciesProviderSingleton.getInstance();
-    this.dependencies.forEach(dependency => {
-      dependenciesProvider.setUpDependency(dependency);
-    });
-  }
-}
diff --git a/src/entryPoints/communityConsole/contentScripts/main.ts b/src/entryPoints/communityConsole/contentScripts/main.ts
index c4f994f..47ec269 100644
--- a/src/entryPoints/communityConsole/contentScripts/main.ts
+++ b/src/entryPoints/communityConsole/contentScripts/main.ts
@@ -8,12 +8,6 @@
   StartupDataStorageDependency,
   WorkflowsImportDependency,
 } from '../../../common/architecture/dependenciesProvider/DependenciesProvider';
-import { Context } from '../../../common/architecture/entrypoint/Context';
-import {
-  ScriptEnvironment,
-  ScriptPage,
-  ScriptRunPhase,
-} from '../../../common/architecture/scripts/Script';
 import AutoRefreshThreadListHideHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListHide.handler';
 import AutoRefreshThreadListSetUpHandler from '../../../features/autoRefresh/presentation/nodeWatcherHandlers/threadListSetUp.handler';
 import AutoRefreshStylesScript from '../../../features/autoRefresh/presentation/scripts/styles.script';
@@ -21,7 +15,6 @@
 import CCDarkThemeEcAppHandler from '../../../features/ccDarkTheme/presentation/nodeWatcherHandlers/ecApp.handler';
 import CCDarkThemeReportDialogHandler from '../../../features/ccDarkTheme/presentation/nodeWatcherHandlers/reportDialog.handler';
 import CCDarkThemeUnifiedProfilesIframeHandler from '../../../features/ccDarkTheme/presentation/nodeWatcherHandlers/unifiedProfilesIframe.handler';
-import Features from '../../../features/Features';
 import CCInfiniteScroll from '../../../features/infiniteScroll/core/ccInfiniteScroll';
 import { NodeWatcherAdapter } from '../../../infrastructure/presentation/nodeWatcher/NodeWatcher.adapter';
 import NodeWatcherScriptAdapter from '../../../infrastructure/presentation/scripts/NodeWatcherScript.adapter';
@@ -29,7 +22,6 @@
 import ScriptSorterAdapter from '../../../infrastructure/presentation/scripts/ScriptSorter.adapter';
 import { SortedScriptsProviderAdapter } from '../../../infrastructure/presentation/scripts/SortedScriptsProvider.adapter';
 import { NodeWatcherHandler } from '../../../presentation/nodeWatcher/NodeWatcherHandler';
-import StandaloneScripts from '../../../presentation/standaloneScripts/Scripts';
 import CCInfiniteScrollSetUpHandler from '../../../features/infiniteScroll/presentation/nodeWatcherHandlers/ccInfiniteScrollSetUp.handler';
 import CCInfiniteScrollLoadMoreBarHandler from '../../../features/infiniteScroll/presentation/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBar.handler';
 import CCInfiniteScrollLoadMoreBtnHandler from '../../../features/infiniteScroll/presentation/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBtn.handler';
@@ -68,12 +60,6 @@
 
   const ccInfiniteScroll = new CCInfiniteScroll();
 
-  const context: Context = {
-    page: ScriptPage.CommunityConsole,
-    environment: ScriptEnvironment.ContentScript,
-    runPhase: ScriptRunPhase.Main,
-  };
-
   return new ScriptRunner(
     new SortedScriptsProviderAdapter(
       [
@@ -161,10 +147,6 @@
         // Standalone scripts
         new ApplyStartupDataModificationsOnMainScript(startupDataStorage),
         new InjectLitComponentsScript(),
-
-        // Non-DI scripts (legacy, should be migrated to use a DI approach)
-        ...new Features().getScripts(context),
-        ...new StandaloneScripts().getScripts(context),
       ],
       new ScriptSorterAdapter(),
     ).getScripts(),
diff --git a/src/entryPoints/communityConsole/contentScripts/start.ts b/src/entryPoints/communityConsole/contentScripts/start.ts
index e7023a2..1d02a6b 100644
--- a/src/entryPoints/communityConsole/contentScripts/start.ts
+++ b/src/entryPoints/communityConsole/contentScripts/start.ts
@@ -8,21 +8,13 @@
   StartupDataStorageDependency,
   WorkflowsImportDependency,
 } from '../../../common/architecture/dependenciesProvider/DependenciesProvider';
-import { Context } from '../../../common/architecture/entrypoint/Context';
-import {
-  ScriptEnvironment,
-  ScriptPage,
-  ScriptRunPhase,
-} from '../../../common/architecture/scripts/Script';
 import AutoRefreshSetUpScript from '../../../features/autoRefresh/presentation/scripts/setUp.script';
 import CCDarkThemeInjectAutoDarkTheme from '../../../features/ccDarkTheme/presentation/scripts/injectAutoDarkTheme.script';
 import CCDarkThemeInjectForcedDarkTheme from '../../../features/ccDarkTheme/presentation/scripts/injectForcedDarkTheme.script';
-import Features from '../../../features/Features';
 import InteropThreadPageSetupScript from '../../../features/interopThreadPage/presentation/scripts/setup.script';
 import ScriptRunner from '../../../infrastructure/presentation/scripts/ScriptRunner';
 import ScriptSorterAdapter from '../../../infrastructure/presentation/scripts/ScriptSorter.adapter';
 import { SortedScriptsProviderAdapter } from '../../../infrastructure/presentation/scripts/SortedScriptsProvider.adapter';
-import StandaloneScripts from '../../../presentation/standaloneScripts/Scripts';
 import LoadDraftsSetupScript from '../../../features/loadDrafts/presentation/scripts/setup.script';
 import WorkflowsImportSetUpScript from '../../../features/workflows/presentation/scripts/importSetUp.script';
 import CCExtraInfoSetUpScript from '../../../features/extraInfo/presentation/scripts/ccExtraInfoSetUp.script';
@@ -48,12 +40,6 @@
     WorkflowsImportDependency,
   );
 
-  const context: Context = {
-    page: ScriptPage.CommunityConsole,
-    environment: ScriptEnvironment.ContentScript,
-    runPhase: ScriptRunPhase.Start,
-  };
-
   return new ScriptRunner(
     new SortedScriptsProviderAdapter(
       [
@@ -71,10 +57,6 @@
         new MWI18nServerScript(),
         new MWOptionsWatcherServerScript(),
         new XHRInterceptorScript(),
-
-        // Non-DI scripts (legacy, should be migrated to use a DI approach)
-        ...new Features().getScripts(context),
-        ...new StandaloneScripts().getScripts(context),
       ],
       new ScriptSorterAdapter(),
     ).getScripts(),
diff --git a/src/features/Features.ts b/src/features/Features.ts
deleted file mode 100644
index f3c9c98..0000000
--- a/src/features/Features.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import Feature from '../common/architecture/features/Feature';
-import ScriptFilterListProvider from '../common/architecture/scripts/ScriptFilterListProvider';
-
-export type ConcreteFeatureClass = { new (): Feature };
-
-export default class Features extends ScriptFilterListProvider {
-  private features: ConcreteFeatureClass[] = [];
-  private initializedFeatures: Feature[];
-
-  protected getUnfilteredScriptsList() {
-    const features = this.getFeatures();
-    return features.map((feature) => feature.getScripts()).flat(1);
-  }
-
-  private getFeatures() {
-    if (this.initializedFeatures === undefined) {
-      this.initializedFeatures = this.features.map((feature) => new feature());
-    }
-    return this.initializedFeatures;
-  }
-}
diff --git a/src/presentation/standaloneScripts/Scripts.ts b/src/presentation/standaloneScripts/Scripts.ts
deleted file mode 100644
index 7f3b602..0000000
--- a/src/presentation/standaloneScripts/Scripts.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import Script, {
-  ConcreteScript,
-} from '../../common/architecture/scripts/Script';
-import ScriptFilterListProvider from '../../common/architecture/scripts/ScriptFilterListProvider';
-
-export default class StandaloneScripts extends ScriptFilterListProvider {
-  private scripts: ConcreteScript[] = [];
-  private initializedScripts: Script[];
-
-  protected getUnfilteredScriptsList() {
-    if (this.initializedScripts === undefined) {
-      this.initializedScripts = this.scripts.map((script) => new script());
-    }
-    return this.initializedScripts;
-  }
-}