UNPKG

4.33 kBTypeScriptView Raw
1import * as vscode from 'vscode';
2import * as proto from 'vscode-languageserver-protocol';
3import { NotebookCellTextDocumentFilter } from 'vscode-languageserver-protocol';
4import { DynamicFeature, FeatureClient, RegistrationData, FeatureState } from './features';
5export type VNotebookDocumentChangeEvent = {
6 /**
7 * The notebook document
8 */
9 notebook: vscode.NotebookDocument;
10 /**
11 * The changed meta data if any.
12 */
13 metadata?: {
14 [key: string]: any;
15 };
16 /**
17 * Changes to cells.
18 */
19 cells?: {
20 /**
21 * Changes to the cell structure to add or
22 * remove cells.
23 */
24 structure?: {
25 /**
26 * The change to the cell array.
27 */
28 array: {
29 start: number;
30 deleteCount: number;
31 cells?: vscode.NotebookCell[];
32 };
33 /**
34 * Additional opened cell text documents.
35 */
36 didOpen?: vscode.NotebookCell[];
37 /**
38 * Additional closed cell text documents.
39 */
40 didClose?: vscode.NotebookCell[];
41 };
42 /**
43 * Changes to notebook cells properties like its
44 * kind or metadata.
45 */
46 data?: vscode.NotebookCell[];
47 /**
48 * Changes to the text content of notebook cells.
49 */
50 textContent?: vscode.TextDocumentChangeEvent[];
51 };
52};
53export type NotebookDocumentOptions = {
54 filterCells?(notebookDocument: vscode.NotebookDocument, cells: vscode.NotebookCell[]): vscode.NotebookCell[];
55};
56export type $NotebookDocumentOptions = {
57 notebookDocumentOptions?: NotebookDocumentOptions;
58};
59export type NotebookDocumentMiddleware = {
60 notebooks?: {
61 didOpen?: (this: void, notebookDocument: vscode.NotebookDocument, cells: vscode.NotebookCell[], next: (this: void, notebookDocument: vscode.NotebookDocument, cells: vscode.NotebookCell[]) => Promise<void>) => Promise<void>;
62 didSave?: (this: void, notebookDocument: vscode.NotebookDocument, next: (this: void, notebookDocument: vscode.NotebookDocument) => Promise<void>) => Promise<void>;
63 didChange?: (this: void, event: VNotebookDocumentChangeEvent, next: (this: void, event: VNotebookDocumentChangeEvent) => Promise<void>) => Promise<void>;
64 didClose?: (this: void, notebookDocument: vscode.NotebookDocument, cells: vscode.NotebookCell[], next: (this: void, notebookDocument: vscode.NotebookDocument, cells: vscode.NotebookCell[]) => Promise<void>) => Promise<void>;
65 };
66};
67export interface NotebookDocumentSyncFeatureShape {
68 sendDidOpenNotebookDocument(notebookDocument: vscode.NotebookDocument): Promise<void>;
69 sendDidSaveNotebookDocument(notebookDocument: vscode.NotebookDocument): Promise<void>;
70 sendDidChangeNotebookDocument(event: VNotebookDocumentChangeEvent): Promise<void>;
71 sendDidCloseNotebookDocument(notebookDocument: vscode.NotebookDocument): Promise<void>;
72}
73export type $NotebookCellTextDocumentFilter = NotebookCellTextDocumentFilter & {
74 sync: true;
75};
76export type NotebookDocumentProviderShape = {
77 getProvider(notebookCell: vscode.NotebookCell): NotebookDocumentSyncFeatureShape | undefined;
78};
79export declare class NotebookDocumentSyncFeature implements DynamicFeature<proto.NotebookDocumentSyncRegistrationOptions>, NotebookDocumentProviderShape {
80 static readonly CellScheme: string;
81 private readonly client;
82 private readonly registrations;
83 private dedicatedChannel;
84 constructor(client: FeatureClient<NotebookDocumentMiddleware, $NotebookDocumentOptions>);
85 getState(): FeatureState;
86 readonly registrationType: proto.RegistrationType<proto.NotebookDocumentSyncRegistrationOptions>;
87 fillClientCapabilities(capabilities: proto.ClientCapabilities): void;
88 preInitialize(capabilities: proto.ServerCapabilities<any>): void;
89 initialize(capabilities: proto.ServerCapabilities<any>): void;
90 register(data: RegistrationData<proto.NotebookDocumentSyncRegistrationOptions>): void;
91 unregister(id: string): void;
92 clear(): void;
93 handles(textDocument: vscode.TextDocument): boolean;
94 getProvider(notebookCell: vscode.NotebookCell): NotebookDocumentSyncFeatureShape | undefined;
95 private findNotebookDocumentAndCell;
96}