Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0ef5dba
Fix background (again) for ipywidgets (#11062) (#11064)
rchiodo Apr 10, 2020
4ccac22
Fix arrowing down through cells (#11095)
rchiodo Apr 11, 2020
c8fc5a5
Fix scrolling in the monaco editor (#11089)
rchiodo Apr 11, 2020
438aa3d
Fixes for UI issues (#11130)
rchiodo Apr 13, 2020
e6c627c
Cherry pick commits from master into April release (#11138)
DonJayamanne Apr 14, 2020
02fa068
Port perf fix to release branch (#11144)
rchiodo Apr 14, 2020
15c68db
Port fix for transient data in notebooks. (#11168)
rchiodo Apr 15, 2020
1fa5423
Port undo fix to release branch (#11181)
rchiodo Apr 15, 2020
d006e83
Ensure save works after saving untitled notebooks (#11190)
DonJayamanne Apr 15, 2020
397555a
Port fix for PDF saving to release (#11194)
rchiodo Apr 15, 2020
998a195
Fix scrolling when don't have focus (#11246)
rchiodo Apr 18, 2020
9dd4b7a
Account for scenarios where module name is undefined (#11248)
DonJayamanne Apr 20, 2020
9e29be4
Add message when widget script is not found on CDN (#11249)
DonJayamanne Apr 20, 2020
4c2be73
Fix failing unit tests on windows (#11191) (#11277)
karthiknadig Apr 20, 2020
04ef5b7
Display error message when fetching script source timesout (#11276)
DonJayamanne Apr 20, 2020
69d2691
Update version and change log for release (#11279)
karthiknadig Apr 20, 2020
bf6a523
Port two fixes to the release branch (#11337)
rchiodo Apr 22, 2020
b7fca7e
Wire unhandled widget messages to the jupyter output (#11273)
rchiodo Apr 20, 2020
03bfd82
Update changelog
rchiodo Apr 22, 2020
9d09af1
Cherry-pick fixes from master (#11367)
karthiknadig Apr 23, 2020
7d0ed6c
Port fixes into April point release (#11392)
DonJayamanne Apr 24, 2020
2a09546
Remove isolate script when running unittest (#11378) (#11407)
karthiknadig Apr 25, 2020
99d9681
Move runStartupCommand to global location (#11409)
rchiodo Apr 25, 2020
52b4fbf
Update version and change logs (#11408)
karthiknadig Apr 25, 2020
e9d084a
Fix widget tests (#11406)
DonJayamanne Apr 27, 2020
9fad82f
Disable CDN unit tests. Don't seem to pass on azure (#11441)
rchiodo Apr 27, 2020
f4ae575
only close interactive session on interactive window close (#11405) (…
IanMatthewHuff Apr 27, 2020
b21ff68
Merge into master
karthiknadig Apr 29, 2020
54366d8
Fix merge problems
karthiknadig Apr 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Account for scenarios where module name is undefined (#11248)
For #11241
  • Loading branch information
DonJayamanne committed Apr 20, 2020
commit 9dd4b7a896e5c40cbe92bcfe6a612363a367b438
85 changes: 4 additions & 81 deletions src/client/datascience/ipywidgets/ipyWidgetScriptSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@

'use strict';
import type * as jupyterlabService from '@jupyterlab/services';
import type * as serialize from '@jupyterlab/services/lib/kernel/serialize';
import { sha256 } from 'hash.js';
import { inject, injectable } from 'inversify';
import { IDisposable } from 'monaco-editor';
import * as path from 'path';
import { Event, EventEmitter, Uri } from 'vscode';
import type { Data as WebSocketData } from 'ws';
import { IApplicationShell, IWorkspaceService } from '../../common/application/types';
import { traceError, traceInfo } from '../../common/logger';
import { IFileSystem } from '../../common/platform/types';
Expand All @@ -29,13 +27,7 @@ import {
InteractiveWindowMessages,
IPyWidgetMessages
} from '../interactive-common/interactiveWindowTypes';
import {
IInteractiveWindowListener,
ILocalResourceUriConverter,
INotebook,
INotebookProvider,
KernelSocketInformation
} from '../types';
import { IInteractiveWindowListener, ILocalResourceUriConverter, INotebook, INotebookProvider } from '../types';
import { IPyWidgetScriptSourceProvider } from './ipyWidgetScriptSourceProvider';
import { WidgetScriptSource } from './types';
// tslint:disable: no-var-requires no-require-imports
Expand All @@ -51,13 +43,6 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener, ILocal
public get postInternalMessage(): Event<{ message: string; payload: any }> {
return this.postInternalMessageEmitter.event;
}
private get deserialize(): typeof serialize.deserialize {
if (!this.jupyterSerialize) {
// tslint:disable-next-line: no-require-imports
this.jupyterSerialize = require('@jupyterlab/services/lib/kernel/serialize') as typeof serialize;
}
return this.jupyterSerialize.deserialize;
}
private readonly resourcesMappedToExtensionFolder = new Map<string, Promise<Uri>>();
private notebookIdentity?: Uri;
private postEmitter = new EventEmitter<{
Expand All @@ -75,13 +60,10 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener, ILocal
private scriptProvider?: IPyWidgetScriptSourceProvider;
private disposables: IDisposable[] = [];
private interpreterForWhichWidgetSourcesWereFetched?: PythonInterpreter;
private kernelSocketInfo?: KernelSocketInformation;
private subscribedToKernelSocket: boolean = false;
/**
* Key value pair of widget modules along with the version that needs to be loaded.
*/
private pendingModuleRequests = new Map<string, string>();
private jupyterSerialize?: typeof serialize;
private pendingModuleRequests = new Map<string, string | undefined>();
private readonly uriConversionPromises = new Map<string, Deferred<Uri>>();
private readonly targetWidgetScriptsFolder: string;
private readonly createTargetWidgetScriptsFolder: Promise<string>;
Expand Down Expand Up @@ -195,9 +177,9 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener, ILocal
* Send the widget script source for a specific widget module & version.
* This is a request made when a widget is certainly used in a notebook.
*/
private async sendWidgetSource(moduleName: string, moduleVersion: string) {
private async sendWidgetSource(moduleName?: string, moduleVersion: string = '*') {
// Standard widgets area already available, hence no need to look for them.
if (moduleName.startsWith('@jupyter')) {
if (!moduleName || moduleName.startsWith('@jupyter')) {
return;
}
if (!this.notebook || !this.scriptProvider) {
Expand Down Expand Up @@ -264,7 +246,6 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener, ILocal
if (!this.notebook) {
return;
}
this.subscribeToKernelSocket();
this.notebook.onDisposed(() => this.dispose());
// When changing a kernel, we might have a new interpreter.
this.notebook.onKernelChanged(
Expand All @@ -285,64 +266,6 @@ export class IPyWidgetScriptSource implements IInteractiveWindowListener, ILocal
);
this.handlePendingRequests();
}
private subscribeToKernelSocket() {
if (this.subscribedToKernelSocket || !this.notebook) {
return;
}
this.subscribedToKernelSocket = true;
// Listen to changes to kernel socket (e.g. restarts or changes to kernel).
this.notebook.kernelSocket.subscribe((info) => {
// Remove old handlers.
this.kernelSocketInfo?.socket?.removeReceiveHook(this.onKernelSocketMessage.bind(this)); // NOSONAR

if (!info || !info.socket) {
// No kernel socket information, hence nothing much we can do.
this.kernelSocketInfo = undefined;
return;
}

this.kernelSocketInfo = info;
this.kernelSocketInfo.socket?.addReceiveHook(this.onKernelSocketMessage.bind(this)); // NOSONAR
});
}
/**
* If we get a comm open message, then we know a widget will be displayed.
* In this case get hold of the name and send it up (pre-fetch it before UI makes a request for it).
*/
private async onKernelSocketMessage(message: WebSocketData): Promise<void> {
// tslint:disable-next-line: no-any
const msg = this.deserialize(message as any);
if (this.jupyterLab?.KernelMessage.isCommOpenMsg(msg) && msg.content.target_module) {
this.sendWidgetSource(msg.content.target_module, '').catch(
traceError.bind('Failed to pre-load Widget Script')
);
} else if (
this.jupyterLab?.KernelMessage.isCommOpenMsg(msg) &&
msg.content.data &&
msg.content.data.state &&
// tslint:disable-next-line: no-any
((msg.content.data.state as any)._view_module || (msg.content.data.state as any)._model_module)
) {
// tslint:disable-next-line: no-any
const viewModule: string = (msg.content.data.state as any)._view_module;
// tslint:disable-next-line: no-any
const viewModuleVersion: string = (msg.content.data.state as any)._view_module_version;
// tslint:disable-next-line: no-any
const modelModule = (msg.content.data.state as any)._model_module;
// tslint:disable-next-line: no-any
const modelModuleVersion = (msg.content.data.state as any)._model_module_version;
if (viewModule) {
this.sendWidgetSource(viewModule, modelModuleVersion || '').catch(
traceError.bind('Failed to pre-load Widget Script')
);
}
if (modelModule) {
this.sendWidgetSource(viewModule, viewModuleVersion || '').catch(
traceError.bind('Failed to pre-load Widget Script')
);
}
}
}
private handlePendingRequests() {
const pendingModuleNames = Array.from(this.pendingModuleRequests.keys());
while (pendingModuleNames.length) {
Expand Down