Skip to content

Commit 4bb5d16

Browse files
authored
Update version & merge fix for IPyWidgets in Interactive window (#4209)
1 parent 4ad8959 commit 4bb5d16

File tree

6 files changed

+35
-24
lines changed

6 files changed

+35
-24
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 2020.12.1 (10 December 2020)
4+
5+
### Fixes
6+
7+
1. Fix support for IPyWidgets in Interactive Window.
8+
([#4203](https://github.com/Microsoft/vscode-jupyter/issues/4203))
9+
310
## 2020.12.0 (9 December 2020)
411

512
### Enhancements

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jupyter",
33
"displayName": "Jupyter",
4-
"version": "2020.12.0",
4+
"version": "2020.12.1",
55
"description": "Jupyter notebook support, interactive programming and computing that supports Intellisense, debugging and more.",
66
"publisher": "ms-toolsai",
77
"enableProposedApi": true,

src/client/datascience/ipywidgets/commonMessageCoordinator.ts

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,8 @@ export class CommonMessageCoordinator {
6262
this.jupyterOutput = this.serviceContainer.get<IOutputChannel>(IOutputChannel, JUPYTER_OUTPUT_CHANNEL);
6363
}
6464

65-
public static async create(identity: Uri, serviceContainer: IServiceContainer): Promise<CommonMessageCoordinator> {
66-
const result = new CommonMessageCoordinator(identity, serviceContainer);
67-
await result.initialize();
68-
return result;
65+
public static create(identity: Uri, serviceContainer: IServiceContainer): CommonMessageCoordinator {
66+
return new CommonMessageCoordinator(identity, serviceContainer);
6967
}
7068

7169
public dispose() {
@@ -94,6 +92,19 @@ export class CommonMessageCoordinator {
9492
this.getIPyWidgetScriptSource()?.onMessage(message, payload);
9593
}
9694

95+
public async initialize() {
96+
const dispatcher = this.getIPyWidgetMessageDispatcher();
97+
const promises = [];
98+
if (dispatcher) {
99+
promises.push(dispatcher.initialize());
100+
}
101+
const scriptSource = this.getIPyWidgetScriptSource();
102+
if (scriptSource) {
103+
promises.push(scriptSource.initialize());
104+
}
105+
return Promise.all(promises);
106+
}
107+
97108
private hash(s: string): string {
98109
return this.hashFn().update(s).digest('hex');
99110
}
@@ -164,6 +175,9 @@ export class CommonMessageCoordinator {
164175
this.ipyWidgetMessageDispatcher = this.serviceContainer
165176
.get<IPyWidgetMessageDispatcherFactory>(IPyWidgetMessageDispatcherFactory)
166177
.create(this.identity);
178+
this.disposables.push(
179+
this.ipyWidgetMessageDispatcher.postMessage(this.postEmitter.fire.bind(this.postEmitter))
180+
);
167181
}
168182
return this.ipyWidgetMessageDispatcher;
169183
}
@@ -183,23 +197,11 @@ export class CommonMessageCoordinator {
183197
this.serviceContainer.get<IPersistentStateFactory>(IPersistentStateFactory),
184198
this.serviceContainer.get<IExtensionContext>(IExtensionContext)
185199
);
200+
this.disposables.push(this.ipyWidgetScriptSource.postMessage(this.postEmitter.fire.bind(this.postEmitter)));
201+
this.disposables.push(
202+
this.ipyWidgetScriptSource.postInternalMessage(this.postEmitter.fire.bind(this.postEmitter))
203+
);
186204
}
187205
return this.ipyWidgetScriptSource;
188206
}
189-
190-
private async initialize() {
191-
const dispatcher = this.getIPyWidgetMessageDispatcher();
192-
const promises = [];
193-
if (dispatcher) {
194-
this.disposables.push(dispatcher.postMessage(this.postEmitter.fire.bind(this.postEmitter)));
195-
promises.push(dispatcher.initialize());
196-
}
197-
const scriptSource = this.getIPyWidgetScriptSource();
198-
if (scriptSource) {
199-
this.disposables.push(scriptSource.postMessage(this.postEmitter.fire.bind(this.postEmitter)));
200-
this.disposables.push(scriptSource.postInternalMessage(this.postEmitter.fire.bind(this.postEmitter)));
201-
promises.push(scriptSource.initialize());
202-
}
203-
return Promise.all(promises);
204-
}
205207
}

src/client/datascience/ipywidgets/notebookIPyWidgetCoordinator.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ export class NotebookIPyWidgetCoordinator implements INotebookKernelResolver {
3838
// entire VS code session, we have a map of notebook document to message coordinator
3939
let promise = this.messageCoordinators.get(document.uri.toString());
4040
if (!promise) {
41-
promise = CommonMessageCoordinator.create(document.uri, this.serviceContainer);
41+
const coordinator = CommonMessageCoordinator.create(document.uri, this.serviceContainer);
42+
promise = coordinator.initialize().then(() => coordinator);
4243
this.messageCoordinators.set(document.uri.toString(), promise);
4344
}
4445
return Cancellation.race(() => promise!.then(this.attachCoordinator.bind(this, document, webview)), token);

src/client/datascience/ipywidgets/webviewIPyWidgetCoordinator.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class WebviewIPyWidgetCoordinator implements IInteractiveWindowListener {
6262
// There should be an instance of the WebviewMessageCoordinator per notebook webview or interactive window. Create
6363
// the message coordinator as soon as we're sure what notebook we're in.
6464
this.notebookIdentity = args.resource;
65-
this.messageCoordinator = await CommonMessageCoordinator.create(this.notebookIdentity, this.serviceContainer);
65+
this.messageCoordinator = CommonMessageCoordinator.create(this.notebookIdentity, this.serviceContainer);
6666
this.messageCoordinatorEvent = this.messageCoordinator.postMessage((e) => {
6767
// Special case a specific message. It must be posted to the internal class, not the webview
6868
if (e.message === InteractiveWindowMessages.ConvertUriForUseInWebViewRequest) {
@@ -71,5 +71,6 @@ export class WebviewIPyWidgetCoordinator implements IInteractiveWindowListener {
7171
this.postEmitter.fire(e);
7272
}
7373
});
74+
return this.messageCoordinator.initialize();
7475
}
7576
}

0 commit comments

Comments
 (0)