chore(architecture): deprecate some of the new architecture
In order to use Dependency Injection, we need to deprecate old classes
which aren't suitable for it, and which will be replaced by other ones
in followup commits.
Bug: twpowertools:226
Change-Id: I232bd9f036b6fb540eba27d7586d8054ce3de789
diff --git a/src/common/architecture/entrypoint/Context.ts b/src/common/architecture/entrypoint/Context.ts
index 0ebe29f..c2f50ad 100644
--- a/src/common/architecture/entrypoint/Context.ts
+++ b/src/common/architecture/entrypoint/Context.ts
@@ -4,6 +4,9 @@
ScriptRunPhase,
} from '../scripts/Script';
+/**
+ * @deprecated
+ */
export interface Context {
page: ScriptPage;
environment: ScriptEnvironment;
diff --git a/src/common/architecture/entrypoint/EntrypointScriptRunner.ts b/src/common/architecture/entrypoint/EntrypointScriptRunner.ts
index 02ce31e..e839168 100644
--- a/src/common/architecture/entrypoint/EntrypointScriptRunner.ts
+++ b/src/common/architecture/entrypoint/EntrypointScriptRunner.ts
@@ -1,14 +1,17 @@
import Features from '../../../features/Features';
import StandaloneScripts from '../../../scripts/Scripts';
import ScriptProvider from '../scripts/ScriptProvider';
-import ScriptRunner from '../scripts/ScriptRunner';
+import LegacyScriptRunner from '../scripts/LegacyScriptRunner';
import { Context } from './Context';
+/**
+ * @deprecated
+ */
export default class EntrypointScriptRunner {
- private scriptRunner: ScriptRunner;
+ private scriptRunner: LegacyScriptRunner;
constructor(public context: Context) {
- this.scriptRunner = new ScriptRunner();
+ this.scriptRunner = new LegacyScriptRunner();
this.addScriptProvider(new Features());
this.addScriptProvider(new StandaloneScripts());
}
diff --git a/src/common/architecture/features/Feature.ts b/src/common/architecture/features/Feature.ts
index 76f5990..5f0cfa0 100644
--- a/src/common/architecture/features/Feature.ts
+++ b/src/common/architecture/features/Feature.ts
@@ -1,6 +1,9 @@
import { OptionCodename } from '../../options/optionsPrototype';
import Script, { ConcreteScript } from '../scripts/Script';
+/**
+ * @deprecated
+ */
export default abstract class Feature {
/**
* Internal codename used for the feature.
diff --git a/src/common/architecture/scripts/ScriptRunner.test.ts b/src/common/architecture/scripts/LegacyScriptRunner.test.ts
similarity index 94%
rename from src/common/architecture/scripts/ScriptRunner.test.ts
rename to src/common/architecture/scripts/LegacyScriptRunner.test.ts
index 7435c8e..1ae8f72 100644
--- a/src/common/architecture/scripts/ScriptRunner.test.ts
+++ b/src/common/architecture/scripts/LegacyScriptRunner.test.ts
@@ -4,7 +4,7 @@
ScriptRunPhase,
} from './Script';
import { beforeEach, expect, it, jest } from '@jest/globals';
-import ScriptRunner from './ScriptRunner';
+import LegacyScriptRunner from './LegacyScriptRunner';
interface FakeScriptOptions {
id: string;
@@ -69,7 +69,7 @@
},
];
- const scriptRunner = new ScriptRunner();
+ const scriptRunner = new LegacyScriptRunner();
scriptRunner.add(...scriptsConfig.map((config) => config.script));
scriptRunner.run();
diff --git a/src/common/architecture/scripts/ScriptRunner.ts b/src/common/architecture/scripts/LegacyScriptRunner.ts
similarity index 89%
rename from src/common/architecture/scripts/ScriptRunner.ts
rename to src/common/architecture/scripts/LegacyScriptRunner.ts
index 4a2ed2d..f7b3e82 100644
--- a/src/common/architecture/scripts/ScriptRunner.ts
+++ b/src/common/architecture/scripts/LegacyScriptRunner.ts
@@ -1,6 +1,6 @@
import Script from './Script';
-export default class ScriptRunner {
+export default class LegacyScriptRunner {
private scripts: Script[] = [];
add(...scripts: Script[]) {
diff --git a/src/common/architecture/scripts/Script.ts b/src/common/architecture/scripts/Script.ts
index 8f45601..0e33e7e 100644
--- a/src/common/architecture/scripts/Script.ts
+++ b/src/common/architecture/scripts/Script.ts
@@ -1,3 +1,6 @@
+/**
+ * @deprecated
+ */
export enum ScriptRunPhase {
/**
* Executed before any Javascript is executed.
@@ -9,15 +12,24 @@
Main,
}
+/**
+ * @deprecated
+ */
export enum ScriptEnvironment {
ContentScript,
InjectedScript,
}
+/**
+ * @deprecated
+ */
export enum ScriptPage {
CommunityConsole,
}
+/**
+ * @deprecated
+ */
export const ScriptRunPhaseToRunTime: Record<
ScriptRunPhase,
chrome.userScripts.RunAt
@@ -26,6 +38,9 @@
[ScriptRunPhase.Main]: 'document_idle',
};
+/**
+ * @deprecated
+ */
export const ScriptEnvironmentToExecutionWorld: Record<
ScriptEnvironment,
chrome.scripting.ExecutionWorld
@@ -45,17 +60,20 @@
/**
* Page where the script should be executed.
+ * @deprecated
*/
abstract readonly page: ScriptPage;
/**
* Environment where the script should be executed.
+ * @deprecated
*/
abstract readonly environment: ScriptEnvironment;
/**
* If {@link environment} is {@link ScriptEnvironment.ContentScript}, phase of
* the page loading when the script should be executed.
+ * @deprecated
*/
abstract readonly runPhase?: ScriptRunPhase;
diff --git a/src/common/architecture/scripts/ScriptFilterListProvider.ts b/src/common/architecture/scripts/ScriptFilterListProvider.ts
index 275a08c..db2610f 100644
--- a/src/common/architecture/scripts/ScriptFilterListProvider.ts
+++ b/src/common/architecture/scripts/ScriptFilterListProvider.ts
@@ -2,6 +2,9 @@
import Script from './Script';
import ScriptProvider from './ScriptProvider';
+/**
+ * @deprecated
+ */
export default abstract class ScriptFilterListProvider
implements ScriptProvider
{
diff --git a/src/common/architecture/scripts/ScriptProvider.ts b/src/common/architecture/scripts/ScriptProvider.ts
index e18e405..63b896e 100644
--- a/src/common/architecture/scripts/ScriptProvider.ts
+++ b/src/common/architecture/scripts/ScriptProvider.ts
@@ -1,6 +1,9 @@
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/NodeWatcherScript.ts b/src/common/architecture/scripts/nodeWatcher/LegacyNodeWatcherScript.ts
similarity index 89%
rename from src/common/architecture/scripts/nodeWatcher/NodeWatcherScript.ts
rename to src/common/architecture/scripts/nodeWatcher/LegacyNodeWatcherScript.ts
index 2c9b91e..b4c07a5 100644
--- a/src/common/architecture/scripts/nodeWatcher/NodeWatcherScript.ts
+++ b/src/common/architecture/scripts/nodeWatcher/LegacyNodeWatcherScript.ts
@@ -2,7 +2,10 @@
import { ConcreteNodeWatcherScriptHandler } from './handlers/NodeWatcherScriptHandler';
import Script from '../Script';
-export default abstract class NodeWatcherScript<Options> extends Script {
+/**
+ * @deprecated
+ */
+export default abstract class LegacyNodeWatcherScript<Options> extends Script {
public abstract handlers: Map<
string,
ConcreteNodeWatcherScriptHandler<Options>
diff --git a/src/common/architecture/scripts/nodeWatcher/handlers/CssSelectorNodeWatcherScriptHandler.ts b/src/common/architecture/scripts/nodeWatcher/handlers/CssSelectorNodeWatcherScriptHandler.ts
index 22e34af..b5c3698 100644
--- a/src/common/architecture/scripts/nodeWatcher/handlers/CssSelectorNodeWatcherScriptHandler.ts
+++ b/src/common/architecture/scripts/nodeWatcher/handlers/CssSelectorNodeWatcherScriptHandler.ts
@@ -1,6 +1,9 @@
import { NodeWatcherScriptHandler } from './NodeWatcherScriptHandler';
import { NodeMutation, NodeMutationType } from '../../../../nodeWatcher/NodeWatcherHandler';
+/**
+ * @deprecated
+ */
export default abstract class CssSelectorNodeWatcherScriptHandler<
Options,
> extends NodeWatcherScriptHandler<Options> {
diff --git a/src/common/architecture/scripts/setUpDependencies/SetUpDependenciesScript.ts b/src/common/architecture/scripts/setUpDependencies/SetUpDependenciesScript.ts
index b5ff6f0..1774a58 100644
--- a/src/common/architecture/scripts/setUpDependencies/SetUpDependenciesScript.ts
+++ b/src/common/architecture/scripts/setUpDependencies/SetUpDependenciesScript.ts
@@ -1,6 +1,9 @@
import DependenciesProviderSingleton, { Dependency } from "../../dependenciesProvider/DependenciesProvider";
import Script from "../Script";
+/**
+ * @deprecated
+ */
export default abstract class SetUpDependenciesScript extends Script {
abstract dependencies: Dependency[];
diff --git a/src/features/autoRefresh/scripts/nodeWatcher.script.ts b/src/features/autoRefresh/scripts/nodeWatcher.script.ts
index 5308a35..be9c2d3 100644
--- a/src/features/autoRefresh/scripts/nodeWatcher.script.ts
+++ b/src/features/autoRefresh/scripts/nodeWatcher.script.ts
@@ -6,7 +6,7 @@
ScriptPage,
ScriptRunPhase,
} from '../../../common/architecture/scripts/Script';
-import NodeWatcherScript from '../../../common/architecture/scripts/nodeWatcher/NodeWatcherScript';
+import LegacyNodeWatcherScript from '../../../common/architecture/scripts/nodeWatcher/LegacyNodeWatcherScript';
import AutoRefresh from '../core/autoRefresh';
import AutoRefreshThreadListHideHandler from '../nodeWatcherHandlers/threadListHide.handler';
import AutoRefreshThreadListSetUpHandler from '../nodeWatcherHandlers/threadListSetUp.handler';
@@ -15,7 +15,7 @@
autoRefresh: AutoRefresh;
}
-export default class AutoRefreshNodeWatcherScript extends NodeWatcherScript<AutoRefreshNodeWatcherDependencies> {
+export default class AutoRefreshNodeWatcherScript extends LegacyNodeWatcherScript<AutoRefreshNodeWatcherDependencies> {
public page = ScriptPage.CommunityConsole;
public environment = ScriptEnvironment.ContentScript;
public runPhase = ScriptRunPhase.Main;
diff --git a/src/features/ccDarkTheme/scripts/nodeWatcher.script.ts b/src/features/ccDarkTheme/scripts/nodeWatcher.script.ts
index 7a78798..83e343e 100644
--- a/src/features/ccDarkTheme/scripts/nodeWatcher.script.ts
+++ b/src/features/ccDarkTheme/scripts/nodeWatcher.script.ts
@@ -7,7 +7,7 @@
ScriptPage,
ScriptRunPhase,
} from '../../../common/architecture/scripts/Script';
-import NodeWatcherScript from '../../../common/architecture/scripts/nodeWatcher/NodeWatcherScript';
+import LegacyNodeWatcherScript from '../../../common/architecture/scripts/nodeWatcher/LegacyNodeWatcherScript';
import OptionsProvider from '../../../common/options/OptionsProvider';
import ReportDialogColorThemeFix from '../core/logic/reportDialog';
import CCDarkThemeEcAppHandler from '../nodeWatcherHandlers/ecApp.handler';
@@ -19,7 +19,7 @@
optionsProvider: OptionsProvider;
}
-export default class CCDarkThemeNodeWatcherScript extends NodeWatcherScript<CCDarkThemeNodeWatcherDependencies> {
+export default class CCDarkThemeNodeWatcherScript extends LegacyNodeWatcherScript<CCDarkThemeNodeWatcherDependencies> {
public page = ScriptPage.CommunityConsole;
public environment = ScriptEnvironment.ContentScript;
public runPhase = ScriptRunPhase.Main;
diff --git a/src/features/extraInfo/scripts/ccExtraInfoMain.script.ts b/src/features/extraInfo/scripts/ccExtraInfoMain.script.ts
index 80fbfbf..199ff18 100644
--- a/src/features/extraInfo/scripts/ccExtraInfoMain.script.ts
+++ b/src/features/extraInfo/scripts/ccExtraInfoMain.script.ts
@@ -6,7 +6,7 @@
ScriptPage,
ScriptRunPhase,
} from '../../../common/architecture/scripts/Script';
-import NodeWatcherScript from '../../../common/architecture/scripts/nodeWatcher/NodeWatcherScript';
+import LegacyNodeWatcherScript from '../../../common/architecture/scripts/nodeWatcher/LegacyNodeWatcherScript';
import ExtraInfo from '../core';
import CCExtraInfoProfileAbuseChipsHandler from '../nodeWatcherHandlers/profile/ccExtraInfoProfileAbuseChips.handler';
import CCExtraInfoProfilePerForumStatsHandler from '../nodeWatcherHandlers/profile/ccExtraInfoProfilePerForumStats.handler';
@@ -20,7 +20,7 @@
extraInfo: ExtraInfo;
}
-export default class CCExtraInfoMainScript extends NodeWatcherScript<CCExtraInfoMainOptions> {
+export default class CCExtraInfoMainScript extends LegacyNodeWatcherScript<CCExtraInfoMainOptions> {
page = ScriptPage.CommunityConsole;
environment = ScriptEnvironment.ContentScript;
runPhase = ScriptRunPhase.Main;
diff --git a/src/features/infiniteScroll/scripts/ccInfiniteScroll.script.ts b/src/features/infiniteScroll/scripts/ccInfiniteScroll.script.ts
index d37dc84..e12a7c4 100644
--- a/src/features/infiniteScroll/scripts/ccInfiniteScroll.script.ts
+++ b/src/features/infiniteScroll/scripts/ccInfiniteScroll.script.ts
@@ -3,7 +3,7 @@
ScriptPage,
ScriptRunPhase,
} from '../../../common/architecture/scripts/Script';
-import NodeWatcherScript from '../../../common/architecture/scripts/nodeWatcher/NodeWatcherScript';
+import LegacyNodeWatcherScript from '../../../common/architecture/scripts/nodeWatcher/LegacyNodeWatcherScript';
import CCInfiniteScroll from '../core/ccInfiniteScroll';
import CCInfiniteScrollLoadMoreBarHandler from '../nodeWatcherHandlers/ccInfiniteScrollLoadMoreBar.handler';
import CCInfiniteScrollLoadMoreBtnHandler from '../nodeWatcherHandlers/ccInfiniteScrollLoadMoreBtn.handler';
@@ -13,7 +13,7 @@
ccInfiniteScroll: CCInfiniteScroll;
}
-export default class CCInfiniteScrollScript extends NodeWatcherScript<InfiniteScrollNodeWatcherOptions> {
+export default class CCInfiniteScrollScript extends LegacyNodeWatcherScript<InfiniteScrollNodeWatcherOptions> {
page = ScriptPage.CommunityConsole;
environment = ScriptEnvironment.ContentScript;
runPhase = ScriptRunPhase.Main;
diff --git a/src/features/workflows/scripts/nodeWatcher.script.ts b/src/features/workflows/scripts/nodeWatcher.script.ts
index 8d26c86..36c5a75 100644
--- a/src/features/workflows/scripts/nodeWatcher.script.ts
+++ b/src/features/workflows/scripts/nodeWatcher.script.ts
@@ -7,7 +7,7 @@
ScriptPage,
ScriptRunPhase,
} from '../../../common/architecture/scripts/Script';
-import NodeWatcherScript from '../../../common/architecture/scripts/nodeWatcher/NodeWatcherScript';
+import LegacyNodeWatcherScript from '../../../common/architecture/scripts/nodeWatcher/LegacyNodeWatcherScript';
import WorkflowsImport from '../core/communityConsole/import';
import Workflows from '../core/communityConsole/workflows';
import WorkflowsImportCRTagsHandler from '../nodeWatcherHandlers/crTags.handler';
@@ -18,7 +18,7 @@
workflowsImport: WorkflowsImport;
}
-export default class WorkflowsNodeWatcherScript extends NodeWatcherScript<WorkflowsNodeWatcherDependencies> {
+export default class WorkflowsNodeWatcherScript extends LegacyNodeWatcherScript<WorkflowsNodeWatcherDependencies> {
public page = ScriptPage.CommunityConsole;
public environment = ScriptEnvironment.ContentScript;
public runPhase = ScriptRunPhase.Main;