1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
|
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import type { PerformanceMark } from 'vs/base/common/performance';
import type { UriComponents, URI } from 'vs/base/common/uri';
import type { IWebSocketFactory } from 'vs/platform/remote/browser/browserSocketFactory';
import type { IURLCallbackProvider } from 'vs/workbench/services/url/browser/urlService';
import type { LogLevel } from 'vs/platform/log/common/log';
import type { IUpdateProvider } from 'vs/workbench/services/update/browser/updateService';
import type { Event } from 'vs/base/common/event';
import type { IWorkspaceProvider } from 'vs/workbench/services/host/browser/browserHostService';
import type { IProductConfiguration } from 'vs/base/common/product';
import type { ICredentialsProvider } from 'vs/platform/credentials/common/credentials';
import type { TunnelProviderFeatures } from 'vs/platform/tunnel/common/tunnel';
import type { IProgress, IProgressCompositeOptions, IProgressDialogOptions, IProgressNotificationOptions, IProgressOptions, IProgressStep, IProgressWindowOptions } from 'vs/platform/progress/common/progress';
import { IObservableValue } from 'vs/base/common/observableValue';
import { TelemetryLevel } from 'vs/platform/telemetry/common/telemetry';
import { IEditorOptions } from 'vs/platform/editor/common/editor';
/**
* The `IWorkbench` interface is the API facade for web embedders
* to call into the workbench.
*
* Note: Changes to this interface need to be announced and adopted.
*/
export interface IWorkbench {
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.
*/
executeCommand(command: string, ...args: any[]): Promise<unknown>;
};
env: {
/**
* @returns the scheme to use for opening the associated desktop
* experience via protocol handler.
*/
getUriScheme(): Promise<string>;
/**
* Retrieve performance marks that have been collected during startup. This function
* returns tuples of source and marks. A source is a dedicated context, like
* the renderer or an extension host.
*
* *Note* that marks can be collected on different machines and in different processes
* and that therefore "different clocks" are used. So, comparing `startTime`-properties
* across contexts should be taken with a grain of salt.
*
* @returns A promise that resolves to tuples of source and marks.
*/
retrievePerformanceMarks(): Promise<[string, readonly PerformanceMark[]][]>;
/**
* Allows to open a `URI` with the standard opener service of the
* workbench.
*/
openUri(target: URI): Promise<boolean>;
/**
* Current workbench telemetry level.
*/
readonly telemetryLevel: IObservableValue<TelemetryLevel>;
};
window: {
/**
* Show progress in the editor. Progress is shown while running the given callback
* and while the promise it returned isn't resolved nor rejected.
*
* @param task A callback returning a promise.
* @return A promise that resolves to the returned value of the given task result.
*/
withProgress<R>(
options: IProgressOptions | IProgressDialogOptions | IProgressNotificationOptions | IProgressWindowOptions | IProgressCompositeOptions,
task: (progress: IProgress<IProgressStep>) => Promise<R>
): Promise<R>;
};
/**
* Triggers shutdown of the workbench programmatically. After this method is
* called, the workbench is not usable anymore and the page needs to reload
* or closed.
*
* This will also remove any `beforeUnload` handlers that would bring up a
* confirmation dialog.
*
* The returned promise should be awaited on to ensure any data to persist
* has been persisted.
*/
shutdown: () => Promise<void>;
}
export interface IWorkbenchConstructionOptions {
//#region Connection related configuration
/**
* The remote authority is the IP:PORT from where the workbench is served
* from. It is for example being used for the websocket connections as address.
*/
readonly remoteAuthority?: string;
/**
* The connection token to send to the server.
*/
readonly connectionToken?: string;
/**
* An endpoint to serve iframe content ("webview") from. This is required
* to provide full security isolation from the workbench host.
*/
readonly webviewEndpoint?: string;
/**
* A factory for web sockets.
*/
readonly webSocketFactory?: IWebSocketFactory;
/**
* A provider for resource URIs.
*/
readonly resourceUriProvider?: IResourceUriProvider;
/**
* Resolves an external uri before it is opened.
*/
readonly resolveExternalUri?: IExternalUriResolver;
/**
* A provider for supplying tunneling functionality,
* such as creating tunnels and showing candidate ports to forward.
*/
readonly tunnelProvider?: ITunnelProvider;
/**
* Endpoints to be used for proxying authentication code exchange calls in the browser.
*/
readonly codeExchangeProxyEndpoints?: { [providerId: string]: string };
/**
* [TEMPORARY]: This will be removed soon.
* Endpoints to be used for proxying repository tarball download calls in the browser.
*/
readonly _tarballProxyEndpoints?: { [providerId: string]: string };
//#endregion
//#region Workbench configuration
/**
* A handler for opening workspaces and providing the initial workspace.
*/
readonly workspaceProvider?: IWorkspaceProvider;
/**
* Settings sync options
*/
readonly settingsSyncOptions?: ISettingsSyncOptions;
/**
* The credentials provider to store and retrieve secrets.
*/
readonly credentialsProvider?: ICredentialsProvider;
/**
* Additional builtin extensions those cannot be uninstalled but only be disabled.
* It can be one of the following:
* - an extension in the Marketplace
* - location of the extension where it is hosted.
*/
readonly additionalBuiltinExtensions?: readonly (MarketplaceExtension | UriComponents)[];
/**
* List of extensions to be enabled if they are installed.
* Note: This will not install extensions if not installed.
*/
readonly enabledExtensions?: readonly ExtensionId[];
/**
* Additional domains allowed to open from the workbench without the
* link protection popup.
*/
readonly additionalTrustedDomains?: string[];
/**
* Enable workspace trust feature for the current window
*/
readonly enableWorkspaceTrust?: boolean;
/**
* Urls that will be opened externally that are allowed access
* to the opener window. This is primarily used to allow
* `window.close()` to be called from the newly opened window.
*/
readonly openerAllowedExternalUrlPrefixes?: string[];
/**
* Support for URL callbacks.
*/
readonly urlCallbackProvider?: IURLCallbackProvider;
/**
* Support adding additional properties to telemetry.
*/
readonly resolveCommonTelemetryProperties?: ICommonTelemetryPropertiesResolver;
/**
* A set of optional commands that should be registered with the commands
* registry.
*
* Note: commands can be called from extensions if the identifier is known!
*/
readonly commands?: readonly ICommand[];
/**
* Optional default layout to apply on first time the workspace is opened (uness `force` is specified).
*/
readonly defaultLayout?: IDefaultLayout;
/**
* Optional configuration default overrides contributed to the workbench.
*/
readonly configurationDefaults?: Record<string, any>;
//#endregion
//#region Update/Quality related
/**
* Support for update reporting
*/
readonly updateProvider?: IUpdateProvider;
/**
* Support for product quality switching
*/
readonly productQualityChangeHandler?: IProductQualityChangeHandler;
//#endregion
//#region Branding
/**
* Optional home indicator to appear above the hamburger menu in the activity bar.
*/
readonly homeIndicator?: IHomeIndicator;
/**
* Optional welcome banner to appear above the workbench. Can be dismissed by the
* user.
*/
readonly welcomeBanner?: IWelcomeBanner;
/**
* Optional override for the product configuration properties.
*/
readonly productConfiguration?: Partial<IProductConfiguration>;
/**
* Optional override for properties of the window indicator in the status bar.
*/
readonly windowIndicator?: IWindowIndicator;
/**
* Specifies the default theme type (LIGHT, DARK..) and allows to provide initial colors that are shown
* until the color theme that is specified in the settings (`editor.colorTheme`) is loaded and applied.
* Once there are persisted colors from a last run these will be used.
*
* The idea is that the colors match the main colors from the theme defined in the `configurationDefaults`.
*/
readonly initialColorTheme?: IInitialColorTheme;
//#endregion
//#region IPC
readonly messagePorts?: ReadonlyMap<ExtensionId, MessagePort>;
//#endregion
//#region Development options
readonly developmentOptions?: IDevelopmentOptions;
//#endregion
}
export interface IResourceUriProvider {
(uri: URI): URI;
}
/**
* The identifier of an extension in the format: `PUBLISHER.NAME`. For example: `vscode.csharp`
*/
export type ExtensionId = string;
export type MarketplaceExtension = ExtensionId | { readonly id: ExtensionId; preRelease?: boolean; migrateStorageFrom?: ExtensionId };
export interface ICommonTelemetryPropertiesResolver {
(): { [key: string]: any };
}
export interface IExternalUriResolver {
(uri: URI): Promise<URI>;
}
export interface IExternalURLOpener {
/**
* Overrides the behavior when an external URL is about to be opened.
* Returning false means that the URL wasn't handled, and the default
* handling behavior should be used: `window.open(href, '_blank', 'noopener');`
*
* @returns true if URL was handled, false otherwise.
*/
openExternal(href: string): boolean | Promise<boolean>;
}
export interface ITunnelProvider {
/**
* Support for creating tunnels.
*/
tunnelFactory?: ITunnelFactory;
/**
* Support for filtering candidate ports.
*/
showPortCandidate?: IShowPortCandidate;
/**
* The features that the tunnel provider supports.
*/
features?: TunnelProviderFeatures;
}
export interface ITunnelFactory {
(tunnelOptions: ITunnelOptions, tunnelCreationOptions: TunnelCreationOptions): Promise<ITunnel> | undefined;
}
export 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;
/**
* @deprecated Use privacy instead
*/
public?: boolean;
privacy?: string;
protocol?: string;
}
export interface TunnelCreationOptions {
/**
* True when the local operating system will require elevation to use the requested local port.
*/
elevationRequired?: boolean;
}
export interface ITunnel {
remoteAddress: { port: number; host: string };
/**
* The complete local address(ex. localhost:1234)
*/
localAddress: string;
/**
* @deprecated Use privacy instead
*/
public?: boolean;
privacy?: string;
/**
* If protocol is not provided, it is assumed to be http, regardless of the localAddress
*/
protocol?: string;
/**
* Implementers of Tunnel should fire onDidDispose when dispose is called.
*/
onDidDispose: Event<void>;
dispose(): Promise<void> | void;
}
export interface IShowPortCandidate {
(host: string, port: number, detail: string): Promise<boolean>;
}
export enum Menu {
CommandPalette,
StatusBarWindowIndicatorMenu,
}
export interface ICommand {
/**
* An identifier for the command. Commands can be executed from extensions
* using the `vscode.commands.executeCommand` API using that command ID.
*/
id: string;
/**
* The optional label of the command. If provided, the command will appear
* in the command palette.
*/
label?: string;
/**
* The optional menus to append this command to. Only valid if `label` is
* provided as well.
* @default Menu.CommandPalette
*/
menu?: Menu | Menu[];
/**
* A function that is being executed with any arguments passed over. The
* return type will be send back to the caller.
*
* Note: arguments and return type should be serializable so that they can
* be exchanged across processes boundaries.
*/
handler: (...args: any[]) => unknown;
}
export interface IHomeIndicator {
/**
* The link to open when clicking the home indicator.
*/
href: string;
/**
* The icon name for the home indicator. This needs to be one of the existing
* icons from our Codicon icon set. For example `code`.
*/
icon: string;
/**
* A tooltip that will appear while hovering over the home indicator.
*/
title: string;
}
export interface IWelcomeBanner {
/**
* Welcome banner message to appear as text.
*/
message: string;
/**
* Optional icon for the banner. This is either the URL to an icon to use
* or the name of one of the existing icons from our Codicon icon set.
*
* If not provided a default icon will be used.
*/
icon?: string | UriComponents;
/**
* Optional actions to appear as links after the welcome banner message.
*/
actions?: IWelcomeBannerAction[];
}
export interface IWelcomeBannerAction {
/**
* The link to open when clicking. Supports command invocation when
* using the `command:<commandId>` value.
*/
href: string;
/**
* The label to show for the action link.
*/
label: string;
/**
* A tooltip that will appear while hovering over the action link.
*/
title?: string;
}
export interface IWindowIndicator {
/**
* Triggering this event will cause the window indicator to update.
*/
readonly onDidChange?: Event<void>;
/**
* Label of the window indicator may include octicons
* e.g. `$(remote) label`
*/
label: string;
/**
* Tooltip of the window indicator should not include
* octicons and be descriptive.
*/
tooltip: string;
/**
* If provided, overrides the default command that
* is executed when clicking on the window indicator.
*/
command?: string;
}
export enum ColorScheme {
DARK = 'dark',
LIGHT = 'light',
HIGH_CONTRAST_LIGHT = 'hcLight',
HIGH_CONTRAST_DARK = 'hcDark'
}
export interface IInitialColorTheme {
/**
* Initial color theme type.
*/
readonly themeType: ColorScheme;
/**
* A list of workbench colors to apply initially.
*/
readonly colors?: { [colorId: string]: string };
}
export interface IDefaultView {
readonly id: string;
}
/**
* @deprecated use `IDefaultEditor.options` instead
*/
export interface IPosition {
readonly line: number;
readonly column: number;
}
/**
* @deprecated use `IDefaultEditor.options` instead
*/
export interface IRange {
readonly start: IPosition;
readonly end: IPosition;
}
export interface IDefaultEditor {
readonly uri: UriComponents;
readonly options?: IEditorOptions;
readonly openOnlyIfExists?: boolean;
/**
* @deprecated use `options` instead
*/
readonly selection?: IRange;
/**
* @deprecated use `options.override` instead
*/
readonly openWith?: string;
}
export interface IDefaultLayout {
readonly views?: IDefaultView[];
readonly editors?: IDefaultEditor[];
/**
* Forces this layout to be applied even if this isn't
* the first time the workspace has been opened
*/
readonly force?: boolean;
}
export interface IProductQualityChangeHandler {
/**
* Handler is being called when the user wants to switch between
* `insider` or `stable` product qualities.
*/
(newQuality: 'insider' | 'stable'): void;
}
/**
* Settings sync options
*/
export interface ISettingsSyncOptions {
/**
* Is settings sync enabled
*/
readonly enabled: boolean;
/**
* Version of extensions sync state.
* Extensions sync state will be reset if version is provided and different from previous version.
*/
readonly extensionsSyncStateVersion?: string;
/**
* Handler is being called when the user changes Settings Sync enablement.
*/
enablementHandler?(enablement: boolean): void;
}
export interface IDevelopmentOptions {
/**
* Current logging level. Default is `LogLevel.Info`.
*/
readonly logLevel?: LogLevel;
/**
* Location of a module containing extension tests to run once the workbench is open.
*/
readonly extensionTestsPath?: UriComponents;
/**
* Add extensions under development.
*/
readonly extensions?: readonly UriComponents[];
/**
* Whether to enable the smoke test driver.
*/
readonly enableSmokeTestDriver?: boolean;
}
|