-
Notifications
You must be signed in to change notification settings - Fork 38.2k
Description
Problem
Imagine a remote extension that spawns two processes: static html server and api server.
The extension can pass the localhost uri for the html server to openExternal and this will automatically establish port forwarding from the client machine to the target port on the remote machine. However the extension cannot currently open the port for the api server so the served up html will not be functional
Proposed API
Rather than letting extensions directly manage port forwarding, introduce a asExternalUri function that hides most of these details. This function would transparently establish port forwarding if it is required but would be a no-op for UI extensions or when VS Code is run locally.
Here's what this api could look like:
/**
* Resolves a uri that points at a resource where the extension is running to a uri to the same resource on
* the client machine.
*
* This is a noop if the extension is running locally
*
* If the extension is running remotely, this function establishes port forwarding from
* the local machine to `target` on the remote and returns the local port for this connection
*
* Note that uris passed through `openExternal` are automatically resolved.
*/
asExternalUri(
target: Uri,
): Thenable<Uri>;In the remote case, the implementation of resolveUri would use VS Code's tunnel service to setup the port forwarding.