Merge from vscode 2e5312cd61ff99c570299ecc122c52584265eda2

This commit is contained in:
ADS Merger
2020-04-23 02:50:35 +00:00
committed by Anthony Dresser
parent 3603f55d97
commit 7f1d8fc32f
659 changed files with 22709 additions and 12497 deletions

View File

@@ -35,33 +35,37 @@ interface IExternalUriResolver {
(uri: URI): Promise<URI>;
}
interface TunnelOptions {
interface ITunnelFactory {
(tunnelOptions: ITunnelOptions): Promise<ITunnel> | undefined;
}
interface ITunnelOptions {
remoteAddress: { port: number, host: string };
/**
* The desired local port. If this port can't be used, then another will be chosen.
*/
localAddressPort?: number;
label?: string;
}
interface Tunnel extends IDisposable {
interface ITunnel extends IDisposable {
remoteAddress: { port: number, host: string };
/**
* The complete local address(ex. localhost:1234)
*/
localAddress: string;
/**
* Implementers of Tunnel should fire onDidDispose when dispose is called.
*/
onDidDispose: Event<void>;
}
interface ITunnelFactory {
(tunnelOptions: TunnelOptions): Thenable<Tunnel> | undefined;
}
interface IShowCandidate {
(host: string, port: number, detail: string): Thenable<boolean>;
interface IShowPortCandidate {
(host: string, port: number, detail: string): Promise<boolean>;
}
interface ICommand {
@@ -82,6 +86,71 @@ interface ICommand {
handler: (...args: any[]) => unknown;
}
interface IHomeIndicator {
/**
* The identifier of the command to run when clicking the home indicator.
*/
command: string;
/**
* The icon name for the home indicator. This needs to be one of the existing
* icons from our Codicon icon set. For example `sync`.
*/
icon: string;
/**
* A tooltip that will appear while hovering over the home indicator.
*/
title: string;
}
interface IDefaultSideBarLayout {
visible?: boolean;
containers?: ({
id: 'explorer' | 'run' | 'scm' | 'search' | 'extensions' | 'remote' | string;
active: true;
order?: number;
views?: {
id: string;
order?: number;
visible?: boolean;
collapsed?: boolean;
}[];
} | {
id: 'explorer' | 'run' | 'scm' | 'search' | 'extensions' | 'remote' | string;
active?: false | undefined;
order?: number;
visible?: boolean;
views?: {
id: string;
order?: number;
visible?: boolean;
collapsed?: boolean;
}[];
})[];
}
interface IDefaultPanelLayout {
visible?: boolean;
containers?: ({
id: 'terminal' | 'debug' | 'problems' | 'output' | 'comments' | string;
order?: number;
active: true;
} | {
id: 'terminal' | 'debug' | 'problems' | 'output' | 'comments' | string;
order?: number;
active?: false | undefined;
visible?: boolean;
})[];
}
interface IDefaultLayout {
sidebar?: IDefaultSideBarLayout;
panel?: IDefaultPanelLayout;
// editors?: IDefaultWorkspaceEditorsLayout
}
interface IWorkbenchConstructionOptions {
//#region Connection related configuration
@@ -126,7 +195,7 @@ interface IWorkbenchConstructionOptions {
/**
* Support for filtering candidate ports
*/
readonly showCandidate?: IShowCandidate;
readonly showCandidate?: IShowPortCandidate;
//#endregion
@@ -144,6 +213,16 @@ interface IWorkbenchConstructionOptions {
*/
userDataProvider?: IFileSystemProvider;
/**
* Session id of the current authenticated user
*/
readonly authenticationSessionId?: string;
/**
* Enables user data sync by default and syncs into the current authenticated user account using the provided [authenticationSessionId}(#authenticationSessionId).
*/
readonly enableSyncByDefault?: boolean;
/**
* The credentials provider to store and retrieve secrets.
*/
@@ -177,6 +256,11 @@ interface IWorkbenchConstructionOptions {
*/
readonly commands?: readonly ICommand[];
/**
* Optional home indicator to appear above the hamburger menu in the activity bar.
*/
readonly homeIndicator?: IHomeIndicator;
//#endregion
@@ -193,6 +277,14 @@ interface IWorkbenchConstructionOptions {
readonly driver?: boolean;
//#endregion
defaultLayout?: IDefaultLayout;
}
interface IWorkbench {
commands: {
executeCommand(command: string, ...args: any[]): Promise<unknown>;
}
}
/**
@@ -202,6 +294,8 @@ interface IWorkbenchConstructionOptions {
* @param options for setting up the workbench
*/
let created = false;
let workbenchPromiseResolve: Function;
const workbenchPromise = new Promise<IWorkbench>(resolve => workbenchPromiseResolve = resolve);
async function create(domElement: HTMLElement, options: IWorkbenchConstructionOptions): Promise<void> {
// Assert that the workbench is not created more than once. We currently
@@ -212,8 +306,9 @@ async function create(domElement: HTMLElement, options: IWorkbenchConstructionOp
created = true;
}
// Startup workbench
await main(domElement, options);
// Startup workbench and resolve waiters
const workbench = await main(domElement, options);
workbenchPromiseResolve(workbench);
// Register commands if any
if (Array.isArray(options.commands)) {
@@ -227,12 +322,31 @@ async function create(domElement: HTMLElement, options: IWorkbenchConstructionOp
}
}
//#region API Facade
namespace commands {
/**
* Allows to execute any command if known with the provided arguments.
*
* @param command Identifier of the command to execute.
* @param rest Parameters passed to the command function.
* @return A promise that resolves to the returned value of the given command.
*/
export async function executeCommand(command: string, ...args: any[]): Promise<unknown> {
const workbench = await workbenchPromise;
return workbench.commands.executeCommand(command, ...args);
}
}
export {
// Factory
create,
IWorkbenchConstructionOptions,
IWorkbench,
// Basic Types
URI,
@@ -282,6 +396,25 @@ export {
// External Uris
IExternalUriResolver,
// Tunnel
ITunnelFactory,
ITunnel,
ITunnelOptions,
// Ports
IShowPortCandidate,
// Commands
ICommand
ICommand,
commands,
// Home Indicator
IHomeIndicator,
// Default layout
IDefaultLayout,
IDefaultPanelLayout,
IDefaultSideBarLayout,
};
//#endregion