mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-26 09:35:38 -05:00
Initial implementation for VSCode Notebook support (#17885)
This commit is contained in:
@@ -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
|
||||
};
|
||||
|
||||
|
||||
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user