|
@@ -42,11 +42,6 @@ import {
|
|
} from './';
|
|
} from './';
|
|
|
|
|
|
|
|
|
|
-/**
|
|
|
|
- * The inspector manager instance.
|
|
|
|
- */
|
|
|
|
-const manager = new InspectorManager();
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* The inspector instance tracker.
|
|
* The inspector instance tracker.
|
|
*/
|
|
*/
|
|
@@ -61,6 +56,7 @@ const service: JupyterLabPlugin<IInspector> = {
|
|
provides: IInspector,
|
|
provides: IInspector,
|
|
autoStart: true,
|
|
autoStart: true,
|
|
activate: (app: JupyterLab, palette: ICommandPalette, restorer: IInstanceRestorer): IInspector => {
|
|
activate: (app: JupyterLab, palette: ICommandPalette, restorer: IInstanceRestorer): IInspector => {
|
|
|
|
+ const manager = new InspectorManager();
|
|
const category = 'Inspector';
|
|
const category = 'Inspector';
|
|
const command = CommandIDs.open;
|
|
const command = CommandIDs.open;
|
|
const label = 'Open Inspector';
|
|
const label = 'Open Inspector';
|
|
@@ -113,9 +109,14 @@ const service: JupyterLabPlugin<IInspector> = {
|
|
*/
|
|
*/
|
|
const consolePlugin: JupyterLabPlugin<void> = {
|
|
const consolePlugin: JupyterLabPlugin<void> = {
|
|
id: 'jupyter.extensions.console-inspector',
|
|
id: 'jupyter.extensions.console-inspector',
|
|
- requires: [IConsoleTracker],
|
|
|
|
|
|
+ requires: [IInspector, IConsoleTracker],
|
|
autoStart: true,
|
|
autoStart: true,
|
|
- activate: (app: JupyterLab, consoles: IConsoleTracker): void => {
|
|
|
|
|
|
+ activate: (app: JupyterLab, manager: IInspector, consoles: IConsoleTracker): void => {
|
|
|
|
+ // Maintain association of new consoles with their respective handlers.
|
|
|
|
+ const handlers = new AttachedProperty<Widget, InspectionHandler>({
|
|
|
|
+ name: 'handler'
|
|
|
|
+ });
|
|
|
|
+
|
|
// Create a handler for each console that is created.
|
|
// Create a handler for each console that is created.
|
|
consoles.widgetAdded.connect((sender, parent) => {
|
|
consoles.widgetAdded.connect((sender, parent) => {
|
|
const session = parent.console.session;
|
|
const session = parent.console.session;
|
|
@@ -124,7 +125,7 @@ const consolePlugin: JupyterLabPlugin<void> = {
|
|
const handler = new InspectionHandler({ kernel, rendermime });
|
|
const handler = new InspectionHandler({ kernel, rendermime });
|
|
|
|
|
|
// Associate the handler to the widget.
|
|
// Associate the handler to the widget.
|
|
- Private.handlers.set(parent, handler);
|
|
|
|
|
|
+ handlers.set(parent, handler);
|
|
|
|
|
|
// Set the initial editor.
|
|
// Set the initial editor.
|
|
let cell = parent.console.prompt;
|
|
let cell = parent.console.prompt;
|
|
@@ -143,13 +144,14 @@ const consolePlugin: JupyterLabPlugin<void> = {
|
|
// Listen for parent disposal.
|
|
// Listen for parent disposal.
|
|
parent.disposed.connect(() => { handler.dispose(); });
|
|
parent.disposed.connect(() => { handler.dispose(); });
|
|
});
|
|
});
|
|
|
|
+
|
|
// Keep track of console instances and set inspector source.
|
|
// Keep track of console instances and set inspector source.
|
|
app.shell.currentChanged.connect((sender, args) => {
|
|
app.shell.currentChanged.connect((sender, args) => {
|
|
let widget = args.newValue;
|
|
let widget = args.newValue;
|
|
if (!widget || !consoles.has(widget)) {
|
|
if (!widget || !consoles.has(widget)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- let source = Private.handlers.get(widget);
|
|
|
|
|
|
+ let source = handlers.get(widget);
|
|
if (source) {
|
|
if (source) {
|
|
manager.source = source;
|
|
manager.source = source;
|
|
}
|
|
}
|
|
@@ -162,9 +164,14 @@ const consolePlugin: JupyterLabPlugin<void> = {
|
|
*/
|
|
*/
|
|
const notebookPlugin: JupyterLabPlugin<void> = {
|
|
const notebookPlugin: JupyterLabPlugin<void> = {
|
|
id: 'jupyter.extensions.notebook-inspector',
|
|
id: 'jupyter.extensions.notebook-inspector',
|
|
- requires: [INotebookTracker],
|
|
|
|
|
|
+ requires: [IInspector, INotebookTracker],
|
|
autoStart: true,
|
|
autoStart: true,
|
|
- activate: (app: JupyterLab, notebooks: INotebookTracker): void => {
|
|
|
|
|
|
+ activate: (app: JupyterLab, manager: IInspector, notebooks: INotebookTracker): void => {
|
|
|
|
+ // Maintain association of new notebooks with their respective handlers.
|
|
|
|
+ const handlers = new AttachedProperty<Widget, InspectionHandler>({
|
|
|
|
+ name: 'handler'
|
|
|
|
+ });
|
|
|
|
+
|
|
// Create a handler for each notebook that is created.
|
|
// Create a handler for each notebook that is created.
|
|
notebooks.widgetAdded.connect((sender, parent) => {
|
|
notebooks.widgetAdded.connect((sender, parent) => {
|
|
const kernel = parent.kernel;
|
|
const kernel = parent.kernel;
|
|
@@ -172,7 +179,7 @@ const notebookPlugin: JupyterLabPlugin<void> = {
|
|
const handler = new InspectionHandler({ kernel, rendermime });
|
|
const handler = new InspectionHandler({ kernel, rendermime });
|
|
|
|
|
|
// Associate the handler to the widget.
|
|
// Associate the handler to the widget.
|
|
- Private.handlers.set(parent, handler);
|
|
|
|
|
|
+ handlers.set(parent, handler);
|
|
|
|
|
|
// Set the initial editor.
|
|
// Set the initial editor.
|
|
let cell = parent.notebook.activeCell;
|
|
let cell = parent.notebook.activeCell;
|
|
@@ -191,13 +198,14 @@ const notebookPlugin: JupyterLabPlugin<void> = {
|
|
// Listen for parent disposal.
|
|
// Listen for parent disposal.
|
|
parent.disposed.connect(() => { handler.dispose(); });
|
|
parent.disposed.connect(() => { handler.dispose(); });
|
|
});
|
|
});
|
|
|
|
+
|
|
// Keep track of notebook instances and set inspector source.
|
|
// Keep track of notebook instances and set inspector source.
|
|
app.shell.currentChanged.connect((sender, args) => {
|
|
app.shell.currentChanged.connect((sender, args) => {
|
|
let widget = args.newValue;
|
|
let widget = args.newValue;
|
|
if (!widget || !notebooks.has(widget)) {
|
|
if (!widget || !notebooks.has(widget)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- let source = Private.handlers.get(widget);
|
|
|
|
|
|
+ let source = handlers.get(widget);
|
|
if (source) {
|
|
if (source) {
|
|
manager.source = source;
|
|
manager.source = source;
|
|
}
|
|
}
|
|
@@ -230,12 +238,4 @@ namespace Private {
|
|
type: 'hints'
|
|
type: 'hints'
|
|
}
|
|
}
|
|
];
|
|
];
|
|
-
|
|
|
|
- /**
|
|
|
|
- * A property that associates inspection handlers with their referent widgets.
|
|
|
|
- */
|
|
|
|
- export
|
|
|
|
- const handlers = new AttachedProperty<Widget, InspectionHandler>({
|
|
|
|
- name: 'handler'
|
|
|
|
- });
|
|
|
|
}
|
|
}
|