Skip to content

Commit a3f7c41

Browse files
authored
Update renderers and notebooks to use new API (#13665)
* Update renderers and notebooks to use new API
1 parent 869ec10 commit a3f7c41

File tree

19 files changed

+429
-362
lines changed

19 files changed

+429
-362
lines changed

.vscode/launch.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,6 @@
22
{
33
"version": "0.1.0",
44
"configurations": [
5-
{
6-
"name": "Node: Current File",
7-
"program": "${file}",
8-
"request": "launch",
9-
"skipFiles": [
10-
"<node_internals>/**"
11-
],
12-
"type": "pwa-node"
13-
},
14-
{
15-
"name": "Python: Current File",
16-
"type": "python",
17-
"justMyCode": true,
18-
"request": "launch",
19-
"program": "${file}",
20-
"console": "integratedTerminal",
21-
"cwd": "${workspaceFolder}"
22-
},
235
{
246
"name": "Extension",
257
"type": "extensionHost",
@@ -304,6 +286,24 @@
304286
"program": "${workspaceFolder}/node_modules/gulp/bin/gulp.js",
305287
"args": ["watch"],
306288
"skipFiles": ["<node_internals>/**"]
289+
},
290+
{
291+
"name": "Node: Current File",
292+
"program": "${file}",
293+
"request": "launch",
294+
"skipFiles": [
295+
"<node_internals>/**"
296+
],
297+
"type": "pwa-node"
298+
},
299+
{
300+
"name": "Python: Current File",
301+
"type": "python",
302+
"justMyCode": true,
303+
"request": "launch",
304+
"program": "${file}",
305+
"console": "integratedTerminal",
306+
"cwd": "${workspaceFolder}"
307307
}
308308
]
309309
}

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"theme": "dark"
2929
},
3030
"engines": {
31-
"vscode": "^1.47.0"
31+
"vscode": "^1.48.0"
3232
},
3333
"keywords": [
3434
"python",
@@ -3419,7 +3419,8 @@
34193419
},
34203420
"notebookOutputRenderer": [
34213421
{
3422-
"viewType": "jupyter-notebook-renderer",
3422+
"id": "jupyter-notebook-renderer",
3423+
"entrypoint": "./out/datascience-ui/renderers/renderers.js",
34233424
"displayName": "Jupyter Notebook Renderer",
34243425
"mimeTypes": [
34253426
"application/geo+json",
@@ -3637,6 +3638,7 @@
36373638
"@types/untildify": "^3.0.0",
36383639
"@types/uuid": "^3.4.3",
36393640
"@types/vscode": "^1.47.0",
3641+
"@types/vscode-notebook-renderer": "^1.48.0",
36403642
"@types/webpack-bundle-analyzer": "^2.13.0",
36413643
"@types/winreg": "^1.2.30",
36423644
"@types/ws": "^6.0.1",

src/client/common/application/notebook.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ import type {
1111
NotebookDocumentFilter,
1212
NotebookEditor,
1313
NotebookKernel,
14-
NotebookKernelProvider,
15-
NotebookOutputRenderer,
16-
NotebookOutputSelector
14+
NotebookKernelProvider
1715
} from 'vscode-proposed';
1816
import { UseProposedApi } from '../constants';
1917
import { IDisposableRegistry } from '../types';
@@ -107,13 +105,6 @@ export class VSCodeNotebook implements IVSCodeNotebook {
107105
): Disposable {
108106
return this.notebook.registerNotebookKernelProvider(selector, provider);
109107
}
110-
public registerNotebookOutputRenderer(
111-
id: string,
112-
outputSelector: NotebookOutputSelector,
113-
renderer: NotebookOutputRenderer
114-
): Disposable {
115-
return this.notebook.registerNotebookOutputRenderer(id, outputSelector, renderer);
116-
}
117108
private addEventHandlers() {
118109
if (this.addedEventHandlers) {
119110
return;

src/client/common/application/types.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ import type {
6767
NotebookDocumentFilter,
6868
NotebookEditor,
6969
NotebookKernel,
70-
NotebookKernelProvider,
71-
NotebookOutputRenderer,
72-
NotebookOutputSelector
70+
NotebookKernelProvider
7371
} from 'vscode-proposed';
7472
import * as vsls from 'vsls/vscode';
7573

@@ -1546,10 +1544,4 @@ export interface IVSCodeNotebook {
15461544
registerNotebookContentProvider(notebookType: string, provider: NotebookContentProvider): Disposable;
15471545

15481546
registerNotebookKernelProvider(selector: NotebookDocumentFilter, provider: NotebookKernelProvider): Disposable;
1549-
1550-
registerNotebookOutputRenderer(
1551-
id: string,
1552-
outputSelector: NotebookOutputSelector,
1553-
renderer: NotebookOutputRenderer
1554-
): Disposable;
15551547
}

src/client/datascience/notebook/integration.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { noop } from '../../common/utils/misc';
1818
import { JupyterNotebookView } from './constants';
1919
import { isJupyterNotebook } from './helpers/helpers';
2020
import { VSCodeKernelPickerProvider } from './kernelProvider';
21-
import { NotebookOutputRenderer } from './renderer';
2221
import { INotebookContentProvider } from './types';
2322

2423
const EditorAssociationUpdatedKey = 'EditorAssociationUpdatedToUseNotebooks';
@@ -36,7 +35,6 @@ export class NotebookIntegration implements IExtensionSingleActivationService {
3635
@inject(IDisposableRegistry) private readonly disposables: IDisposableRegistry,
3736
@inject(INotebookContentProvider) private readonly notebookContentProvider: INotebookContentProvider,
3837
@inject(VSCodeKernelPickerProvider) private readonly kernelProvider: VSCodeKernelPickerProvider,
39-
@inject(NotebookOutputRenderer) private readonly renderer: NotebookOutputRenderer,
4038
@inject(IApplicationEnvironment) private readonly env: IApplicationEnvironment,
4139
@inject(IApplicationShell) private readonly shell: IApplicationShell,
4240
@inject(IWorkspaceService) private readonly workspace: IWorkspaceService,
@@ -66,34 +64,6 @@ export class NotebookIntegration implements IExtensionSingleActivationService {
6664
this.kernelProvider
6765
)
6866
);
69-
this.disposables.push(
70-
this.vscNotebook.registerNotebookOutputRenderer(
71-
'jupyter-notebook-renderer',
72-
{
73-
mimeTypes: [
74-
'application/geo+json',
75-
'application/vdom.v1+json',
76-
'application/vnd.dataresource+json',
77-
'application/vnd.plotly.v1+json',
78-
'application/vnd.vega.v2+json',
79-
'application/vnd.vega.v3+json',
80-
'application/vnd.vega.v4+json',
81-
'application/vnd.vega.v5+json',
82-
'application/vnd.vegalite.v1+json',
83-
'application/vnd.vegalite.v2+json',
84-
'application/vnd.vegalite.v3+json',
85-
'application/vnd.vegalite.v4+json',
86-
'application/x-nteract-model-debug+json',
87-
'image/gif',
88-
'image/png',
89-
'image/jpeg',
90-
'text/latex',
91-
'text/vnd.plotly.v1+html'
92-
]
93-
},
94-
this.renderer
95-
)
96-
);
9767
} catch (ex) {
9868
// If something goes wrong, and we're not in Insiders & not using the NativeEditor experiment, then swallow errors.
9969
traceError('Failed to register VS Code Notebook API', ex);

src/client/datascience/notebook/notebookEditor.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
'use strict';
55

6-
import { CellKind, ConfigurationTarget, Event, EventEmitter, Uri, WebviewPanel } from 'vscode';
6+
import { ConfigurationTarget, Event, EventEmitter, Uri, WebviewPanel } from 'vscode';
77
import type { NotebookDocument } from 'vscode-proposed';
88
import { IApplicationShell, ICommandManager, IVSCodeNotebook } from '../../common/application/types';
99
import { traceError } from '../../common/logger';
@@ -23,6 +23,8 @@ import {
2323
IStatusProvider
2424
} from '../types';
2525
import { getDefaultCodeLanguage } from './helpers/helpers';
26+
// tslint:disable-next-line: no-var-requires no-require-imports
27+
const vscodeNotebookEnums = require('vscode') as typeof import('vscode-proposed');
2628

2729
export class NotebookEditor implements INotebookEditor {
2830
public readonly type = 'native';
@@ -128,7 +130,14 @@ export class NotebookEditor implements INotebookEditor {
128130
const defaultLanguage = getDefaultCodeLanguage(this.model);
129131
this.vscodeNotebook.activeNotebookEditor.edit((editor) => {
130132
const totalLength = this.document.cells.length;
131-
editor.insert(this.document.cells.length, '', defaultLanguage, CellKind.Code, [], undefined);
133+
editor.insert(
134+
this.document.cells.length,
135+
'',
136+
defaultLanguage,
137+
vscodeNotebookEnums.CellKind.Code,
138+
[],
139+
undefined
140+
);
132141
for (let i = totalLength - 1; i >= 0; i = i - 1) {
133142
editor.delete(i);
134143
}

src/client/datascience/notebook/renderer.ts

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/client/datascience/notebook/serviceRegistry.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { NotebookContentProvider } from './contentProvider';
1111
import { NotebookIntegration } from './integration';
1212
import { VSCodeKernelPickerProvider } from './kernelProvider';
1313
import { NotebookDisposeService } from './notebookDisposeService';
14-
import { NotebookOutputRenderer } from './renderer';
1514
import { NotebookSurveyBanner, NotebookSurveyDataLogger } from './survey';
1615
import { INotebookContentProvider } from './types';
1716

@@ -27,7 +26,6 @@ export function registerTypes(serviceManager: IServiceManager) {
2726
);
2827
serviceManager.addSingleton<NotebookIntegration>(NotebookIntegration, NotebookIntegration);
2928
serviceManager.addSingleton<IKernelProvider>(IKernelProvider, KernelProvider);
30-
serviceManager.addSingleton<NotebookOutputRenderer>(NotebookOutputRenderer, NotebookOutputRenderer);
3129
serviceManager.addSingleton<NotebookSurveyBanner>(NotebookSurveyBanner, NotebookSurveyBanner);
3230
serviceManager.addSingleton<VSCodeKernelPickerProvider>(VSCodeKernelPickerProvider, VSCodeKernelPickerProvider);
3331
serviceManager.addSingleton<IExtensionSingleActivationService>(

0 commit comments

Comments
 (0)