@theia/plugin 1.51.0 → 1.53.0-next.18

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.51.0",
3
+ "version": "1.53.0-next.18+c3ffc5fa8",
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.51.0"
30
+ "@theia/ext-scripts": "1.52.0"
31
31
  },
32
32
  "nyc": {
33
33
  "extends": "../../configs/nyc.json"
34
34
  },
35
- "gitHead": "fe70ec5d445d733038564d81357c78aedf5c7e0e"
35
+ "gitHead": "c3ffc5fa81879943e3b3ad3caec3738ed2d0e5f9"
36
36
  }
package/src/theia.d.ts CHANGED
@@ -24,23 +24,26 @@
24
24
  import './theia-extra';
25
25
  import './theia.proposed.canonicalUriProvider';
26
26
  import './theia.proposed.customEditorMove';
27
+ import './theia.proposed.debugVisualization';
27
28
  import './theia.proposed.diffCommand';
28
29
  import './theia.proposed.documentPaste';
29
30
  import './theia.proposed.editSessionIdentityProvider';
30
31
  import './theia.proposed.extensionsAny';
31
32
  import './theia.proposed.externalUriOpener';
33
+ import './theia.proposed.findTextInFiles';
34
+ import './theia.proposed.fsChunks';
32
35
  import './theia.proposed.mappedEditsProvider';
36
+ import './theia.proposed.multiDocumentHighlightProvider';
33
37
  import './theia.proposed.notebookCellExecutionState';
34
38
  import './theia.proposed.notebookKernelSource';
35
39
  import './theia.proposed.notebookMessaging';
36
- import './theia.proposed.findTextInFiles';
37
- import './theia.proposed.fsChunks';
38
- import './theia.proposed.multiDocumentHighlightProvider';
40
+ import './theia.proposed.portsAttributes';
39
41
  import './theia.proposed.profileContentHandlers';
40
42
  import './theia.proposed.resolvers';
41
43
  import './theia.proposed.scmValidation';
42
44
  import './theia.proposed.shareProvider';
43
45
  import './theia.proposed.terminalQuickFixProvider';
46
+ import './theia.proposed.terminalShellIntegration';
44
47
  import './theia.proposed.textSearchProvider';
45
48
  import './theia.proposed.timeline';
46
49
 
@@ -3172,7 +3175,7 @@ export module '@theia/plugin' {
3172
3175
  /**
3173
3176
  * The icon path or {@link ThemeIcon} for the terminal.
3174
3177
  */
3175
- iconPath?: ThemeIcon;
3178
+ iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
3176
3179
 
3177
3180
  /**
3178
3181
  * The icon {@link ThemeColor} for the terminal.
@@ -3293,7 +3296,7 @@ export module '@theia/plugin' {
3293
3296
  /**
3294
3297
  * The icon path or {@link ThemeIcon} for the terminal.
3295
3298
  */
3296
- iconPath?: ThemeIcon;
3299
+ iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
3297
3300
 
3298
3301
  /**
3299
3302
  * The icon {@link ThemeColor} for the terminal.
@@ -12085,6 +12088,12 @@ export module '@theia/plugin' {
12085
12088
  * When true, the debug viewlet will not be automatically revealed for this session.
12086
12089
  */
12087
12090
  suppressDebugView?: boolean;
12091
+ /**
12092
+ * Signals to the editor that the debug session was started from a test run
12093
+ * request. This is used to link the lifecycle of the debug session and
12094
+ * test run in UI actions.
12095
+ */
12096
+ testRun?: TestRun;
12088
12097
  }
12089
12098
 
12090
12099
  /**
@@ -12546,13 +12555,11 @@ export module '@theia/plugin' {
12546
12555
  * thread or stack is focused. A thread can be focused any time there is
12547
12556
  * an active debug session, while a stack frame can only be focused when
12548
12557
  * a session is paused and the call stack has been retrieved.
12549
- * @stubbed
12550
12558
  */
12551
12559
  export const activeStackItem: DebugThread | DebugStackFrame | undefined;
12552
12560
 
