@theia/plugin 1.53.0-next.6 → 1.53.0-next.64

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/theia.d.ts +397 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theia/plugin",
3
- "version": "1.53.0-next.6+5255c512c",
3
+ "version": "1.53.0-next.64+23b351d26",
4
4
  "description": "Theia - Plugin API",
5
5
  "types": "./src/theia.d.ts",
6
6
  "publishConfig": {
@@ -27,10 +27,10 @@
27
27
  "watch": "theiaext watch"
28
28
  },
29
29
  "devDependencies": {
30
- "@theia/ext-scripts": "1.52.0"
30
+ "@theia/ext-scripts": "1.53.0"
31
31
  },
32
32
  "nyc": {
33
33
  "extends": "../../configs/nyc.json"
34
34
  },
35
- "gitHead": "5255c512c6c9da44c11cb4d5fca7379de60b71cc"
35
+ "gitHead": "23b351d26346a2b5d6aca3ee81fba59c056132f7"
36
36
  }
package/src/theia.d.ts CHANGED
@@ -3057,6 +3057,19 @@ export module '@theia/plugin' {
3057
3057
  */
3058
3058
  readonly state: TerminalState;
3059
3059
 
3060
+ /**
3061
+ * An object that contains [shell integration](https://code.visualstudio.com/docs/terminal/shell-integration)-powered
3062
+ * features for the terminal. This will always be `undefined` immediately after the terminal
3063
+ * is created. Listen to {@link window.onDidChangeTerminalShellIntegration} to be notified
3064
+ * when shell integration is activated for a terminal.
3065
+ *
3066
+ * Note that this object may remain undefined if shell integation never activates. For
3067
+ * example Command Prompt does not support shell integration and a user's shell setup could
3068
+ * conflict with the automatic shell integration activation.
3069
+ * @stubbed
3070
+ */
3071
+ readonly shellIntegration: TerminalShellIntegration | undefined;
3072
+
3060
3073
  /**
3061
3074
  * Send text to the terminal.
3062
3075
  * @param text - The text to send.
@@ -3100,6 +3113,333 @@ export module '@theia/plugin' {
3100
3113
  readonly isInteractedWith: boolean;
3101
3114
  }
3102
3115
 
3116
+ /**
3117
+ * [Shell integration](https://code.visualstudio.com/docs/terminal/shell-integration)-powered capabilities owned by a terminal.
3118
+ * @stubbed
3119
+ */
3120
+ export interface TerminalShellIntegration {
3121
+ /**
3122
+ * The current working directory of the terminal. This {@link Uri} may represent a file on
3123
+ * another machine (eg. ssh into another machine). This requires the shell integration to
3124
+ * support working directory reporting.
3125
+ * @stubbed
3126
+ */
3127
+ readonly cwd: Uri | undefined;
3128
+
3129
+ /**
3130
+ * Execute a command, sending ^C as necessary to interrupt any running command if needed.
3131
+ *
3132
+ * @param commandLine The command line to execute, this is the exact text that will be sent
3133
+ * to the terminal.
3134
+ *
3135
+ * @example
3136
+ * // Execute a command in a terminal immediately after being created
3137
+ * const myTerm = window.createTerminal();
3138
+ * window.onDidChangeTerminalShellIntegration(async ({ terminal, shellIntegration }) => {
3139
+ * if (terminal === myTerm) {
3140
+ * const execution = shellIntegration.executeCommand('echo "Hello world"');
3141
+ * window.onDidEndTerminalShellExecution(event => {
3142
+ * if (event.execution === execution) {
3143
+ * console.log(`Command exited with code ${event.exitCode}`);
3144
+ * }
3145
+ * }
3146
+ * }));
3147
+ * // Fallback to sendText if there is no shell integration within 3 seconds of launching
3148
+ * setTimeout(() => {
3149
+ * if (!myTerm.shellIntegration) {
3150
+ * myTerm.sendText('echo "Hello world"');
3151
+ * // Without shell integration, we can't know when the command has finished or what the
3152
+ * // exit code was.
3153
+ * }
3154
+ * }, 3000);
3155
+ *
3156
+ * @example
3157
+ * // Send command to terminal that has been alive for a while
3158
+ * const commandLine = 'echo "Hello world"';
3159
+ * if (term.shellIntegration) {
3160
+ * const execution = shellIntegration.executeCommand({ commandLine });
3161
+ * window.onDidEndTerminalShellExecution(event => {
3162
+ * if (event.execution === execution) {
3163
+ * console.log(`Command exited with code ${event.exitCode}`);
3164
+ * }
3165
+ * } else {
3166
+ * term.sendText(commandLine);
3167
+ * // Without shell integration, we can't know when the command has finished or what the
3168
+ * // exit code was.
3169
+ * }
3170
+ * @stubbed
3171
+ */
3172
+ executeCommand(commandLine: string): TerminalShellExecution;
3173
+
3174
+ /**
3175
+ * Execute a command, sending ^C as necessary to interrupt any running command if needed.
3176
+ *
3177
+ * *Note* This is not guaranteed to work as [shell integration](https://code.visualstudio.com/docs/terminal/shell-integration)
3178
+ * must be activated. Check whether {@link TerminalShellExecution.exitCode} is rejected to
3179
+ * verify whether it was successful.
3180
+ *
3181
+ * @param command A command to run.
3182
+ * @param args Arguments to launch the executable with which will be automatically escaped
3183
+ * based on the executable type.
3184
+ *
3185
+ * @example
3186
+ * // Execute a command in a terminal immediately after being created
3187
+ * const myTerm = window.createTerminal();
3188
+ * window.onDidActivateTerminalShellIntegration(async ({ terminal, shellIntegration }) => {
3189
+ * if (terminal === myTerm) {
3190
+ * const command = shellIntegration.executeCommand({
3191
+ * command: 'echo',
3192
+ * args: ['Hello world']
3193
+ * });
3194
+ * const code = await command.exitCode;
3195
+ * console.log(`Command exited with code ${code}`);
3196
+ * }
3197
+ * }));
3198
+ * // Fallback to sendText if there is no shell integration within 3 seconds of launching
3199
+ * setTimeout(() => {
3200
+ * if (!myTerm.shellIntegration) {
3201
+ * myTerm.sendText('echo "Hello world"');
3202
+ * // Without shell integration, we can't know when the command has finished or what the
3203
+ * // exit code was.
3204
+ * }
3205
+ * }, 3000);
3206
+ *
3207
+ * @example
3208
+ * // Send command to terminal that has been alive for a while
3209
+ * const commandLine = 'echo "Hello world"';
3210
+ * if (term.shellIntegration) {
3211
+ * const command = term.shellIntegration.executeCommand({
3212
+ * command: 'echo',
3213
+ * args: ['Hello world']
3214
+ * });
3215
+ * const code = await command.exitCode;
3216
+ * console.log(`Command exited with code ${code}`);
3217
+ * } else {
3218
+ * term.sendText(commandLine);
3219
+ * // Without shell integration, we can't know when the command has finished or what the
3220
+ * // exit code was.
3221
+ * }
3222
+ * @stubbed
3223
+ */
3224
+ executeCommand(executable: string, args: string[]): TerminalShellExecution;
3225
+ }
3226
+
3227
+ /**
3228
+ * A command that was executed in a terminal.
3229
+ * @stubbed
3230
+ */
3231
+ export interface TerminalShellExecution {
3232
+ /**
3233
+ * The command line that was executed. The {@link TerminalShellExecutionCommandLineConfidence confidence}
3234
+ * of this value depends on the specific shell's shell integration implementation. This
3235
+ * value may become more accurate after {@link window.onDidEndTerminalShellExecution} is
3236
+ * fired.
3237
+ *
3238
+ * @example
3239
+ * // Log the details of the command line on start and end
3240
+ * window.onDidStartTerminalShellExecution(event => {
3241
+ * const commandLine = event.execution.commandLine;
3242
+ * console.log(`Command started\n${summarizeCommandLine(commandLine)}`);
3243
+ * });
3244
+ * window.onDidEndTerminalShellExecution(event => {
3245
+ * const commandLine = event.execution.commandLine;
3246
+ * console.log(`Command ended\n${summarizeCommandLine(commandLine)}`);
3247
+ * });
3248
+ * function summarizeCommandLine(commandLine: TerminalShellExecutionCommandLine) {
3249
+ * return [
3250
+ * ` Command line: ${command.commandLine.value}`,
3251
+ * ` Confidence: ${command.commandLine.confidence}`,
3252
+ * ` Trusted: ${command.commandLine.isTrusted}
3253
+ * ].join('\n');
3254
+ * }
3255
+ * @stubbed
3256
+ */
3257
+ readonly commandLine: TerminalShellExecutionCommandLine;
3258
+
3259
+ /**
3260
+ * The working directory that was reported by the shell when this command executed. This
3261
+ * {@link Uri} may represent a file on another machine (eg. ssh into another machine). This
3262
+ * requires the shell integration to support working directory reporting.
3263
+ * @stubbed
3264
+ */
3265
+ readonly cwd: Uri | undefined;
3266
+
3267
+ /**
3268
+ * Creates a stream of raw data (including escape sequences) that is written to the
3269
+ * terminal. This will only include data that was written after `read` was called for
3270
+ * the first time, ie. you must call `read` immediately after the command is executed via
3271
+ * {@link TerminalShellIntegration.executeCommand} or
3272
+ * {@link window.onDidStartTerminalShellExecution} to not miss any data.
3273
+ *
3274
+ * @example
3275
+ * // Log all data written to the terminal for a command
3276
+ * const command = term.shellIntegration.executeCommand({ commandLine: 'echo "Hello world"' });
3277
+ * const stream = command.read();
3278
+ * for await (const data of stream) {
3279
+ * console.log(data);
3280
+ * }
3281
+ * @stubbed
3282
+ */
3283
+ read(): AsyncIterable<string>;
3284
+ }
3285
+
3286
+ /**
3287
+ * A command line that was executed in a terminal.
3288
+ * @stubbed
3289
+ */
3290
+ export interface TerminalShellExecutionCommandLine {
3291
+ /**
3292
+ * The full command line that was executed, including both the command and its arguments.
3293
+ * @stubbed
3294
+ */
3295
+ readonly value: string;
3296
+
3297
+ /**
3298
+ * Whether the command line value came from a trusted source and is therefore safe to
3299
+ * execute without user additional confirmation, such as a notification that asks "Do you
3300
+ * want to execute (command)?". This verification is likely only needed if you are going to
3301
+ * execute the command again.
3302
+ *
3303
+ * This is `true` only when the command line was reported explicitly by the shell
3304
+ * integration script (ie. {@link TerminalShellExecutionCommandLineConfidence.High high confidence})
3305
+ * and it used a nonce for verification.
3306
+ * @stubbed
3307
+ */
3308
+ readonly isTrusted: boolean;
3309
+
3310
+ /**
3311
+ * The confidence of the command line value which is determined by how the value was
3312
+ * obtained. This depends upon the implementation of the shell integration script.
3313
+ * @stubbed
3314
+ */
3315
+ readonly confidence: TerminalShellExecutionCommandLineConfidence;
3316
+ }
3317
+
3318
+ /**
3319
+ * The confidence of a {@link TerminalShellExecutionCommandLine} value.
3320
+ */
3321
+ enum TerminalShellExecutionCommandLineConfidence {
3322
+ /**
3323
+ * The command line value confidence is low. This means that the value was read from the
3324
+ * terminal buffer using markers reported by the shell integration script. Additionally one
3325
+ * of the following conditions will be met:
3326
+ *
3327
+ * - The command started on the very left-most column which is unusual, or
3328
+ * - The command is multi-line which is more difficult to accurately detect due to line
3329
+ * continuation characters and right prompts.
3330
+ * - Command line markers were not reported by the shell integration script.
3331
+ */
3332
+ Low = 0,
3333
+
3334
+ /**
3335
+ * The command line value confidence is medium. This means that the value was read from the
3336
+ * terminal buffer using markers reported by the shell integration script. The command is
3337
+ * single-line and does not start on the very left-most column (which is unusual).
3338
+ */
3339
+ Medium = 1,
3340
+
3341
+ /**
3342
+ * The command line value confidence is high. This means that the value was explicitly sent
3343
+ * from the shell integration script or the command was executed via the
3344
+ * {@link TerminalShellIntegration.executeCommand} API.
3345
+ */
3346
+ High = 2
3347
+ }
3348
+
3349
+ /**
3350
+ * An event signalling that a terminal's shell integration has changed.
3351
+ * @stubbed
3352
+ */
3353
+ export interface TerminalShellIntegrationChangeEvent {
3354
+ /**
3355
+ * The terminal that shell integration has been activated in.
3356
+ * @stubbed
3357
+ */
3358
+ readonly terminal: Terminal;
3359
+
3360
+ /**
3361
+ * The shell integration object.
3362
+ * @stubbed
3363
+ */
3364
+ readonly shellIntegration: TerminalShellIntegration;
3365
+ }
3366
+
3367
+ /**
3368
+ * An event signalling that an execution has started in a terminal.
3369
+ * @stubbed
3370
+ */
3371
+ export interface TerminalShellExecutionStartEvent {
3372
+ /**
3373
+ * The terminal that shell integration has been activated in.
3374
+ * @stubbed
3375
+ */
3376
+ readonly terminal: Terminal;
3377
+
3378
+ /**
3379
+ * The shell integration object.
3380
+ * @stubbed
3381
+ */
3382
+ readonly shellIntegration: TerminalShellIntegration;
3383
+
3384
+ /**
3385
+ * The terminal shell execution that has ended.
3386
+ * @stubbed
3387
+ */
3388
+ readonly execution: TerminalShellExecution;
3389
+ }
3390
+
3391
+ /**
3392
+ * An event signalling that an execution has ended in a terminal.
3393
+ * @stubbed
3394
+ */
3395
+ export interface TerminalShellExecutionEndEvent {
3396
+ /**
3397
+ * The terminal that shell integration has been activated in.
3398
+ * @stubbed
3399
+ */
3400
+ readonly terminal: Terminal;
3401
+
3402
+ /**
3403
+ * The shell integration object.
3404
+ * @stubbed
3405
+ */
3406
+ readonly shellIntegration: TerminalShellIntegration;
3407
+
3408
+ /**
3409
+ * The terminal shell execution that has ended.
3410
+ * @stubbed
3411
+ */
3412
+ readonly execution: TerminalShellExecution;
3413
+
3414
+ /**
3415
+ * The exit code reported by the shell.
3416
+ *
3417
+ * Note that `undefined` means the shell either did not report an exit code (ie. the shell
3418
+ * integration script is misbehaving) or the shell reported a command started before the command
3419
+ * finished (eg. a sub-shell was opened). Generally this should not happen, depending on the use
3420
+ * case, it may be best to treat this as a failure.
3421
+ *
3422
+ * @example
3423
+ * const execution = shellIntegration.executeCommand({
3424
+ * command: 'echo',
3425
+ * args: ['Hello world']
3426
+ * });
3427
+ * window.onDidEndTerminalShellExecution(event => {
3428
+ * if (event.execution === execution) {
3429
+ * if (event.exitCode === undefined) {
3430
+ * console.log('Command finished but exit code is unknown');
3431
+ * } else if (event.exitCode === 0) {
3432
+ * console.log('Command succeeded');
3433
+ * } else {
3434
+ * console.log('Command failed');
3435
+ * }
3436
+ * }
3437
+ * });
3438
+ * @stubbed
3439
+ */
3440
+ readonly exitCode: number | undefined;
3441
+ }
3442
+
3103
3443
  /**
3104
3444
  * Options to create terminal widget.
3105
3445
  */
@@ -3180,7 +3520,6 @@ export module '@theia/plugin' {
3180
3520
  * The icon {@link ThemeColor} for the terminal.
3181
3521
  * The `terminal.ansi*` theme keys are
3182
3522
  * recommended for the best contrast and consistency across themes.
3183
- * @stubbed
3184
3523
  */
3185
3524
  color?: ThemeColor;
3186
3525
  }
@@ -5499,6 +5838,28 @@ export module '@theia/plugin' {
5499
5838
  */
5500
5839
  export const onDidChangeTerminalState: Event<Terminal>;
5501
5840
 
5841
+ /**
5842
+ * Fires when shell integration activates or one of its properties changes in a terminal.
5843
+ * @stubbed
5844
+ */
5845
+ export const onDidChangeTerminalShellIntegration: Event<TerminalShellIntegrationChangeEvent>;
5846
+
5847
+ /**
5848
+ * This will be fired when a terminal command is started. This event will fire only when
5849
+ * [shell integration](https://code.visualstudio.com/docs/terminal/shell-integration) is
5850
+ * activated for the terminal.
5851
+ * @stubbed
5852
+ */
5853
+ export const onDidStartTerminalShellExecution: Event<TerminalShellExecutionStartEvent>;
5854
+
5855
+ /**
5856
+ * This will be fired when a terminal command is ended. This event will fire only when
5857
+ * [shell integration](https://code.visualstudio.com/docs/terminal/shell-integration) is
5858
+ * activated for the terminal.
5859
+ * @stubbed
5860
+ */
5861
+ export const onDidEndTerminalShellExecution: Event<TerminalShellExecutionEndEvent>;
5862
+
5502
5863
  /**
5503
5864
  * Create new terminal with predefined options.
5504
5865
  * @param - terminal options.
@@ -14083,6 +14444,11 @@ export module '@theia/plugin' {
14083
14444
  * Note: you cannot use this option with any other options that prompt the user like {@link createIfNone}.
14084
14445
  */
14085
14446
  silent?: boolean;
14447
+
14448
+ /**
14449
+ * The account that you would like to get a session for. This is passed down to the Authentication Provider to be used for creating the correct session.
14450
+ */
14451
+ account?: AuthenticationSessionAccountInformation;
14086
14452
  }
14087
14453
 
14088
14454
  /**
@@ -14143,6 +14509,18 @@ export module '@theia/plugin' {
14143
14509
  readonly changed: readonly AuthenticationSession[] | undefined;
14144
14510
  }
14145
14511
 
14512
+ /**
14513
+ * The options passed in to the {@link AuthenticationProvider.getSessions} and
14514
+ * {@link AuthenticationProvider.createSession} call.
14515
+ */
14516
+ export interface AuthenticationProviderSessionOptions {
14517
+ /**
14518
+ * The account that is being asked about. If this is passed in, the provider should
14519
+ * attempt to return the sessions that are only related to this account.
14520
+ */
14521
+ account?: AuthenticationSessionAccountInformation;
14522
+ }
14523
+
14146
14524
  /**
14147
14525
  * A provider for performing authentication to a service.
14148
14526
  */
@@ -14157,9 +14535,10 @@ export module '@theia/plugin' {
14157
14535
  * Get a list of sessions.
14158
14536
  * @param scopes An optional list of scopes. If provided, the sessions returned should match
14159
14537
  * these permissions, otherwise all sessions should be returned.
14538
+ * @param options Additional options for getting sessions.
14160
14539
  * @returns A promise that resolves to an array of authentication sessions.
14161
14540
  */
14162
- getSessions(scopes?: readonly string[]): Thenable<readonly AuthenticationSession[]>;
14541
+ getSessions(scopes: readonly string[] | undefined, options: AuthenticationProviderSessionOptions): Thenable<AuthenticationSession[]>;
14163
14542
 
14164
14543
  /**
14165
14544
  * Prompts a user to login.
@@ -14172,9 +14551,10 @@ export module '@theia/plugin' {
14172
14551
  * then this should never be called if there is already an existing session matching these
14173
14552
  * scopes.
14174
14553
  * @param scopes A list of scopes, permissions, that the new session should be created with.
14554
+ * @param options Additional options for creating a session.
14175
14555
  * @returns A promise that resolves to an authentication session.
14176
14556
  */
14177
- createSession(scopes: readonly string[]): Thenable<AuthenticationSession>;
14557
+ createSession(scopes: readonly string[], options: AuthenticationProviderSessionOptions): Thenable<AuthenticationSession>;
14178
14558
 
14179
14559
  /**
14180
14560
  * Removes the session corresponding to session id.
@@ -14234,6 +14614,20 @@ export module '@theia/plugin' {
14234
14614
  */
14235
14615
  export function getSession(providerId: string, scopes: readonly string[], options?: AuthenticationGetSessionOptions): Thenable<AuthenticationSession | undefined>;
14236
14616
 
14617
+ /**
14618
+ * Get all accounts that the user is logged in to for the specified provider.
14619
+ * Use this paired with {@link getSession} in order to get an authentication session for a specific account.
14620
+ *
14621
+ * Currently, there are only two authentication providers that are contributed from built in extensions
14622
+ * to the editor that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'.
14623
+ *
14624
+ * Note: Getting accounts does not imply that your extension has access to that account or its authentication sessions. You can verify access to the account by calling {@link getSession}.
14625
+ *
14626
+ * @param providerId The id of the provider to use
14627
+ * @returns A thenable that resolves to a readonly array of authentication accounts.
14628
+ */
14629
+ export function getAccounts(providerId: string): Thenable<readonly AuthenticationSessionAccountInformation[]>;
14630
+
14237
14631
  /**
14238
14632
  * An {@link Event event} which fires when the authentication sessions of an authentication provider have
14239
14633
  * been added, removed, or changed.