Skip to content

Commit

Permalink
Send connection response to Cider (#2302)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliette authored Dec 12, 2023
1 parent c26b8c8 commit b339a50
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dwds/debug_extension_mv3/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: mv3_extension
publish_to: none
version: 2.1.0
version: 2.1.1
homepage: https://github.com/dart-lang/webdev
description: >-
A Chrome extension for Dart debugging.
Expand Down
5 changes: 5 additions & 0 deletions dwds/debug_extension_mv3/web/cider_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const _ciderDartMessageKey = 'CIDER_DART';
/// The types must match those defined by ChromeExtensionMessageType in the
/// Cider extension.
enum CiderMessageType {
connected,
error,
inspectorUrlResponse,
inspectorUrlRequest,
Expand Down Expand Up @@ -54,11 +55,14 @@ Port? _ciderPort;
/// URIs for Cider are set in the externally_connectable field in the manifest.
void handleCiderConnectRequest(Port port) {
if (port.name == _ciderPortName) {
debugLog('Received connect request from Cider', verbose: true);
_ciderPort = port;

port.onMessage.addListener(
allowInterop(_handleMessageFromCider),
);

sendMessageToCider(messageType: CiderMessageType.connected);
}
}

Expand Down Expand Up @@ -130,6 +134,7 @@ Future<void> _startDebugging({String? appId}) async {
final tabId = _tabId(appId);
// TODO(https://github.com/dart-lang/webdev/issues/2198): When debugging
// with Cider, disable debugging with DevTools.
debugLog('Attach debugger to Cider', verbose: true);
await attachDebugger(tabId, trigger: Trigger.cider);
}

Expand Down
4 changes: 3 additions & 1 deletion dwds/debug_extension_mv3/web/debug_session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Future<void> attachDebugger(
forwardErrorsToCider: trigger == Trigger.cider,
);
if (!tabIsDebuggable) return;

debugLog('Attaching to tab $dartAppTabId', verbose: true);
_tabIdToTrigger[dartAppTabId] = trigger;
_registerDebugEventListeners();
chrome.debugger.attach(
Expand Down Expand Up @@ -357,6 +357,7 @@ Future<bool> _connectToDwds({
? WebSocketClient(WebSocketChannel.connect(uri))
: SseSocketClient(SseClient(uri.toString(), debugKey: 'DebugExtension'));
final trigger = _tabIdToTrigger[dartAppTabId];
debugLog('Connecting to DWDS...', verbose: true);
final debugSession = _DebugSession(
client: client,
appTabId: dartAppTabId,
Expand Down Expand Up @@ -418,6 +419,7 @@ void _routeDwdsEvent(String eventData, SocketClient client, int tabId) {
}
}
if (message.method == 'dwds.debugUri') {
debugLog('Sending debug URI to Cider ${message.params}', verbose: true);
sendMessageToCider(
messageType: CiderMessageType.startDebugResponse,
messageBody: message.params,
Expand Down
2 changes: 1 addition & 1 deletion dwds/debug_extension_mv3/web/manifest_mv3.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Dart Debug Extension",
"version": "2.1",
"version": "2.1.1",
"manifest_version": 3,
"devtools_page": "static_assets/devtools.html",
"action": {
Expand Down

0 comments on commit b339a50

Please sign in to comment.