Skip to content

Commit

Permalink
move API
Browse files Browse the repository at this point in the history
address feedback in #127367
  • Loading branch information
joaomoreno committed Jun 29, 2021
1 parent 48bcdeb commit 339ff8d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 67 deletions.
12 changes: 8 additions & 4 deletions src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8261,8 +8261,7 @@ declare module 'vscode' {
export function openExternal(target: Uri): Thenable<boolean>;

/**
* Resolves a uri to form that is accessible externally. Currently only supports `https:`, `http:` and
* `vscode.env.uriScheme` uris.
* Resolves a uri to a form that is accessible externally.
*
* #### `http:` or `https:` scheme
*
Expand All @@ -8282,7 +8281,7 @@ declare module 'vscode' {
* Creates a uri that - if opened in a browser (e.g. via `openExternal`) - will result in a registered {@link UriHandler}
* to trigger.
*
* Extensions should not make any assumptions about the resulting uri and should not alter it in anyway.
* Extensions should not make any assumptions about the resulting uri and should not alter it in any way.
* Rather, extensions can e.g. use this uri in an authentication flow, by adding the uri as callback query
* argument to the server to authenticate to.
*
Expand All @@ -8299,14 +8298,19 @@ declare module 'vscode' {
* }
* });
*
* const callableUri = await vscode.env.asExternalUri(vscode.Uri.parse('${vscode.env.uriScheme}://my.extension/did-authenticate'));
* const callableUri = await vscode.env.asExternalUri(vscode.Uri.parse(`${vscode.env.uriScheme}://my.extension/did-authenticate`));
* await vscode.env.openExternal(callableUri);
* ```
*
* *Note* that extensions should not cache the result of `asExternalUri` as the resolved uri may become invalid due to
* a system or user action — for example, in remote cases, a user may close a port forwarding tunnel that was opened by
* `asExternalUri`.
*
* #### Any other scheme
*
* Any other scheme will be handled as if the provided URI is a workspace URI. In that case, the method will return
* a URI which, when handled, will make the editor open the workspace.
*
* @return A uri that can be used on the client machine.
*/
export function asExternalUri(target: Uri): Thenable<Uri>;
Expand Down
63 changes: 0 additions & 63 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2479,69 +2479,6 @@ declare module 'vscode' {

//#endregion

//#region @joaomoreno https://github.com/microsoft/vscode/issues/124263
// This API change only affects behavior and documentation, not API surface.

namespace env {

/**
* Resolves a uri to form that is accessible externally.
*
* #### `http:` or `https:` scheme
*
* Resolves an *external* uri, such as a `http:` or `https:` link, from where the extension is running to a
* uri to the same resource on the client machine.
*
* This is a no-op if the extension is running on the client machine.
*
* If the extension is running remotely, this function automatically establishes a port forwarding tunnel
* from the local machine to `target` on the remote and returns a local uri to the tunnel. The lifetime of
* the port forwarding tunnel is managed by the editor and the tunnel can be closed by the user.
*
* *Note* that uris passed through `openExternal` are automatically resolved and you should not call `asExternalUri` on them.
*
* #### `vscode.env.uriScheme`
*
* Creates a uri that - if opened in a browser (e.g. via `openExternal`) - will result in a registered {@link UriHandler}
* to trigger.
*
* Extensions should not make any assumptions about the resulting uri and should not alter it in anyway.
* Rather, extensions can e.g. use this uri in an authentication flow, by adding the uri as callback query
* argument to the server to authenticate to.
*
* *Note* that if the server decides to add additional query parameters to the uri (e.g. a token or secret), it
* will appear in the uri that is passed to the {@link UriHandler}.
*
* **Example** of an authentication flow:
* ```typescript
* vscode.window.registerUriHandler({
* handleUri(uri: vscode.Uri): vscode.ProviderResult<void> {
* if (uri.path === '/did-authenticate') {
* console.log(uri.toString());
* }
* }
* });
*
* const callableUri = await vscode.env.asExternalUri(vscode.Uri.parse(`${vscode.env.uriScheme}://my.extension/did-authenticate`));
* await vscode.env.openExternal(callableUri);
* ```
*
* *Note* that extensions should not cache the result of `asExternalUri` as the resolved uri may become invalid due to
* a system or user action — for example, in remote cases, a user may close a port forwarding tunnel that was opened by
* `asExternalUri`.
*
* #### Any other scheme
*
* Any other scheme will be handled as if the provided URI is a workspace URI. In that case, the method will return
* a URI which, when handled, will make the editor open the workspace.
*
* @return A uri that can be used on the client machine.
*/
export function asExternalUri(target: Uri): Thenable<Uri>;
}

//#endregion

//#region https://github.com/Microsoft/vscode/issues/15178

// TODO@API must be a class
Expand Down

0 comments on commit 339ff8d

Please sign in to comment.