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[];