forked from microsoft/accessibility-insights-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tab-context-factory.ts
212 lines (199 loc) · 9.1 KB
/
tab-context-factory.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { NeedsReviewCardSelectionActionCreator } from 'background/actions/needs-review-card-selection-action-creator';
import { NeedsReviewScanResultActionCreator } from 'background/actions/needs-review-scan-result-action-creator';
import { TabStopRequirementActionCreator } from 'background/actions/tab-stop-requirement-action-creator';
import { BrowserMessageBroadcasterFactory } from 'background/browser-message-broadcaster-factory';
import { DevToolsMonitor } from 'background/dev-tools-monitor';
import { PersistedData } from 'background/get-persisted-data';
import { BrowserAdapter } from 'common/browser-adapters/browser-adapter';
import { VisualizationConfigurationFactory } from 'common/configs/visualization-configuration-factory';
import { IndexedDBAPI } from 'common/indexedDB/indexedDB';
import { Logger } from 'common/logging/logger';
import { NotificationCreator } from 'common/notification-creator';
import { PromiseFactory } from 'common/promises/promise-factory';
import { StateDispatcher } from 'common/state-dispatcher';
import { UrlParser } from 'common/url-parser';
import { ActionCreator } from './actions/action-creator';
import { ActionHub } from './actions/action-hub';
import { CardSelectionActionCreator } from './actions/card-selection-action-creator';
import { ContentActionCreator } from './actions/content-action-creator';
import { DetailsViewActionCreator } from './actions/details-view-action-creator';
import { DevToolsActionCreator } from './actions/dev-tools-action-creator';
import { InjectionActionCreator } from './actions/injection-action-creator';
import { InspectActionCreator } from './actions/inspect-action-creator';
import { PathSnippetActionCreator } from './actions/path-snippet-action-creator';
import { PopupActionCreator } from './actions/popup-action-creator';
import { ShortcutsPageActionCreator } from './actions/shortcuts-page-action-creator';
import { TabActionCreator } from './actions/tab-action-creator';
import { UnifiedScanResultActionCreator } from './actions/unified-scan-result-action-creator';
import { ExtensionDetailsViewController } from './extension-details-view-controller';
import { ContentScriptInjector } from './injector/content-script-injector';
import { InjectorController } from './injector-controller';
import { Interpreter } from './interpreter';
import { ShortcutsPageController } from './shortcuts-page-controller';
import { TabContextStoreHub } from './stores/tab-context-store-hub';
import { TabContext } from './tab-context';
import { TargetTabController } from './target-tab-controller';
import { TelemetryEventHandler } from './telemetry/telemetry-event-handler';
import { UsageLogger } from './usage-logger';
export class TabContextFactory {
constructor(
private visualizationConfigurationFactory: VisualizationConfigurationFactory,
private telemetryEventHandler: TelemetryEventHandler,
private targetTabController: TargetTabController,
private notificationCreator: NotificationCreator,
private detailsViewController: ExtensionDetailsViewController,
private browserAdapter: BrowserAdapter,
private readonly broadcasterFactory: BrowserMessageBroadcasterFactory,
private readonly promiseFactory: PromiseFactory,
private readonly logger: Logger,
private readonly usageLogger: UsageLogger,
private readonly persistedData: PersistedData,
private readonly indexedDBInstance: IndexedDBAPI,
private readonly urlParser: UrlParser,
) {}
public createTabContext(tabId: number): TabContext {
const interpreter = new Interpreter();
const actionsHub = new ActionHub();
const storeHub = new TabContextStoreHub(
actionsHub,
this.visualizationConfigurationFactory,
this.persistedData,
this.indexedDBInstance,
this.logger,
tabId,
this.urlParser,
);
const shortcutsPageController = new ShortcutsPageController(this.browserAdapter);
const shortcutsPageActionCreator = new ShortcutsPageActionCreator(
interpreter,
shortcutsPageController,
this.telemetryEventHandler,
this.logger,
);
const actionCreator = new ActionCreator(
interpreter,
actionsHub,
this.detailsViewController,
this.telemetryEventHandler,
this.notificationCreator,
this.visualizationConfigurationFactory,
this.targetTabController,
this.logger,
);
const detailsViewActionCreator = new DetailsViewActionCreator(
interpreter,
actionsHub.detailsViewActions,
actionsHub.sidePanelActions,
this.detailsViewController,
this.telemetryEventHandler,
);
const tabStopRequirementActionCreator = new TabStopRequirementActionCreator(
interpreter,
actionsHub.tabStopRequirementActions,
this.telemetryEventHandler,
);
const tabActionCreator = new TabActionCreator(
interpreter,
actionsHub.tabActions,
this.browserAdapter,
this.telemetryEventHandler,
this.logger,
tabId,
);
const popupActionCreator = new PopupActionCreator(
interpreter,
actionsHub.tabActions,
this.telemetryEventHandler,
this.usageLogger,
);
const devToolsActionCreator = new DevToolsActionCreator(
interpreter,
actionsHub.devToolActions,
this.telemetryEventHandler,
);
const inspectActionsCreator = new InspectActionCreator(
interpreter,
actionsHub.inspectActions,
this.telemetryEventHandler,
this.browserAdapter,
this.logger,
);
const pathSnippetActionCreator = new PathSnippetActionCreator(
interpreter,
actionsHub.pathSnippetActions,
);
const unifiedScanResultActionCreator = new UnifiedScanResultActionCreator(
interpreter,
actionsHub.unifiedScanResultActions,
this.telemetryEventHandler,
this.notificationCreator,
);
const needsReviewScanResultActionCreator = new NeedsReviewScanResultActionCreator(
interpreter,
actionsHub.needsReviewScanResultActions,
this.telemetryEventHandler,
this.notificationCreator,
);
const contentActionCreator = new ContentActionCreator(
interpreter,
actionsHub.contentActions,
this.telemetryEventHandler,
this.detailsViewController,
);
const cardSelectionActionCreator = new CardSelectionActionCreator(
interpreter,
actionsHub.cardSelectionActions,
actionsHub.visualizationActions,
this.telemetryEventHandler,
);
const needsReviewCardSelectionActionCreator = new NeedsReviewCardSelectionActionCreator(
interpreter,
actionsHub.needsReviewCardSelectionActions,
actionsHub.visualizationActions,
this.telemetryEventHandler,
);
const injectionActionCreator = new InjectionActionCreator(
interpreter,
actionsHub.injectionActions,
this.notificationCreator,
);
const injectorController = new InjectorController(
new ContentScriptInjector(this.browserAdapter, this.promiseFactory, this.logger),
storeHub.visualizationStore,
interpreter,
storeHub.tabStore,
storeHub.inspectStore,
this.logger,
);
const messageBroadcaster = this.broadcasterFactory.createTabSpecificBroadcaster(tabId);
shortcutsPageActionCreator.registerCallbacks();
actionCreator.registerCallbacks();
detailsViewActionCreator.registerCallback();
devToolsActionCreator.registerCallbacks();
inspectActionsCreator.registerCallbacks();
pathSnippetActionCreator.registerCallbacks();
tabActionCreator.registerCallbacks();
tabStopRequirementActionCreator.registerCallbacks();
popupActionCreator.registerCallbacks();
contentActionCreator.registerCallbacks();
needsReviewScanResultActionCreator.registerCallbacks();
needsReviewCardSelectionActionCreator.registerCallbacks();
unifiedScanResultActionCreator.registerCallbacks();
cardSelectionActionCreator.registerCallbacks();
injectionActionCreator.registerCallbacks();
injectorController.initialize();
const dispatcher = new StateDispatcher(messageBroadcaster, storeHub, this.logger);
dispatcher.initialize();
const devToolsMonitor = new DevToolsMonitor(
tabId,
this.browserAdapter,
this.promiseFactory,
interpreter,
actionsHub.devToolActions,
);
devToolsMonitor.initialize();
return new TabContext(interpreter, storeHub);
}
}