Repository navigation
Expand file tree
/
Copy pathvscode.proposed.d.ts
More file actions
540 lines (464 loc) · 16 KB
/
Copy pathvscode.proposed.d.ts
File metadata and controls
540 lines (464 loc) · 16 KB
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import {
Event,
GlobPattern,
Uri,
TextDocument,
ViewColumn,
CancellationToken,
Disposable,
DocumentSelector
} from 'vscode';
// Copy nb section from https://github.com/microsoft/vscode/blob/master/src/vs/vscode.proposed.d.ts.
declare module 'vscode' {
export enum CellKind {
Markdown = 1,
Code = 2
}
export enum CellOutputKind {
Text = 1,
Error = 2,
Rich = 3
}
export interface CellStreamOutput {
outputKind: CellOutputKind.Text;
text: string;
}
export interface CellErrorOutput {
outputKind: CellOutputKind.Error;
/**
* Exception Name
*/
ename: string;
/**
* Exception Value
*/
evalue: string;
/**
* Exception call stack
*/
traceback: string[];
}
export interface NotebookCellOutputMetadata {
/**
* Additional attributes of a cell metadata.
*/
custom?: { [key: string]: any };
}
export interface CellDisplayOutput {
outputKind: CellOutputKind.Rich;
/**
* { mime_type: value }
*
* Example:
* ```json
* {
* "outputKind": vscode.CellOutputKind.Rich,
* "data": {
* "text/html": [
* "<h1>Hello</h1>"
* ],
* "text/plain": [
* "<IPython.lib.display.IFrame at 0x11dee3e80>"
* ]
* }
* }
*/
data: { [key: string]: any };
readonly metadata?: NotebookCellOutputMetadata;
}
export type CellOutput = CellStreamOutput | CellErrorOutput | CellDisplayOutput;
export enum NotebookCellRunState {
Running = 1,
Idle = 2,
Success = 3,
Error = 4
}
export interface NotebookCellMetadata {
/**
* Controls if the content of a cell is editable or not.
*/
editable?: boolean;
/**
* Controls if the cell is executable.
* This metadata is ignored for markdown cell.
*/
runnable?: boolean;
/**
* Controls if the cell has a margin to support the breakpoint UI.
* This metadata is ignored for markdown cell.
*/
breakpointMargin?: boolean;
/**
* Whether the [execution order](#NotebookCellMetadata.executionOrder) indicator will be displayed.
* Defaults to true.
*/
hasExecutionOrder?: boolean;
/**
* The order in which this cell was executed.
*/
executionOrder?: number;
/**
* A status message to be shown in the cell's status bar
*/
statusMessage?: string;
/**
* The cell's current run state
*/
runState?: NotebookCellRunState;
/**
* If the cell is running, the time at which the cell started running
*/
runStartTime?: number;
/**
* The total duration of the cell's last run
*/
lastRunDuration?: number;
/**
* Additional attributes of a cell metadata.
*/
custom?: { [key: string]: any };
}
export interface NotebookCell {
readonly notebook: NotebookDocument;
readonly uri: Uri;
readonly cellKind: CellKind;
readonly document: TextDocument;
language: string;
outputs: CellOutput[];
metadata: NotebookCellMetadata;
}
export interface NotebookDocumentMetadata {
/**
* Controls if users can add or delete cells
* Defaults to true
*/
editable?: boolean;
/**
* Controls whether the full notebook can be run at once.
* Defaults to true
*/
runnable?: boolean;
/**
* Default value for [cell editable metadata](#NotebookCellMetadata.editable).
* Defaults to true.
*/
cellEditable?: boolean;
/**
* Default value for [cell runnable metadata](#NotebookCellMetadata.runnable).
* Defaults to true.
*/
cellRunnable?: boolean;
/**
* Default value for [cell hasExecutionOrder metadata](#NotebookCellMetadata.hasExecutionOrder).
* Defaults to true.
*/
cellHasExecutionOrder?: boolean;
displayOrder?: GlobPattern[];
/**
* Additional attributes of the document metadata.
*/
custom?: { [key: string]: any };
}
export interface NotebookDocument {
readonly uri: Uri;
readonly fileName: string;
readonly viewType: string;
readonly isDirty: boolean;
readonly cells: NotebookCell[];
languages: string[];
displayOrder?: GlobPattern[];
metadata: NotebookDocumentMetadata;
}
export interface NotebookConcatTextDocument {
isClosed: boolean;
dispose(): void;
onDidChange: Event<void>;
version: number;
getText(): string;
getText(range: Range): string;
offsetAt(position: Position): number;
positionAt(offset: number): Position;
validateRange(range: Range): Range;
validatePosition(position: Position): Position;
locationAt(positionOrRange: Position | Range): Location;
positionAt(location: Location): Position;
contains(uri: Uri): boolean;
}
export interface NotebookEditorCellEdit {
insert(
index: number,
content: string | string[],
language: string,
type: CellKind,
outputs: CellOutput[],
metadata: NotebookCellMetadata | undefined
): void;
delete(index: number): void;
}
export interface NotebookEditor {
/**
* The document associated with this notebook editor.
*/
readonly document: NotebookDocument;
/**
* The primary selected cell on this notebook editor.
*/
readonly selection?: NotebookCell;
/**
* The column in which this editor shows.
*/
viewColumn?: ViewColumn;
/**
* Whether the panel is active (focused by the user).
*/
readonly active: boolean;
/**
* Whether the panel is visible.
*/
readonly visible: boolean;
/**
* Fired when the panel is disposed.
*/
readonly onDidDispose: Event<void>;
/**
* Fired when the output hosting webview posts a message.
*/
readonly onDidReceiveMessage: Event<any>;
/**
* Post a message to the output hosting webview.
*
* Messages are only delivered if the editor is live.
*
* @param message Body of the message. This must be a string or other json serilizable object.
*/
postMessage(message: any): Thenable<boolean>;
/**
* Convert a uri for the local file system to one that can be used inside outputs webview.
*/
asWebviewUri(localResource: Uri): Uri;
edit(callback: (editBuilder: NotebookEditorCellEdit) => void): Thenable<boolean>;
}
export interface NotebookOutputSelector {
mimeTypes?: string[];
}
export interface NotebookRenderRequest {
output: CellDisplayOutput;
mimeType: string;
outputId: string;
}
export interface NotebookOutputRenderer {
/**
*
* @returns HTML fragment. We can probably return `CellOutput` instead of string ?
*
*/
render(document: NotebookDocument, request: NotebookRenderRequest): string;
/**
* Call before HTML from the renderer is executed, and will be called for
* every editor associated with notebook documents where the renderer
* is or was used.
*
* The communication object will only send and receive messages to the
* render API, retrieved via `acquireNotebookRendererApi`, acquired with
* this specific renderer's ID.
*
* If you need to keep an association between the communication object
* and the document for use in the `render()` method, you can use a WeakMap.
*/
resolveNotebook?(document: NotebookDocument, communication: NotebookCommunication): void;
readonly preloads?: Uri[];
}
export interface NotebookCellsChangeData {
readonly start: number;
readonly deletedCount: number;
readonly deletedItems: NotebookCell[];
readonly items: NotebookCell[];
}
export interface NotebookCellsChangeEvent {
/**
* The affected document.
*/
readonly document: NotebookDocument;
readonly changes: ReadonlyArray<NotebookCellsChangeData>;
}
export interface NotebookCellMoveEvent {
/**
* The affected document.
*/
readonly document: NotebookDocument;
readonly index: number;
readonly newIndex: number;
}
export interface NotebookCellOutputsChangeEvent {
/**
* The affected document.
*/
readonly document: NotebookDocument;
readonly cells: NotebookCell[];
}
export interface NotebookCellLanguageChangeEvent {
/**
* The affected document.
*/
readonly document: NotebookDocument;
readonly cell: NotebookCell;
readonly language: string;
}
export interface NotebookCellData {
readonly cellKind: CellKind;
readonly source: string;
language: string;
outputs: CellOutput[];
metadata: NotebookCellMetadata;
}
export interface NotebookData {
readonly cells: NotebookCellData[];
readonly languages: string[];
readonly metadata: NotebookDocumentMetadata;
}
interface NotebookDocumentContentChangeEvent {
/**
* The document that the edit is for.
*/
readonly document: NotebookDocument;
}
interface NotebookDocumentEditEvent {
/**
* The document that the edit is for.
*/
readonly document: NotebookDocument;
/**
* Undo the edit operation.
*
* This is invoked by VS Code when the user undoes this edit. To implement `undo`, your
* extension should restore the document and editor to the state they were in just before this
* edit was added to VS Code's internal edit stack by `onDidChangeCustomDocument`.
*/
undo(): Thenable<void> | void;
/**
* Redo the edit operation.
*
* This is invoked by VS Code when the user redoes this edit. To implement `redo`, your
* extension should restore the document and editor to the state they were in just after this
* edit was added to VS Code's internal edit stack by `onDidChangeCustomDocument`.
*/
redo(): Thenable<void> | void;
/**
* Display name describing the edit.
*
* This will be shown to users in the UI for undo/redo operations.
*/
readonly label?: string;
}
interface NotebookDocumentBackup {
/**
* Unique identifier for the backup.
*
* This id is passed back to your extension in `openCustomDocument` when opening a custom editor from a backup.
*/
readonly id: string;
/**
* Delete the current backup.
*
* This is called by VS Code when it is clear the current backup is no longer needed, such as when a new backup
* is made or when the file is saved.
*/
delete(): void;
}
interface NotebookDocumentBackupContext {
readonly destination: Uri;
}
interface NotebookDocumentOpenContext {
readonly backupId?: string;
}
/**
* Communication object passed to the {@link NotebookContentProvider} and
* {@link NotebookOutputRenderer} to communicate with the webview.
*/
export interface NotebookCommunication {
/**
* ID of the editor this object communicates with. A single notebook
* document can have multiple attached webviews and editors, when the
* notebook is split for instance. The editor ID lets you differentiate
* between them.
*/
readonly editorId: string;
/**
* Fired when the output hosting webview posts a message.
*/
readonly onDidReceiveMessage: Event<any>;
/**
* Post a message to the output hosting webview.
*
* Messages are only delivered if the editor is live.
*
* @param message Body of the message. This must be a string or other json serilizable object.
*/
postMessage(message: any): Thenable<boolean>;
/**
* Convert a uri for the local file system to one that can be used inside outputs webview.
*/
asWebviewUri(localResource: Uri): Uri;
}
export interface NotebookContentProvider {
openNotebook(uri: Uri, openContext: NotebookDocumentOpenContext): NotebookData | Promise<NotebookData>;
resolveNotebook(document: NotebookDocument, webview: NotebookCommunication): Promise<void>;
saveNotebook(document: NotebookDocument, cancellation: CancellationToken): Promise<void>;
saveNotebookAs(targetResource: Uri, document: NotebookDocument, cancellation: CancellationToken): Promise<void>;
readonly onDidChangeNotebook: Event<NotebookDocumentContentChangeEvent | NotebookDocumentEditEvent>;
backupNotebook(
document: NotebookDocument,
context: NotebookDocumentBackupContext,
cancellation: CancellationToken
): Promise<NotebookDocumentBackup>;
kernel?: NotebookKernel;
}
export interface NotebookKernel {
label: string;
preloads?: Uri[];
executeCell(document: NotebookDocument, cell: NotebookCell, token: CancellationToken): Promise<void>;
executeAllCells(document: NotebookDocument, token: CancellationToken): Promise<void>;
}
export namespace notebook {
export function registerNotebookContentProvider(
notebookType: string,
provider: NotebookContentProvider
): Disposable;
export function registerNotebookKernel(
id: string,
selectors: GlobPattern[],
kernel: NotebookKernel
): Disposable;
export function registerNotebookOutputRenderer(
id: string,
outputSelector: NotebookOutputSelector,
renderer: NotebookOutputRenderer
): Disposable;
export const onDidOpenNotebookDocument: Event<NotebookDocument>;
export const onDidCloseNotebookDocument: Event<NotebookDocument>;
/**
* All currently known notebook documents.
*/
export const notebookDocuments: ReadonlyArray<NotebookDocument>;
export let visibleNotebookEditors: NotebookEditor[];
export const onDidChangeVisibleNotebookEditors: Event<NotebookEditor[]>;
export let activeNotebookEditor: NotebookEditor | undefined;
export const onDidChangeActiveNotebookEditor: Event<NotebookEditor | undefined>;
export const onDidChangeNotebookCells: Event<NotebookCellsChangeEvent>;
export const onDidChangeCellOutputs: Event<NotebookCellOutputsChangeEvent>;
export const onDidChangeCellLanguage: Event<NotebookCellLanguageChangeEvent>;
/**
* Create a document that is the concatenation of all notebook cells. By default all code-cells are included
* but a selector can be provided to narrow to down the set of cells.
*
* @param notebook
* @param selector
*/
export function createConcatTextDocument(
notebook: NotebookDocument,
selector?: DocumentSelector
): NotebookConcatTextDocument;
}
}