@theia/plugin 1.33.0-next.8 → 1.33.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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/theia.d.ts +1576 -5
package/src/theia.d.ts CHANGED
@@ -3768,6 +3768,14 @@ export module '@theia/plugin' {
3768
3768
  */
3769
3769
  readonly enableScripts?: boolean;
3770
3770
 
3771
+ /**
3772
+ * Controls whether forms are enabled in the webview content or not.
3773
+ *
3774
+ * Defaults to true if {@link WebviewOptions.enableScripts scripts are enabled}. Otherwise defaults to false.
3775
+ * Explicitly setting this property to either true or false overrides the default.
3776
+ */
3777
+ readonly enableForms?: boolean;
3778
+
3771
3779
  /**
3772
3780
  * Controls whether command uris are enabled in webview content or not.
3773
3781
  *
@@ -4642,6 +4650,60 @@ export module '@theia/plugin' {
4642
4650
  */
4643
4651
  export function showTextDocument(uri: Uri, options?: TextDocumentShowOptions): Thenable<TextEditor>;
4644
4652
 
4653
+ /**
4654
+ * The currently visible {@link NotebookEditor notebook editors} or an empty array.
4655
+ * @stubbed
4656
+ */
4657
+ export const visibleNotebookEditors: readonly NotebookEditor[];
4658
+
4659
+ /**
4660
+ * An {@link Event} which fires when the {@link window.visibleNotebookEditors visible notebook editors}
4661
+ * has changed.
4662
+ * @stubbed
4663
+ */
4664
+ export const onDidChangeVisibleNotebookEditors: Event<readonly NotebookEditor[]>;
4665
+
4666
+ /**
4667
+ * The currently active {@link NotebookEditor notebook editor} or `undefined`. The active editor is the one
4668
+ * that currently has focus or, when none has focus, the one that has changed
4669
+ * input most recently.
4670
+ * @stubbed
4671
+ */
4672
+ export const activeNotebookEditor: NotebookEditor | undefined;
4673
+
4674
+ /**
4675
+ * An {@link Event} which fires when the {@link window.activeNotebookEditor active notebook editor}
4676
+ * has changed. *Note* that the event also fires when the active editor changes
4677
+ * to `undefined`.
4678
+ * @stubbed
4679
+ */
4680
+ export const onDidChangeActiveNotebookEditor: Event<NotebookEditor | undefined>;
4681
+
4682
+ /**
4683
+ * An {@link Event} which fires when the {@link NotebookEditor.selections notebook editor selections}
4684
+ * have changed.
4685
+ * @stubbed
4686
+ */
4687
+ export const onDidChangeNotebookEditorSelection: Event<NotebookEditorSelectionChangeEvent>;
4688
+
4689
+ /**
4690
+ * An {@link Event} which fires when the {@link NotebookEditor.visibleRanges notebook editor visible ranges}
4691
+ * have changed.
4692
+ * @stubbed
4693
+ */
4694
+ export const onDidChangeNotebookEditorVisibleRanges: Event<NotebookEditorVisibleRangesChangeEvent>;
4695
+
4696
+ /**
4697
+ * Show the given {@link NotebookDocument} in a {@link NotebookEditor notebook editor}.
4698
+ *
4699
+ * @param document A text document to be shown.
4700
+ * @param options {@link NotebookDocumentShowOptions Editor options} to configure the behavior of showing the {@link NotebookEditor notebook editor}.
4701
+ *
4702
+ * @return A promise that resolves to an {@link NotebookEditor notebook editor}.
4703
+ * @stubbed
4704
+ */
4705
+ export function showNotebookDocument(document: NotebookDocument, options?: NotebookDocumentShowOptions): Thenable<NotebookEditor>;
4706
+
4645
4707
  /**
4646
4708
  * Shows a selection list.
4647
4709
  *
@@ -5184,7 +5246,8 @@ export module '@theia/plugin' {
5184
5246
  export enum ColorThemeKind {
5185
5247
  Light = 1,
5186
5248
  Dark = 2,
5187
- HighContrast = 3
5249
+ HighContrast = 3,
5250
+ HighContrastLight = 4
5188
5251
  }
5189
5252
 
5190
5253
  /**
@@ -5192,7 +5255,7 @@ export module '@theia/plugin' {
5192
5255
  */
5193
5256
  export interface ColorTheme {
5194
5257
  /**
5195
- * The kind of this color theme: light, dark or high contrast.
5258
+ * The kind of this color theme: light, dark, high contrast dark and high contrast light.
5196
5259
  */
5197
5260
  readonly kind: ColorThemeKind;
5198
5261
  }
@@ -5961,6 +6024,18 @@ export module '@theia/plugin' {
5961
6024
  SymbolicLink = 64
5962
6025
  }
5963
6026
 
6027
+ export enum FilePermission {
6028
+ /**
6029
+ * The file is readonly.
6030
+ *
6031
+ * *Note:* All `FileStat` from a `FileSystemProvider` that is registered with
6032
+ * the option `isReadonly: true` will be implicitly handled as if `FilePermission.Readonly`
6033
+ * is set. As a consequence, it is not possible to have a readonly file system provider
6034
+ * registered where some `FileStat` are not readonly.
6035
+ */
6036
+ Readonly = 1
6037
+ }
6038
+
5964
6039
  /**
5965
6040
  * The `FileStat`-type represents metadata about a file
5966
6041
  */
@@ -5992,6 +6067,12 @@ export module '@theia/plugin' {
5992
6067
  * example.
5993
6068
  */
5994
6069
  size: number;
6070
+ /**
6071
+ * The permissions of the file, e.g. whether the file is readonly.
6072
+ *
6073
+ * *Note:* This value might be a bitmask, e.g. `FilePermission.Readonly | FilePermission.Other`.
6074
+ */
6075
+ permissions?: FilePermission;
5995
6076
  }
5996
6077
 
5997
6078
  /**
@@ -6301,6 +6382,21 @@ export module '@theia/plugin' {
6301
6382
  * @param options Defines if existing files should be overwritten.
6302
6383
  */
6303
6384
  copy(source: Uri, target: Uri, options?: { overwrite?: boolean }): Thenable<void>;
6385
+
6386
+ /**
6387
+ * Check if a given file system supports writing files.
6388
+ *
6389
+ * Keep in mind that just because a file system supports writing, that does
6390
+ * not mean that writes will always succeed. There may be permissions issues
6391
+ * or other errors that prevent writing a file.
6392
+ *
6393
+ * @param scheme The scheme of the filesystem, for example `file` or `git`.
6394
+ *
6395
+ * @return `true` if the file system supports writing, `false` if it does not
6396
+ * support writing (i.e. it is readonly), and `undefined` if the editor does not
6397
+ * know about the filesystem.
6398
+ */
6399
+ isWritableFileSystem(scheme: string): boolean | undefined;
6304
6400
  }
6305
6401
 
6306
6402
  /**
@@ -6376,6 +6472,14 @@ export module '@theia/plugin' {
6376
6472
  */
6377
6473
  export let textDocuments: readonly TextDocument[];
6378
6474
 
6475
+ /**
6476
+ * All notebook documents currently known to the editor.
6477
+ *
6478
+ * @readonly
6479
+ * @stubbed
6480
+ */
6481
+ export let notebookDocuments: readonly NotebookDocument[];
6482
+
6379
6483
  /**
6380
6484
  * Register a text document content provider.
6381
6485
  *
@@ -6387,6 +6491,40 @@ export module '@theia/plugin' {
6387
6491
  */
6388
6492
  export function registerTextDocumentContentProvider(scheme: string, provider: TextDocumentContentProvider): Disposable;
6389
6493
 
6494
+ /**
6495
+ * An event that is emitted when a {@link NotebookDocument notebook} is opened.
6496
+ * @stubbed
6497
+ */
6498
+ export const onDidOpenNotebookDocument: Event<NotebookDocument>;
6499
+
6500
+ /**
6501
+ * An event that is emitted when a notebook is disposed.
6502
+ *
6503
+ * Note 1: There is no guarantee that this event fires when an editor tab is closed.
6504
+ *
6505
+ * Note 2: A notebook can be open but not shown in an editor which means this event can fire for a notebook that has not been shown in an editor.
6506
+ * @stubbed
6507
+ */
6508
+ export const onDidCloseNotebookDocument: Event<NotebookDocument>;
6509
+
6510
+ /**
6511
+ * An event that is emitted when a {@link NotebookDocument notebook} is saved.
6512
+ * @stubbed
6513
+ */
6514
+ export const onDidSaveNotebookDocument: Event<NotebookDocument>;
6515
+
6516
+ /**
6517
+ * Register a notebook serializer.
6518
+ *
6519
+ * A notebook serializer must be contributed through the notebooks extension point. When opening a notebook file, the editor will send the onNotebook:<notebookType> activation event, and extensions must register their serializer in return.
6520
+ * @param notebookType a notebook.
6521
+ * @param serializer a notebook serializer.
6522
+ * @param options Optional context options that define what parts of a notebook should be persisted
6523
+ * @return A {@link Disposable disposable} that unregisters this serializer when being disposed.
6524
+ * @stubbed
6525
+ */
6526
+ export function registerNotebookSerializer(notebookType: string, serializer: NotebookSerializer, options?: NotebookDocumentContentOptions): Disposable;
6527
+
6390
6528
  /**
6391
6529
  * An event that is emitted when a {@link TextDocument text document} is opened.
6392
6530
  *
@@ -6396,10 +6534,14 @@ export module '@theia/plugin' {
6396
6534
  * - The event is emitted before the {@link TextDocument document} is updated in the
6397
6535
  * {@link window.activeTextEditor active text editor}
6398
6536
  * - When a {@link TextDocument text document} is already open (e.g.: open in another {@link window.visibleTextEditors visible text editor}) this event is not emitted
6399
- *
6400
6537
  */