12553
12561
  /**
12554
12562
  * An event which fires when the {@link debug.activeStackItem} has changed.
12555
- * @stubbed
12556
12563
  */
12557
12564
  export const onDidChangeActiveStackItem: Event<DebugThread | DebugStackFrame | undefined>;
12558
12565
 
@@ -0,0 +1,189 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 Typefox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ /*---------------------------------------------------------------------------------------------
18
+ * Copyright (c) Microsoft Corporation. All rights reserved.
19
+ * Licensed under the MIT License. See License.txt in the project root for license information.
20
+ *--------------------------------------------------------------------------------------------*/
21
+
22
+ /* eslint-disable @typescript-eslint/no-explicit-any */
23
+
24
+ declare module '@theia/plugin' {
25
+ export namespace debug {
26
+ /**
27
+ * Registers a custom data visualization for variables when debugging.
28
+ *
29
+ * @param id The corresponding ID in the package.json `debugVisualizers` contribution point.
30
+ * @param provider The {@link DebugVisualizationProvider} to register
31
+ * @stubbed
32
+ */
33
+ export function registerDebugVisualizationProvider<T extends DebugVisualization>(
34
+ id: string,
35
+ provider: DebugVisualizationProvider<T>
36
+ ): Disposable;
37
+
38
+ /**
39
+ * Registers a tree that can be referenced by {@link DebugVisualization.visualization}.
40
+ * @param id
41
+ * @param provider
42
+ * @stubbed
43
+ */
44
+ export function registerDebugVisualizationTreeProvider<T extends DebugTreeItem>(
45
+ id: string,
46
+ provider: DebugVisualizationTree<T>
47
+ ): Disposable;
48
+ }
49
+
50
+ /**
51
+ * An item from the {@link DebugVisualizationTree}
52
+ */
53
+ export interface DebugTreeItem {
54
+ /**
55
+ * A human-readable string describing this item.
56
+ */
57
+ label: string;
58
+
59
+ /**
60
+ * A human-readable string which is rendered less prominent.
61
+ */
62
+ description?: string;
63
+
64
+ /**
65
+ * {@link TreeItemCollapsibleState} of the tree item.
66
+ */
67
+ collapsibleState?: TreeItemCollapsibleState;
68
+
69
+ /**
70
+ * Context value of the tree item. This can be used to contribute item specific actions in the tree.
71
+ * For example, a tree item is given a context value as `folder`. When contributing actions to `view/item/context`
72
+ * using `menus` extension point, you can specify context value for key `viewItem` in `when` expression like `viewItem == folder`.
73
+ * ```json
74
+ * "contributes": {
75
+ * "menus": {
76
+ * "view/item/context": [
77
+ * {
78
+ * "command": "extension.deleteFolder",
79
+ * "when": "viewItem == folder"
80
+ * }
81
+ * ]
82
+ * }
83
+ * }
84
+ * ```
85
+ * This will show action `extension.deleteFolder` only for items with `contextValue` is `folder`.
86
+ */
87
+ contextValue?: string;
88
+
89
+ /**
90
+ * Whether this item can be edited by the user.
91
+ */
92
+ canEdit?: boolean;
93
+ }
94
+
95
+ /**
96
+ * Provides a tree that can be referenced in debug visualizations.
97
+ */
98
+ export interface DebugVisualizationTree<T extends DebugTreeItem = DebugTreeItem> {
99
+ /**
100
+ * Gets the tree item for an element or the base context item.
101
+ */
102
+ getTreeItem(context: DebugVisualizationContext): ProviderResult<T>;
103
+ /**
104
+ * Gets children for the tree item or the best context item.
105
+ */
106
+ getChildren(element: T): ProviderResult<T[]>;
107
+ /**
108
+ * Handles the user editing an item.
109
+ */
110
+ editItem?(item: T, value: string): ProviderResult<T>;
111
+ }
112
+
113
+ export class DebugVisualization {
114
+ /**
115
+ * The name of the visualization to show to the user.
116
+ */
117
+ name: string;
118
+
119
+ /**
120
+ * An icon for the view when it's show in inline actions.
121
+ */
122
+ iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
123
+
124
+ /**
125
+ * Visualization to use for the variable. This may be either:
126
+ * - A command to run when the visualization is selected for a variable.
127
+ * - A reference to a previously-registered {@link DebugVisualizationTree}
128
+ */
129
+ visualization?: Command | { treeId: string };
130
+
131
+ /**
132
+ * Creates a new debug visualization object.
133
+ * @param name Name of the visualization to show to the user.
134
+ */
135
+ constructor(name: string);
136
+ }
137
+
138
+ export interface DebugVisualizationProvider<T extends DebugVisualization = DebugVisualization> {
139
+ /**
140
+ * Called for each variable when the debug session stops. It should return
141
+ * any visualizations the extension wishes to show to the user.
142
+ *
143
+ * Note that this is only called when its `when` clause defined under the
144
+ * `debugVisualizers` contribution point in the `package.json` evaluates
145
+ * to true.
146
+ */
147
+ provideDebugVisualization(context: DebugVisualizationContext, token: CancellationToken): ProviderResult<T[]>;
148
+
149
+ /**
150
+ * Invoked for a variable when a user picks the visualizer.
151
+ *
152
+ * It may return a {@link TreeView} that's shown in the Debug Console or
153
+ * inline in a hover. A visualizer may choose to return `undefined` from
154
+ * this function and instead trigger other actions in the UI, such as opening
155
+ * a custom {@link WebviewView}.
156
+ */
157
+ resolveDebugVisualization?(visualization: T, token: CancellationToken): ProviderResult<T>;
158
+ }
159
+
160
+ export interface DebugVisualizationContext {
161
+ /**
162
+ * The Debug Adapter Protocol Variable to be visualized.
163
+ * @see https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable
164
+ */
165
+ variable: any;
166
+ /**
167
+ * The Debug Adapter Protocol variable reference the type (such as a scope
168
+ * or another variable) that contained this one. Empty for variables
169
+ * that came from user evaluations in the Debug Console.
170
+ * @see https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable
171
+ */
172
+ containerId?: number;
173
+ /**
174
+ * The ID of the Debug Adapter Protocol StackFrame in which the variable was found,
175
+ * for variables that came from scopes in a stack frame.
176
+ * @see https://microsoft.github.io/debug-adapter-protocol/specification#Types_StackFrame
177
+ */
178
+ frameId?: number;
179
+ /**
180
+ * The ID of the Debug Adapter Protocol Thread in which the variable was found.
181
+ * @see https://microsoft.github.io/debug-adapter-protocol/specification#Types_StackFrame
182
+ */
183
+ threadId: number;
184
+ /**
185
+ * The debug session the variable belongs to.
186
+ */
187
+ session: DebugSession;
188
+ }
189
+ }
@@ -0,0 +1,115 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 Typefox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ /*---------------------------------------------------------------------------------------------
18
+ * Copyright (c) Microsoft Corporation. All rights reserved.
19
+ * Licensed under the MIT License. See License.txt in the project root for license information.
20
+ *--------------------------------------------------------------------------------------------*/
21
+
22
+ declare module '@theia/plugin' {
23
+
24
+ /**
25
+ * The action that should be taken when a port is discovered through automatic port forwarding discovery.
26
+ */
27
+ export enum PortAutoForwardAction {
28
+ /**
29
+ * Notify the user that the port is being forwarded. This is the default action.
30
+ */
31
+ Notify = 1,
32
+ /**
33
+ * Once the port is forwarded, open the user's web browser to the forwarded port.
34
+ */
35
+ OpenBrowser = 2,
36
+ /**
37
+ * Once the port is forwarded, open the preview browser to the forwarded port.
38
+ */
39
+ OpenPreview = 3,
40
+ /**
41
+ * Forward the port silently.
42
+ */
43
+ Silent = 4,
44
+ /**
45
+ * Do not forward the port.
46
+ */
47
+ Ignore = 5
48
+ }
49
+
50
+ /**
51
+ * The attributes that a forwarded port can have.
52
+ */
53
+ export class PortAttributes {
54
+ /**
55
+ * The action to be taken when this port is detected for auto forwarding.
56
+ */
57
+ autoForwardAction: PortAutoForwardAction;
58
+
59
+ /**
60
+ * Creates a new PortAttributes object
61
+ * @param port the port number
62
+ * @param autoForwardAction the action to take when this port is detected
63
+ */
64
+ constructor(autoForwardAction: PortAutoForwardAction);
65
+ }
66
+
67
+ /**
68
+ * A provider of port attributes. Port attributes are used to determine what action should be taken when a port is discovered.
69
+ */
70
+ export interface PortAttributesProvider {
71
+ /**
72
+ * Provides attributes for the given port. For ports that your extension doesn't know about, simply
73
+ * return undefined. For example, if `providePortAttributes` is called with ports 3000 but your
74
+ * extension doesn't know anything about 3000 you should return undefined.
75
+ * @param port The port number of the port that attributes are being requested for.
76
+ * @param pid The pid of the process that is listening on the port. If the pid is unknown, undefined will be passed.
77
+ * @param commandLine The command line of the process that is listening on the port. If the command line is unknown, undefined will be passed.
78
+ * @param token A cancellation token that indicates the result is no longer needed.
79
+ */
80
+ providePortAttributes(attributes: { port: number; pid?: number; commandLine?: string }, token: CancellationToken): ProviderResult<PortAttributes>;
81
+ }
82
+
83
+ /**
84
+ * A selector that will be used to filter which {@link PortAttributesProvider} should be called for each port.
85
+ */
86
+ export interface PortAttributesSelector {
87
+ /**
88
+ * Specifying a port range will cause your provider to only be called for ports within the range.
89
+ * The start is inclusive and the end is exclusive.
90
+ */
91
+ portRange?: [number, number] | number;
92
+
93
+ /**
94
+ * Specifying a command pattern will cause your provider to only be called for processes whose command line matches the pattern.
95
+ */
96
+ commandPattern?: RegExp;
97
+ }
98
+
99
+ export namespace workspace {
100
+ /**
101
+ * If your extension listens on ports, consider registering a PortAttributesProvider to provide information
102
+ * about the ports. For example, a debug extension may know about debug ports in it's debuggee. By providing
103
+ * this information with a PortAttributesProvider the extension can tell the editor that these ports should be
104
+ * ignored, since they don't need to be user facing.
105
+ *
106
+ * The results of the PortAttributesProvider are merged with the user setting `remote.portsAttributes`. If the values conflict, the user setting takes precedence.
107
+ *
108
+ * @param portSelector It is best practice to specify a port selector to avoid unnecessary calls to your provider.
109
+ * If you don't specify a port selector your provider will be called for every port, which will result in slower port forwarding for the user.
110
+ * @param provider The {@link PortAttributesProvider PortAttributesProvider}.
111
+ * @stubbed
112
+ */
113
+ export function registerPortAttributesProvider(portSelector: PortAttributesSelector, provider: PortAttributesProvider): Disposable;
114
+ }
115
+ }
@@ -0,0 +1,329 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 Typefox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ /*---------------------------------------------------------------------------------------------
18
+ * Copyright (c) Microsoft Corporation. All rights reserved.
19
+ * Licensed under the MIT License. See License.txt in the project root for license information.
20
+ *--------------------------------------------------------------------------------------------*/
21
+
22
+ declare module '@theia/plugin' {
23
+
24
+ // https://github.com/microsoft/vscode/issues/145234
25
+
26
+ /**
27
+ * A command that was executed in a terminal.
28
+ */
29
+ export interface TerminalShellExecution {
30
+ /**
31
+ * The command line that was executed. The {@link TerminalShellExecutionCommandLineConfidence confidence}
32
+ * of this value depends on the specific shell's shell integration implementation. This
33
+ * value may become more accurate after {@link window.onDidEndTerminalShellExecution} is
34
+ * fired.
35
+ *
36
+ * @example
37
+ * // Log the details of the command line on start and end
38
+ * window.onDidStartTerminalShellExecution(event => {
39
+ * const commandLine = event.execution.commandLine;
40
+ * console.log(`Command started\n${summarizeCommandLine(commandLine)}`);
41
+ * });
42
+ * window.onDidEndTerminalShellExecution(event => {
43
+ * const commandLine = event.execution.commandLine;
44
+ * console.log(`Command ended\n${summarizeCommandLine(commandLine)}`);
45
+ * });
46
+ * function summarizeCommandLine(commandLine: TerminalShellExecutionCommandLine) {
47
+ * return [
48
+ * ` Command line: ${command.ommandLine.value}`,
49
+ * ` Confidence: ${command.ommandLine.confidence}`,
50
+ * ` Trusted: ${command.ommandLine.isTrusted}
51
+ * ].join('\n');
52
+ * }
53
+ */
54
+ readonly commandLine: TerminalShellExecutionCommandLine;
55
+
56
+ /**
57
+ * The working directory that was reported by the shell when this command executed. This
58
+ * {@link Uri} may represent a file on another machine (eg. ssh into another machine). This
59
+ * requires the shell integration to support working directory reporting.
60
+ */
61
+ readonly cwd: Uri | undefined;
62
+
63
+ /**
64
+ * Creates a stream of raw data (including escape sequences) that is written to the
65
+ * terminal. This will only include data that was written after `read` was called for
66
+ * the first time, ie. you must call `read` immediately after the command is executed via
67
+ * {@link TerminalShellIntegration.executeCommand} or
68
+ * {@link window.onDidStartTerminalShellExecution} to not miss any data.
69
+ *
70
+ * @example
71
+ * // Log all data written to the terminal for a command
72
+ * const command = term.shellIntegration.executeCommand({ commandLine: 'echo "Hello world"' });
73
+ * const stream = command.read();
74
+ * for await (const data of stream) {
75
+ * console.log(data);
76
+ * }
77
+ */
78
+ read(): AsyncIterable<string>;
79
+ }
80
+
81
+ /**
82
+ * A command line that was executed in a terminal.
83
+ */
84
+ export interface TerminalShellExecutionCommandLine {
85
+ /**
86
+ * The full command line that was executed, including both the command and its arguments.
87
+ */
88
+ readonly value: string;
89
+
90
+ /**
91
+ * Whether the command line value came from a trusted source and is therefore safe to
92
+ * execute without user additional confirmation, such as a notification that asks "Do you
93
+ * want to execute (command)?". This verification is likely only needed if you are going to
94
+ * execute the command again.
95
+ *
96
+ * This is `true` only when the command line was reported explicitly by the shell
97
+ * integration script (ie. {@link TerminalShellExecutionCommandLineConfidence.High high confidence})
98
+ * and it used a nonce for verification.
99
+ */
100
+ readonly isTrusted: boolean;
101
+
102
+ /**
103
+ * The confidence of the command line value which is determined by how the value was
104
+ * obtained. This depends upon the implementation of the shell integration script.
105
+ */
106
+ readonly confidence: TerminalShellExecutionCommandLineConfidence;
107
+ }
108
+
109
+ /**
110
+ * The confidence of a {@link TerminalShellExecutionCommandLine} value.
111
+ */
112
+ enum TerminalShellExecutionCommandLineConfidence {
113
+ /**
114
+ * The command line value confidence is low. This means that the value was read from the
115
+ * terminal buffer using markers reported by the shell integration script. Additionally one
116
+ * of the following conditions will be met:
117
+ *
118
+ * - The command started on the very left-most column which is unusual, or
119
+ * - The command is multi-line which is more difficult to accurately detect due to line
120
+ * continuation characters and right prompts.
121
+ * - Command line markers were not reported by the shell integration script.
122
+ */
123
+ Low = 0,
124
+
125
+ /**
126
+ * The command line value confidence is medium. This means that the value was read from the
127
+ * terminal buffer using markers reported by the shell integration script. The command is
128
+ * single-line and does not start on the very left-most column (which is unusual).
129
+ */
130
+ Medium = 1,
131
+
132
+ /**
133
+ * The command line value confidence is high. This means that the value was explicitly sent
134
+ * from the shell integration script or the command was executed via the
135
+ * {@link TerminalShellIntegration.executeCommand} API.
136
+ */
137
+ High = 2
138
+ }
139
+
140
+ export interface Terminal {
141
+ /**
142
+ * An object that contains [shell integration](https://code.visualstudio.com/docs/terminal/shell-integration)-powered
143
+ * features for the terminal. This will always be `undefined` immediately after the terminal
144
+ * is created. Listen to {@link window.onDidActivateTerminalShellIntegration} to be notified
145
+ * when shell integration is activated for a terminal.
146
+ *
147
+ * Note that this object may remain undefined if shell integation never activates. For
148
+ * example Command Prompt does not support shell integration and a user's shell setup could
149
+ * conflict with the automatic shell integration activation.
150
+ */
151
+ readonly shellIntegration: TerminalShellIntegration | undefined;
152
+ }
153
+
154
+ /**
155
+ * [Shell integration](https://code.visualstudio.com/docs/terminal/shell-integration)-powered capabilities owned by a terminal.
156
+ */
157
+ export interface TerminalShellIntegration {
158
+ /**
159
+ * The current working directory of the terminal. This {@link Uri} may represent a file on
160
+ * another machine (eg. ssh into another machine). This requires the shell integration to
161
+ * support working directory reporting.
162
+ */
163
+ readonly cwd: Uri | undefined;
164
+
165
+ /**
166
+ * Execute a command, sending ^C as necessary to interrupt any running command if needed.
167
+ *
168
+ * @param commandLine The command line to execute, this is the exact text that will be sent
169
+ * to the terminal.
170
+ *
171
+ * @example
172
+ * // Execute a command in a terminal immediately after being created
173
+ * const myTerm = window.createTerminal();
174
+ * window.onDidActivateTerminalShellIntegration(async ({ terminal, shellIntegration }) => {
175
+ * if (terminal === myTerm) {
176
+ * const command = shellIntegration.executeCommand('echo "Hello world"');
177
+ * const code = await command.exitCode;
178
+ * console.log(`Command exited with code ${code}`);
179
+ * }
180
+ * }));
181
+ * // Fallback to sendText if there is no shell integration within 3 seconds of launching
182
+ * setTimeout(() => {
183
+ * if (!myTerm.shellIntegration) {
184
+ * myTerm.sendText('echo "Hello world"');
185
+ * // Without shell integration, we can't know when the command has finished or what the
186
+ * // exit code was.
187
+ * }
188
+ * }, 3000);
189
+ *
190
+ * @example
191
+ * // Send command to terminal that has been alive for a while
192
+ * const commandLine = 'echo "Hello world"';
193
+ * if (term.shellIntegration) {
194
+ * const command = term.shellIntegration.executeCommand({ commandLine });
195
+ * const code = await command.exitCode;
196
+ * console.log(`Command exited with code ${code}`);
197
+ * } else {
198
+ * term.sendText(commandLine);
199
+ * // Without shell integration, we can't know when the command has finished or what the
200
+ * // exit code was.
201
+ * }
202
+ */
203
+ executeCommand(commandLine: string): TerminalShellExecution;
204
+
205
+ /**
206
+ * Execute a command, sending ^C as necessary to interrupt any running command if needed.
207
+ *
208
+ * *Note* This is not guaranteed to work as [shell integration](https://code.visualstudio.com/docs/terminal/shell-integration)
209
+ * must be activated. Check whether {@link TerminalShellExecution.exitCode} is rejected to
210
+ * verify whether it was successful.
211
+ *
212
+ * @param command A command to run.
213
+ * @param args Arguments to launch the executable with which will be automatically escaped
214
+ * based on the executable type.
215
+ *
216
+ * @example
217
+ * // Execute a command in a terminal immediately after being created
218
+ * const myTerm = window.createTerminal();
219
+ * window.onDidActivateTerminalShellIntegration(async ({ terminal, shellIntegration }) => {
220
+ * if (terminal === myTerm) {
221
+ * const command = shellIntegration.executeCommand({
222
+ * command: 'echo',
223
+ * args: ['Hello world']
224
+ * });
225
+ * const code = await command.exitCode;
226
+ * console.log(`Command exited with code ${code}`);
227
+ * }
228
+ * }));
229
+ * // Fallback to sendText if there is no shell integration within 3 seconds of launching
230
+ * setTimeout(() => {
231
+ * if (!myTerm.shellIntegration) {
232
+ * myTerm.sendText('echo "Hello world"');
233
+ * // Without shell integration, we can't know when the command has finished or what the
234
+ * // exit code was.
235
+ * }
236
+ * }, 3000);
237
+ *
238
+ * @example
239
+ * // Send command to terminal that has been alive for a while
240
+ * const commandLine = 'echo "Hello world"';
241
+ * if (term.shellIntegration) {
242
+ * const command = term.shellIntegration.executeCommand({
243
+ * command: 'echo',
244
+ * args: ['Hello world']
245
+ * });
246
+ * const code = await command.exitCode;
247
+ * console.log(`Command exited with code ${code}`);
248
+ * } else {
249
+ * term.sendText(commandLine);
250
+ * // Without shell integration, we can't know when the command has finished or what the
251
+ * // exit code was.
252
+ * }
253
+ */
254
+ executeCommand(executable: string, args: string[]): TerminalShellExecution;
255
+ }
256
+
257
+ export interface TerminalShellIntegrationChangeEvent {
258
+ /**
259
+ * The terminal that shell integration has been activated in.
260
+ */
261
+ readonly terminal: Terminal;
262
+
263
+ /**
264
+ * The shell integration object.
265
+ */
266
+ readonly shellIntegration: TerminalShellIntegration;
267
+ }
268
+
269
+ export interface TerminalShellExecutionStartEvent {
270
+ /**
271
+ * The terminal that shell integration has been activated in.
272
+ */
273
+ readonly terminal: Terminal;
274
+
275
+ /**
276
+ * The shell integration object.
277
+ */
278
+ readonly shellIntegration: TerminalShellIntegration;
279
+
280
+ /**
281
+ * The terminal shell execution that has ended.
282
+ */
283
+ readonly execution: TerminalShellExecution;
284
+ }
285
+
286
+ export interface TerminalShellExecutionEndEvent {
287
+ /**
288
+ * The terminal that shell integration has been activated in.
289
+ */
290
+ readonly terminal: Terminal;
291
+
292
+ /**
293
+ * The shell integration object.
294
+ */
295
+ readonly shellIntegration: TerminalShellIntegration;
296
+
297
+ /**
298
+ * The terminal shell execution that has ended.
299
+ */
300
+ readonly execution: TerminalShellExecution;
301
+
302
+ /**
303
+ * The exit code reported by the shell. `undefined` means the shell did not report an exit
304
+ * code or the shell reported a command started before the command finished.
305
+ */
306
+ readonly exitCode: number | undefined;
307
+ }
308
+
309
+ export namespace window {
310
+ /**
311
+ * Fires when shell integration activates or one of its properties changes in a terminal.
312
+ */
313
+ export const onDidChangeTerminalShellIntegration: Event<TerminalShellIntegrationChangeEvent>;
314
+
315
+ /**
316
+ * This will be fired when a terminal command is started. This event will fire only when
317
+ * [shell integration](https://code.visualstudio.com/docs/terminal/shell-integration) is
318
+ * activated for the terminal.
319
+ */
320
+ export const onDidStartTerminalShellExecution: Event<TerminalShellExecutionStartEvent>;
321
+
322
+ /**
323
+ * This will be fired when a terminal command is ended. This event will fire only when
324
+ * [shell integration](https://code.visualstudio.com/docs/terminal/shell-integration) is
325
+ * activated for the terminal.
326
+ */
327
+ export const onDidEndTerminalShellExecution: Event<TerminalShellExecutionEndEvent>;
328
+ }
329
+ }