Skip to content

Commit 8378035

Browse files
Pi Songkunthamgrouma
authored andcommitted
Started the backend of the Dart Debug Extension if the flag is enabled. (#491)
* Started the backend of the Dart Debug Extension if the flag is enabled.
1 parent f278b51 commit 8378035

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

dwds/lib/dwds.dart

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import 'src/handlers/asset_handler.dart';
1616
import 'src/handlers/dev_handler.dart';
1717
import 'src/handlers/injected_handler.dart';
1818
import 'src/servers/devtools.dart';
19+
import 'src/servers/extension_backend.dart';
1920

2021
export 'src/connections/app_connection.dart' show AppConnection;
2122
export 'src/connections/debug_connection.dart' show DebugConnection;
@@ -56,7 +57,11 @@ class Dwds {
5657
@required bool serveDevTools,
5758
@required LogWriter logWriter,
5859
@required bool verbose,
60+
@optional bool enableDebugExtension,
5961
}) async {
62+
String extensionHostname;
63+
int extensionPort;
64+
enableDebugExtension ??= false;
6065
var assetHandler = AssetHandler(
6166
assetServerPort,
6267
applicationTarget,
@@ -66,8 +71,14 @@ class Dwds {
6671
var cascade = Cascade();
6772
var pipeline = const Pipeline();
6873

69-
pipeline =
70-
pipeline.addMiddleware(createInjectedHandler(reloadConfiguration));
74+
if (enableDebugExtension) {
75+
var extensionBackend = await ExtensionBackend.start();
76+
extensionHostname = extensionBackend.hostname;
77+
extensionPort = extensionBackend.port;
78+
}
79+
80+
pipeline = pipeline.addMiddleware(createInjectedHandler(reloadConfiguration,
81+
extensionHostname: extensionHostname, extensionPort: extensionPort));
7182

7283
DevTools devTools;
7384
if (serveDevTools) {

webdev/lib/src/serve/webdev_server.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ class WebDevServer {
5959
}
6060

6161
static Future<WebDevServer> start(
62-
ServerOptions options,
63-
Stream<BuildResults> buildResults,
64-
) async {
62+
ServerOptions options, Stream<BuildResults> buildResults) async {
6563
var pipeline = const Pipeline();
6664

6765
if (options.configuration.logRequests) {
@@ -87,6 +85,7 @@ class WebDevServer {
8785
reloadConfiguration: options.configuration.reload,
8886
serveDevTools: options.configuration.debug,
8987
verbose: options.configuration.verbose,
88+
enableDebugExtension: options.configuration.debugExtension,
9089
);
9190

9291
var hostname = options.configuration.hostname;

0 commit comments

Comments
 (0)