@datalayer/jupyter-react 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +4 -0
- package/package.json +16 -11
- package/lib/components/cell/Cell.d.ts +0 -15
- package/lib/components/cell/Cell.js +0 -48
- package/lib/components/cell/CellAdapter.d.ts +0 -14
- package/lib/components/cell/CellAdapter.js +0 -133
- package/lib/components/cell/CellCommands.d.ts +0 -6
- package/lib/components/cell/CellCommands.js +0 -37
- package/lib/components/cell/CellState.d.ts +0 -22
- package/lib/components/cell/CellState.js +0 -45
- package/lib/components/commands/Commands.d.ts +0 -2
- package/lib/components/commands/Commands.js +0 -8
- package/lib/components/commands/CommandsAdapter.d.ts +0 -9
- package/lib/components/commands/CommandsAdapter.js +0 -35
- package/lib/components/commands/CommandsState.d.ts +0 -15
- package/lib/components/commands/CommandsState.js +0 -29
- package/lib/components/console/Console.d.ts +0 -2
- package/lib/components/console/Console.js +0 -8
- package/lib/components/console/ConsoleAdapter.d.ts +0 -11
- package/lib/components/console/ConsoleAdapter.js +0 -85
- package/lib/components/console/ConsoleState.d.ts +0 -15
- package/lib/components/console/ConsoleState.js +0 -29
- package/lib/components/dialog/Dialog.d.ts +0 -2
- package/lib/components/dialog/Dialog.js +0 -12
- package/lib/components/dialog/DialogAdapter.d.ts +0 -10
- package/lib/components/dialog/DialogAdapter.js +0 -18
- package/lib/components/editor/CodeMirrorEditor.d.ts +0 -7
- package/lib/components/editor/CodeMirrorEditor.js +0 -61
- package/lib/components/filebrowser/FileBrowser.d.ts +0 -2
- package/lib/components/filebrowser/FileBrowser.js +0 -8
- package/lib/components/filebrowser/FileBrowserAdapter.d.ts +0 -13
- package/lib/components/filebrowser/FileBrowserAdapter.js +0 -266
- package/lib/components/filebrowser/FileBrowserState.d.ts +0 -15
- package/lib/components/filebrowser/FileBrowserState.js +0 -29
- package/lib/components/filebrowser/FileBrowserTree.d.ts +0 -2
- package/lib/components/filebrowser/FileBrowserTree.js +0 -59
- package/lib/components/ipywidgets/IpyWidgetsComponent.d.ts +0 -5
- package/lib/components/ipywidgets/IpyWidgetsComponent.js +0 -8
- package/lib/components/notebook/Notebook.d.ts +0 -25
- package/lib/components/notebook/Notebook.js +0 -78
- package/lib/components/notebook/NotebookAdapter.d.ts +0 -25
- package/lib/components/notebook/NotebookAdapter.js +0 -186
- package/lib/components/notebook/NotebookCommands.d.ts +0 -38
- package/lib/components/notebook/NotebookCommands.js +0 -368
- package/lib/components/notebook/NotebookState.d.ts +0 -49
- package/lib/components/notebook/NotebookState.js +0 -116
- package/lib/components/notebook/content/CellSidebar.d.ts +0 -8
- package/lib/components/notebook/content/CellSidebar.js +0 -22
- package/lib/components/notebook/content/ContentFactoryWithSidebar.d.ts +0 -14
- package/lib/components/notebook/content/ContentFactoryWithSidebar.js +0 -19
- package/lib/components/notebook/content/NotebookInputPrompt.d.ts +0 -21
- package/lib/components/notebook/content/NotebookInputPrompt.js +0 -66
- package/lib/components/notebook/render/marked.d.ts +0 -3
- package/lib/components/notebook/render/marked.js +0 -71
- package/lib/components/outputs/Output.d.ts +0 -16
- package/lib/components/outputs/Output.js +0 -55
- package/lib/components/outputs/OutputAdapter.d.ts +0 -20
- package/lib/components/outputs/OutputAdapter.js +0 -69
- package/lib/components/outputs/OutputState.d.ts +0 -15
- package/lib/components/outputs/OutputState.js +0 -29
- package/lib/components/settings/Settings.d.ts +0 -2
- package/lib/components/settings/Settings.js +0 -8
- package/lib/components/settings/SettingsAdapter.d.ts +0 -10
- package/lib/components/settings/SettingsAdapter.js +0 -15
- package/lib/components/settings/SettingsState.d.ts +0 -15
- package/lib/components/settings/SettingsState.js +0 -29
- package/lib/components/terminal/Terminal.d.ts +0 -2
- package/lib/components/terminal/Terminal.js +0 -15
- package/lib/components/terminal/TerminalAdapter.d.ts +0 -13
- package/lib/components/terminal/TerminalAdapter.js +0 -27
- package/lib/components/terminal/TerminalState.d.ts +0 -15
- package/lib/components/terminal/TerminalState.js +0 -37
- package/lib/index.d.ts +0 -23
- package/lib/index.js +0 -35
- package/lib/jupyter/AuthError.d.ts +0 -7
- package/lib/jupyter/AuthError.js +0 -7
- package/lib/jupyter/Handlers.d.ts +0 -8
- package/lib/jupyter/Handlers.js +0 -49
- package/lib/jupyter/Jupyter.d.ts +0 -23
- package/lib/jupyter/Jupyter.js +0 -34
- package/lib/jupyter/JupyterConfig.d.ts +0 -37
- package/lib/jupyter/JupyterConfig.js +0 -58
- package/lib/jupyter/JupyterContext.d.ts +0 -35
- package/lib/jupyter/JupyterContext.js +0 -63
- package/lib/jupyter/ipywidgets/IPyWidgetsAttached.d.ts +0 -8
- package/lib/jupyter/ipywidgets/IPyWidgetsAttached.js +0 -14
- package/lib/jupyter/ipywidgets/IPyWidgetsClassicManager.d.ts +0 -18
- package/lib/jupyter/ipywidgets/IPyWidgetsClassicManager.js +0 -75
- package/lib/jupyter/ipywidgets/IPyWidgetsJupyterLabPlugin.d.ts +0 -15
- package/lib/jupyter/ipywidgets/IPyWidgetsJupyterLabPlugin.js +0 -177
- package/lib/jupyter/ipywidgets/IpyWidgetsManager.d.ts +0 -11
- package/lib/jupyter/ipywidgets/IpyWidgetsManager.js +0 -70
- package/lib/jupyter/ipywidgets/plotly/Figure.d.ts +0 -587
- package/lib/jupyter/ipywidgets/plotly/Figure.js +0 -1696
- package/lib/jupyter/ipywidgets/plotly/JupyterlabPlugin.d.ts +0 -5
- package/lib/jupyter/ipywidgets/plotly/JupyterlabPlugin.js +0 -11
- package/lib/jupyter/ipywidgets/plotly/Version.d.ts +0 -8
- package/lib/jupyter/ipywidgets/plotly/Version.js +0 -15
- package/lib/jupyter/ipywidgets/plotly/index.d.ts +0 -2
- package/lib/jupyter/ipywidgets/plotly/index.js +0 -3
- package/lib/jupyter/lumino/LuminoAttached.d.ts +0 -9
- package/lib/jupyter/lumino/LuminoAttached.js +0 -22
- package/lib/jupyter/lumino/LuminoDetached.d.ts +0 -9
- package/lib/jupyter/lumino/LuminoDetached.js +0 -12
- package/lib/jupyter/lumino/LuminoObservable.d.ts +0 -6
- package/lib/jupyter/lumino/LuminoObservable.js +0 -15
- package/lib/jupyter/lumino/LuminoReactPortal.d.ts +0 -180
- package/lib/jupyter/lumino/LuminoReactPortal.js +0 -194
- package/lib/jupyter/lumino/LuminoRedux.d.ts +0 -8
- package/lib/jupyter/lumino/LuminoRedux.js +0 -1
- package/lib/jupyter/services/Services.d.ts +0 -16
- package/lib/jupyter/services/Services.js +0 -40
- package/lib/jupyter/services/kernel/Kernel.d.ts +0 -15
- package/lib/jupyter/services/kernel/Kernel.js +0 -64
- package/lib/jupyter/services/kernel/KernelModel.d.ts +0 -18
- package/lib/jupyter/services/kernel/KernelModel.js +0 -51
- package/lib/state/State.d.ts +0 -14
- package/lib/state/State.js +0 -31
- package/lib/state/Store.d.ts +0 -4
- package/lib/state/Store.js +0 -38
- package/lib/state/init/Init.d.ts +0 -3
- package/lib/state/init/Init.js +0 -11
- package/lib/state/init/InitState.d.ts +0 -19
- package/lib/state/init/InitState.js +0 -47
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Copyright (c) Datalayer Inc. All rights reserved.
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
[](https://datalayer.io)
|
|
2
2
|
|
|
3
3
|
# Jupyter React
|
|
4
|
+
|
|
5
|
+
<div align="center" style="text-align: center">
|
|
6
|
+
<img alt="Jupyter React Gallery" src="https://datalayer-jupyter-examples.s3.amazonaws.com/jupyter-react-gallery.gif" />
|
|
7
|
+
</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datalayer/jupyter-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Jupyter React",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
"react",
|
|
15
15
|
"jupyterlab"
|
|
16
16
|
],
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/datalayer/jupyter-react.git",
|
|
20
|
+
"directory": "packages/react"
|
|
21
|
+
},
|
|
17
22
|
"scripts": {
|
|
18
23
|
"build": "gulp resources-to-lib && tsc && NODE_OPTIONS=\"${NODE_OPTIONS}\" webpack",
|
|
19
24
|
"build:prod": "gulp resources-to-lib && tsc && NODE_OPTIONS=\"${NODE_OPTIONS}\"",
|
|
@@ -31,6 +36,8 @@
|
|
|
31
36
|
"@codemirror/basic-setup": "0.19.0",
|
|
32
37
|
"@codemirror/lang-python": "0.19.2",
|
|
33
38
|
"@datalayer/typescript-fsa-redux-observable": "0.18.0",
|
|
39
|
+
"@emotion/react": "11.4.0",
|
|
40
|
+
"@emotion/styled": "11.3.0",
|
|
34
41
|
"@jupyter-widgets/base": "6.0.0-rc.1",
|
|
35
42
|
"@jupyter-widgets/controls": "5.0.0-rc.1",
|
|
36
43
|
"@jupyter-widgets/html-manager": "1.0.0-rc.1",
|
|
@@ -65,6 +72,13 @@
|
|
|
65
72
|
"@lumino/coreutils": "1.12.0",
|
|
66
73
|
"@lumino/default-theme": "0.21.1",
|
|
67
74
|
"@lumino/widgets": "1.31.1",
|
|
75
|
+
"@mui/material": "5.8.3",
|
|
76
|
+
"@mui/icons-material": "5.8.3",
|
|
77
|
+
"@mui/lab": "5.0.0-alpha.85",
|
|
78
|
+
"@mui/styles": "5.8.3",
|
|
79
|
+
"@mui/system": "5.8.3",
|
|
80
|
+
"@primer/react": "35.3.0",
|
|
81
|
+
"assert": "2.0.0",
|
|
68
82
|
"marked": "4.0.10",
|
|
69
83
|
"lodash": "^4.17.4",
|
|
70
84
|
"plotly.js": "2.11.1",
|
|
@@ -75,6 +89,7 @@
|
|
|
75
89
|
"redux": "4.1.0",
|
|
76
90
|
"redux-observable": "1.2.0",
|
|
77
91
|
"rxjs": "6.6.0",
|
|
92
|
+
"stream": "0.0.2",
|
|
78
93
|
"typescript-fsa": "3.0.0",
|
|
79
94
|
"typescript-fsa-reducers": "1.2.1",
|
|
80
95
|
"uuid": "8.3.2"
|
|
@@ -91,15 +106,6 @@
|
|
|
91
106
|
"@types/react": "18.0.9",
|
|
92
107
|
"@types/react-dom": "18.0.5",
|
|
93
108
|
"@types/uuid": "8.3.0",
|
|
94
|
-
"@emotion/react": "11.4.0",
|
|
95
|
-
"@emotion/styled": "11.3.0",
|
|
96
|
-
"@mui/material": "5.8.3",
|
|
97
|
-
"@mui/icons-material": "5.8.3",
|
|
98
|
-
"@mui/lab": "5.0.0-alpha.85",
|
|
99
|
-
"@mui/styles": "5.8.3",
|
|
100
|
-
"@mui/system": "5.8.3",
|
|
101
|
-
"@primer/react": "35.3.0",
|
|
102
|
-
"assert": "2.0.0",
|
|
103
109
|
"babel-loader": "8.2.2",
|
|
104
110
|
"bundle-loader": "0.5.6",
|
|
105
111
|
"css-loader": "5.2.4",
|
|
@@ -110,7 +116,6 @@
|
|
|
110
116
|
"gulp-watch": "5.0.1",
|
|
111
117
|
"html-webpack-plugin": "5.3.1",
|
|
112
118
|
"html-webpack-tags-plugin": "2.0.17",
|
|
113
|
-
"mini-css-extract-plugin": "~0.9.0",
|
|
114
119
|
"npm-run-all": "4.1.5",
|
|
115
120
|
"process": "^0.11.10",
|
|
116
121
|
"raw-loader": "~4.0.0",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import '@jupyterlab/application/style/index.css';
|
|
2
|
-
import '@jupyterlab/cells/style/index.css';
|
|
3
|
-
import '@jupyterlab/completer/style/index.css';
|
|
4
|
-
import '@jupyterlab/theme-light-extension/style/theme.css';
|
|
5
|
-
import '@jupyterlab/theme-light-extension/style/variables.css';
|
|
6
|
-
import './Cell.css';
|
|
7
|
-
export declare type ICellProps = {
|
|
8
|
-
source?: string;
|
|
9
|
-
autoStart?: boolean;
|
|
10
|
-
};
|
|
11
|
-
declare const Cell: {
|
|
12
|
-
(props: ICellProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
13
|
-
defaultProps: Partial<ICellProps>;
|
|
14
|
-
};
|
|
15
|
-
export default Cell;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { useMemo, useEffect } from 'react';
|
|
3
|
-
import { useDispatch } from "react-redux";
|
|
4
|
-
import { CodeCell } from '@jupyterlab/cells';
|
|
5
|
-
import { cellActions } from './CellState';
|
|
6
|
-
import CellAdapter from './CellAdapter';
|
|
7
|
-
import LuminoAttached from '../../jupyter/lumino/LuminoAttached';
|
|
8
|
-
import '@jupyterlab/application/style/index.css';
|
|
9
|
-
import '@jupyterlab/cells/style/index.css';
|
|
10
|
-
import '@jupyterlab/completer/style/index.css';
|
|
11
|
-
// This should be only index.css, looks like jupyterlab has a regression here...
|
|
12
|
-
import '@jupyterlab/theme-light-extension/style/theme.css';
|
|
13
|
-
import '@jupyterlab/theme-light-extension/style/variables.css';
|
|
14
|
-
import './Cell.css';
|
|
15
|
-
const DEFAULT_SOURCE = `from IPython.display import display
|
|
16
|
-
|
|
17
|
-
for i in range(10):
|
|
18
|
-
display('String {} added to the DOM in separated DIV.'.format(i))`;
|
|
19
|
-
const Cell = (props) => {
|
|
20
|
-
const adapter = useMemo(() => new CellAdapter(props.source), []);
|
|
21
|
-
const dispatch = useDispatch();
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
dispatch(cellActions.update({ adapter }));
|
|
24
|
-
dispatch(cellActions.source(props.source));
|
|
25
|
-
adapter.codeCell.model.value.changed.connect((sender, changedArgs) => {
|
|
26
|
-
dispatch(cellActions.source(sender.text));
|
|
27
|
-
});
|
|
28
|
-
adapter.codeCell.outputArea.outputLengthChanged.connect((_, outputsCount) => {
|
|
29
|
-
dispatch(cellActions.outputsCount(outputsCount));
|
|
30
|
-
});
|
|
31
|
-
adapter.sessionContext.initialize().then(() => {
|
|
32
|
-
if (props.autoStart) {
|
|
33
|
-
const executePromise = CodeCell.execute(adapter.codeCell, adapter.sessionContext);
|
|
34
|
-
executePromise.then((msg) => {
|
|
35
|
-
dispatch(cellActions.update({
|
|
36
|
-
kernelAvailable: true,
|
|
37
|
-
}));
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}, []);
|
|
42
|
-
return _jsx(LuminoAttached, { children: adapter.panel }, void 0);
|
|
43
|
-
};
|
|
44
|
-
Cell.defaultProps = {
|
|
45
|
-
source: DEFAULT_SOURCE,
|
|
46
|
-
autoStart: true,
|
|
47
|
-
};
|
|
48
|
-
export default Cell;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { BoxPanel } from '@lumino/widgets';
|
|
2
|
-
import { SessionContext } from '@jupyterlab/apputils';
|
|
3
|
-
import { CodeCell } from '@jupyterlab/cells';
|
|
4
|
-
export declare class CellAdapter {
|
|
5
|
-
private _codeCell;
|
|
6
|
-
private _cellPanel;
|
|
7
|
-
private _sessionContext;
|
|
8
|
-
constructor(source: string);
|
|
9
|
-
get panel(): BoxPanel;
|
|
10
|
-
get codeCell(): CodeCell;
|
|
11
|
-
get sessionContext(): SessionContext;
|
|
12
|
-
execute: () => void;
|
|
13
|
-
}
|
|
14
|
-
export default CellAdapter;
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { BoxPanel, Widget } from '@lumino/widgets';
|
|
2
|
-
import { SessionContext, Toolbar, ToolbarButton } from '@jupyterlab/apputils';
|
|
3
|
-
import { CodeCellModel, CodeCell } from '@jupyterlab/cells';
|
|
4
|
-
import { CodeMirrorMimeTypeService } from '@jupyterlab/codemirror';
|
|
5
|
-
import { runIcon } from '@jupyterlab/ui-components';
|
|
6
|
-
import { Completer, CompleterModel, CompletionHandler, ConnectorProxy, KernelCompleterProvider } from '@jupyterlab/completer';
|
|
7
|
-
import { RenderMimeRegistry, standardRendererFactories as initialFactories } from '@jupyterlab/rendermime';
|
|
8
|
-
import { SessionManager, KernelManager, KernelSpecManager } from '@jupyterlab/services';
|
|
9
|
-
import { ServerConnection } from '@jupyterlab/services';
|
|
10
|
-
import { CommandRegistry } from '@lumino/commands';
|
|
11
|
-
import { IPyWidgetsClassicManager } from "../../jupyter/ipywidgets/IPyWidgetsClassicManager";
|
|
12
|
-
import { requireLoader } from "@jupyter-widgets/html-manager";
|
|
13
|
-
import { WIDGET_MIMETYPE, WidgetRenderer } from "@jupyter-widgets/html-manager/lib/output_renderers";
|
|
14
|
-
import CellCommands from './CellCommands';
|
|
15
|
-
export class CellAdapter {
|
|
16
|
-
constructor(source) {
|
|
17
|
-
this.execute = () => {
|
|
18
|
-
CodeCell.execute(this._codeCell, this._sessionContext);
|
|
19
|
-
};
|
|
20
|
-
this._cellPanel = new BoxPanel();
|
|
21
|
-
this._cellPanel.direction = 'top-to-bottom';
|
|
22
|
-
this._cellPanel.spacing = 0;
|
|
23
|
-
this._cellPanel.addClass('dla-JupyterCell');
|
|
24
|
-
const serverSettings = ServerConnection.makeSettings({
|
|
25
|
-
appendToken: true,
|
|
26
|
-
init: {
|
|
27
|
-
credentials: "include",
|
|
28
|
-
mode: 'cors',
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
const kernelManager = new KernelManager({
|
|
32
|
-
serverSettings
|
|
33
|
-
});
|
|
34
|
-
const specsManager = new KernelSpecManager({
|
|
35
|
-
serverSettings
|
|
36
|
-
});
|
|
37
|
-
const sessionManager = new SessionManager({
|
|
38
|
-
serverSettings,
|
|
39
|
-
kernelManager
|
|
40
|
-
});
|
|
41
|
-
this._sessionContext = new SessionContext({
|
|
42
|
-
sessionManager,
|
|
43
|
-
specsManager,
|
|
44
|
-
name: 'Datalayer'
|
|
45
|
-
});
|
|
46
|
-
const mimeService = new CodeMirrorMimeTypeService();
|
|
47
|
-
const commands = new CommandRegistry();
|
|
48
|
-
const useCapture = true;
|
|
49
|
-
document.addEventListener('keydown', event => {
|
|
50
|
-
commands.processKeydownEvent(event);
|
|
51
|
-
}, useCapture);
|
|
52
|
-
const rendermime = new RenderMimeRegistry({ initialFactories });
|
|
53
|
-
const iPyWidgetsClassicManager = new IPyWidgetsClassicManager({ loader: requireLoader });
|
|
54
|
-
rendermime.addFactory({
|
|
55
|
-
safe: false,
|
|
56
|
-
mimeTypes: [WIDGET_MIMETYPE],
|
|
57
|
-
createRenderer: (options) => new WidgetRenderer(options, iPyWidgetsClassicManager),
|
|
58
|
-
}, 0);
|
|
59
|
-
const codeCell = new CodeCell({
|
|
60
|
-
rendermime,
|
|
61
|
-
model: new CodeCellModel({
|
|
62
|
-
cell: {
|
|
63
|
-
cell_type: 'code',
|
|
64
|
-
source: source,
|
|
65
|
-
metadata: {}
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
});
|
|
69
|
-
this._sessionContext.kernelChanged.connect((sender, arg) => {
|
|
70
|
-
const kernelConnection = arg.newValue;
|
|
71
|
-
iPyWidgetsClassicManager.registerWithKernel(kernelConnection);
|
|
72
|
-
});
|
|
73
|
-
this._codeCell = codeCell.initializeState();
|
|
74
|
-
this._sessionContext.kernelChanged.connect(() => {
|
|
75
|
-
var _a, _b;
|
|
76
|
-
void ((_b = (_a = this._sessionContext.session) === null || _a === void 0 ? void 0 : _a.kernel) === null || _b === void 0 ? void 0 : _b.info.then(info => {
|
|
77
|
-
const lang = info.language_info;
|
|
78
|
-
const mimeType = mimeService.getMimeTypeByLanguage(lang);
|
|
79
|
-
this._codeCell.model.mimeType = mimeType;
|
|
80
|
-
}));
|
|
81
|
-
});
|
|
82
|
-
this._sessionContext.kernelPreference = { autoStartDefault: true };
|
|
83
|
-
const editor = this._codeCell.editor;
|
|
84
|
-
const model = new CompleterModel();
|
|
85
|
-
const completer = new Completer({ editor, model });
|
|
86
|
-
const timeout = 1000;
|
|
87
|
-
const provider = new KernelCompleterProvider();
|
|
88
|
-
const connector = new ConnectorProxy({ widget: this._codeCell, editor, session: this._sessionContext.session }, [provider], timeout);
|
|
89
|
-
const handler = new CompletionHandler({ completer, connector });
|
|
90
|
-
void this._sessionContext.ready.then(() => {
|
|
91
|
-
const provider = new KernelCompleterProvider();
|
|
92
|
-
handler.connector = new ConnectorProxy({ widget: this._codeCell, editor, session: this._sessionContext.session }, [provider], timeout);
|
|
93
|
-
});
|
|
94
|
-
handler.editor = editor;
|
|
95
|
-
CellCommands(commands, this._codeCell, this._sessionContext, handler);
|
|
96
|
-
completer.hide();
|
|
97
|
-
completer.addClass('jp-Completer-Cell');
|
|
98
|
-
Widget.attach(completer, document.body);
|
|
99
|
-
const toolbar = new Toolbar();
|
|
100
|
-
toolbar.addItem('spacer', Toolbar.createSpacerItem());
|
|
101
|
-
const runButton = new ToolbarButton({
|
|
102
|
-
icon: runIcon,
|
|
103
|
-
onClick: () => {
|
|
104
|
-
CodeCell.execute(this._codeCell, this._sessionContext);
|
|
105
|
-
},
|
|
106
|
-
tooltip: 'Run'
|
|
107
|
-
});
|
|
108
|
-
toolbar.addItem('run', runButton);
|
|
109
|
-
toolbar.addItem('interrupt', Toolbar.createInterruptButton(this._sessionContext));
|
|
110
|
-
toolbar.addItem('restart', Toolbar.createRestartButton(this._sessionContext));
|
|
111
|
-
// toolbar.addItem('name', Toolbar.createKernelNameItem(this._sessionContext));
|
|
112
|
-
toolbar.addItem('status', Toolbar.createKernelStatusItem(this._sessionContext));
|
|
113
|
-
this._cellPanel.addWidget(toolbar);
|
|
114
|
-
BoxPanel.setStretch(toolbar, 0);
|
|
115
|
-
this._cellPanel.addWidget(this._codeCell);
|
|
116
|
-
BoxPanel.setStretch(this._codeCell, 1);
|
|
117
|
-
window.addEventListener('resize', () => {
|
|
118
|
-
this._cellPanel.update();
|
|
119
|
-
});
|
|
120
|
-
this._codeCell.outputsScrolled = false;
|
|
121
|
-
this._codeCell.activate();
|
|
122
|
-
}
|
|
123
|
-
get panel() {
|
|
124
|
-
return this._cellPanel;
|
|
125
|
-
}
|
|
126
|
-
get codeCell() {
|
|
127
|
-
return this._codeCell;
|
|
128
|
-
}
|
|
129
|
-
get sessionContext() {
|
|
130
|
-
return this._sessionContext;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
export default CellAdapter;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { CommandRegistry } from "@lumino/commands";
|
|
2
|
-
import { CompletionHandler } from "@jupyterlab/completer";
|
|
3
|
-
import { CodeCell } from '@jupyterlab/cells';
|
|
4
|
-
import { SessionContext } from '@jupyterlab/apputils';
|
|
5
|
-
export declare const CellCommands: (commandRegistry: CommandRegistry, codeCell: CodeCell, sessionContext: SessionContext, completerHandler: CompletionHandler) => void;
|
|
6
|
-
export default CellCommands;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { CodeCell } from '@jupyterlab/cells';
|
|
2
|
-
const cmdIds = {
|
|
3
|
-
invoke: "completer:invoke",
|
|
4
|
-
select: "completer:select",
|
|
5
|
-
};
|
|
6
|
-
export const CellCommands = (commandRegistry, codeCell, sessionContext, completerHandler) => {
|
|
7
|
-
commandRegistry.addCommand(cmdIds.invoke, {
|
|
8
|
-
label: "Completer: Invoke",
|
|
9
|
-
execute: () => completerHandler.invoke(),
|
|
10
|
-
});
|
|
11
|
-
commandRegistry.addCommand(cmdIds.select, {
|
|
12
|
-
label: "Completer: Select",
|
|
13
|
-
execute: () => completerHandler.completer.selectActive(),
|
|
14
|
-
});
|
|
15
|
-
commandRegistry.addCommand('run:cell', {
|
|
16
|
-
execute: () => CodeCell.execute(codeCell, sessionContext)
|
|
17
|
-
});
|
|
18
|
-
commandRegistry.addKeyBinding({
|
|
19
|
-
selector: '.jp-InputArea-editor.jp-mod-completer-enabled',
|
|
20
|
-
keys: ['Tab'],
|
|
21
|
-
command: cmdIds.invoke
|
|
22
|
-
});
|
|
23
|
-
commandRegistry.addKeyBinding({
|
|
24
|
-
selector: '.jp-InputArea-editor',
|
|
25
|
-
keys: ['Shift Enter'],
|
|
26
|
-
command: 'run:cell'
|
|
27
|
-
});
|
|
28
|
-
const bindings = [
|
|
29
|
-
{
|
|
30
|
-
selector: `.jp-InputArea-editor.jp-mod-completer-active`,
|
|
31
|
-
keys: ["Enter"],
|
|
32
|
-
command: cmdIds.select,
|
|
33
|
-
},
|
|
34
|
-
];
|
|
35
|
-
bindings.map((binding) => commandRegistry.addKeyBinding(binding));
|
|
36
|
-
};
|
|
37
|
-
export default CellCommands;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import CellAdapter from "./CellAdapter";
|
|
2
|
-
export interface ICellState {
|
|
3
|
-
source: string;
|
|
4
|
-
outputsCount: number;
|
|
5
|
-
kernelAvailable: boolean;
|
|
6
|
-
adapter?: CellAdapter;
|
|
7
|
-
}
|
|
8
|
-
export declare const cellInitialState: ICellState;
|
|
9
|
-
export declare const selectCell: () => ICellState;
|
|
10
|
-
export declare enum ActionType {
|
|
11
|
-
SOURCE = "cell/SOURCE",
|
|
12
|
-
OUTPUTS_COUNT = "cell/OUTPUTS_COUNT",
|
|
13
|
-
EXECUTE = "cell/EXECUTE",
|
|
14
|
-
UPDATE = "cell/UPDATE"
|
|
15
|
-
}
|
|
16
|
-
export declare const cellActions: {
|
|
17
|
-
source: import("typescript-fsa").ActionCreator<string>;
|
|
18
|
-
outputsCount: import("typescript-fsa").ActionCreator<number>;
|
|
19
|
-
execute: import("typescript-fsa").ActionCreator<void>;
|
|
20
|
-
update: import("typescript-fsa").ActionCreator<Partial<ICellState>>;
|
|
21
|
-
};
|
|
22
|
-
export declare const cellReducer: import("typescript-fsa-reducers").ReducerBuilder<ICellState, ICellState>;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import actionCreatorFactory from "typescript-fsa";
|
|
2
|
-
import { useSelector } from "react-redux";
|
|
3
|
-
import { reducerWithInitialState } from "typescript-fsa-reducers";
|
|
4
|
-
export const cellInitialState = {
|
|
5
|
-
source: '',
|
|
6
|
-
outputsCount: -1,
|
|
7
|
-
kernelAvailable: false,
|
|
8
|
-
};
|
|
9
|
-
/* Selectors */
|
|
10
|
-
export const selectCell = () => useSelector((state) => {
|
|
11
|
-
if (state.cell) {
|
|
12
|
-
return state.cell;
|
|
13
|
-
}
|
|
14
|
-
return cellInitialState;
|
|
15
|
-
});
|
|
16
|
-
/* Actions */
|
|
17
|
-
export var ActionType;
|
|
18
|
-
(function (ActionType) {
|
|
19
|
-
ActionType["SOURCE"] = "cell/SOURCE";
|
|
20
|
-
ActionType["OUTPUTS_COUNT"] = "cell/OUTPUTS_COUNT";
|
|
21
|
-
ActionType["EXECUTE"] = "cell/EXECUTE";
|
|
22
|
-
ActionType["UPDATE"] = "cell/UPDATE";
|
|
23
|
-
})(ActionType || (ActionType = {}));
|
|
24
|
-
const actionCreator = actionCreatorFactory('jupyterReact');
|
|
25
|
-
export const cellActions = {
|
|
26
|
-
source: actionCreator(ActionType.SOURCE),
|
|
27
|
-
outputsCount: actionCreator(ActionType.OUTPUTS_COUNT),
|
|
28
|
-
execute: actionCreator(ActionType.EXECUTE),
|
|
29
|
-
update: actionCreator(ActionType.UPDATE),
|
|
30
|
-
};
|
|
31
|
-
/* Reducers */
|
|
32
|
-
export const cellReducer = reducerWithInitialState(cellInitialState)
|
|
33
|
-
.case(cellActions.execute, (state, payload) => {
|
|
34
|
-
if (state.adapter) {
|
|
35
|
-
state.adapter.execute();
|
|
36
|
-
}
|
|
37
|
-
return Object.assign({}, state);
|
|
38
|
-
})
|
|
39
|
-
.case(cellActions.source, (state, source) => {
|
|
40
|
-
return Object.assign(Object.assign({}, state), { source });
|
|
41
|
-
})
|
|
42
|
-
.case(cellActions.update, (state, partial) => (Object.assign(Object.assign({}, state), partial)))
|
|
43
|
-
.case(cellActions.outputsCount, (state, outputsCount) => {
|
|
44
|
-
return Object.assign(Object.assign({}, state), { outputsCount });
|
|
45
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import CommandAdapter from './CommandsAdapter';
|
|
3
|
-
import LuminoAttached from '../../jupyter/lumino/LuminoAttached';
|
|
4
|
-
const Commands = () => {
|
|
5
|
-
const commandsAdapter = new CommandAdapter();
|
|
6
|
-
return _jsx(LuminoAttached, { children: commandsAdapter.panel }, void 0);
|
|
7
|
-
};
|
|
8
|
-
export default Commands;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BoxPanel } from '@lumino/widgets';
|
|
2
|
-
import '@lumino/default-theme/style/index.css';
|
|
3
|
-
import './CommandsAdapter.css';
|
|
4
|
-
declare class CommandsAdapter {
|
|
5
|
-
private commandsPanel;
|
|
6
|
-
constructor();
|
|
7
|
-
get panel(): BoxPanel;
|
|
8
|
-
}
|
|
9
|
-
export default CommandsAdapter;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { CommandRegistry } from '@lumino/commands';
|
|
2
|
-
import { CommandPalette, BoxPanel } from '@lumino/widgets';
|
|
3
|
-
import '@lumino/default-theme/style/index.css';
|
|
4
|
-
import './CommandsAdapter.css';
|
|
5
|
-
class CommandsAdapter {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.commandsPanel = new BoxPanel();
|
|
8
|
-
this.commandsPanel.id = 'datalayer-jupyter-commands';
|
|
9
|
-
this.commandsPanel.spacing = 0;
|
|
10
|
-
// Initialize the command registry with the key bindings.
|
|
11
|
-
const commands = new CommandRegistry();
|
|
12
|
-
const palette = new CommandPalette({ commands });
|
|
13
|
-
BoxPanel.setStretch(palette, 0);
|
|
14
|
-
this.commandsPanel.addWidget(palette);
|
|
15
|
-
// Handle resize events.
|
|
16
|
-
window.addEventListener('resize', () => {
|
|
17
|
-
this.commandsPanel.update();
|
|
18
|
-
});
|
|
19
|
-
const selector = '.jp-ConsolePanel';
|
|
20
|
-
const category = 'Console';
|
|
21
|
-
const command = 'console:execute';
|
|
22
|
-
commands.addCommand(command, {
|
|
23
|
-
label: 'Execute Cell',
|
|
24
|
-
execute: () => {
|
|
25
|
-
window.alert('Execute Cell');
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
palette.addItem({ command, category });
|
|
29
|
-
commands.addKeyBinding({ command, selector, keys: ['Shift Enter'] });
|
|
30
|
-
}
|
|
31
|
-
get panel() {
|
|
32
|
-
return this.commandsPanel;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export default CommandsAdapter;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare type ICommand = number;
|
|
2
|
-
export interface ICommandState {
|
|
3
|
-
outputs: ICommand;
|
|
4
|
-
}
|
|
5
|
-
export declare const commandsInitialState: ICommandState;
|
|
6
|
-
export declare const selectCommands: () => ICommandState;
|
|
7
|
-
export declare enum ActionType {
|
|
8
|
-
OUTPUTS = "commands/OUTPUTS",
|
|
9
|
-
EXECUTE = "commands/EXECUTE"
|
|
10
|
-
}
|
|
11
|
-
export declare const commandsActions: {
|
|
12
|
-
outputs: import("typescript-fsa").ActionCreator<number>;
|
|
13
|
-
execute: import("typescript-fsa").ActionCreator<void>;
|
|
14
|
-
};
|
|
15
|
-
export declare const commandsReducer: import("typescript-fsa-reducers").ReducerBuilder<ICommandState, ICommandState>;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import actionCreatorFactory from "typescript-fsa";
|
|
2
|
-
import { useSelector } from "react-redux";
|
|
3
|
-
import { reducerWithInitialState } from "typescript-fsa-reducers";
|
|
4
|
-
export const commandsInitialState = {
|
|
5
|
-
outputs: 0
|
|
6
|
-
};
|
|
7
|
-
/* Selectors */
|
|
8
|
-
export const selectCommands = () => useSelector((state) => {
|
|
9
|
-
if (state.commands) {
|
|
10
|
-
return state.commands;
|
|
11
|
-
}
|
|
12
|
-
return { outputs: 0 };
|
|
13
|
-
});
|
|
14
|
-
/* Actions */
|
|
15
|
-
export var ActionType;
|
|
16
|
-
(function (ActionType) {
|
|
17
|
-
ActionType["OUTPUTS"] = "commands/OUTPUTS";
|
|
18
|
-
ActionType["EXECUTE"] = "commands/EXECUTE";
|
|
19
|
-
})(ActionType || (ActionType = {}));
|
|
20
|
-
const actionCreator = actionCreatorFactory('jupyterReact');
|
|
21
|
-
export const commandsActions = {
|
|
22
|
-
outputs: actionCreator(ActionType.OUTPUTS),
|
|
23
|
-
execute: actionCreator(ActionType.EXECUTE),
|
|
24
|
-
};
|
|
25
|
-
/* Reducers */
|
|
26
|
-
export const commandsReducer = reducerWithInitialState(commandsInitialState)
|
|
27
|
-
.case(commandsActions.outputs, (state, success) => {
|
|
28
|
-
return Object.assign(Object.assign({}, state), { outputs: success });
|
|
29
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import ConsoleAdapter from './ConsoleAdapter';
|
|
3
|
-
import LuminoAttached from '../../jupyter/lumino/LuminoAttached';
|
|
4
|
-
const Console = () => {
|
|
5
|
-
const consoleAdapter = new ConsoleAdapter();
|
|
6
|
-
return _jsx(LuminoAttached, { children: consoleAdapter.panel }, void 0);
|
|
7
|
-
};
|
|
8
|
-
export default Console;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BoxPanel } from '@lumino/widgets';
|
|
2
|
-
import '@jupyterlab/console/style/index.css';
|
|
3
|
-
import '@jupyterlab/theme-light-extension/style/theme.css';
|
|
4
|
-
import '@jupyterlab/theme-light-extension/style/variables.css';
|
|
5
|
-
import './ConsoleAdapter.css';
|
|
6
|
-
declare class ConsoleAdapter {
|
|
7
|
-
private consolePanel;
|
|
8
|
-
constructor();
|
|
9
|
-
get panel(): BoxPanel;
|
|
10
|
-
}
|
|
11
|
-
export default ConsoleAdapter;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { RenderMimeRegistry, standardRendererFactories as initialFactories } from '@jupyterlab/rendermime';
|
|
2
|
-
import { CommandRegistry } from '@lumino/commands';
|
|
3
|
-
import { BoxPanel } from '@lumino/widgets';
|
|
4
|
-
import { ServiceManager } from '@jupyterlab/services';
|
|
5
|
-
import { editorServices } from '@jupyterlab/codemirror';
|
|
6
|
-
import { ConsolePanel } from '@jupyterlab/console';
|
|
7
|
-
import '@jupyterlab/console/style/index.css';
|
|
8
|
-
import '@jupyterlab/theme-light-extension/style/theme.css';
|
|
9
|
-
import '@jupyterlab/theme-light-extension/style/variables.css';
|
|
10
|
-
import './ConsoleAdapter.css';
|
|
11
|
-
class ConsoleAdapter {
|
|
12
|
-
constructor() {
|
|
13
|
-
this.consolePanel = new BoxPanel();
|
|
14
|
-
this.consolePanel.direction = 'top-to-bottom';
|
|
15
|
-
this.consolePanel.spacing = 0;
|
|
16
|
-
this.consolePanel.addClass('dla-JupyterLab-Console');
|
|
17
|
-
const serviceManager = new ServiceManager();
|
|
18
|
-
function start(path, serviceManager, panel) {
|
|
19
|
-
const commands = new CommandRegistry();
|
|
20
|
-
document.addEventListener('keydown', event => {
|
|
21
|
-
commands.processKeydownEvent(event);
|
|
22
|
-
});
|
|
23
|
-
const rendermime = new RenderMimeRegistry({ initialFactories });
|
|
24
|
-
const editorFactory = editorServices.factoryService.newInlineEditor;
|
|
25
|
-
const contentFactory = new ConsolePanel.ContentFactory({ editorFactory });
|
|
26
|
-
const console = new ConsolePanel({
|
|
27
|
-
rendermime,
|
|
28
|
-
manager: serviceManager,
|
|
29
|
-
path,
|
|
30
|
-
contentFactory,
|
|
31
|
-
mimeTypeService: editorServices.mimeTypeService,
|
|
32
|
-
kernelPreference: {
|
|
33
|
-
shouldStart: true,
|
|
34
|
-
name: 'python3',
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
console.title.label = 'Console';
|
|
38
|
-
BoxPanel.setStretch(console, 1);
|
|
39
|
-
panel.addWidget(console);
|
|
40
|
-
window.addEventListener('resize', () => {
|
|
41
|
-
panel.update();
|
|
42
|
-
});
|
|
43
|
-
const selector = '.jp-ConsolePanel';
|
|
44
|
-
let command;
|
|
45
|
-
command = 'console:clear';
|
|
46
|
-
commands.addCommand(command, {
|
|
47
|
-
label: 'Clear',
|
|
48
|
-
execute: () => {
|
|
49
|
-
console.console.clear();
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
command = 'console:execute';
|
|
53
|
-
commands.addCommand(command, {
|
|
54
|
-
label: 'Execute Prompt',
|
|
55
|
-
execute: () => {
|
|
56
|
-
return console.console.execute();
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
commands.addKeyBinding({ command, selector, keys: ['Enter'] });
|
|
60
|
-
command = 'console:execute-forced';
|
|
61
|
-
commands.addCommand(command, {
|
|
62
|
-
label: 'Execute Cell (forced)',
|
|
63
|
-
execute: () => {
|
|
64
|
-
return console.console.execute(true);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
commands.addKeyBinding({ command, selector, keys: ['Shift Enter'] });
|
|
68
|
-
command = 'console:linebreak';
|
|
69
|
-
commands.addCommand(command, {
|
|
70
|
-
label: 'Insert Line Break',
|
|
71
|
-
execute: () => {
|
|
72
|
-
console.console.insertLinebreak();
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
commands.addKeyBinding({ command, selector, keys: ['Ctrl Enter'] });
|
|
76
|
-
}
|
|
77
|
-
void serviceManager.ready.then(() => {
|
|
78
|
-
start('console-path', serviceManager, this.consolePanel);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
get panel() {
|
|
82
|
-
return this.consolePanel;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
export default ConsoleAdapter;
|