Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/notebook/common/notebookRendererMessagingService.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Event } from '../../../../base/common/event.js';
7
import { IDisposable } from '../../../../base/common/lifecycle.js';
8
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
9
10
export const INotebookRendererMessagingService = createDecorator<INotebookRendererMessagingService>('INotebookRendererMessagingService');
11
12
export interface INotebookRendererMessagingService {
13
readonly _serviceBrand: undefined;
14
15
/**
16
* Event that fires when a message should be posted to extension hosts.
17
*/
18
onShouldPostMessage: Event<{ editorId: string; rendererId: string; message: unknown }>;
19
20
/**
21
* Prepares messaging for the given renderer ID.
22
*/
23
prepare(rendererId: string): void;
24
/**
25
* Gets messaging scoped for a specific editor.
26
*/
27
getScoped(editorId: string): IScopedRendererMessaging;
28
29
/**
30
* Called when the main thread gets a message for a renderer.
31
*/
32
receiveMessage(editorId: string | undefined, rendererId: string, message: unknown): Promise<boolean>;
33
}
34
35
export interface IScopedRendererMessaging extends IDisposable {
36
/**
37
* Method called when a message is received. Should return a boolean
38
* indicating whether a renderer received it.
39
*/
40
receiveMessageHandler?: (rendererId: string, message: unknown) => Promise<boolean>;
41
42
/**
43
* Sends a message to an extension from a renderer.
44
*/
45
postMessage(rendererId: string, message: unknown): void;
46
}
47
48