Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions webdev/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.2

- Support `package:dwds` version `0.3.0`.

## 2.0.1

- Fix launching Chrome on Windows.
Expand Down
6 changes: 2 additions & 4 deletions webdev/lib/src/daemon/app_domain.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ class AppDomain extends Domain {
_appDebugServices = await devHandler.loadAppServices(
connection.request.appId, connection.request.instanceId);
_appId = connection.request.appId;
unawaited(_appDebugServices
.debugService.chromeProxyService.tabConnection.onClose.first
unawaited(_appDebugServices.chromeProxyService.tabConnection.onClose.first
.then((_) {
sendEvent('app.log', {
'appId': _appId,
Expand Down Expand Up @@ -176,8 +175,7 @@ class AppDomain extends Domain {
Future<bool> _stop(Map<String, dynamic> args) async {
var appId = getStringArg(args, 'appId', required: true);
if (_appId != appId) throw ArgumentError.value(appId, 'appId', 'Not found');
await _appDebugServices.debugService.chromeProxyService.tabConnection
.close();
await _appDebugServices.chromeProxyService.tabConnection.close();
return true;
}

Expand Down
5 changes: 5 additions & 0 deletions webdev/lib/src/serve/debugger/app_debug_services.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import 'dart:async';
import 'package:dwds/service.dart';
// ignore: implementation_imports
import 'package:dwds/src/chrome_proxy_service.dart' show ChromeProxyService;

import '../../serve/chrome.dart';
import '../debugger/webdev_vm_client.dart';
Expand All @@ -14,6 +16,9 @@ class AppDebugServices {
final DebugService debugService;
final WebdevVmClient webdevClient;

ChromeProxyService get chromeProxyService =>
debugService.chromeProxyService as ChromeProxyService;

/// The instance ID for the currently connected application, if there is one.
///
/// We only allow a given app to be debugged in a single tab at a time.
Expand Down
16 changes: 9 additions & 7 deletions webdev/lib/src/serve/debugger/webdev_vm_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import 'dart:async';
import 'dart:convert';

import 'package:dwds/service.dart';
// ignore: implementation_imports
import 'package:dwds/src/chrome_proxy_service.dart' show ChromeProxyService;
import 'package:pedantic/pedantic.dart';
import 'package:vm_service_lib/vm_service_lib.dart';

Expand Down Expand Up @@ -35,13 +37,13 @@ class WebdevVmClient {
responseController.stream.map(jsonEncode),
(request) => requestController.sink
.add(jsonDecode(request) as Map<String, dynamic>));
var chromeProxyService =
debugService.chromeProxyService as ChromeProxyService;
client.registerServiceCallback('hotRestart', (request) async {
debugService.chromeProxyService.destroyIsolate();
var response = await debugService.chromeProxyService.tabConnection.runtime
.sendCommand('Runtime.evaluate', params: {
'expression': r'$dartHotRestart();',
'awaitPromise': true
});
chromeProxyService.destroyIsolate();
var response = await chromeProxyService.tabConnection.runtime.sendCommand(
'Runtime.evaluate',
params: {'expression': r'$dartHotRestart();', 'awaitPromise': true});
var exceptionDetails = response.result['exceptionDetails'];
if (exceptionDetails != null) {
return {
Expand All @@ -52,7 +54,7 @@ class WebdevVmClient {
}
};
} else {
unawaited(debugService.chromeProxyService.createIsolate());
unawaited(chromeProxyService.createIsolate());
return {'result': Success().toJson()};
}
});
Expand Down
19 changes: 9 additions & 10 deletions webdev/lib/src/serve/handlers/dev_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class DevHandler {
// If you load the same app in a different tab then we need to throw
// away our old services and start new ones.
if (!(await _isCorrectTab(message.instanceId,
appServices.debugService.chromeProxyService.tabConnection))) {
appServices.chromeProxyService.tabConnection))) {
unawaited(appServices.close());
unawaited(_servicesByAppId.remove(message.appId));
appServices =
Expand All @@ -150,10 +150,9 @@ class DevHandler {
.serialize(DevToolsResponse((b) => b..success = true))));

appServices.connectedInstanceId = message.instanceId;
await appServices.debugService.chromeProxyService.tabConnection.runtime
.evaluate(
'window.open("http://${_devTools.hostname}:${_devTools.port}'
'/?uri=${appServices.debugService.wsUri}", "", "_blank")');
await appServices.chromeProxyService.tabConnection.runtime.evaluate(
'window.open("http://${_devTools.hostname}:${_devTools.port}'
'/?uri=${appServices.debugService.wsUri}", "", "_blank")');
} else if (message is ConnectRequest) {
if (appId != null) {
throw StateError('Duplicate connection request from the same app. '
Expand All @@ -168,10 +167,10 @@ class DevHandler {
if (services != null && services.connectedInstanceId == null) {
// Re-connect to the previous instance if its in the same tab,
// otherwise do nothing for now.
if (await _isCorrectTab(message.instanceId,
services.debugService.chromeProxyService.tabConnection)) {
if (await _isCorrectTab(
message.instanceId, services.chromeProxyService.tabConnection)) {
services.connectedInstanceId = message.instanceId;
await services.debugService.chromeProxyService.createIsolate();
await services.chromeProxyService.createIsolate();
}
}

Expand All @@ -184,7 +183,7 @@ class DevHandler {
if (appId != null) {
var services = await _servicesByAppId[appId];
services?.connectedInstanceId = null;
services?.debugService?.chromeProxyService?.destroyIsolate();
services?.chromeProxyService?.destroyIsolate();
}
}));
}
Expand All @@ -210,7 +209,7 @@ class DevHandler {
var appServices = AppDebugServices(chrome, debugService, webdevClient);

unawaited(
debugService.chromeProxyService.tabConnection.onClose.first.then((_) {
appServices.chromeProxyService.tabConnection.onClose.first.then((_) {
appServices.close();
_servicesByAppId.remove(appId);
logHandler(
Expand Down
2 changes: 1 addition & 1 deletion webdev/lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions webdev/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: webdev
version: 2.0.1
version: 2.0.2
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/webdev
description: >-
Expand All @@ -14,7 +14,7 @@ dependencies:
build_daemon: ^0.5.0
built_value: ^6.3.0
crypto: ^2.0.6
dwds: ^0.2.0
dwds: ^0.3.0
devtools: ^0.0.15-dev.1
http: ^0.12.0
io: ^0.3.2+1
Expand Down