|
| 1 | +diff --git a/lib/index.js b/lib/index.js |
| 2 | +index bbafe18540f26d4939ab94c6537bd42b88824a0e..f3056c125a53d0795cdc890a98ab70be1f64eb9d 100644 |
| 3 | +--- a/lib/index.js |
| 4 | ++++ b/lib/index.js |
| 5 | +@@ -6,6 +6,7 @@ |
| 6 | + */ |
| 7 | + import { ILabShell, ILayoutRestorer } from '@jupyterlab/application'; |
| 8 | + import { ICommandPalette, MainAreaWidget, WidgetTracker } from '@jupyterlab/apputils'; |
| 9 | ++import { DocumentWidget } from '@jupyterlab/docregistry'; |
| 10 | + import { ILoggerRegistry, LogConsolePanel, LoggerRegistry } from '@jupyterlab/logconsole'; |
| 11 | + import { IRenderMimeRegistry } from '@jupyterlab/rendermime'; |
| 12 | + import { ISettingRegistry } from '@jupyterlab/settingregistry'; |
| 13 | +@@ -34,14 +35,20 @@ const logConsolePlugin = { |
| 14 | + id: LOG_CONSOLE_PLUGIN_ID, |
| 15 | + description: 'Provides the logger registry.', |
| 16 | + provides: ILoggerRegistry, |
| 17 | +- requires: [ILabShell, IRenderMimeRegistry, ITranslator], |
| 18 | +- optional: [ICommandPalette, ILayoutRestorer, ISettingRegistry, IStatusBar], |
| 19 | ++ requires: [IRenderMimeRegistry, ITranslator], |
| 20 | ++ optional: [ |
| 21 | ++ ILabShell, |
| 22 | ++ ICommandPalette, |
| 23 | ++ ILayoutRestorer, |
| 24 | ++ ISettingRegistry, |
| 25 | ++ IStatusBar |
| 26 | ++ ], |
| 27 | + autoStart: true |
| 28 | + }; |
| 29 | + /** |
| 30 | + * Activate the Log Console extension. |
| 31 | + */ |
| 32 | +-function activateLogConsole(app, labShell, rendermime, translator, palette, restorer, settingRegistry, statusBar) { |
| 33 | ++function activateLogConsole(app, rendermime, translator, labShell, palette, restorer, settingRegistry, statusBar) { |
| 34 | + const trans = translator.load('jupyterlab'); |
| 35 | + let logConsoleWidget = null; |
| 36 | + let logConsolePanel = null; |
| 37 | +@@ -75,10 +82,21 @@ function activateLogConsole(app, labShell, rendermime, translator, palette, rest |
| 38 | + }, |
| 39 | + translator |
| 40 | + }); |
| 41 | ++ const getCurrentWidgetPath = () => { |
| 42 | ++ const currentWidget = app.shell.currentWidget; |
| 43 | ++ if (labShell === null || labShell === void 0 ? void 0 : labShell.currentPath) { |
| 44 | ++ return labShell.currentPath; |
| 45 | ++ } |
| 46 | ++ // For other shells, set the source to the current widget path |
| 47 | ++ if (currentWidget && currentWidget instanceof DocumentWidget) { |
| 48 | ++ return currentWidget.context.path; |
| 49 | ++ } |
| 50 | ++ return null; |
| 51 | ++ }; |
| 52 | + const createLogConsoleWidget = (options = {}) => { |
| 53 | + var _a, _b; |
| 54 | + logConsolePanel = new LogConsolePanel(loggerRegistry, translator); |
| 55 | +- logConsolePanel.source = (_b = (_a = options.source) !== null && _a !== void 0 ? _a : labShell.currentPath) !== null && _b !== void 0 ? _b : null; |
| 56 | ++ logConsolePanel.source = (_b = (_a = options.source) !== null && _a !== void 0 ? _a : getCurrentWidgetPath()) !== null && _b !== void 0 ? _b : null; |
| 57 | + logConsoleWidget = new MainAreaWidget({ content: logConsolePanel }); |
| 58 | + logConsoleWidget.addClass('jp-LogConsole'); |
| 59 | + logConsoleWidget.title.closable = true; |
| 60 | +@@ -194,8 +212,13 @@ function activateLogConsole(app, labShell, rendermime, translator, palette, rest |
| 61 | + var _a; |
| 62 | + // Set source only after app is restored in order to allow restorer to |
| 63 | + // restore previous source first, which may set the renderer |
| 64 | +- labShell.currentPathChanged.connect((_, { newValue }) => setSource(newValue)); |
| 65 | +- setSource((_a = labShell.currentPath) !== null && _a !== void 0 ? _a : null); |
| 66 | ++ if (labShell) { |
| 67 | ++ labShell.currentPathChanged.connect((_, { newValue }) => setSource(newValue)); |
| 68 | ++ setSource((_a = labShell.currentPath) !== null && _a !== void 0 ? _a : null); |
| 69 | ++ } |
| 70 | ++ else { |
| 71 | ++ setSource(getCurrentWidgetPath()); |
| 72 | ++ } |
| 73 | + }); |
| 74 | + if (settingRegistry) { |
| 75 | + const updateSettings = (settings) => { |
0 commit comments