Initial implementation for VSCode Notebook support (#17885)

This commit is contained in:
Cory Rivera
2022-01-03 15:59:37 -08:00
committed by GitHub
parent af5575a852
commit 2ecc3d35ca
45 changed files with 1533 additions and 260 deletions

View File

@@ -14,6 +14,7 @@ import { JSONObject } from 'sql/workbench/services/notebook/common/jsonext';
import { OutputTypes } from 'sql/workbench/services/notebook/common/contracts';
import { nbversion } from 'sql/workbench/services/notebook/common/notebookConstants';
import { nbformat } from 'sql/workbench/services/notebook/common/nbformat';
import { NBFORMAT } from 'sql/workbench/common/constants';
type MimeBundle = { [key: string]: string | string[] | undefined };
@@ -65,7 +66,7 @@ namespace v4 {
let notebook: nb.INotebookContents = {
cells: [],
metadata: contents.metadata,
nbformat: 4,
nbformat: NBFORMAT,
nbformat_minor: contents.nbformat_minor
};
@@ -206,7 +207,7 @@ namespace v3 {
cells: [],
metadata: contents.metadata,
// Note: upgrading to v4 as we're converting to our codebase
nbformat: 4,
nbformat: NBFORMAT,
nbformat_minor: nbversion.MINOR_VERSION
};

View File

@@ -112,6 +112,7 @@ export interface INotebookProviderRegistry {
readonly onNewDescriptionRegistration: Event<{ id: string, registration: ProviderDescriptionRegistration }>;
updateProviderDescriptionLanguages(providerId: string, languages: string[]): void;
registerProviderDescription(provider: ProviderDescriptionRegistration): void;
registerNotebookLanguageMagic(magic: NotebookLanguageMagicRegistration): void;
}
@@ -123,6 +124,24 @@ class NotebookProviderRegistry implements INotebookProviderRegistry {
private _onNewDescriptionRegistration = new Emitter<{ id: string, registration: ProviderDescriptionRegistration }>();
public readonly onNewDescriptionRegistration: Event<{ id: string, registration: ProviderDescriptionRegistration }> = this._onNewDescriptionRegistration.event;
updateProviderDescriptionLanguages(providerId: string, languages: string[]): void {
let registration = this._providerDescriptionRegistration.get(providerId);
if (!registration) {
throw new Error(localize('providerNotInRegistryError', "The specified provider '{0}' is not present in the notebook registry.", providerId));
}
let kernels = languages.map<azdata.nb.IStandardKernel>(language => {
return {
name: language,
displayName: language,
connectionProviderIds: []
};
});
registration.standardKernels = kernels;
// Update provider description with new info
this.registerProviderDescription(registration);
}
registerProviderDescription(registration: ProviderDescriptionRegistration): void {
this._providerDescriptionRegistration.set(registration.provider, registration);
this._onNewDescriptionRegistration.fire({ id: registration.provider, registration: registration });