diff --git a/packages/devtools/lib/src/framework/framework_core.dart b/packages/devtools/lib/src/framework/framework_core.dart index 2173086dcdb7..8d4661b9b85c 100644 --- a/packages/devtools/lib/src/framework/framework_core.dart +++ b/packages/devtools/lib/src/framework/framework_core.dart @@ -5,7 +5,7 @@ import 'dart:async'; import 'dart:html' hide Screen; -import 'package:devtools/src/utils.dart'; +import 'package:vm_service_lib/utils.dart'; import '../../devtools.dart' as devtools show version; import '../core/message_bus.dart'; @@ -45,7 +45,7 @@ class FrameworkCore { // Map the URI (which may be Observatory web app) to a WebSocket URI for // the VM service. - uri = getVmServiceUriFromObservatoryUri(uri); + uri = convertToWebSocketUrl(serviceProtocolUrl: uri); try { final VmServiceWrapper service = await connect(uri, finishedCompleter); diff --git a/packages/devtools/lib/src/utils.dart b/packages/devtools/lib/src/utils.dart index 2a7614fd5b8e..68265c19c261 100644 --- a/packages/devtools/lib/src/utils.dart +++ b/packages/devtools/lib/src/utils.dart @@ -163,20 +163,6 @@ class Property { Stream get onValueChange => _changeController.stream; } -/// Map the URI (which may already be Observatory web app) to a WebSocket URI -/// for the VM service. If the URI is already a VM Service WebSocket URI it -/// will not be modified. -Uri getVmServiceUriFromObservatoryUri(Uri uri) { - final isSecure = uri.isScheme('wss') || uri.isScheme('https'); - final scheme = isSecure ? 'wss' : 'ws'; - - final path = uri.path.endsWith('/ws') - ? uri.path - : (uri.path.endsWith('/') ? '${uri.path}ws' : '${uri.path}/ws'); - - return uri.replace(scheme: scheme, path: path); -} - /// A typedef to represent a function taking no arguments and with no return /// value. typedef VoidFunction = void Function(); diff --git a/packages/devtools/pubspec.yaml b/packages/devtools/pubspec.yaml index 3e9e88532f85..026bf6de5d55 100644 --- a/packages/devtools/pubspec.yaml +++ b/packages/devtools/pubspec.yaml @@ -24,7 +24,7 @@ dependencies: pedantic: ^1.4.0 platform_detect: ^1.3.5 rxdart: ^0.21.0 - vm_service_lib: ^3.14.3-dev.4 + vm_service_lib: ^3.15.1+1 # We would use local dependencies for these packages if pub publish allowed it. octicons_css: ^0.0.1 diff --git a/packages/devtools/test/support/cli_test_driver.dart b/packages/devtools/test/support/cli_test_driver.dart index 20f842defd97..858960bf4f50 100644 --- a/packages/devtools/test/support/cli_test_driver.dart +++ b/packages/devtools/test/support/cli_test_driver.dart @@ -6,8 +6,8 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; -import 'package:devtools/src/utils.dart'; import 'package:devtools/src/vm_service_wrapper.dart'; +import 'package:vm_service_lib/utils.dart'; import 'package:vm_service_lib/vm_service_lib.dart'; import 'package:vm_service_lib/vm_service_lib_io.dart'; @@ -105,7 +105,7 @@ class CliAppFixture extends AppFixture { } // Map to WS URI. - uri = getVmServiceUriFromObservatoryUri(uri); + uri = convertToWebSocketUrl(serviceProtocolUrl: uri); final VmServiceWrapper serviceConnection = VmServiceWrapper(await vmServiceConnectUri(uri.toString())); diff --git a/packages/devtools/test/support/flutter_test_driver.dart b/packages/devtools/test/support/flutter_test_driver.dart index 448020ecc8d7..9daa44450d08 100644 --- a/packages/devtools/test/support/flutter_test_driver.dart +++ b/packages/devtools/test/support/flutter_test_driver.dart @@ -6,9 +6,9 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; -import 'package:devtools/src/utils.dart'; import 'package:devtools/src/vm_service_wrapper.dart'; import 'package:pedantic/pedantic.dart'; +import 'package:vm_service_lib/utils.dart'; import 'package:vm_service_lib/vm_service_lib.dart'; import 'package:vm_service_lib/vm_service_lib_io.dart'; @@ -324,7 +324,8 @@ class FlutterRunTestDriver extends FlutterTestDriver { _vmServiceWsUri = Uri.parse(wsUriString); // Map to WS URI. - _vmServiceWsUri = getVmServiceUriFromObservatoryUri(_vmServiceWsUri); + _vmServiceWsUri = + convertToWebSocketUrl(serviceProtocolUrl: _vmServiceWsUri); vmService = VmServiceWrapper( await vmServiceConnectUri(_vmServiceWsUri.toString()), diff --git a/packages/devtools_server/lib/src/server.dart b/packages/devtools_server/lib/src/server.dart index 41c1c6bd0458..b8dd7e2a7371 100644 --- a/packages/devtools_server/lib/src/server.dart +++ b/packages/devtools_server/lib/src/server.dart @@ -13,6 +13,7 @@ import 'package:path/path.dart' as path; import 'package:shelf/shelf.dart' as shelf; import 'package:shelf/shelf_io.dart' as shelf; import 'package:shelf_static/shelf_static.dart'; +import 'package:vm_service_lib/utils.dart'; import 'package:vm_service_lib/vm_service_lib.dart' hide Isolate; import 'chrome.dart'; @@ -235,7 +236,7 @@ Future registerLaunchDevToolsService( Future _connectToVmService(Uri uri) async { // Fix up the various acceptable URI formats into a WebSocket URI to connect. - uri = getVmServiceUriFromObservatoryUri(uri); + uri = convertToWebSocketUrl(serviceProtocolUrl: uri); final WebSocket ws = await WebSocket.connect(uri.toString()); @@ -269,20 +270,3 @@ void printOutput( }) { print(machineMode ? jsonEncode(json) : message); } - -/// Map the URI (which may already be Observatory web app) to a WebSocket URI -/// for the VM service. -/// -/// If the URI is already a VM Service WebSocket URI it will not be modified. -Uri getVmServiceUriFromObservatoryUri(Uri uri) { - // TODO(dantup): We have two copies of this and should move it to vm_service_lib - // then switch to that. - final isSecure = uri.isScheme('wss') || uri.isScheme('https'); - final scheme = isSecure ? 'wss' : 'ws'; - - final path = uri.path.endsWith('/ws') - ? uri.path - : (uri.path.endsWith('/') ? '${uri.path}ws' : '${uri.path}/ws'); - - return uri.replace(scheme: scheme, path: path); -} diff --git a/packages/devtools_server/pubspec.yaml b/packages/devtools_server/pubspec.yaml index f38ed7bad607..13d4fdd90a2e 100644 --- a/packages/devtools_server/pubspec.yaml +++ b/packages/devtools_server/pubspec.yaml @@ -16,5 +16,5 @@ dependencies: pedantic: ^1.4.0 shelf: ^0.7.4 shelf_static: ^0.2.8 - vm_service_lib: ^3.14.3-dev.4 + vm_service_lib: ^3.15.1+1 webkit_inspection_protocol: ^0.4.0