6401
6538
  export const onDidOpenTextDocument: Event<TextDocument>;
6402
6539
 
6540
+ /**
6541
+ * An event that is emitted when a {@link TextDocument text document} is saved to disk.
6542
+ */
6543
+ export const onDidSaveTextDocument: Event<TextDocument>;
6544
+
6403
6545
  /**
6404
6546
  * An event that is emitted when a {@link TextDocument text document} is disposed.
6405
6547
  *
@@ -6432,9 +6574,10 @@ export module '@theia/plugin' {
6432
6574
  export const onWillSaveTextDocument: Event<TextDocumentWillSaveEvent>;
6433
6575
 
6434
6576
  /**
6435
- * An event that is emitted when a {@link TextDocument text document} is saved to disk.
6577
+ * An event that is emitted when a {@link Notebook notebook} has changed.
6578
+ * @stubbed
6436
6579
  */
6437
- export const onDidSaveTextDocument: Event<TextDocument>;
6580
+ export const onDidChangeNotebookDocument: Event<NotebookDocumentChangeEvent>;
6438
6581
 
6439
6582
  /**
6440
6583
  * An event that is emitted when files are being created.
@@ -6544,6 +6687,31 @@ export module '@theia/plugin' {
6544
6687
  */
6545
6688
  export function openTextDocument(options?: { language?: string; content?: string; }): Thenable<TextDocument | undefined>;
6546
6689
 
6690
+ /**
6691
+ * Open a notebook. Will return early if this notebook is already {@link NotebookDocument loaded}.
6692
+ * Otherwise the notebook is loaded and the {@link onDidOpenNotebookDocument onDidOpenNotebookDocument}-event fires.
6693
+ *
6694
+ * Note that the lifecycle of the returned notebook is owned by the editor and not by the extension.
6695
+ * That means an {@link onDidCloseNotebookDocument onDidCloseNotebookDocument}-event can occur at any time after.
6696
+ * Note that opening a notebook does not show a notebook editor. This function only returns a notebook document
6697
+ * which can be shown in a notebook editor but it can also be used for other things.
6698
+ *
6699
+ * @param uri The resource to open.
6700
+ * @return A promise that resolves to a {@link NotebookDocument notebook}.
6701
+ * @stubbed
6702
+ */
6703
+ export function openNotebookDocument(uri: Uri): Thenable<NotebookDocument> | undefined;
6704
+
6705
+ /**
6706
+ * Open an untitled notebook. The editor will prompt the user for a file path when the document is to be saved.
6707
+ *
6708
+ * @param notebookType The notebook type that should be used.
6709
+ * @param content The initial contents of the notebook.
6710
+ * @return A promise that resolves to a {@link NotebookDocument notebook}.
6711
+ * @stubbed
6712
+ */
6713
+ export function openNotebookDocument(notebookType: string, content?: NotebookData): Thenable<NotebookDocument> | undefined;
6714
+
6547
6715
  /**
6548
6716
  * Get a workspace configuration object.
6549
6717
  *
@@ -6968,6 +7136,19 @@ export module '@theia/plugin' {
6968
7136
  * to filter documents to a {@link WorkspaceFolder workspace folder}.
6969
7137
  */
6970
7138
  readonly pattern?: GlobPattern;
7139
+
7140
+ /**
7141
+ * The {@link NotebookDocument.notebookType type} of a notebook, like `jupyter-notebook`. This allows
7142
+ * to narrow down on the type of a notebook that a {@link NotebookCell.document cell document} belongs to.
7143
+ *
7144
+ * *Note* that setting the `notebookType`-property changes how `scheme` and `pattern` are interpreted. When set
7145
+ * they are evaluated against the {@link NotebookDocument.uri notebook uri}, not the document uri.
7146
+ *
7147
+ * @example <caption>Match python document inside jupyter notebook that aren't stored yet (`untitled`)</caption>
7148
+ * { language: 'python', notebookType: 'jupyter-notebook', scheme: 'untitled' }
7149
+ * @stubbed
7150
+ */
7151
+ readonly notebookType?: string;
6971
7152
  }
6972
7153
 
6973
7154
  /**
@@ -8292,6 +8473,143 @@ export module '@theia/plugin' {
8292
8473
  resolveCompletionItem?(item: T, token: CancellationToken): ProviderResult<T>;
8293
8474
  }
8294
8475
 
8476
+ /**
8477
+ * The inline completion item provider interface defines the contract between extensions and
8478
+ * the inline completion feature.
8479
+ *
8480
+ * Providers are asked for completions either explicitly by a user gesture or implicitly when typing.
8481
+ */
8482
+ export interface InlineCompletionItemProvider {
8483
+
8484
+ /**
8485
+ * Provides inline completion items for the given position and document.
8486
+ * If inline completions are enabled, this method will be called whenever the user stopped typing.
8487
+ * It will also be called when the user explicitly triggers inline completions or explicitly asks for the next or previous inline completion.
8488
+ * In that case, all available inline completions should be returned.
8489
+ * `context.triggerKind` can be used to distinguish between these scenarios.
8490
+ *
8491
+ * @param document The document inline completions are requested for.
8492
+ * @param position The position inline completions are requested for.
8493
+ * @param context A context object with additional information.
8494
+ * @param token A cancellation token.
8495
+ * @return An array of completion items or a thenable that resolves to an array of completion items.
8496
+ */
8497
+ provideInlineCompletionItems(document: TextDocument, position: Position, context: InlineCompletionContext, token: CancellationToken): ProviderResult<InlineCompletionItem[] | InlineCompletionList>;
8498
+ }
8499
+
8500
+ /**
8501
+ * Represents a collection of {@link InlineCompletionItem inline completion items} to be presented
8502
+ * in the editor.
8503
+ */
8504
+ export class InlineCompletionList {
8505
+ /**
8506
+ * The inline completion items.
8507
+ */
8508
+ items: InlineCompletionItem[];
8509
+
8510
+ /**
8511
+ * Creates a new list of inline completion items.
8512
+ */
8513
+ constructor(items: InlineCompletionItem[]);
8514
+ }
8515
+
8516
+ /**
8517
+ * Provides information about the context in which an inline completion was requested.
8518
+ */
8519
+ export interface InlineCompletionContext {
8520
+ /**
8521
+ * Describes how the inline completion was triggered.
8522
+ */
8523
+ readonly triggerKind: InlineCompletionTriggerKind;
8524
+
8525
+ /**
8526
+ * Provides information about the currently selected item in the autocomplete widget if it is visible.
8527
+ *
8528
+ * If set, provided inline completions must extend the text of the selected item
8529
+ * and use the same range, otherwise they are not shown as preview.
8530
+ * As an example, if the document text is `console.` and the selected item is `.log` replacing the `.` in the document,
8531
+ * the inline completion must also replace `.` and start with `.log`, for example `.log()`.
8532
+ *
8533
+ * Inline completion providers are requested again whenever the selected item changes.
8534
+ */
8535
+ readonly selectedCompletionInfo: SelectedCompletionInfo | undefined;
8536
+ }
8537
+
8538
+ /**
8539
+ * Describes the currently selected completion item.
8540
+ */
8541
+ export interface SelectedCompletionInfo {
8542
+ /**
8543
+ * The range that will be replaced if this completion item is accepted.
8544
+ */
8545
+ readonly range: Range;
8546
+
8547
+ /**
8548
+ * The text the range will be replaced with if this completion is accepted.
8549
+ */
8550
+ readonly text: string;
8551
+ }
8552
+
8553
+ /**
8554
+ * Describes how an {@link InlineCompletionItemProvider inline completion provider} was triggered.
8555
+ */
8556
+ export enum InlineCompletionTriggerKind {
8557
+ /**
8558
+ * Completion was triggered explicitly by a user gesture.
8559
+ * Return multiple completion items to enable cycling through them.
8560
+ */
8561
+ Invoke = 0,
8562
+
8563
+ /**
8564
+ * Completion was triggered automatically while editing.
8565
+ * It is sufficient to return a single completion item in this case.
8566
+ */
8567
+ Automatic = 1,
8568
+ }
8569
+
8570
+ /**
8571
+ * An inline completion item represents a text snippet that is proposed inline to complete text that is being typed.
8572
+ *
8573
+ * @see {@link InlineCompletionItemProvider.provideInlineCompletionItems}
8574
+ */
8575
+ export class InlineCompletionItem {
8576
+ /**
8577
+ * The text to replace the range with. Must be set.
8578
+ * Is used both for the preview and the accept operation.
8579
+ */
8580
+ insertText: string | SnippetString;
8581
+
8582
+ /**
8583
+ * A text that is used to decide if this inline completion should be shown. When `falsy`
8584
+ * the {@link InlineCompletionItem.insertText} is used.
8585
+ *
8586
+ * An inline completion is shown if the text to replace is a prefix of the filter text.
8587
+ */
8588
+ filterText?: string;
8589
+
8590
+ /**
8591
+ * The range to replace.
8592
+ * Must begin and end on the same line.
8593
+ *
8594
+ * Prefer replacements over insertions to provide a better experience when the user deletes typed text.
8595
+ */
8596
+ range?: Range;
8597
+
8598
+ /**
8599
+ * An optional {@link Command} that is executed *after* inserting this completion.
8600
+ */
8601
+ command?: Command;
8602
+
8603
+ /**
8604
+ * Creates a new inline completion item.
8605
+ *
8606
+ * @param insertText The text to replace the range with.
8607
+ * @param range The range to replace. If not set, the word at the requested position will be used.
8608
+ * @param command An optional {@link Command} that is executed *after* inserting this completion.
8609
+ */
8610
+ constructor(insertText: string | SnippetString, range?: Range, command?: Command);
8611
+ }
8612
+
8295
8613
  /**
8296
8614
  * Represents a location inside a resource, such as a line
8297
8615
  * inside a text file.
@@ -9659,6 +9977,19 @@ export module '@theia/plugin' {
9659
9977
  */
