Path: blob/main/src/vs/workbench/contrib/interactive/browser/interactiveDocumentService.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 { Emitter, Event } from '../../../../base/common/event.js';6import { Disposable } from '../../../../base/common/lifecycle.js';7import { URI } from '../../../../base/common/uri.js';8import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';910export const IInteractiveDocumentService = createDecorator<IInteractiveDocumentService>('IInteractiveDocumentService');1112export interface IInteractiveDocumentService {13readonly _serviceBrand: undefined;14onWillAddInteractiveDocument: Event<{ notebookUri: URI; inputUri: URI; languageId: string }>;15onWillRemoveInteractiveDocument: Event<{ notebookUri: URI; inputUri: URI }>;16willCreateInteractiveDocument(notebookUri: URI, inputUri: URI, languageId: string): void;17willRemoveInteractiveDocument(notebookUri: URI, inputUri: URI): void;18}1920export class InteractiveDocumentService extends Disposable implements IInteractiveDocumentService {21declare readonly _serviceBrand: undefined;22private readonly _onWillAddInteractiveDocument = this._register(new Emitter<{ notebookUri: URI; inputUri: URI; languageId: string }>());23onWillAddInteractiveDocument = this._onWillAddInteractiveDocument.event;24private readonly _onWillRemoveInteractiveDocument = this._register(new Emitter<{ notebookUri: URI; inputUri: URI }>());25onWillRemoveInteractiveDocument = this._onWillRemoveInteractiveDocument.event;2627constructor() {28super();29}3031willCreateInteractiveDocument(notebookUri: URI, inputUri: URI, languageId: string) {32this._onWillAddInteractiveDocument.fire({33notebookUri,34inputUri,35languageId36});37}3839willRemoveInteractiveDocument(notebookUri: URI, inputUri: URI) {40this._onWillRemoveInteractiveDocument.fire({41notebookUri,42inputUri43});44}45}464748