Path: blob/main/src/vs/workbench/contrib/notebook/common/notebookRendererMessagingService.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Event } from '../../../../base/common/event.js';6import { IDisposable } from '../../../../base/common/lifecycle.js';7import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';89export const INotebookRendererMessagingService = createDecorator<INotebookRendererMessagingService>('INotebookRendererMessagingService');1011export interface INotebookRendererMessagingService {12readonly _serviceBrand: undefined;1314/**15* Event that fires when a message should be posted to extension hosts.16*/17onShouldPostMessage: Event<{ editorId: string; rendererId: string; message: unknown }>;1819/**20* Prepares messaging for the given renderer ID.21*/22prepare(rendererId: string): void;23/**24* Gets messaging scoped for a specific editor.25*/26getScoped(editorId: string): IScopedRendererMessaging;2728/**29* Called when the main thread gets a message for a renderer.30*/31receiveMessage(editorId: string | undefined, rendererId: string, message: unknown): Promise<boolean>;32}3334export interface IScopedRendererMessaging extends IDisposable {35/**36* Method called when a message is received. Should return a boolean37* indicating whether a renderer received it.38*/39receiveMessageHandler?: (rendererId: string, message: unknown) => Promise<boolean>;4041/**42* Sends a message to an extension from a renderer.43*/44postMessage(rendererId: string, message: unknown): void;45}464748