/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import type { PerformanceMark } from '../../base/common/performance.js';6import type { UriComponents, URI } from '../../base/common/uri.js';7import type { IWebSocketFactory } from '../../platform/remote/browser/browserSocketFactory.js';8import type { IURLCallbackProvider } from '../services/url/browser/urlService.js';9import type { LogLevel } from '../../platform/log/common/log.js';10import type { IUpdateProvider } from '../services/update/browser/updateService.js';11import type { Event } from '../../base/common/event.js';12import type { IProductConfiguration } from '../../base/common/product.js';13import type { ISecretStorageProvider } from '../../platform/secrets/common/secrets.js';14import type { TunnelProviderFeatures } from '../../platform/tunnel/common/tunnel.js';15import type { IProgress, IProgressCompositeOptions, IProgressDialogOptions, IProgressNotificationOptions, IProgressOptions, IProgressStep, IProgressWindowOptions } from '../../platform/progress/common/progress.js';16import type { ITextEditorOptions } from '../../platform/editor/common/editor.js';17import type { IFolderToOpen, IWorkspaceToOpen } from '../../platform/window/common/window.js';18import type { EditorGroupLayout } from '../services/editor/common/editorGroupsService.js';19import type { IEmbedderTerminalOptions } from '../services/terminal/common/embedderTerminalService.js';20import type { IAuthenticationProvider } from '../services/authentication/common/authentication.js';2122/**23* The `IWorkbench` interface is the API facade for web embedders24* to call into the workbench.25*26* Note: Changes to this interface need to be announced and adopted.27*/28export interface IWorkbench {2930commands: {3132/**33* Allows to execute any command if known with the provided arguments.34*35* @param command Identifier of the command to execute.36* @param rest Parameters passed to the command function.37* @return A promise that resolves to the returned value of the given command.38*/39executeCommand(command: string, ...args: any[]): Promise<unknown>;40};4142logger: {4344/**45* Logging for embedder.46*47* @param level The log level of the message to be printed.48* @param message Message to be printed.49*/50log(level: LogLevel, message: string): void;51};5253env: {5455/**56* @returns the scheme to use for opening the associated desktop57* experience via protocol handler.58*/59getUriScheme(): Promise<string>;6061/**62* Retrieve performance marks that have been collected during startup. This function63* returns tuples of source and marks. A source is a dedicated context, like64* the renderer or an extension host.65*66* *Note* that marks can be collected on different machines and in different processes67* and that therefore "different clocks" are used. So, comparing `startTime`-properties68* across contexts should be taken with a grain of salt.69*70* @returns A promise that resolves to tuples of source and marks.71*/72retrievePerformanceMarks(): Promise<[string, readonly PerformanceMark[]][]>;7374/**75* Allows to open a target Uri with the standard opener service of the76* workbench.77*/78openUri(target: URI | UriComponents): Promise<boolean>;79};8081window: {8283/**84* Show progress in the editor. Progress is shown while running the given callback85* and while the promise it returned isn't resolved nor rejected.86*87* @param task A callback returning a promise.88* @return A promise that resolves to the returned value of the given task result.89*/90withProgress<R>(91options: IProgressOptions | IProgressDialogOptions | IProgressNotificationOptions | IProgressWindowOptions | IProgressCompositeOptions,92task: (progress: IProgress<IProgressStep>) => Promise<R>93): Promise<R>;9495/**96* Creates a terminal with limited capabilities that is intended for97* writing output from the embedder before the workbench has finished98* loading. When an embedder terminal is created it will automatically99* show to the user.100*101* @param options The definition of the terminal, this is similar to102* `ExtensionTerminalOptions` in the extension API.103*/104createTerminal(options: IEmbedderTerminalOptions): Promise<void>;105106/**107* Show an information message to users. Optionally provide an array of items which will be presented as108* clickable buttons.109*110* @param message The message to show.111* @param items A set of items that will be rendered as actions in the message.112* @returns A thenable that resolves to the selected item or `undefined` when being dismissed.113*/114showInformationMessage<T extends string>(message: string, ...items: T[]): Promise<T | undefined>;115};116117workspace: {118/**119* Resolves once the remote authority has been resolved.120*/121didResolveRemoteAuthority(): Promise<void>;122123/**124* Forwards a port. If the current embedder implements a tunnelFactory then that will be used to make the tunnel.125* By default, openTunnel only support localhost; however, a tunnelFactory can be used to support other ips.126*127* @throws When run in an environment without a remote.128*129* @param tunnelOptions The `localPort` is a suggestion only. If that port is not available another will be chosen.130*/131openTunnel(tunnelOptions: ITunnelOptions): Promise<ITunnel>;132};133134/**135* Triggers shutdown of the workbench programmatically. After this method is136* called, the workbench is not usable anymore and the page needs to reload137* or closed.138*139* This will also remove any `beforeUnload` handlers that would bring up a140* confirmation dialog.141*142* The returned promise should be awaited on to ensure any data to persist143* has been persisted.144*/145shutdown: () => Promise<void>;146}147148export interface IWorkbenchConstructionOptions {149150//#region Connection related configuration151152/**153* The remote authority is the IP:PORT from where the workbench is served154* from. It is for example being used for the websocket connections as address.155*/156readonly remoteAuthority?: string;157158/**159* The server base path is the path where the workbench is served from.160* The path must be absolute (start with a slash).161* Corresponds to option `server-base-path` on the server side.162*/163readonly serverBasePath?: string;164165/**166* The connection token to send to the server.167*/168readonly connectionToken?: string | Promise<string>;169170/**171* An endpoint to serve iframe content ("webview") from. This is required172* to provide full security isolation from the workbench host.173*/174readonly webviewEndpoint?: string;175176/**177* A factory for web sockets.178*/179readonly webSocketFactory?: IWebSocketFactory;180181/**182* A provider for resource URIs.183*184* *Note*: This will only be invoked after the `connectionToken` is resolved.185*/186readonly resourceUriProvider?: IResourceUriProvider;187188/**189* Resolves an external uri before it is opened.190*/191readonly resolveExternalUri?: IExternalUriResolver;192193/**194* A provider for supplying tunneling functionality,195* such as creating tunnels and showing candidate ports to forward.196*/197readonly tunnelProvider?: ITunnelProvider;198199/**200* Endpoints to be used for proxying authentication code exchange calls in the browser.201*/202readonly codeExchangeProxyEndpoints?: { [providerId: string]: string };203204/**205* The identifier of an edit session associated with the current workspace.206*/207readonly editSessionId?: string;208209/**210* Resource delegation handler that allows for loading of resources when211* using remote resolvers.212*213* This is exclusive with {@link resourceUriProvider}. `resourceUriProvider`214* should be used if a {@link webSocketFactory} is used, and will be preferred.215*/216readonly remoteResourceProvider?: IRemoteResourceProvider;217218//#endregion219220221//#region Workbench configuration222223/**224* A handler for opening workspaces and providing the initial workspace.225*/226readonly workspaceProvider?: IWorkspaceProvider;227228/**229* Settings sync options230*/231readonly settingsSyncOptions?: ISettingsSyncOptions;232233/**234* The secret storage provider to store and retrieve secrets.235*/236readonly secretStorageProvider?: ISecretStorageProvider;237238/**239* Additional builtin extensions those cannot be uninstalled but only be disabled.240* It can be one of the following:241* - an extension in the Marketplace242* - location of the extension where it is hosted.243*/244readonly additionalBuiltinExtensions?: readonly (MarketplaceExtension | UriComponents)[];245246/**247* List of extensions to be enabled if they are installed.248* Note: This will not install extensions if not installed.249*/250readonly enabledExtensions?: readonly ExtensionId[];251252/**253* Additional domains allowed to open from the workbench without the254* link protection popup.255*/256readonly additionalTrustedDomains?: string[];257258/**259* Enable workspace trust feature for the current window260*/261readonly enableWorkspaceTrust?: boolean;262263/**264* Urls that will be opened externally that are allowed access265* to the opener window. This is primarily used to allow266* `window.close()` to be called from the newly opened window.267*/268readonly openerAllowedExternalUrlPrefixes?: string[];269270/**271* Support for URL callbacks.272*/273readonly urlCallbackProvider?: IURLCallbackProvider;274275/**276* Support adding additional properties to telemetry.277*/278readonly resolveCommonTelemetryProperties?: ICommonTelemetryPropertiesResolver;279280/**281* A set of optional commands that should be registered with the commands282* registry.283*284* Note: commands can be called from extensions if the identifier is known!285*/286readonly commands?: readonly ICommand[];287288/**289* Optional default layout to apply on first time the workspace is opened290* (unless `force` is specified). This includes visibility of views and291* editors including editor grid layout.292*/293readonly defaultLayout?: IDefaultLayout;294295/**296* Optional configuration default overrides contributed to the workbench.297*/298readonly configurationDefaults?: Record<string, any>;299300//#endregion301302//#region Profile options303304/**305* Profile to use for the workbench.306*/307readonly profile?: { readonly name: string; readonly contents?: string | UriComponents };308309/**310* URI of the profile to preview.311*/312readonly profileToPreview?: UriComponents;313314//#endregion315316317//#region Update/Quality related318319/**320* Support for update reporting321*/322readonly updateProvider?: IUpdateProvider;323324/**325* Support for product quality switching326*/327readonly productQualityChangeHandler?: IProductQualityChangeHandler;328329//#endregion330331332//#region Branding333334/**335* Optional welcome banner to appear above the workbench. Can be dismissed by the336* user.337*/338readonly welcomeBanner?: IWelcomeBanner;339340/**341* Optional override for the product configuration properties.342*/343readonly productConfiguration?: Partial<IProductConfiguration>;344345/**346* Optional override for properties of the window indicator in the status bar.347*/348readonly windowIndicator?: IWindowIndicator;349350/**351* Specifies the default theme type (LIGHT, DARK..) and allows to provide initial colors that are shown352* until the color theme that is specified in the settings (`editor.colorTheme`) is loaded and applied.353* Once there are persisted colors from a last run these will be used.354*355* The idea is that the colors match the main colors from the theme defined in the `configurationDefaults`.356*/357readonly initialColorTheme?: IInitialColorTheme;358359//#endregion360361362//#region IPC363364readonly messagePorts?: ReadonlyMap<ExtensionId, MessagePort>;365366//#endregion367368//#region Authentication Providers369370/**371* Optional authentication provider contributions. These take precedence over372* any authentication providers contributed via extensions.373*/374readonly authenticationProviders?: readonly IAuthenticationProvider[];375376//#endregion377378//#region Development options379380readonly developmentOptions?: IDevelopmentOptions;381382//#endregion383384}385386387/**388* A workspace to open in the workbench can either be:389* - a workspace file with 0-N folders (via `workspaceUri`)390* - a single folder (via `folderUri`)391* - empty (via `undefined`)392*/393export type IWorkspace = IWorkspaceToOpen | IFolderToOpen | undefined;394395export interface IWorkspaceProvider {396397/**398* The initial workspace to open.399*/400readonly workspace: IWorkspace;401402/**403* Arbitrary payload from the `IWorkspaceProvider.open` call.404*/405readonly payload?: object;406407/**408* Return `true` if the provided [workspace](#IWorkspaceProvider.workspace) is trusted, `false` if not trusted, `undefined` if unknown.409*/410readonly trusted: boolean | undefined;411412/**413* Asks to open a workspace in the current or a new window.414*415* @param workspace the workspace to open.416* @param options optional options for the workspace to open.417* - `reuse`: whether to open inside the current window or a new window418* - `payload`: arbitrary payload that should be made available419* to the opening window via the `IWorkspaceProvider.payload` property.420* @param payload optional payload to send to the workspace to open.421*422* @returns true if successfully opened, false otherwise.423*/424open(workspace: IWorkspace, options?: { reuse?: boolean; payload?: object }): Promise<boolean>;425}426427export interface IResourceUriProvider {428(uri: URI): URI;429}430431/**432* The identifier of an extension in the format: `PUBLISHER.NAME`. For example: `vscode.csharp`433*/434export type ExtensionId = string;435436export type MarketplaceExtension = ExtensionId | { readonly id: ExtensionId; preRelease?: boolean; migrateStorageFrom?: ExtensionId };437438export interface ICommonTelemetryPropertiesResolver {439(): { [key: string]: any };440}441442export interface IExternalUriResolver {443(uri: URI): Promise<URI>;444}445446export interface IExternalURLOpener {447448/**449* Overrides the behavior when an external URL is about to be opened.450* Returning false means that the URL wasn't handled, and the default451* handling behavior should be used: `window.open(href, '_blank', 'noopener');`452*453* @returns true if URL was handled, false otherwise.454*/455openExternal(href: string): boolean | Promise<boolean>;456}457458export interface ITunnelProvider {459460/**461* Support for creating tunnels.462*/463tunnelFactory?: ITunnelFactory;464465/**466* Support for filtering candidate ports.467*/468showPortCandidate?: IShowPortCandidate;469470/**471* The features that the tunnel provider supports.472*/473features?: TunnelProviderFeatures;474}475476export interface ITunnelFactory {477(tunnelOptions: ITunnelOptions, tunnelCreationOptions: TunnelCreationOptions): Promise<ITunnel> | undefined;478}479480export interface ITunnelOptions {481482remoteAddress: { port: number; host: string };483484/**485* The desired local port. If this port can't be used, then another will be chosen.486*/487localAddressPort?: number;488489label?: string;490491privacy?: string;492493protocol?: string;494}495496export interface TunnelCreationOptions {497498/**499* True when the local operating system will require elevation to use the requested local port.500*/501elevationRequired?: boolean;502}503504export interface ITunnel {505506remoteAddress: { port: number; host: string };507508/**509* The complete local address(ex. localhost:1234)510*/511localAddress: string;512513privacy?: string;514515/**516* If protocol is not provided, it is assumed to be http, regardless of the localAddress517*/518protocol?: string;519520/**521* Implementers of Tunnel should fire onDidDispose when dispose is called.522*/523onDidDispose: Event<void>;524525dispose(): Promise<void> | void;526}527528export interface IShowPortCandidate {529(host: string, port: number, detail: string): Promise<boolean>;530}531532export enum Menu {533CommandPalette,534StatusBarWindowIndicatorMenu,535}536537export interface ICommand {538539/**540* An identifier for the command. Commands can be executed from extensions541* using the `vscode.commands.executeCommand` API using that command ID.542*/543id: string;544545/**546* The optional label of the command. If provided, the command will appear547* in the command palette.548*/549label?: string;550551/**552* The optional menus to append this command to. Only valid if `label` is553* provided as well.554* @default Menu.CommandPalette555*/556menu?: Menu | Menu[];557558/**559* A function that is being executed with any arguments passed over. The560* return type will be send back to the caller.561*562* Note: arguments and return type should be serializable so that they can563* be exchanged across processes boundaries.564*/565handler: (...args: any[]) => unknown;566}567568export interface IWelcomeBanner {569570/**571* Welcome banner message to appear as text.572*/573message: string;574575/**576* Optional icon for the banner. This is either the URL to an icon to use577* or the name of one of the existing icons from our Codicon icon set.578*579* If not provided a default icon will be used.580*/581icon?: string | UriComponents;582583/**584* Optional actions to appear as links after the welcome banner message.585*/586actions?: IWelcomeLinkAction[];587}588589export interface IWelcomeLinkAction {590591/**592* The link to open when clicking. Supports command invocation when593* using the `command:<commandId>` value.594*/595href: string;596597/**598* The label to show for the action link.599*/600label: string;601602/**603* A tooltip that will appear while hovering over the action link.604*/605title?: string;606}607608export interface IWindowIndicator {609610/**611* Triggering this event will cause the window indicator to update.612*/613readonly onDidChange?: Event<void>;614615/**616* Label of the window indicator may include octicons617* e.g. `$(remote) label`618*/619label: string;620621/**622* Tooltip of the window indicator should not include623* octicons and be descriptive.624*/625tooltip: string;626627/**628* If provided, overrides the default command that629* is executed when clicking on the window indicator.630*/631command?: string;632}633634export enum ColorScheme {635DARK = 'dark',636LIGHT = 'light',637HIGH_CONTRAST_LIGHT = 'hcLight',638HIGH_CONTRAST_DARK = 'hcDark'639}640641export interface IInitialColorTheme {642643/**644* Initial color theme type.645*/646readonly themeType: ColorScheme;647648/**649* A list of workbench colors to apply initially.650*/651readonly colors?: { [colorId: string]: string };652}653654export interface IDefaultView {655656/**657* The identifier of the view to show by default.658*/659readonly id: string;660}661662export interface IDefaultEditor {663664/**665* The location of the editor in the editor grid layout.666* Editors are layed out in editor groups and the view667* column is counted from top left to bottom right in668* the order of appearance beginning with `1`.669*670* If not provided, the editor will open in the active671* group.672*/673readonly viewColumn?: number;674675/**676* The resource of the editor to open.677*/678readonly uri: UriComponents;679680/**681* Optional extra options like which editor682* to use or which text to select.683*/684readonly options?: ITextEditorOptions;685686/**687* Will not open an untitled editor in case688* the resource does not exist.689*/690readonly openOnlyIfExists?: boolean;691}692693export interface IDefaultLayout {694695/**696* A list of views to show by default.697*/698readonly views?: IDefaultView[];699700/**701* A list of editors to show by default.702*/703readonly editors?: IDefaultEditor[];704705/**706* The layout to use for the workbench.707*/708readonly layout?: {709710/**711* The layout of the editor area.712*/713readonly editors?: EditorGroupLayout;714};715716/**717* Forces this layout to be applied even if this isn't718* the first time the workspace has been opened719*/720readonly force?: boolean;721}722723export interface IProductQualityChangeHandler {724725/**726* Handler is being called when the user wants to switch between727* `insider` or `stable` product qualities.728*/729(newQuality: 'insider' | 'stable'): void;730}731732/**733* Settings sync options734*/735export interface ISettingsSyncOptions {736737/**738* Is settings sync enabled739*/740readonly enabled: boolean;741742/**743* Version of extensions sync state.744* Extensions sync state will be reset if version is provided and different from previous version.745*/746readonly extensionsSyncStateVersion?: string;747748/**749* Handler is being called when the user changes Settings Sync enablement.750*/751enablementHandler?(enablement: boolean, authenticationProvider: string): void;752753/**754* Authentication provider755*/756readonly authenticationProvider?: {757758/**759* Unique identifier of the authentication provider.760*/761readonly id: string;762763/**764* Called when the user wants to signin to Settings Sync using the given authentication provider.765* The returned promise should resolve to the authentication session id.766*/767signIn(): Promise<string>;768};769}770771export interface IDevelopmentOptions {772773/**774* Current logging level. Default is `LogLevel.Info`.775*/776readonly logLevel?: LogLevel;777778/**779* Extension log level.780*/781readonly extensionLogLevel?: [string, LogLevel][];782783/**784* Location of a module containing extension tests to run once the workbench is open.785*/786readonly extensionTestsPath?: UriComponents;787788/**789* Add extensions under development.790*/791readonly extensions?: readonly UriComponents[];792793/**794* Whether to enable the smoke test driver.795*/796readonly enableSmokeTestDriver?: boolean;797}798799/**800* Utility provided in the {@link WorkbenchOptions} which allows loading resources801* when remote resolvers are used in the web.802*/803export interface IRemoteResourceProvider {804805/**806* Path the workbench should delegate requests to. The embedder should807* install a service worker on this path and emit {@link onDidReceiveRequest}808* events when requests come in for that path.809*/810readonly path: string;811812/**813* Event that should fire when requests are made on the {@link pathPrefix}.814*/815readonly onDidReceiveRequest: Event<IRemoteResourceRequest>;816}817818/**819* todo@connor4312: this may eventually gain more properties like method and820* headers, but for now we only deal with GET requests.821*/822export interface IRemoteResourceRequest {823824/**825* Request URI. Generally will begin with the current826* origin and {@link IRemoteResourceProvider.pathPrefix}.827*/828uri: URI;829830/**831* A method called by the editor to issue a response to the request.832*/833respondWith(statusCode: number, body: Uint8Array, headers: Record<string, string>): void;834}835836837