9660
9978
  export function registerCompletionItemProvider(selector: DocumentSelector, provider: CompletionItemProvider, ...triggerCharacters: string[]): Disposable;
9661
9979
 
9980
+ /**
9981
+ * Registers an inline completion provider.
9982
+ *
9983
+ * Multiple providers can be registered for a language. In that case providers are asked in
9984
+ * parallel and the results are merged. A failing provider (rejected promise or exception) will
9985
+ * not cause a failure of the whole operation.
9986
+ *
9987
+ * @param selector A selector that defines the documents this provider is applicable to.
9988
+ * @param provider An inline completion provider.
9989
+ * @return A {@link Disposable} that unregisters this provider when being disposed.
9990
+ */
9991
+ export function registerInlineCompletionItemProvider(selector: DocumentSelector, provider: InlineCompletionItemProvider): Disposable;
9992
+
9662
9993
  /**
9663
9994
  * Register a definition provider.
9664
9995
  *
@@ -12782,6 +13113,1246 @@ export module '@theia/plugin' {
12782
13113
  */
12783
13114
  export function registerAuthenticationProvider(id: string, label: string, provider: AuthenticationProvider, options?: AuthenticationProviderOptions): Disposable;
12784
13115
  }
13116
+
13117
+ /**
13118
+ * Represents a notebook editor that is attached to a {@link NotebookDocument notebook}.
13119
+ */
13120
+ export enum NotebookEditorRevealType {
13121
+ /**
13122
+ * The range will be revealed with as little scrolling as possible.
13123
+ */
13124
+ Default = 0,
13125
+
13126
+ /**
13127
+ * The range will always be revealed in the center of the viewport.
13128
+ */
13129
+ InCenter = 1,
13130
+
13131
+ /**
13132
+ * If the range is outside the viewport, it will be revealed in the center of the viewport.
13133
+ * Otherwise, it will be revealed with as little scrolling as possible.
13134
+ */
13135
+ InCenterIfOutsideViewport = 2,
13136
+
13137
+ /**
13138
+ * The range will always be revealed at the top of the viewport.
13139
+ */
13140
+ AtTop = 3
13141
+ }
13142
+
13143
+ /**
13144
+ * Represents a notebook editor that is attached to a {@link NotebookDocument notebook}.
13145
+ * Additional properties of the NotebookEditor are available in the proposed
13146
+ * API, which will be finalized later.
13147
+ */
13148
+ export interface NotebookEditor {
13149
+
13150
+ /**
13151
+ * The {@link NotebookDocument notebook document} associated with this notebook editor.
13152
+ * @stubbed
13153
+ */
13154
+ readonly notebook: NotebookDocument;
13155
+
13156
+ /**
13157
+ * The primary selection in this notebook editor.
13158
+ * @stubbed
13159
+ */
13160
+ selection: NotebookRange;
13161
+
13162
+ /**
13163
+ * All selections in this notebook editor.
13164
+ *
13165
+ * The primary selection (or focused range) is `selections[0]`. When the document has no cells, the primary selection is empty `{ start: 0, end: 0 }`;
13166
+ * @stubbed
13167
+ */
13168
+ selections: readonly NotebookRange[];
13169
+
13170
+ /**
13171
+ * The current visible ranges in the editor (vertically).
13172
+ * @stubbed
13173
+ */
13174
+ readonly visibleRanges: readonly NotebookRange[];
13175
+
13176
+ /**
13177
+ * The column in which this editor shows.
13178
+ * @stubbed
13179
+ */
13180
+ readonly viewColumn?: ViewColumn;
13181
+
13182
+ /**
13183
+ * Scroll as indicated by `revealType` in order to reveal the given range.
13184
+ *
13185
+ * @param range A range.
13186
+ * @param revealType The scrolling strategy for revealing `range`.
13187
+ * @stubbed
13188
+ */
13189
+ revealRange(range: NotebookRange, revealType?: NotebookEditorRevealType): void;
13190
+ }
13191
+
13192
+ /**
13193
+ * Renderer messaging is used to communicate with a single renderer. It's returned from {@link notebooks.createRendererMessaging}.
13194
+ */
13195
+ export interface NotebookRendererMessaging {
13196
+ /**
13197
+ * An event that fires when a message is received from a renderer.
13198
+ * @stubbed
13199
+ */
13200
+ readonly onDidReceiveMessage: Event<{
13201
+ readonly editor: NotebookEditor;
13202
+ readonly message: any;
13203
+ }>;
13204
+
13205
+ /**
13206
+ * Send a message to one or all renderer.
13207
+ *
13208
+ * @param message Message to send
13209
+ * @param editor Editor to target with the message. If not provided, the
13210
+ * message is sent to all renderers.
13211
+ * @returns a boolean indicating whether the message was successfully
13212
+ * delivered to any renderer.
13213
+ * @stubbed
13214
+ */
13215
+ postMessage(message: any, editor?: NotebookEditor): Thenable<boolean>;
13216
+ }
13217
+
13218
+ /**
13219
+ * A notebook cell kind.
13220
+ */
13221
+ export enum NotebookCellKind {
13222
+
13223
+ /**
13224
+ * A markup-cell is formatted source that is used for display.
13225
+ */
13226
+ Markup = 1,
13227
+
13228
+ /**
13229
+ * A code-cell is source that can be {@link NotebookController executed} and that
13230
+ * produces {@link NotebookCellOutput output}.
13231
+ */
13232
+ Code = 2
13233
+ }
13234
+
13235
+ /**
13236
+ * Represents a cell of a {@link NotebookDocument notebook}, either a {@link NotebookCellKind.Code code}-cell
13237
+ * or {@link NotebookCellKind.Markup markup}-cell.
13238
+ *
13239
+ * NotebookCell instances are immutable and are kept in sync for as long as they are part of their notebook.
13240
+ */
13241
+ export interface NotebookCell {
13242
+
13243
+ /**
13244
+ * The index of this cell in its {@link NotebookDocument.cellAt containing notebook}. The
13245
+ * index is updated when a cell is moved within its notebook. The index is `-1`
13246
+ * when the cell has been removed from its notebook.
13247
+ * @stubbed
13248
+ */
13249
+ readonly index: number;
13250
+
13251
+ /**
13252
+ * The {@link NotebookDocument notebook} that contains this cell.
13253
+ * @stubbed
13254
+ */
13255
+ readonly notebook: NotebookDocument;
13256
+
13257
+ /**
13258
+ * The kind of this cell.
13259
+ * @stubbed
13260
+ */
13261
+ readonly kind: NotebookCellKind;
13262
+
13263
+ /**
13264
+ * The {@link TextDocument text} of this cell, represented as text document.
13265
+ * @stubbed
13266
+ */
13267
+ readonly document: TextDocument;
13268
+
13269
+ /**
13270
+ * The metadata of this cell. Can be anything but must be JSON-stringifyable.
13271
+ * @stubbed
13272
+ */
13273
+ readonly metadata: { readonly [key: string]: any };
13274
+
13275
+ /**
13276
+ * The outputs of this cell.
13277
+ * @stubbed
13278
+ */
13279
+ readonly outputs: readonly NotebookCellOutput[];
13280
+
13281
+ /**
13282
+ * The most recent {@link NotebookCellExecutionSummary execution summary} for this cell.
13283
+ * @stubbed
13284
+ */
13285
+ readonly executionSummary: NotebookCellExecutionSummary | undefined;
13286
+ }
13287
+
13288
+ /**
13289
+ * Represents a notebook which itself is a sequence of {@link NotebookCell code or markup cells}. Notebook documents are
13290
+ * created from {@link NotebookData notebook data}.
13291
+ */
13292
+ export interface NotebookDocument {
13293
+
13294
+ /**
13295
+ * The associated uri for this notebook.
13296
+ *
13297
+ * *Note* that most notebooks use the `file`-scheme, which means they are files on disk. However, **not** all notebooks are
13298
+ * saved on disk and therefore the `scheme` must be checked before trying to access the underlying file or siblings on disk.
13299
+ * @stubbed
13300
+ *
13301
+ * @see {@link FileSystemProvider}
13302
+ */
13303
+ readonly uri: Uri;
13304
+
13305
+ /**
13306
+ * The type of notebook.
13307
+ * @stubbed
13308
+ */
13309
+ readonly notebookType: string;
13310
+
13311
+ /**
13312
+ * The version number of this notebook (it will strictly increase after each
13313
+ * change, including undo/redo).
13314
+ * @stubbed
13315
+ */
13316
+ readonly version: number;
13317
+
13318
+ /**
13319
+ * `true` if there are unpersisted changes.
13320
+ * @stubbed
13321
+ */
13322
+ readonly isDirty: boolean;
13323
+
13324
+ /**
13325
+ * Is this notebook representing an untitled file which has not been saved yet.
13326
+ * @stubbed
13327
+ */
13328
+ readonly isUntitled: boolean;
13329
+
13330
+ /**
13331
+ * `true` if the notebook has been closed. A closed notebook isn't synchronized anymore
13332
+ * and won't be re-used when the same resource is opened again.
13333
+ * @stubbed
13334
+ */
13335
+ readonly isClosed: boolean;
13336
+
13337
+ /**
13338
+ * Arbitrary metadata for this notebook. Can be anything but must be JSON-stringifyable.
13339
+ * @stubbed
13340
+ */
13341
+ readonly metadata: { [key: string]: any };
13342
+
13343
+ /**
13344
+ * The number of cells in the notebook.
13345
+ * @stubbed
13346
+ */
13347
+ readonly cellCount: number;
13348
+
13349
+ /**
13350
+ * Return the cell at the specified index. The index will be adjusted to the notebook.
13351
+ *
13352
+ * @param index - The index of the cell to retrieve.
13353
+ * @return A {@link NotebookCell cell}.
13354
+ * @stubbed
13355
+ */
13356
+ cellAt(index: number): NotebookCell;
13357
+
13358
+ /**
13359
+ * Get the cells of this notebook. A subset can be retrieved by providing
13360
+ * a range. The range will be adjusted to the notebook.
13361
+ *
13362
+ * @param range A notebook range.
13363
+ * @returns The cells contained by the range or all cells.
13364
+ * @stubbed
13365
+ */
13366
+ getCells(range?: NotebookRange): NotebookCell[];
13367
+
13368
+ /**
13369
+ * Save the document. The saving will be handled by the corresponding {@link NotebookSerializer serializer}.
13370
+ *
13371
+ * @return A promise that will resolve to true when the document
13372
+ * has been saved. Will return false if the file was not dirty or when save failed.
13373
+ * @stubbed
13374
+ */
13375
+ save(): Thenable<boolean>;
13376
+ }
13377
+
13378
+ /**
13379
+ * Describes a change to a notebook cell.
13380
+ *
13381
+ * @see {@link NotebookDocumentChangeEvent}
13382
+ */
13383
+ export interface NotebookDocumentCellChange {
13384
+
13385
+ /**
13386
+ * The affected cell.
13387
+ * @stubbed
13388
+ */
13389
+ readonly cell: NotebookCell;
13390
+
13391
+ /**
13392
+ * The document of the cell or `undefined` when it did not change.
13393
+ *
13394
+ * *Note* that you should use the {@link workspace.onDidChangeTextDocument onDidChangeTextDocument}-event
13395
+ * for detailed change information, like what edits have been performed.
13396
+ * @stubbed
13397
+ */
13398
+ readonly document: TextDocument | undefined;
13399
+
13400
+ /**
13401
+ * The new metadata of the cell or `undefined` when it did not change.
13402
+ * @stubbed
13403
+ */
13404
+ readonly metadata: { [key: string]: any } | undefined;
13405
+
13406
+ /**
13407
+ * The new outputs of the cell or `undefined` when they did not change.
13408
+ * @stubbed
13409
+ */
13410
+ readonly outputs: readonly NotebookCellOutput[] | undefined;
13411
+
13412
+ /**
13413
+ * The new execution summary of the cell or `undefined` when it did not change.
13414
+ * @stubbed
13415
+ */
13416
+ readonly executionSummary: NotebookCellExecutionSummary | undefined;
13417
+ }
13418
+
13419
+ /**
13420
+ * Describes a structural change to a notebook document, e.g newly added and removed cells.
13421
+ *
13422
+ * @see {@link NotebookDocumentChangeEvent}
13423
+ */
13424
+ export interface NotebookDocumentContentChange {
13425
+
13426
+ /**
13427
+ * The range at which cells have been either added or removed.
13428
+ *
13429
+ * Note that no cells have been {@link NotebookDocumentContentChange.removedCells removed}
13430
+ * when this range is {@link NotebookRange.isEmpty empty}.
13431
+ * @stubbed
13432
+ */
13433
+ readonly range: NotebookRange;
13434
+
13435
+ /**
13436
+ * Cells that have been added to the document.
13437
+ * @stubbed
13438
+ */
13439
+ readonly addedCells: readonly NotebookCell[];
13440
+
13441
+ /**
13442
+ * Cells that have been removed from the document.
13443
+ * @stubbed
13444
+ */
13445
+ readonly removedCells: readonly NotebookCell[];
13446
+ }
13447
+
13448
+ /**
13449
+ * An event describing a transactional {@link NotebookDocument notebook} change.
13450
+ */
13451
+ export interface NotebookDocumentChangeEvent {
13452
+
13453
+ /**
13454
+ * The affected notebook.
13455
+ * @stubbed
13456
+ */
13457
+ readonly notebook: NotebookDocument;
13458
+
13459
+ /**
13460
+ * The new metadata of the notebook or `undefined` when it did not change.
13461
+ * @stubbed
13462
+ */
13463
+ readonly metadata: { [key: string]: any } | undefined;
13464
+
13465
+ /**
13466
+ * An array of content changes describing added or removed {@link NotebookCell cells}.
13467
+ * @stubbed
13468
+ */
13469
+ readonly contentChanges: readonly NotebookDocumentContentChange[];
13470
+
13471
+ /**
13472
+ * An array of {@link NotebookDocumentCellChange cell changes}.
13473
+ * @stubbed
13474
+ */
13475
+ readonly cellChanges: readonly NotebookDocumentCellChange[];
13476
+ }
13477
+
13478
+ /**
13479
+ * The summary of a notebook cell execution.
13480
+ */
13481
+ export interface NotebookCellExecutionSummary {
13482
+
13483
+ /**
13484
+ * The order in which the execution happened.
13485
+ * @stubbed
13486
+ */
13487
+ readonly executionOrder?: number;
13488
+
13489
+ /**
13490
+ * If the execution finished successfully.
13491
+ * @stubbed
13492
+ */
13493
+ readonly success?: boolean;
13494
+
13495
+ /**
13496
+ * The times at which execution started and ended, as unix timestamps
13497
+ * @stubbed
13498
+ */
13499
+ readonly timing?: { readonly startTime: number; readonly endTime: number };
13500
+ }
13501
+
13502
+ /**
13503
+ * A notebook range represents an ordered pair of two cell indices.
13504
+ * It is guaranteed that start is less than or equal to end.
13505
+ */
13506
+ export class NotebookRange {
13507
+
13508
+ /**
13509
+ * The zero-based start index of this range.
13510
+ * @stubbed
13511
+ */
13512
+ readonly start: number;
13513
+
13514
+ /**
13515
+ * The exclusive end index of this range (zero-based).
13516
+ * @stubbed
13517
+ */
13518
+ readonly end: number;
13519
+
13520
+ /**
13521
+ * `true` if `start` and `end` are equal.
13522
+ * @stubbed
13523
+ */
13524
+ readonly isEmpty: boolean;
13525
+
13526
+ /**
13527
+ * Create a new notebook range. If `start` is not
13528
+ * before or equal to `end`, the values will be swapped.
13529
+ *
13530
+ * @param start start index
13531
+ * @param end end index.
13532
+ * @stubbed
13533
+ */
13534
+ constructor(start: number, end: number);
13535
+
13536
+ /**
13537
+ * Derive a new range for this range.
13538
+ *
13539
+ * @param change An object that describes a change to this range.
13540
+ * @return A range that reflects the given change. Will return `this` range if the change
13541
+ * is not changing anything.
13542
+ * @stubbed
13543
+ */
13544
+ with(change: { start?: number; end?: number }): NotebookRange;
13545
+ }
13546
+
13547
+ /**
13548
+ * One representation of a {@link NotebookCellOutput notebook output}, defined by MIME type and data.
13549
+ */
13550
+ export class NotebookCellOutputItem {
13551
+
13552
+ /**
13553
+ * Factory function to create a `NotebookCellOutputItem` from a string.
13554
+ *
13555
+ * *Note* that an UTF-8 encoder is used to create bytes for the string.
13556
+ *
13557
+ * @param value A string.
13558
+ * @param mime Optional MIME type, defaults to `text/plain`.
13559
+ * @returns A new output item object.
13560
+ */
13561
+ static text(value: string, mime?: string): NotebookCellOutputItem;
13562
+
13563
+ /**
13564
+ * Factory function to create a `NotebookCellOutputItem` from
13565
+ * a JSON object.
13566
+ *
13567
+ * *Note* that this function is not expecting "stringified JSON" but
13568
+ * an object that can be stringified. This function will throw an error
13569
+ * when the passed value cannot be JSON-stringified.
13570
+ *
13571
+ * @param value A JSON-stringifyable value.
13572
+ * @param mime Optional MIME type, defaults to `application/json`
13573
+ * @returns A new output item object.
13574
+ */
13575
+ static json(value: any, mime?: string): NotebookCellOutputItem;
13576
+
13577
+ /**
13578
+ * Factory function to create a `NotebookCellOutputItem` that uses
13579
+ * uses the `application/vnd.code.notebook.stdout` mime type.
13580
+ *
13581
+ * @param value A string.
13582
+ * @returns A new output item object.
13583
+ */
13584
+ static stdout(value: string): NotebookCellOutputItem;
13585
+
13586
+ /**
13587
+ * Factory function to create a `NotebookCellOutputItem` that uses
13588
+ * uses the `application/vnd.code.notebook.stderr` mime type.
13589
+ *
13590
+ * @param value A string.
13591
+ * @returns A new output item object.
13592
+ */
13593
+ static stderr(value: string): NotebookCellOutputItem;
13594
+
13595
+ /**
13596
+ * Factory function to create a `NotebookCellOutputItem` that uses
13597
+ * uses the `application/vnd.code.notebook.error` mime type.
13598
+ *
13599
+ * @param value An error object.
13600
+ * @returns A new output item object.
13601
+ */
13602
+ static error(value: Error): NotebookCellOutputItem;
13603
+
13604
+ /**
13605
+ * The mime type which determines how the {@linkcode NotebookCellOutputItem.data data}-property
13606
+ * is interpreted.
13607
+ *
13608
+ * Notebooks have built-in support for certain mime-types, extensions can add support for new
13609
+ * types and override existing types.
13610
+ */
13611
+ mime: string;
13612
+
13613
+ /**
13614
+ * The data of this output item. Must always be an array of unsigned 8-bit integers.
13615
+ */
13616
+ data: Uint8Array;
13617
+
13618
+ /**
13619
+ * Create a new notebook cell output item.
13620
+ *
13621
+ * @param data The value of the output item.
13622
+ * @param mime The mime type of the output item.
13623
+ */
13624
+ constructor(data: Uint8Array, mime: string);
13625
+ }
13626
+
13627
+ /**
13628
+ * Notebook cell output represents a result of executing a cell. It is a container type for multiple
13629
+ * {@link NotebookCellOutputItem output items} where contained items represent the same result but
13630
+ * use different MIME types.
13631
+ */
13632
+ export class NotebookCellOutput {
13633
+
13634
+ /**
13635
+ * The output items of this output. Each item must represent the same result. _Note_ that repeated
13636
+ * MIME types per output is invalid and that the editor will just pick one of them.
13637
+ *
13638
+ * ```ts
13639
+ * new vscode.NotebookCellOutput([
13640
+ * vscode.NotebookCellOutputItem.text('Hello', 'text/plain'),
13641
+ * vscode.NotebookCellOutputItem.text('<i>Hello</i>', 'text/html'),
13642
+ * vscode.NotebookCellOutputItem.text('_Hello_', 'text/markdown'),
13643
+ * vscode.NotebookCellOutputItem.text('Hey', 'text/plain'), // INVALID: repeated type, editor will pick just one
13644
+ * ])
13645
+ * ```
13646
+ * @stubbed
13647
+ */
13648
+ items: NotebookCellOutputItem[];
13649
+
13650
+ /**
13651
+ * Arbitrary metadata for this cell output. Can be anything but must be JSON-stringifyable.
13652
+ * @stubbed
13653
+ */
13654
+ metadata?: { [key: string]: any };
13655
+
13656
+ /**
13657
+ * Create new notebook output.
13658
+ *
13659
+ * @param items Notebook output items.
13660
+ * @param metadata Optional metadata.
13661
+ * @stubbed
13662
+ */
13663
+ constructor(items: NotebookCellOutputItem[], metadata?: { [key: string]: any });
13664
+ }
13665
+
13666
+ /**
13667
+ * NotebookCellData is the raw representation of notebook cells. Its is part of {@linkcode NotebookData}.
13668
+ */
13669
+ export class NotebookCellData {
13670
+
13671
+ /**
13672
+ * The {@link NotebookCellKind kind} of this cell data.
13673
+ * @stubbed
13674
+ */
13675
+ kind: NotebookCellKind;
13676
+
13677
+ /**
13678
+ * The source value of this cell data - either source code or formatted text.
13679
+ * @stubbed
13680
+ */
13681
+ value: string;
13682
+
13683
+ /**
13684
+ * The language identifier of the source value of this cell data. Any value from
13685
+ * {@linkcode languages.getLanguages getLanguages} is possible.
13686
+ * @stubbed
13687
+ */
13688
+ languageId: string;
13689
+
13690
+ /**
13691
+ * The outputs of this cell data.
13692
+ * @stubbed
13693
+ */
13694
+ outputs?: NotebookCellOutput[];
13695
+
13696
+ /**
13697
+ * Arbitrary metadata of this cell data. Can be anything but must be JSON-stringifyable.
13698
+ */
13699
+ metadata?: { [key: string]: any };
13700
+
13701
+ /**
13702
+ * The execution summary of this cell data.
13703
+ * @stubbed
13704
+ */
13705
+ executionSummary?: NotebookCellExecutionSummary;
13706
+
13707
+ /**
13708
+ * Create new cell data. Minimal cell data specifies its kind, its source value, and the
13709
+ * language identifier of its source.
13710
+ *
13711
+ * @param kind The kind.
13712
+ * @param value The source value.
13713
+ * @param languageId The language identifier of the source value.
13714
+ * @stubbed
13715
+ */
13716
+ constructor(kind: NotebookCellKind, value: string, languageId: string);
13717
+ }
13718
+
13719
+ /**
13720
+ * Raw representation of a notebook.
13721
+ *
13722
+ * Extensions are responsible for creating {@linkcode NotebookData} so that the editor
13723
+ * can create a {@linkcode NotebookDocument}.
13724
+ *
13725
+ * @see {@link NotebookSerializer}
13726
+ */
13727
+ export class NotebookData {
13728
+ /**
13729
+ * The cell data of this notebook data.
13730
+ * @stubbed
13731
+ */
13732
+ cells: NotebookCellData[];
13733
+
13734
+ /**
13735
+ * Arbitrary metadata of notebook data.
13736
+ * @stubbed
13737
+ */
13738
+ metadata?: { [key: string]: any };
13739
+
13740
+ /**
13741
+ * Create new notebook data.
13742
+ *
13743
+ * @param cells An array of cell data.
13744
+ * @stubbed
13745
+ */
13746
+ constructor(cells: NotebookCellData[]);
13747
+ }
13748
+
13749
+ /**
13750
+ * The notebook serializer enables the editor to open notebook files.
13751
+ *
13752
+ * At its core the editor only knows a {@link NotebookData notebook data structure} but not
13753
+ * how that data structure is written to a file, nor how it is read from a file. The
13754
+ * notebook serializer bridges this gap by deserializing bytes into notebook data and
13755
+ * vice versa.
13756
+ */
13757
+ export interface NotebookSerializer {
13758
+
13759
+ /**
13760
+ * Deserialize contents of a notebook file into the notebook data structure.
13761
+ *
13762
+ * @param content Contents of a notebook file.
13763
+ * @param token A cancellation token.
13764
+ * @return Notebook data or a thenable that resolves to such.
13765
+ * @stubbed
13766
+ */
13767
+ deserializeNotebook(content: Uint8Array, token: CancellationToken): NotebookData | Thenable<NotebookData>;
13768
+
13769
+ /**
13770
+ * Serialize notebook data into file contents.
13771
+ *
13772
+ * @param data A notebook data structure.
13773
+ * @param token A cancellation token.
13774
+ * @returns An array of bytes or a thenable that resolves to such.
13775
+ * @stubbed
13776
+ */
13777
+ serializeNotebook(data: NotebookData, token: CancellationToken): Uint8Array | Thenable<Uint8Array>;
13778
+ }
13779
+
13780
+ /**
13781
+ * Notebook content options define what parts of a notebook are persisted. Note
13782
+ *
13783
+ * For instance, a notebook serializer can opt-out of saving outputs and in that case the editor doesn't mark a
13784
+ * notebooks as {@link NotebookDocument.isDirty dirty} when its output has changed.
13785
+ */
13786
+ export interface NotebookDocumentContentOptions {
13787
+ /**
13788
+ * Controls if output change events will trigger notebook document content change events and
13789
+ * if it will be used in the diff editor, defaults to false. If the content provider doesn't
13790
+ * persist the outputs in the file document, this should be set to true.
13791
+ * @stubbed
13792
+ */
13793
+ transientOutputs?: boolean;
13794
+
13795
+ /**
13796
+ * Controls if a cell metadata property change event will trigger notebook document content
13797
+ * change events and if it will be used in the diff editor, defaults to false. If the
13798
+ * content provider doesn't persist a metadata property in the file document, it should be
13799
+ * set to true.
13800
+ * @stubbed
13801
+ */
13802
+ transientCellMetadata?: { [key: string]: boolean | undefined };
13803
+
13804
+ /**
13805
+ * Controls if a document metadata property change event will trigger notebook document
13806
+ * content change event and if it will be used in the diff editor, defaults to false. If the
13807
+ * content provider doesn't persist a metadata property in the file document, it should be
13808
+ * set to true.
13809
+ * @stubbed
13810
+ */
13811
+ transientDocumentMetadata?: { [key: string]: boolean | undefined };
13812
+ }
13813
+
13814
+ /**
13815
+ * Represents options to configure the behavior of showing a {@link NotebookDocument notebook document} in an {@link NotebookEditor notebook editor}.
13816
+ */
13817
+ export interface NotebookDocumentShowOptions {
13818
+ /**
13819
+ * An optional view column in which the {@link NotebookEditor notebook editor} should be shown.
13820
+ * The default is the {@link ViewColumn.Active active}. Columns that do not exist
13821
+ * will be created as needed up to the maximum of {@linkcode ViewColumn.Nine}.
13822
+ * Use {@linkcode ViewColumn.Beside} to open the editor to the side of the currently
13823
+ * active one.
13824
+ * @stubbed
13825
+ */
13826
+ readonly viewColumn?: ViewColumn;
13827
+
13828
+ /**
13829
+ * An optional flag that when `true` will stop the {@link NotebookEditor notebook editor} from taking focus.
13830
+ * @stubbed
13831
+ */
13832
+ readonly preserveFocus?: boolean;
13833
+
13834
+ /**
13835
+ * An optional flag that controls if an {@link NotebookEditor notebook editor}-tab shows as preview. Preview tabs will
13836
+ * be replaced and reused until set to stay - either explicitly or through editing. The default behaviour depends
13837
+ * on the `workbench.editor.enablePreview`-setting.
13838
+ * @stubbed
13839
+ */
13840
+ readonly preview?: boolean;
13841
+
13842
+ /**
13843
+ * An optional selection to apply for the document in the {@link NotebookEditor notebook editor}.
13844
+ * @stubbed
13845
+ */
13846
+ readonly selections?: readonly NotebookRange[];
13847
+ }
13848
+
13849
+ /**
13850
+ * A notebook edit represents edits that should be applied to the contents of a notebook.
13851
+ */
13852
+ export class NotebookEdit {
13853
+
13854
+ /**
13855
+ * Utility to create a edit that replaces cells in a notebook.
13856
+ *
13857
+ * @param range The range of cells to replace
13858
+ * @param newCells The new notebook cells.
13859
+ * @stubbed
13860
+ */
13861
+ static replaceCells(range: NotebookRange, newCells: NotebookCellData[]): NotebookEdit;
13862
+
13863
+ /**
13864
+ * Utility to create an edit that replaces cells in a notebook.
13865
+ *
13866
+ * @param index The index to insert cells at.
13867
+ * @param newCells The new notebook cells.
13868
+ * @stubbed
13869
+ */
13870
+ static insertCells(index: number, newCells: NotebookCellData[]): NotebookEdit;
13871
+
13872
+ /**
13873
+ * Utility to create an edit that deletes cells in a notebook.
13874
+ *
13875
+ * @param range The range of cells to delete.
13876
+ * @stubbed
13877
+ */
13878
+ static deleteCells(range: NotebookRange): NotebookEdit;
13879
+
13880
+ /**
13881
+ * Utility to create an edit that update a cell's metadata.
13882
+ *
13883
+ * @param index The index of the cell to update.
13884
+ * @param newCellMetadata The new metadata for the cell.
13885
+ * @stubbed
13886
+ */
13887
+ static updateCellMetadata(index: number, newCellMetadata: { [key: string]: any }): NotebookEdit;
13888
+
13889
+ /**
13890
+ * Utility to create an edit that updates the notebook's metadata.
13891
+ *
13892
+ * @param newNotebookMetadata The new metadata for the notebook.
13893
+ * @stubbed
13894
+ */
13895
+ static updateNotebookMetadata(newNotebookMetadata: { [key: string]: any }): NotebookEdit;
13896
+
13897
+ /**
13898
+ * Range of the cells being edited. May be empty.
13899
+ * @stubbed
13900
+ */
13901
+ range: NotebookRange;
13902
+
13903
+ /**
13904
+ * New cells being inserted. May be empty.
13905
+ * @stubbed
13906
+ */
13907
+ newCells: NotebookCellData[];
13908
+
13909
+ /**
13910
+ * Optional new metadata for the cells.
13911
+ * @stubbed
13912
+ */
13913
+ newCellMetadata?: { [key: string]: any };
13914
+
13915
+ /**
13916
+ * Optional new metadata for the notebook.
13917
+ * @stubbed
13918
+ */
13919
+ newNotebookMetadata?: { [key: string]: any };
13920
+
13921
+ constructor(range: NotebookRange, newCells: NotebookCellData[]);
13922
+ }
13923
+
13924
+ /**
13925
+ * Represents an event describing the change in a {@link NotebookEditor.selections notebook editor's selections}.
13926
+ */
13927
+ export interface NotebookEditorSelectionChangeEvent {
13928
+ /**
13929
+ * The {@link NotebookEditor notebook editor} for which the selections have changed.
13930
+ * @stubbed
13931
+ */
13932
+ readonly notebookEditor: NotebookEditor;
13933
+
13934
+ /**
13935
+ * The new value for the {@link NotebookEditor.selections notebook editor's selections}.
13936
+ * @stubbed
13937
+ */
13938
+ readonly selections: readonly NotebookRange[];
13939
+ }
13940
+
13941
+ /**
13942
+ * Represents an event describing the change in a {@link NotebookEditor.visibleRanges notebook editor's visibleRanges}.
13943
+ */
13944
+ export interface NotebookEditorVisibleRangesChangeEvent {
13945
+ /**
13946
+ * The {@link NotebookEditor notebook editor} for which the visible ranges have changed.
13947
+ * @stubbed
13948
+ */
13949
+ readonly notebookEditor: NotebookEditor;
13950
+
13951
+ /**
13952
+ * The new value for the {@link NotebookEditor.visibleRanges notebook editor's visibleRanges}.
13953
+ * @stubbed
13954
+ */
13955
+ readonly visibleRanges: readonly NotebookRange[];
13956
+ }
13957
+
13958
+ /**
13959
+ * Notebook controller affinity for notebook documents.
13960
+ *
13961
+ * @see {@link NotebookController.updateNotebookAffinity}
13962
+ */
13963
+ export enum NotebookControllerAffinity {
13964
+ /**
13965
+ * Default affinity.
13966
+ */
13967
+ Default = 1,
13968
+ /**
13969
+ * A controller is preferred for a notebook.
13970
+ */
13971
+ Preferred = 2
13972
+ }
13973
+
13974
+ /**
13975
+ * A notebook controller represents an entity that can execute notebook cells. This is often referred to as a kernel.
13976
+ *
13977
+ * There can be multiple controllers and the editor will let users choose which controller to use for a certain notebook. The
13978
+ * {@linkcode NotebookController.notebookType notebookType}-property defines for what kind of notebooks a controller is for and
13979
+ * the {@linkcode NotebookController.updateNotebookAffinity updateNotebookAffinity}-function allows controllers to set a preference
13980
+ * for specific notebook documents. When a controller has been selected its
13981
+ * {@link NotebookController.onDidChangeSelectedNotebooks onDidChangeSelectedNotebooks}-event fires.
13982
+ *
13983
+ * When a cell is being run the editor will invoke the {@linkcode NotebookController.executeHandler executeHandler} and a controller
13984
+ * is expected to create and finalize a {@link NotebookCellExecution notebook cell execution}. However, controllers are also free
13985
+ * to create executions by themselves.
13986
+ */
13987
+ export interface NotebookController {
13988
+
13989
+ /**
13990
+ * The identifier of this notebook controller.
13991
+ *
13992
+ * _Note_ that controllers are remembered by their identifier and that extensions should use
13993
+ * stable identifiers across sessions.
13994
+ * @stubbed
13995
+ */
13996
+ readonly id: string;
13997
+
13998
+ /**
13999
+ * The notebook type this controller is for.
14000
+ * @stubbed
14001
+ */
14002
+ readonly notebookType: string;
14003
+
14004
+ /**
14005
+ * An array of language identifiers that are supported by this
14006
+ * controller. Any language identifier from {@linkcode languages.getLanguages getLanguages}
14007
+ * is possible. When falsy all languages are supported.
14008
+ *
14009
+ * Samples:
14010
+ * ```js
14011
+ * // support JavaScript and TypeScript
14012
+ * myController.supportedLanguages = ['javascript', 'typescript']
14013
+ *
14014
+ * // support all languages
14015
+ * myController.supportedLanguages = undefined; // falsy
14016
+ * myController.supportedLanguages = []; // falsy
14017
+ * ```
14018
+ * @stubbed
14019
+ */
14020
+ supportedLanguages?: string[];
14021
+
14022
+ /**
14023
+ * The human-readable label of this notebook controller.
14024
+ * @stubbed
14025
+ */
14026
+ label: string;
14027
+
14028
+ /**
14029
+ * The human-readable description which is rendered less prominent.
14030
+ * @stubbed
14031
+ */
14032
+ description?: string;
14033
+
14034
+ /**
14035
+ * The human-readable detail which is rendered less prominent.
14036
+ * @stubbed
14037
+ */
14038
+ detail?: string;
14039
+
14040
+ /**
14041
+ * Whether this controller supports execution order so that the
14042
+ * editor can render placeholders for them.
14043
+ * @stubbed
14044
+ */
14045
+ supportsExecutionOrder?: boolean;
14046
+
14047
+ /**
14048
+ * Create a cell execution task.
14049
+ *
14050
+ * _Note_ that there can only be one execution per cell at a time and that an error is thrown if
14051
+ * a cell execution is created while another is still active.
14052
+ *
14053
+ * This should be used in response to the {@link NotebookController.executeHandler execution handler}
14054
+ * being called or when cell execution has been started else, e.g when a cell was already
14055
+ * executing or when cell execution was triggered from another source.
14056
+ *
14057
+ * @param cell The notebook cell for which to create the execution.
14058
+ * @returns A notebook cell execution.
14059
+ * @stubbed
14060
+ */
14061
+ createNotebookCellExecution(cell: NotebookCell): NotebookCellExecution;
14062
+
14063
+ /**
14064
+ * The execute handler is invoked when the run gestures in the UI are selected, e.g Run Cell, Run All,
14065
+ * Run Selection etc. The execute handler is responsible for creating and managing {@link NotebookCellExecution execution}-objects.
14066
+ * @stubbed
14067
+ */
14068
+ executeHandler: (cells: NotebookCell[], notebook: NotebookDocument, controller: NotebookController) => void | Thenable<void>;
14069
+
14070
+ /**
14071
+ * Optional interrupt handler.
14072
+ *
14073
+ * By default cell execution is canceled via {@link NotebookCellExecution.token tokens}. Cancellation
14074
+ * tokens require that a controller can keep track of its execution so that it can cancel a specific execution at a later
14075
+ * point. Not all scenarios allow for that, eg. REPL-style controllers often work by interrupting whatever is currently
14076
+ * running. For those cases the interrupt handler exists - it can be thought of as the equivalent of `SIGINT`
14077
+ * or `Control+C` in terminals.
14078
+ *
14079
+ * _Note_ that supporting {@link NotebookCellExecution.token cancellation tokens} is preferred and that interrupt handlers should
14080
+ * only be used when tokens cannot be supported.
14081
+ * @stubbed
14082
+ */
14083
+ interruptHandler?: (notebook: NotebookDocument) => void | Thenable<void>;
14084
+
14085
+ /**
14086
+ * An event that fires whenever a controller has been selected or un-selected for a notebook document.
14087
+ *
14088
+ * There can be multiple controllers for a notebook and in that case a controllers needs to be _selected_. This is a user gesture
14089
+ * and happens either explicitly or implicitly when interacting with a notebook for which a controller was _suggested_. When possible,
14090
+ * the editor _suggests_ a controller that is most likely to be _selected_.
14091
+ *
14092
+ * _Note_ that controller selection is persisted (by the controllers {@link NotebookController.id id}) and restored as soon as a
14093
+ * controller is re-created or as a notebook is {@link workspace.onDidOpenNotebookDocument opened}.
14094
+ * @stubbed
14095
+ */
14096
+ readonly onDidChangeSelectedNotebooks: Event<{ readonly notebook: NotebookDocument; readonly selected: boolean }>;
14097
+
14098
+ /**
14099
+ * A controller can set affinities for specific notebook documents. This allows a controller
14100
+ * to be presented more prominent for some notebooks.
14101
+ *
14102
+ * @param notebook The notebook for which a priority is set.
14103
+ * @param affinity A controller affinity
14104
+ * @stubbed
14105
+ */
14106
+ updateNotebookAffinity(notebook: NotebookDocument, affinity: NotebookControllerAffinity): void;
14107
+
14108
+ /**
14109
+ * Dispose and free associated resources.
14110
+ * @stubbed
14111
+ */
14112
+ dispose(): void;
14113
+ }
14114
+
14115
+ /**
14116
+ * A NotebookCellExecution is how {@link NotebookController notebook controller} modify a notebook cell as
14117
+ * it is executing.
14118
+ *
14119
+ * When a cell execution object is created, the cell enters the {@linkcode NotebookCellExecutionState.Pending Pending} state.
14120
+ * When {@linkcode NotebookCellExecution.start start(...)} is called on the execution task, it enters the {@linkcode NotebookCellExecutionState.Executing Executing} state. When
14121
+ * {@linkcode NotebookCellExecution.end end(...)} is called, it enters the {@linkcode NotebookCellExecutionState.Idle Idle} state.
14122
+ */
14123
+ export interface NotebookCellExecution {
14124
+
14125
+ /**
14126
+ * The {@link NotebookCell cell} for which this execution has been created.
14127
+ * @stubbed
14128
+ */
14129
+ readonly cell: NotebookCell;
14130
+
14131
+ /**
14132
+ * A cancellation token which will be triggered when the cell execution is canceled
14133
+ * from the UI.
14134
+ *
14135
+ * _Note_ that the cancellation token will not be triggered when the {@link NotebookController controller}
14136
+ * that created this execution uses an {@link NotebookController.interruptHandler interrupt-handler}.
14137
+ * @stubbed
14138
+ */
14139
+ readonly token: CancellationToken;
14140
+
14141
+ /**
14142
+ * Set and unset the order of this cell execution.
14143
+ * @stubbed
14144
+ */
14145
+ executionOrder: number | undefined;
14146
+
14147
+ /**
14148
+ * Signal that the execution has begun.
14149
+ *
14150
+ * @param startTime The time that execution began, in milliseconds in the Unix epoch. Used to drive the clock
14151
+ * that shows for how long a cell has been running. If not given, the clock won't be shown.
14152
+ * @stubbed
14153
+ */
14154
+ start(startTime?: number): void;
14155
+
14156
+ /**
14157
+ * Signal that execution has ended.
14158
+ *
14159
+ * @param success If true, a green check is shown on the cell status bar.
14160
+ * If false, a red X is shown.
14161
+ * If undefined, no check or X icon is shown.
14162
+ * @param endTime The time that execution finished, in milliseconds in the Unix epoch.
14163
+ * @stubbed
14164
+ */
14165
+ end(success: boolean | undefined, endTime?: number): void;
14166
+
14167
+ /**
14168
+ * Clears the output of the cell that is executing or of another cell that is affected by this execution.
14169
+ *
14170
+ * @param cell Cell for which output is cleared. Defaults to the {@link NotebookCellExecution.cell cell} of
14171
+ * this execution.
14172
+ * @return A thenable that resolves when the operation finished.
14173
+ * @stubbed
14174
+ */
14175
+ clearOutput(cell?: NotebookCell): Thenable<void>;
14176
+
14177
+ /**
14178
+ * Replace the output of the cell that is executing or of another cell that is affected by this execution.
14179
+ *
14180
+ * @param out Output that replaces the current output.
14181
+ * @param cell Cell for which output is cleared. Defaults to the {@link NotebookCellExecution.cell cell} of
14182
+ * this execution.
14183
+ * @return A thenable that resolves when the operation finished.
14184
+ * @stubbed
14185
+ */
14186
+ replaceOutput(out: NotebookCellOutput | readonly NotebookCellOutput[], cell?: NotebookCell): Thenable<void>;
14187
+
14188
+ /**
14189
+ * Append to the output of the cell that is executing or to another cell that is affected by this execution.
14190
+ *
14191
+ * @param out Output that is appended to the current output.
14192
+ * @param cell Cell for which output is cleared. Defaults to the {@link NotebookCellExecution.cell cell} of
14193
+ * this execution.
14194
+ * @return A thenable that resolves when the operation finished.
14195
+ * @stubbed
14196
+ */
14197
+ appendOutput(out: NotebookCellOutput | readonly NotebookCellOutput[], cell?: NotebookCell): Thenable<void>;
14198
+
14199
+ /**
14200
+ * Replace all output items of existing cell output.
14201
+ *
14202
+ * @param items Output items that replace the items of existing output.
14203
+ * @param output Output object that already exists.
14204
+ * @return A thenable that resolves when the operation finished.
14205
+ * @stubbed
14206
+ */
14207
+ replaceOutputItems(items: NotebookCellOutputItem | readonly NotebookCellOutputItem[], output: NotebookCellOutput): Thenable<void>;
14208
+
14209
+ /**
14210
+ * Append output items to existing cell output.
14211
+ *
14212
+ * @param items Output items that are append to existing output.
14213
+ * @param output Output object that already exists.
14214
+ * @return A thenable that resolves when the operation finished.
14215
+ * @stubbed
14216
+ */
14217
+ appendOutputItems(items: NotebookCellOutputItem | readonly NotebookCellOutputItem[], output: NotebookCellOutput): Thenable<void>;
14218
+ }
14219
+
14220
+ /**
14221
+ * Represents the alignment of status bar items.
14222
+ */
14223
+ export enum NotebookCellStatusBarAlignment {
14224
+
14225
+ /**
14226
+ * Aligned to the left side.
14227
+ */
14228
+ Left = 1,
14229
+
14230
+ /**
14231
+ * Aligned to the right side.
14232
+ */
14233
+ Right = 2
14234
+ }
14235
+
14236
+ /**
14237
+ * A contribution to a cell's status bar
14238
+ */
14239
+ export class NotebookCellStatusBarItem {
14240
+ /**
14241
+ * The text to show for the item.
14242
+ * @stubbed
14243
+ */
14244
+ text: string;
14245
+
14246
+ /**
14247
+ * Whether the item is aligned to the left or right.
14248
+ * @stubbed
14249
+ */
14250
+ alignment: NotebookCellStatusBarAlignment;
14251
+
14252
+ /**
14253
+ * An optional {@linkcode Command} or identifier of a command to run on click.
14254
+ *
14255
+ * The command must be {@link commands.getCommands known}.
14256
+ *
14257
+ * Note that if this is a {@linkcode Command} object, only the {@linkcode Command.command command} and {@linkcode Command.arguments arguments}
14258
+ * are used by the editor.
14259
+ * @stubbed
14260
+ */
14261
+ command?: string | Command;
14262
+
14263
+ /**
14264
+ * A tooltip to show when the item is hovered.
14265
+ * @stubbed
14266
+ */
14267
+ tooltip?: string;
14268
+
14269
+ /**
14270
+ * The priority of the item. A higher value item will be shown more to the left.
14271
+ * @stubbed
14272
+ */
14273
+ priority?: number;
14274
+
14275
+ /**
14276
+ * Accessibility information used when a screen reader interacts with this item.
14277
+ * @stubbed
14278
+ */
14279
+ accessibilityInformation?: AccessibilityInformation;
14280
+
14281
+ /**
14282
+ * Creates a new NotebookCellStatusBarItem.
14283
+ * @param text The text to show for the item.
14284
+ * @param alignment Whether the item is aligned to the left or right.
14285
+ * @stubbed
14286
+ */
14287
+ constructor(text: string, alignment: NotebookCellStatusBarAlignment);
14288
+ }
14289
+
14290
+ /**
14291
+ * A provider that can contribute items to the status bar that appears below a cell's editor.
14292
+ */
14293
+ export interface NotebookCellStatusBarItemProvider {
14294
+ /**
14295
+ * An optional event to signal that statusbar items have changed. The provide method will be called again.
14296
+ * @stubbed
14297
+ */
14298
+ onDidChangeCellStatusBarItems?: Event<void>;
14299
+
14300
+ /**
14301
+ * The provider will be called when the cell scrolls into view, when its content, outputs, language, or metadata change, and when it changes execution state.
14302
+ * @param cell The cell for which to return items.
14303
+ * @param token A token triggered if this request should be cancelled.
14304
+ * @return One or more {@link NotebookCellStatusBarItem cell statusbar items}
14305
+ * @stubbed
14306
+ */
14307
+ provideCellStatusBarItems(cell: NotebookCell, token: CancellationToken): ProviderResult<NotebookCellStatusBarItem | NotebookCellStatusBarItem[]>;
14308
+ }
14309
+
14310
+ /**
14311
+ * Namespace for notebooks.
14312
+ * The notebooks functionality is composed of three loosely coupled components:
14313
+ * -{@link NotebookSerializer} enable the editor to open, show, and save notebooks
14314
+ * -{@link NotebookController} own the execution of notebooks, e.g they create output from code cells.
14315
+ * -{@link NotebookRenderer} present notebook output in the editor. They run in a separate context.
14316
+ *
14317
+ */
14318
+ export namespace notebooks {
14319
+
14320
+ /**
14321
+ * Creates a new notebook controller.
14322
+ * @param id Identifier of the controller. Must be unique per extension.
14323
+ * @param notebookType A notebook type for which this controller is for.
14324
+ * @param label The label of the controller.
14325
+ * @param handler The execute-handler of the controller.
14326
+ * @returns a new instance of {@link NotebookController}
14327
+ * @stubbed
14328
+ */
14329
+ export function createNotebookController(
14330
+ id: string,
14331
+ notebookType: string,
14332
+ label: string,
14333
+ handler?: (cells: NotebookCell[],
14334
+ notebook: NotebookDocument,
14335
+ controller: NotebookController) => void | Thenable<void>): NotebookController;
14336
+
14337
+ /**
14338
+ * Creates a new messaging instance used to communicate with a specific renderer.
14339
+ * - Note 1: Extensions can only create renderer that they have defined in their package.json - file
14340
+ * - Note 2: A renderer only has access to messaging if requiresMessaging is set to always or optional in its notebookRenderer contribution.
14341
+ * @param rendererId The renderer ID to communicate with
14342
+ * @returns A new notebook renderer messaging object.
14343
+ * @stubbed
14344
+ */
14345
+ export function createRendererMessaging(rendererId: string): NotebookRendererMessaging;
14346
+
14347
+ /**
14348
+ * Register a cell statusbar item provider for the given notebook type.
14349
+ * @param notebookType The notebook type to register for.
14350
+ * @param provider A cell status bar provider.
14351
+ * @returns A Disposable that unregisters this provider when being disposed.
14352
+ * @stubbed
14353
+ */
14354
+ export function registerNotebookCellStatusBarItemProvider(notebookType: string, provider: NotebookCellStatusBarItemProvider): Disposable;
14355
+ }
12785
14356
  }
12786
14357
 
12787
14358
  /**