Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect to VS Code using a JSON-RPC API over postMessage or WebSocket #5921

Closed
wants to merge 1 commit into from

Conversation

DanTup
Copy link
Contributor

@DanTup DanTup commented Jun 15, 2023

@jacob314 @kenzieschmoll interested in your thoughts on this (I don't expect to land it like this, it's just for discussion).

It's a bit of an evolution of #5747 (although only focusing on the DevTools-hosted panel for now). Using something like JSON-RPC between the Dart panel and the VS Code extension seems better than the custom code in #5747 (and would make it easier to make available to TypeScript extensions without having to build all API classes also in TypeScript).

It expands the panel Kenzie added to show information about the selected device from VS Code, and also a button that changes the device. It listens to events from VS Code for whenever the selected device changes.

When the panel is run with ?embed=true on the querystring, it uses postMessage to communicate to VS Code. If you run it without, it'll show a form that lets you paste in a WebSocket URL and will connect over that instead (the API behaves identically, allowing you to use hot reload and debugging while still interacting with VS Code).

Here's a video showing it working with both setups:

https://drive.google.com/file/d/14kvLNJHJXq2P8F8YKeJxEuTZruUleoK9/view?usp=sharing

At 0:22 I run a "Dart: Connect External DevTools Sidebar" command which provides a WS URL (it's offscreen just in the debug console atm, but it would be shown at the top somewhere easily copyable), which is then pasted into the DevTools sidebar page.

Currently the API only includes some VS Code stuff (executeComand, getSelectedDevice, onSelectedDeviceChanged) but could be expanded to have lsp and other APIs that the Dart extension can provide access to.

The VS Code changes (which needs some tidying up) are on the Dart-Code new-sidebar branch. The APIs specifically here.

@DanTup DanTup changed the title Connect to VS Code using a JSON-RPC API over postMessage of WebSocket Connect to VS Code using a JSON-RPC API over postMessage or WebSocket Jun 15, 2023
@DanTup
Copy link
Contributor Author

DanTup commented Jul 26, 2023

Closing in favour of #6104.

@DanTup DanTup closed this Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant