Skip to content

Commit dd9f9d7

Browse files
dgp1130dylhunn
authored andcommitted
Revert "refactor(devtools): implement iframe support for Angular DevTools' browser code (angular#53934)" (angular#54629)
This reverts commit dd3dac9. PR Close angular#54629
1 parent 133319e commit dd9f9d7

15 files changed

Lines changed: 354 additions & 899 deletions

devtools/projects/protocol/src/lib/messages.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -213,19 +213,6 @@ export interface Route {
213213
isAux: boolean;
214214
}
215215

216-
export interface AngularDetection {
217-
// This is necessary because the runtime
218-
// message listener handles messages globally
219-
// including from other extensions. We don't
220-
// want to set icon and/or popup based on
221-
// a message coming from an unrelated extension.
222-
isAngularDevTools: true;
223-
isIvy: boolean;
224-
isAngular: boolean;
225-
isDebugMode: boolean;
226-
isSupportedAngularVersion: boolean;
227-
}
228-
229216
export type Topic = keyof Events;
230217

231218
export interface InjectorGraphViewQuery {
@@ -286,13 +273,4 @@ export interface Events {
286273
) => void;
287274

288275
logProvider: (injector: SerializedInjector, providers: SerializedProviderRecord) => void;
289-
290-
contentScriptConnected: (frameId: number, name: string, url: string) => void;
291-
contentScriptDisconnected: (frameId: number, name: string, url: string) => void;
292-
enableFrameConnection: (frameId: number, tabId: number) => void;
293-
frameConnected: (frameId: number) => void;
294-
detectAngular: (detectionResult: AngularDetection) => void;
295-
backendReady: () => void;
296-
297-
log: (logEvent: {message: string; level: 'log' | 'warn' | 'debug' | 'error'}) => void;
298276
}

devtools/projects/shell-browser/src/app/BUILD.bazel

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
load("@io_bazel_rules_sass//:defs.bzl", "sass_binary")
22
load("//devtools/tools:ng_module.bzl", "ng_module")
3-
load("//devtools/tools:typescript.bzl", "ts_library", "ts_test_library")
3+
load("//devtools/tools:typescript.bzl", "ts_library")
44
load("//tools:defaults.bzl", "esbuild")
5-
load("//devtools/tools:defaults.bzl", "karma_web_test_suite")
65

76
package(default_visibility = ["//visibility:public"])
87

@@ -16,6 +15,7 @@ ng_module(
1615
srcs = [
1716
"app.component.ts",
1817
"app.module.ts",
18+
"inject.ts",
1919
],
2020
angular_assets = [
2121
"app.component.html",
@@ -35,8 +35,6 @@ ng_module(
3535
"//packages/core",
3636
"//packages/platform-browser",
3737
"//packages/platform-browser/animations",
38-
"@npm//@angular/material",
39-
"@npm//rxjs",
4038
],
4139
)
4240

@@ -80,10 +78,8 @@ ts_library(
8078
"chrome-application-operations.ts",
8179
],
8280
deps = [
83-
":chrome_application_environment",
8481
"//devtools/projects/ng-devtools",
8582
"//devtools/projects/protocol",
86-
"//packages/core",
8783
"@npm//@types",
8884
],
8985
)
@@ -130,38 +126,7 @@ ts_library(
130126
srcs = [
131127
"background.ts",
132128
],
133-
deps = [
134-
":tab_manager",
135-
"//devtools/projects/protocol",
136-
"//devtools/projects/shell-browser/src/app:detect_angular_for_extension_icon",
137-
],
138-
)
139-
140-
ts_library(
141-
name = "tab_manager",
142-
srcs = [
143-
"tab_manager.ts",
144-
],
145-
deps = [
146-
"//devtools/projects/protocol",
147-
],
148-
)
149-
150-
karma_web_test_suite(
151-
name = "tab_manager_test",
152-
deps = [
153-
":tab_manager_test_lib",
154-
],
155-
)
156-
157-
ts_test_library(
158-
name = "tab_manager_test_lib",
159-
srcs = [
160-
"tab_manager_spec.ts",
161-
],
162-
deps = [
163-
":tab_manager",
164-
],
129+
deps = ["//devtools/projects/shell-browser/src/app:detect_angular_for_extension_icon"],
165130
)
166131

167132
ts_library(
@@ -197,8 +162,6 @@ ts_library(
197162
"detect-angular-for-extension-icon.ts",
198163
],
199164
deps = [
200-
":same_page_message_bus",
201-
"//devtools/projects/protocol",
202165
"//devtools/projects/shared-utils",
203166
"@npm//@types",
204167
],

devtools/projects/shell-browser/src/app/app.component.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,39 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {ChangeDetectorRef, Component, inject, OnInit} from '@angular/core';
9+
import {ChangeDetectorRef, Component, NgZone, OnInit} from '@angular/core';
10+
import {Events, MessageBus, PriorityAwareMessageBus} from 'protocol';
11+
12+
import {injectScripts} from './inject';
13+
import {ZoneAwareChromeMessageBus} from './zone-aware-chrome-message-bus';
14+
import {DevToolsComponent} from 'ng-devtools';
1015

1116
@Component({
1217
selector: 'app-root',
1318
templateUrl: './app.component.html',
1419
styleUrls: ['./app.component.scss'],
20+
providers: [
21+
{
22+
provide: MessageBus,
23+
useFactory(ngZone: NgZone): MessageBus<Events> {
24+
const port = chrome.runtime.connect({
25+
name: '' + chrome.devtools.inspectedWindow.tabId,
26+
});
27+
return new PriorityAwareMessageBus(new ZoneAwareChromeMessageBus(port, ngZone));
28+
},
29+
deps: [NgZone],
30+
},
31+
],
1532
})
1633
export class AppComponent implements OnInit {
17-
private _cd = inject(ChangeDetectorRef);
34+
constructor(private _cd: ChangeDetectorRef) {}
1835

1936
ngOnInit(): void {
2037
chrome.devtools.network.onNavigated.addListener(() => {
2138
window.location.reload();
2239
});
2340

41+
injectScripts(['app/backend_bundle.js']);
2442
this._cd.detectChanges();
2543
}
2644
}

devtools/projects/shell-browser/src/app/app.module.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,17 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {NgModule, NgZone} from '@angular/core';
10-
import {MatSelect} from '@angular/material/select';
9+
import {NgModule} from '@angular/core';
1110
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
1211
import {ApplicationEnvironment, ApplicationOperations, DevToolsComponent} from 'ng-devtools';
1312

1413
import {AppComponent} from './app.component';
1514
import {ChromeApplicationEnvironment} from './chrome-application-environment';
1615
import {ChromeApplicationOperations} from './chrome-application-operations';
17-
import {ZoneAwareChromeMessageBus} from './zone-aware-chrome-message-bus';
18-
import {Events, MessageBus, PriorityAwareMessageBus} from 'protocol';
1916

2017
@NgModule({
2118
declarations: [AppComponent],
22-
imports: [BrowserAnimationsModule, DevToolsComponent, MatSelect],
19+
imports: [BrowserAnimationsModule, DevToolsComponent],
2320
bootstrap: [AppComponent],
2421
providers: [
2522
{
@@ -30,17 +27,6 @@ import {Events, MessageBus, PriorityAwareMessageBus} from 'protocol';
3027
provide: ApplicationEnvironment,
3128
useClass: ChromeApplicationEnvironment,
3229
},
33-
{
34-
provide: MessageBus,
35-
useFactory(ngZone: NgZone): MessageBus<Events> {
36-
const port = chrome.runtime.connect({
37-
name: '' + chrome.devtools.inspectedWindow.tabId,
38-
});
39-
40-
return new PriorityAwareMessageBus(new ZoneAwareChromeMessageBus(port, ngZone));
41-
},
42-
deps: [NgZone],
43-
},
4430
],
4531
})
4632
export class AppModule {}

devtools/projects/shell-browser/src/app/backend.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import {initializeExtendedWindowOperations} from './chrome-window-extensions';
1414
import {SamePageMessageBus} from './same-page-message-bus';
1515

1616
const messageBus = new SamePageMessageBus(
17-
`angular-devtools-backend-${location.href}`,
18-
`angular-devtools-content-script-${location.href}`,
17+
'angular-devtools-backend',
18+
'angular-devtools-content-script',
1919
);
2020

2121
let initialized = false;
@@ -47,6 +47,4 @@ messageBus.on('handshake', () => {
4747
},
4848
false,
4949
);
50-
51-
messageBus.emit('backendReady');
5250
});

0 commit comments

Comments
 (0)