Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/interactive/browser/interactiveDocumentService.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 { Emitter, Event } from '../../../../base/common/event.js';
7
import { Disposable } from '../../../../base/common/lifecycle.js';
8
import { URI } from '../../../../base/common/uri.js';
9
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
10
11
export const IInteractiveDocumentService = createDecorator<IInteractiveDocumentService>('IInteractiveDocumentService');
12
13
export interface IInteractiveDocumentService {
14
readonly _serviceBrand: undefined;
15
onWillAddInteractiveDocument: Event<{ notebookUri: URI; inputUri: URI; languageId: string }>;
16
onWillRemoveInteractiveDocument: Event<{ notebookUri: URI; inputUri: URI }>;
17
willCreateInteractiveDocument(notebookUri: URI, inputUri: URI, languageId: string): void;
18
willRemoveInteractiveDocument(notebookUri: URI, inputUri: URI): void;
19
}
20
21
export class InteractiveDocumentService extends Disposable implements IInteractiveDocumentService {
22
declare readonly _serviceBrand: undefined;
23
private readonly _onWillAddInteractiveDocument = this._register(new Emitter<{ notebookUri: URI; inputUri: URI; languageId: string }>());
24
onWillAddInteractiveDocument = this._onWillAddInteractiveDocument.event;
25
private readonly _onWillRemoveInteractiveDocument = this._register(new Emitter<{ notebookUri: URI; inputUri: URI }>());
26
onWillRemoveInteractiveDocument = this._onWillRemoveInteractiveDocument.event;
27
28
constructor() {
29
super();
30
}
31
32
willCreateInteractiveDocument(notebookUri: URI, inputUri: URI, languageId: string) {
33
this._onWillAddInteractiveDocument.fire({
34
notebookUri,
35
inputUri,
36
languageId
37
});
38
}
39
40
willRemoveInteractiveDocument(notebookUri: URI, inputUri: URI) {
41
this._onWillRemoveInteractiveDocument.fire({
42
notebookUri,
43
inputUri
44
});
45
}
46
}
47
48