@theia/plugin 1.53.0-next.6 → 1.53.0

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.53.0-next.6+5255c512c",
3
+ "version": "1.53.0",
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": "e094481839bc0920b91f726f81cb759a4cba9cc5"
36
36
  }
package/src/theia.d.ts CHANGED
@@ -43,6 +43,7 @@ import './theia.proposed.resolvers';
43
43
  import './theia.proposed.scmValidation';
44
44
  import './theia.proposed.shareProvider';
45
45
  import './theia.proposed.terminalQuickFixProvider';
46
+ import './theia.proposed.terminalShellIntegration';
46
47
  import './theia.proposed.textSearchProvider';
47
48
  import './theia.proposed.timeline';
48
49
 
@@ -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
+ }