@theia/plugin 1.22.1 → 1.23.0-next.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theia/plugin",
3
- "version": "1.22.1",
3
+ "version": "1.23.0-next.26+0aa2621d3fd",
4
4
  "description": "Theia - Plugin API",
5
5
  "types": "./src/theia.d.ts",
6
6
  "publishConfig": {
@@ -32,5 +32,5 @@
32
32
  "nyc": {
33
33
  "extends": "../../configs/nyc.json"
34
34
  },
35
- "gitHead": "49910aeaecf520a54b253db0215b28c2268bb2f3"
35
+ "gitHead": "0aa2621d3fd7ce5f1dff771506f5473200104fea"
36
36
  }
@@ -81,12 +81,6 @@ export module '@theia/plugin' {
81
81
  */
82
82
  readonly supportsMultipleAccounts: boolean;
83
83
 
84
- /**
85
- * An [event](#Event) which fires when the array of sessions has changed, or data
86
- * within a session has changed.
87
- */
88
- readonly onDidChangeSessions: Event<AuthenticationProviderAuthenticationSessionsChangeEvent>;
89
-
90
84
  /**
91
85
  * Returns an array of current sessions.
92
86
  */
package/src/theia.d.ts CHANGED
@@ -2745,6 +2745,7 @@ export module '@theia/plugin' {
2745
2745
 
2746
2746
  /**
2747
2747
  * Options a virtual process terminal.
2748
+ * @deprecated since 1.23.0 - Use [ExtensionTerminalOptions](#ExtensionTerminalOptions) instead.
2748
2749
  */
2749
2750
  export interface PseudoTerminalOptions {
2750
2751
  /**
@@ -2759,6 +2760,22 @@ export module '@theia/plugin' {
2759
2760
  pty: Pseudoterminal;
2760
2761
  }
2761
2762
 
2763
+ /**
2764
+ * Options a virtual process terminal.
2765
+ */
2766
+ export interface ExtensionTerminalOptions {
2767
+ /**
2768
+ * The name of the terminal.
2769
+ */
2770
+ name: string;
2771
+
2772
+ /**
2773
+ * An implementation of [Pseudoterminal](#Pseudoterminal) where an extension can
2774
+ * control it.
2775
+ */
2776
+ pty: Pseudoterminal;
2777
+ }
2778
+
2762
2779
  /**
2763
2780
  * Defines the interface of a terminal pty, enabling extensions to control a terminal.
2764
2781
  */
@@ -3971,6 +3988,87 @@ export module '@theia/plugin' {
3971
3988
 
3972
3989
  }
3973
3990
 
3991
+ export interface WebviewView {
3992
+ /**
3993
+ * Identifies the type of the webview view, such as `'hexEditor.dataView'`.
3994
+ */
3995
+ readonly viewType: string;
3996
+
3997
+ /**
3998
+ * The underlying webview for the view.
3999
+ */
4000
+ readonly webview: Webview;
4001
+
4002
+ /**
4003
+ * View title displayed in the UI.
4004
+ *
4005
+ * The view title is initially taken from the extension `package.json` contribution.
4006
+ */
4007
+ title?: string;
4008
+
4009
+ /**
4010
+ * Human-readable string which is rendered less prominently in the title.
4011
+ */
4012
+ description?: string;
4013
+
4014
+ /**
4015
+ * Event fired when the view is disposed.
4016
+ *
4017
+ * Views are disposed when they are explicitly hidden by a user (this happens when a user
4018
+ * right clicks in a view and unchecks the webview view).
4019
+ *
4020
+ * Trying to use the view after it has been disposed throws an exception.
4021
+ */
4022
+ readonly onDidDispose: Event<void>;
4023
+
4024
+ /**
4025
+ * Tracks if the webview is currently visible.
4026
+ *
4027
+ * Views are visible when they are on the screen and expanded.
4028
+ */
4029
+ readonly visible: boolean;
4030
+
4031
+ /**
4032
+ * Event fired when the visibility of the view changes.
4033
+ *
4034
+ * Actions that trigger a visibility change:
4035
+ *
4036
+ * - The view is collapsed or expanded.
4037
+ * - The user switches to a different view group in the sidebar or panel.
4038
+ *
4039
+ * Note that hiding a view using the context menu instead disposes of the view and fires `onDidDispose`.
4040
+ */
4041
+ readonly onDidChangeVisibility: Event<boolean>;
4042
+
4043
+ /**
4044
+ * Reveal the view in the UI.
4045
+ *
4046
+ * If the view is collapsed, this will expand it.
4047
+ *
4048
+ * @param preserveFocus When `true` the view will not take focus.
4049
+ */
4050
+ show(preserveFocus?: boolean): void;
4051
+ }
4052
+ /**
4053
+ * Provider for creating `WebviewView` elements.
4054
+ */
4055
+ export interface WebviewViewProvider {
4056
+ /**
4057
+ * Revolves a webview view.
4058
+ *
4059
+ * `resolveWebviewView` is called when a view first becomes visible. This may happen when the view is
4060
+ * first loaded or when the user hides and then shows a view again.
4061
+ *
4062
+ * @param webviewView Webview view to restore. The provider should take ownership of this view. The
4063
+ * provider must set the webview's `.html` and hook up all webview events it is interested in.
4064
+ * @param context Additional metadata about the view being resolved.
4065
+ * @param token Cancellation token indicating that the view being provided is no longer needed.
4066
+ *
4067
+ * @return Optional thenable indicating that the view has been fully resolved.
4068
+ */
4069
+ resolveWebviewView(webviewView: WebviewView, context: WebviewViewResolveContext, token: CancellationToken): Thenable<void> | void;
4070
+ }
4071
+
3974
4072
  /**
3975
4073
  * Common namespace for dealing with window and editor, showing messages and user input.
3976
4074
  */
@@ -4304,6 +4402,70 @@ export module '@theia/plugin' {
4304
4402
  * @param viewType Type of the webview panel that can be serialized.
4305
4403
  * @param serializer Webview serializer.
4306
4404
  */
4405
+
4406
+ /**
4407
+ * Additional information the webview view being resolved.
4408
+ *
4409
+ * @param T Type of the webview's state.
4410
+ */
4411
+ interface WebviewViewResolveContext<T = unknown> {
4412
+ /**
4413
+ * Persisted state from the webview content.
4414
+ *
4415
+ * To save resources, VS Code normally deallocates webview documents (the iframe content) that are not visible.
4416
+ * For example, when the user collapse a view or switches to another top level activity in the sidebar, the
4417
+ * `WebviewView` itself is kept alive but the webview's underlying document is deallocated. It is recreated when
4418
+ * the view becomes visible again.
4419
+ *
4420
+ * You can prevent this behavior by setting `retainContextWhenHidden` in the `WebviewOptions`. However this
4421
+ * increases resource usage and should be avoided wherever possible. Instead, you can use persisted state to
4422
+ * save off a webview's state so that it can be quickly recreated as needed.
4423
+ *
4424
+ * To save off a persisted state, inside the webview call `acquireVsCodeApi().setState()` with
4425
+ * any json serializable object. To restore the state again, call `getState()`. For example:
4426
+ *
4427
+ * ```js
4428
+ * // Within the webview
4429
+ * const vscode = acquireVsCodeApi();
4430
+ *
4431
+ * // Get existing state
4432
+ * const oldState = vscode.getState() || { value: 0 };
4433
+ *
4434
+ * // Update state
4435
+ * setState({ value: oldState.value + 1 })
4436
+ * ```
4437
+ *
4438
+ * VS Code ensures that the persisted state is saved correctly when a webview is hidden and across
4439
+ * editor restarts.
4440
+ */
4441
+ readonly state: T | undefined;
4442
+ }
4443
+
4444
+ export function registerWebviewViewProvider(viewId: string, provider: WebviewViewProvider, options?: {
4445
+ /**
4446
+ * Content settings for the webview created for this view.
4447
+ */
4448
+ readonly webviewOptions?: {
4449
+ /**
4450
+ * Controls if the webview element itself (iframe) is kept around even when the view
4451
+ * is no longer visible.
4452
+ *
4453
+ * Normally the webview's html context is created when the view becomes visible
4454
+ * and destroyed when it is hidden. Extensions that have complex state
4455
+ * or UI can set the `retainContextWhenHidden` to make the editor keep the webview
4456
+ * context around, even when the webview moves to a background tab. When a webview using
4457
+ * `retainContextWhenHidden` becomes hidden, its scripts and other dynamic content are suspended.
4458
+ * When the view becomes visible again, the context is automatically restored
4459
+ * in the exact same state it was in originally. You cannot send messages to a
4460
+ * hidden webview, even with `retainContextWhenHidden` enabled.
4461
+ *
4462
+ * `retainContextWhenHidden` has a high memory overhead and should only be used if
4463
+ * your view's context cannot be quickly saved and restored.
4464
+ */
4465
+ readonly retainContextWhenHidden?: boolean;
4466
+ };
4467
+ }): Disposable;
4468
+
4307
4469
  export function registerWebviewPanelSerializer(viewType: string, serializer: WebviewPanelSerializer): Disposable;
4308
4470
 
4309
4471
  /**
@@ -4439,6 +4601,14 @@ export module '@theia/plugin' {
4439
4601
  */
4440
4602
  export function createTerminal(options: PseudoTerminalOptions): Terminal;
4441
4603
 
4604
+ /**
4605
+ * Creates a pseudo where an extension controls its input and output.
4606
+ *
4607
+ * @param options ExtensionTerminalOptions.
4608
+ * @return A new Terminal.
4609
+ */
4610
+ export function createTerminal(options: ExtensionTerminalOptions): Terminal;
4611
+
4442
4612
  /**
4443
4613
  * Register a [TreeDataProvider](#TreeDataProvider) for the view contributed using the extension point `views`.
4444
4614
  * This will allow you to contribute data to the [TreeView](#TreeView) and update if the data changes.
@@ -6024,6 +6194,28 @@ export module '@theia/plugin' {
6024
6194
  * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
6025
6195
  */
6026
6196
  export function registerTaskProvider(type: string, provider: TaskProvider): Disposable;
6197
+
6198
+ /**
6199
+ * When true, the user has explicitly trusted the contents of the workspace.
6200
+ */
6201
+ export const isTrusted: boolean;
6202
+
6203
+ export function requestWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Promise<boolean | undefined>;
6204
+
6205
+ /**
6206
+ * Event that fires when the current workspace has been trusted.
6207
+ */
6208
+ export const onDidGrantWorkspaceTrust: Event<void>;
6209
+ }
6210
+
6211
+ export interface WorkspaceTrustRequestButton {
6212
+ readonly label: string;
6213
+ readonly type: 'ContinueWithTrust' | 'ContinueWithoutTrust' | 'Manage' | 'Cancel'
6214
+ }
6215
+
6216
+ export interface WorkspaceTrustRequestOptions {
6217
+ readonly buttons?: WorkspaceTrustRequestButton[];
6218
+ readonly message?: string;
6027
6219
  }
6028
6220
 
6029
6221
  export namespace env {
@@ -10992,6 +11184,28 @@ export module '@theia/plugin' {
10992
11184
  * Defaults to false.
10993
11185
  */
10994
11186
  clearSessionPreference?: boolean;
11187
+
11188
+ /**
11189
+ * Whether we should attempt to reauthenticate even if there is already a session available.
11190
+ *
11191
+ * If true, a modal dialog will be shown asking the user to sign in again. This is mostly used for scenarios
11192
+ * where the token needs to be re minted because it has lost some authorization.
11193
+ *
11194
+ * Defaults to false.
11195
+ */
11196
+ forceNewSession?: boolean | { detail: string };
11197
+
11198
+ /**
11199
+ * Whether we should show the indication to sign in in the Accounts menu.
11200
+ *
11201
+ * If false, the user will be shown a badge on the Accounts menu with an option to sign in for the extension.
11202
+ * If true, no indication will be shown.
11203
+ *
11204
+ * Defaults to false.
11205
+ *
11206
+ * Note: you cannot use this option with any other options that prompt the user like {@link createIfNone}.
11207
+ */
11208
+ silent?: boolean;
10995
11209
  }
10996
11210
 
10997
11211
  /**
@@ -11019,6 +11233,83 @@ export module '@theia/plugin' {
11019
11233
  readonly provider: AuthenticationProviderInformation;
11020
11234
  }
11021
11235
 
11236
+ /**
11237
+ * Options for creating an {@link AuthenticationProvider}.
11238
+ */
11239
+ export interface AuthenticationProviderOptions {
11240
+ /**
11241
+ * Whether it is possible to be signed into multiple accounts at once with this provider.
11242
+ * If not specified, will default to false.
11243
+ */
11244
+ readonly supportsMultipleAccounts?: boolean;
11245
+ }
11246
+
11247
+ /**
11248
+ * An {@link Event} which fires when an {@link AuthenticationSession} is added, removed, or changed.
11249
+ */
11250
+ export interface AuthenticationProviderAuthenticationSessionsChangeEvent {
11251
+ /**
11252
+ * The {@link AuthenticationSession AuthenticationSessions} of the {@link AuthenticationProvider} that have been added.
11253
+ */
11254
+ readonly added: readonly AuthenticationSession[] | undefined;
11255
+
11256
+ /**
11257
+ * The {@link AuthenticationSession AuthenticationSessions} of the {@link AuthenticationProvider} that have been removed.
11258
+ */
11259
+ readonly removed: readonly AuthenticationSession[] | undefined;
11260
+
11261
+ /**
11262
+ * The {@link AuthenticationSession AuthenticationSessions} of the {@link AuthenticationProvider} that have been changed.
11263
+ * A session changes when its data excluding the id are updated. An example of this is a session refresh that results in a new
11264
+ * access token being set for the session.
11265
+ */
11266
+ readonly changed: readonly AuthenticationSession[] | undefined;
11267
+ }
11268
+
11269
+ /**
11270
+ * A provider for performing authentication to a service.
11271
+ */
11272
+ export interface AuthenticationProvider {
11273
+ /**
11274
+ * An {@link Event} which fires when the array of sessions has changed, or data
11275
+ * within a session has changed.
11276
+ */
11277
+ readonly onDidChangeSessions: Event<AuthenticationProviderAuthenticationSessionsChangeEvent>;
11278
+
11279
+ /**
11280
+ * Get a list of sessions.
11281
+ * @param scopes An optional list of scopes. If provided, the sessions returned should match
11282
+ * these permissions, otherwise all sessions should be returned.
11283
+ * @returns A promise that resolves to an array of authentication sessions.
11284
+ */
11285
+ getSessions(scopes?: readonly string[]): Thenable<readonly AuthenticationSession[]>;
11286
+
11287
+ /**
11288
+ * Prompts a user to login.
11289
+ *
11290
+ * If login is successful, the onDidChangeSessions event should be fired.
11291
+ *
11292
+ * If login fails, a rejected promise should be returned.
11293
+ *
11294
+ * If the provider has specified that it does not support multiple accounts,
11295
+ * then this should never be called if there is already an existing session matching these
11296
+ * scopes.
11297
+ * @param scopes A list of scopes, permissions, that the new session should be created with.
11298
+ * @returns A promise that resolves to an authentication session.
11299
+ */
11300
+ createSession(scopes: readonly string[]): Thenable<AuthenticationSession>;
11301
+
11302
+ /**
11303
+ * Removes the session corresponding to session id.
11304
+ *
11305
+ * If the removal is successful, the onDidChangeSessions event should be fired.
11306
+ *
11307
+ * If a session cannot be removed, the provider should reject with an error message.
11308
+ * @param sessionId The id of the session to remove.
11309
+ */
11310
+ removeSession(sessionId: string): Thenable<void>;
11311
+ }
11312
+
11022
11313
  /**
11023
11314
  * Namespace for authentication.
11024
11315
  */
@@ -11038,6 +11329,21 @@ export module '@theia/plugin' {
11038
11329
  */
11039
11330
  export function getSession(providerId: string, scopes: string[], options: AuthenticationGetSessionOptions & { createIfNone: true }): Thenable<AuthenticationSession>;
11040
11331
 
11332
+ /**
11333
+ * Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not
11334
+ * registered, or if the user does not consent to sharing authentication information with
11335
+ * the extension. If there are multiple sessions with the same scopes, the user will be shown a
11336
+ * quickpick to select which account they would like to use.
11337
+ *
11338
+ * Currently, there are only two authentication providers that are contributed from built in extensions
11339
+ * to the editor that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'.
11340
+ * @param providerId The id of the provider to use
11341
+ * @param scopes A list of scopes representing the permissions requested. These are dependent on the authentication provider
11342
+ * @param options The {@link AuthenticationGetSessionOptions} to use
11343
+ * @returns A thenable that resolves to an authentication session
11344
+ */
11345
+ export function getSession(providerId: string, scopes: readonly string[], options: AuthenticationGetSessionOptions & { forceNewSession: true | { detail: string } }): Thenable<AuthenticationSession>;
11346
+
11041
11347
  /**
11042
11348
  * Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not
11043
11349
  * registered, or if the user does not consent to sharing authentication information with
@@ -11056,5 +11362,25 @@ export module '@theia/plugin' {
11056
11362
  * been added, removed, or changed.
11057
11363
  */
11058
11364
  export const onDidChangeSessions: Event<AuthenticationSessionsChangeEvent>;
11365
+
11366
+ /**
11367
+ * Register an authentication provider.
11368
+ *
11369
+ * There can only be one provider per id and an error is being thrown when an id
11370
+ * has already been used by another provider. Ids are case-sensitive.
11371
+ *
11372
+ * @param id The unique identifier of the provider.
11373
+ * @param label The human-readable name of the provider.
11374
+ * @param provider The authentication provider provider.
11375
+ * @params options Additional options for the provider.
11376
+ * @return A {@link Disposable} that unregisters this provider when being disposed.
11377
+ */
11378
+ export function registerAuthenticationProvider(id: string, label: string, provider: AuthenticationProvider, options?: AuthenticationProviderOptions): Disposable;
11379
+
11380
+ /**
11381
+ * @deprecated Use {@link getSession()} {@link AuthenticationGetSessionOptions.silent} instead.
11382
+ */
11383
+ export function hasSession(providerId: string, scopes: readonly string[]): Thenable<boolean>;
11384
+
11059
11385
  }
11060
11386
  }