mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Start enforcing the tunnels API (#163187)
* Start enforcing the tunnels API * Fix API test
This commit is contained in:
parent
96ee91332f
commit
23e6c032af
|
@ -34,6 +34,7 @@
|
||||||
"taskPresentationGroup",
|
"taskPresentationGroup",
|
||||||
"terminalDataWriteEvent",
|
"terminalDataWriteEvent",
|
||||||
"terminalDimensions",
|
"terminalDimensions",
|
||||||
|
"tunnels",
|
||||||
"envShellEvent",
|
"envShellEvent",
|
||||||
"testCoverage",
|
"testCoverage",
|
||||||
"testObserver",
|
"testObserver",
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"enableProposedApi": true,
|
"enableProposedApi": true,
|
||||||
"enabledApiProposals": [
|
"enabledApiProposals": [
|
||||||
"resolvers"
|
"resolvers",
|
||||||
|
"tunnels"
|
||||||
],
|
],
|
||||||
"private": true,
|
"private": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*",
|
"src/**/*",
|
||||||
"../../src/vscode-dts/vscode.d.ts",
|
"../../src/vscode-dts/vscode.d.ts",
|
||||||
|
"../../src/vscode-dts/vscode.proposed.tunnels.d.ts",
|
||||||
"../../src/vscode-dts/vscode.proposed.resolvers.d.ts"
|
"../../src/vscode-dts/vscode.proposed.resolvers.d.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1010,7 +1010,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||||
return extHostFileSystemEvent.getOnWillRenameFileEvent(extension)(listener, thisArg, disposables);
|
return extHostFileSystemEvent.getOnWillRenameFileEvent(extension)(listener, thisArg, disposables);
|
||||||
},
|
},
|
||||||
openTunnel: (forward: vscode.TunnelOptions) => {
|
openTunnel: (forward: vscode.TunnelOptions) => {
|
||||||
checkProposedApiEnabled(extension, 'resolvers');
|
checkProposedApiEnabled(extension, 'tunnels');
|
||||||
return extHostTunnelService.openTunnel(extension, forward).then(value => {
|
return extHostTunnelService.openTunnel(extension, forward).then(value => {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
throw new Error('cannot open tunnel');
|
throw new Error('cannot open tunnel');
|
||||||
|
@ -1019,11 +1019,11 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
get tunnels() {
|
get tunnels() {
|
||||||
checkProposedApiEnabled(extension, 'resolvers');
|
checkProposedApiEnabled(extension, 'tunnels');
|
||||||
return extHostTunnelService.getTunnels();
|
return extHostTunnelService.getTunnels();
|
||||||
},
|
},
|
||||||
onDidChangeTunnels: (listener, thisArg?, disposables?) => {
|
onDidChangeTunnels: (listener, thisArg?, disposables?) => {
|
||||||
checkProposedApiEnabled(extension, 'resolvers');
|
checkProposedApiEnabled(extension, 'tunnels');
|
||||||
return extHostTunnelService.onDidChangeTunnels(listener, thisArg, disposables);
|
return extHostTunnelService.onDidChangeTunnels(listener, thisArg, disposables);
|
||||||
},
|
},
|
||||||
registerPortAttributesProvider: (portSelector: { pid?: number; portRange?: [number, number]; commandMatcher?: RegExp }, provider: vscode.PortAttributesProvider) => {
|
registerPortAttributesProvider: (portSelector: { pid?: number; portRange?: [number, number]; commandMatcher?: RegExp }, provider: vscode.PortAttributesProvider) => {
|
||||||
|
|
29
src/vscode-dts/vscode.proposed.resolvers.d.ts
vendored
29
src/vscode-dts/vscode.proposed.resolvers.d.ts
vendored
|
@ -43,7 +43,7 @@ declare module 'vscode' {
|
||||||
label: string;
|
label: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TunnelOptions {
|
interface TunnelOptions {
|
||||||
remoteAddress: { port: number; host: string };
|
remoteAddress: { port: number; host: string };
|
||||||
// The desired local port. If this port can't be used, then another will be chosen.
|
// The desired local port. If this port can't be used, then another will be chosen.
|
||||||
localAddressPort?: number;
|
localAddressPort?: number;
|
||||||
|
@ -56,7 +56,7 @@ declare module 'vscode' {
|
||||||
protocol?: string;
|
protocol?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TunnelDescription {
|
interface TunnelDescription {
|
||||||
remoteAddress: { port: number; host: string };
|
remoteAddress: { port: number; host: string };
|
||||||
//The complete local address(ex. localhost:1234)
|
//The complete local address(ex. localhost:1234)
|
||||||
localAddress: { port: number; host: string } | string;
|
localAddress: { port: number; host: string } | string;
|
||||||
|
@ -69,7 +69,7 @@ declare module 'vscode' {
|
||||||
protocol?: string;
|
protocol?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Tunnel extends TunnelDescription {
|
interface Tunnel extends TunnelDescription {
|
||||||
// Implementers of Tunnel should fire onDidDispose when dispose is called.
|
// Implementers of Tunnel should fire onDidDispose when dispose is called.
|
||||||
onDidDispose: Event<void>;
|
onDidDispose: Event<void>;
|
||||||
dispose(): void | Thenable<void>;
|
dispose(): void | Thenable<void>;
|
||||||
|
@ -164,29 +164,6 @@ declare module 'vscode' {
|
||||||
candidatePortSource?: CandidatePortSource;
|
candidatePortSource?: CandidatePortSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace workspace {
|
|
||||||
/**
|
|
||||||
* Forwards a port. If the current resolver implements RemoteAuthorityResolver:forwardPort then that will be used to make the tunnel.
|
|
||||||
* By default, openTunnel only support localhost; however, RemoteAuthorityResolver:tunnelFactory can be used to support other ips.
|
|
||||||
*
|
|
||||||
* @throws When run in an environment without a remote.
|
|
||||||
*
|
|
||||||
* @param tunnelOptions The `localPort` is a suggestion only. If that port is not available another will be chosen.
|
|
||||||
*/
|
|
||||||
export function openTunnel(tunnelOptions: TunnelOptions): Thenable<Tunnel>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets an array of the currently available tunnels. This does not include environment tunnels, only tunnels that have been created by the user.
|
|
||||||
* Note that these are of type TunnelDescription and cannot be disposed.
|
|
||||||
*/
|
|
||||||
// export let tunnels: Thenable<TunnelDescription[]>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fired when the list of tunnels has changed.
|
|
||||||
*/
|
|
||||||
export const onDidChangeTunnels: Event<void>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ResourceLabelFormatter {
|
export interface ResourceLabelFormatter {
|
||||||
scheme: string;
|
scheme: string;
|
||||||
authority?: string;
|
authority?: string;
|
||||||
|
|
10
src/vscode-dts/vscode.proposed.tunnels.d.ts
vendored
10
src/vscode-dts/vscode.proposed.tunnels.d.ts
vendored
|
@ -12,6 +12,10 @@ declare module 'vscode' {
|
||||||
// The desired local port. If this port can't be used, then another will be chosen.
|
// The desired local port. If this port can't be used, then another will be chosen.
|
||||||
localAddressPort?: number;
|
localAddressPort?: number;
|
||||||
label?: string;
|
label?: string;
|
||||||
|
/**
|
||||||
|
* @deprecated Use privacy instead
|
||||||
|
*/
|
||||||
|
public?: boolean;
|
||||||
privacy?: string;
|
privacy?: string;
|
||||||
protocol?: string;
|
protocol?: string;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +24,10 @@ declare module 'vscode' {
|
||||||
remoteAddress: { port: number; host: string };
|
remoteAddress: { port: number; host: string };
|
||||||
//The complete local address(ex. localhost:1234)
|
//The complete local address(ex. localhost:1234)
|
||||||
localAddress: { port: number; host: string } | string;
|
localAddress: { port: number; host: string } | string;
|
||||||
|
/**
|
||||||
|
* @deprecated Use privacy instead
|
||||||
|
*/
|
||||||
|
public?: boolean;
|
||||||
privacy?: string;
|
privacy?: string;
|
||||||
// If protocol is not provided it is assumed to be http, regardless of the localAddress.
|
// If protocol is not provided it is assumed to be http, regardless of the localAddress.
|
||||||
protocol?: string;
|
protocol?: string;
|
||||||
|
@ -51,6 +59,6 @@ declare module 'vscode' {
|
||||||
/**
|
/**
|
||||||
* Fired when the list of tunnels has changed.
|
* Fired when the list of tunnels has changed.
|
||||||
*/
|
*/
|
||||||
// export const onDidChangeTunnels: Event<void>;
|
export const onDidChangeTunnels: Event<void>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue