Skip to content

Commit

Permalink
notebook: convert NotebookKernelPreload to a class
Browse files Browse the repository at this point in the history
  • Loading branch information
connor4312 committed May 3, 2021
1 parent 7da0243 commit 5148712
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
22 changes: 18 additions & 4 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1764,10 +1764,24 @@ declare module 'vscode' {

//#region https://github.com/microsoft/vscode/issues/106744, NotebookKernel

// todo@API make class?
export interface NotebookKernelPreload {
provides?: string | string[];
uri: Uri;
export class NotebookKernelPreload {
/**
* APIs that the preload provides to the renderer. These are matched
* against the `dependencies` and `optionalDependencies` arrays in the
* notebook renderer contribution point.
*/
readonly provides: string[];

/**
* URI for the file to preload
*/
readonly uri: Uri;

/**
* @param uri URI for the file to preload
* @param provides Value for the `provides` property
*/
constructor(uri: Uri, provides?: string | string[]);
}

export interface NotebookCellExecuteStartContext {
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
NotebookCellMetadata: extHostTypes.NotebookCellMetadata,
NotebookCellData: extHostTypes.NotebookCellData,
NotebookData: extHostTypes.NotebookData,
NotebookKernelPreload: extHostTypes.NotebookKernelPreload,
NotebookCellStatusBarAlignment: extHostTypes.NotebookCellStatusBarAlignment,
NotebookEditorRevealType: extHostTypes.NotebookEditorRevealType,
NotebookCellOutput: extHostTypes.NotebookCellOutput,
Expand Down
6 changes: 2 additions & 4 deletions src/vs/workbench/api/common/extHostTypeConverters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1660,16 +1660,14 @@ export namespace NotebookKernelPreload {
export function from(preload: vscode.NotebookKernelPreload): { uri: UriComponents; provides: string[] } {
return {
uri: preload.uri,
// todo@connor4312: the conditional here can be removed after a migration period
provides: typeof preload.provides === 'string'
? [preload.provides]
: preload.provides ?? []
};
}
export function to(preload: { uri: UriComponents; provides: string[] }): vscode.NotebookKernelPreload {
return {
uri: URI.revive(preload.uri),
provides: preload.provides
};
return new types.NotebookKernelPreload(URI.revive(preload.uri), preload.provides);
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/vs/workbench/api/common/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3168,6 +3168,17 @@ export enum NotebookControllerAffinity {
Preferred = 2
}

export class NotebookKernelPreload {
public readonly provides: string[];

constructor(
public readonly uri: vscode.Uri,
provides: string | string[] = []
) {
this.provides = typeof provides === 'string' ? [provides] : provides;
}
}

//#endregion

//#region Timeline
Expand Down

0 comments on commit 5148712

Please sign in to comment.