Skip to content

Commit d535b0a

Browse files
fix(labextension) + kernelTransfer (#327)
* fix: lab extension * fix: lab extension * lint * chore: export codemirror * fix: webpack federation * chore: kernel transfer * Automatic application of license header * fix: sharedpackage --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent dfa14de commit d535b0a

31 files changed

+419
-117
lines changed

packages/react/package.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@datalayer/jupyter-react",
3-
"version": "0.18.11",
3+
"version": "0.18.12",
44
"description": "Jupyter React - React.js components 100% compatible with Jupyter.",
55
"license": "MIT",
66
"main": "lib/index.js",
@@ -264,6 +264,16 @@
264264
"extension": "./lib/jupyter/lab/plugin.js",
265265
"outputDir": "jupyter_react/labextension",
266266
"schemaDir": "schema",
267+
"sharedPackages": {
268+
"react": {
269+
"bundled": false,
270+
"singleton": true
271+
},
272+
"react-dom": {
273+
"bundled": false,
274+
"singleton": true
275+
}
276+
},
267277
"webpackConfig": "./webpack.lab-config.js"
268278
},
269279
"jupyter-releaser": {

packages/react/src/app/JupyterReact.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import { ReactJsIcon, RingedPlanetIcon } from '@datalayer/icons-react';
1212
import { ServerConnection } from '@jupyterlab/services';
1313
import { JupyterReactTheme } from '../theme';
1414
import { requestAPI } from '../jupyter/JupyterHandlers';
15-
import AboutTab from './tabs/AboutTab';
16-
import ComponentsTab from './tabs/ComponentsTab';
15+
import { AboutTab } from './tabs/AboutTab';
16+
import { ComponentsTab } from './tabs/ComponentsTab';
1717

1818
export type JupyterFrontEndProps = {
1919
app?: JupyterFrontEnd;
@@ -37,7 +37,7 @@ const JupyterReact = (props: JupyterFrontEndProps): JSX.Element => {
3737
return (
3838
<>
3939
<JupyterReactTheme loadJupyterLabCss={false}>
40-
<Box mb={3}>
40+
<Box mb={3} style={{minWidth: 200}}>
4141
<UnderlineNav aria-label="jupyter-react">
4242
<UnderlineNav.Item
4343
aria-current={tab === 1 ? "page" : undefined}

packages/react/src/app/tabs/AboutTab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type Props = {
1212
version: string;
1313
};
1414

15-
const AboutTab = (props: Props): JSX.Element => {
15+
export const AboutTab = (props: Props): JSX.Element => {
1616
const { version } = props;
1717
const [egg, setEgg] = useState(false);
1818
return (

packages/react/src/app/tabs/ComponentsTab.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
import { useState } from 'react';
88
import { Box, NavList } from '@primer/react';
99
import { JupyterFrontEndProps } from '../JupyterReact';
10-
import FileBrowserComponent from './components/FileBrowserComponent';
11-
// import CellComponent from './components/CellComponent';
12-
// import NotebookComponent from './components/NotebookComponent';
13-
import IPyWidgetsComponent from './components/IPyWidgetsComponent';
14-
import ViewerComponent from './components/ViewerComponent';
10+
import { FileBrowserComponent } from './components/FileBrowserComponent';
11+
import { CellComponent } from './components/CellComponent';
12+
import { NotebookComponent } from './components/NotebookComponent';
13+
import { IPyWidgetsComponent } from './components/IPyWidgetsComponent';
14+
import { ViewerComponent } from './components/ViewerComponent';
1515

16-
const MainTab = (props: JupyterFrontEndProps) => {
16+
export const ComponentsTab = (props: JupyterFrontEndProps) => {
1717
const [nav, setNav] = useState(1);
1818
return (
1919
<>
@@ -60,16 +60,14 @@ const MainTab = (props: JupyterFrontEndProps) => {
6060
</Box>
6161
<Box ml={3} sx={{ width: '100%' }}>
6262
{nav === 1 && <FileBrowserComponent />}
63-
{nav === 4 && <IPyWidgetsComponent />}
64-
{nav === 5 && <ViewerComponent />}
65-
{/*
6663
{nav === 2 && <CellComponent />}
6764
{nav === 3 && <NotebookComponent />}
68-
*/}
65+
{nav === 4 && <IPyWidgetsComponent />}
66+
{nav === 5 && <ViewerComponent />}
6967
</Box>
7068
</Box>
7169
</>
7270
);
7371
};
7472

75-
export default MainTab;
73+
export default ComponentsTab;

packages/react/src/app/tabs/components/CellComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import Cell from '../../../components/cell/Cell';
88

9-
const CellComponent = () => {
9+
export const CellComponent = () => {
1010
return (
1111
<>
1212
<Cell source="print('Hello 🪐 ⚛️ Jupyter React')" />

packages/react/src/app/tabs/components/FileBrowserComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { useJupyter } from './../../../jupyter/JupyterContext';
88
import { FileBrowser } from '../../../components/filebrowser/FileBrowser';
99

10-
const FileBrowserComponent = () => {
10+
export const FileBrowserComponent = () => {
1111
const { serviceManager } = useJupyter();
1212
return (
1313
serviceManager

packages/react/src/app/tabs/components/IPyWidgetsComponent.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44
* MIT License
55
*/
66

7-
import OutputIPyWidgets from '../../../components/output/OutputIPyWidgets';
7+
import { OutputIPyWidgets} from '../../../components/output';
8+
import { view, state } from './../../../examples/notebooks/OutputIPyWidgetsExample';
89

9-
import {
10-
view,
11-
state,
12-
} from './../../../examples/notebooks/OutputIPyWidgetsExample';
13-
14-
const IPyWidgetsComponent = () => {
10+
export const IPyWidgetsComponent = () => {
1511
return (
1612
<>
1713
<OutputIPyWidgets view={view} state={state} />

packages/react/src/app/tabs/components/NotebookComponent.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
import Notebook from '../../../components/notebook/Notebook';
88
import CellSidebarNew from './../../../components/notebook/cell/sidebar/CellSidebarButton';
99

10-
import nbformat from './../../..//examples/notebooks/IPyWidgetsExample.ipynb.json';
10+
import nbformat from './../../..//examples/notebooks/NotebookExample1.ipynb.json';
1111

12-
const NotebookComponent = () => {
12+
export const NotebookComponent = () => {
1313
return (
1414
<>
1515
<Notebook
16+
startDefaultKernel={true}
1617
nbformat={nbformat}
1718
id="notebook-id"
1819
cellSidebarMargin={60}

packages/react/src/app/tabs/components/ViewerComponent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
import Viewer from '../../../components/viewer/Viewer';
88

9-
// import nbformat from '../../..//examples/notebooks/IPyWidgetsExample.ipynb.json';
9+
// import nbformat from '../../../examples/notebooks/IPyWidgetsExample.ipynb.json';
1010

11-
const ViewerComponent = () => {
11+
export const ViewerComponent = () => {
1212
return (
1313
<>
1414
<Viewer

packages/react/src/components/cell/Cell.tsx

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,50 @@
77
import { useState, useEffect } from 'react';
88
import { CodeCell, MarkdownCell } from '@jupyterlab/cells';
99
import { Box } from '@primer/react';
10-
import { useJupyter } from './../../jupyter/JupyterContext';
10+
import { useJupyter } from './../../jupyter';
1111
import { newUuid } from '../../utils';
1212
import { Lumino } from '../lumino';
13-
import CellAdapter from './CellAdapter';
14-
import useCellsStore from './CellState';
13+
import { CellAdapter } from './CellAdapter';
14+
import { useCellsStore } from './CellState';
1515

1616
export type ICellProps = {
1717
/**
18-
* An id that can be provided to identify unique cell
18+
* Whether to execute directly the code cell or not.
1919
*/
20-
id: string;
20+
autoStart?: boolean;
2121
/**
22-
* Cell type
22+
* An id that can be provided to identify unique cell
2323
*/
24-
type: 'code' | 'markdown' | 'raw';
24+
id: string;
2525
/**
2626
* Cell source
2727
*/
2828
source?: string;
2929
/**
30-
* Whether to execute directly the code cell or not.
30+
* Whether to start the default kernel or not
3131
*/
32-
autoStart?: boolean;
32+
startDefaultKernel?: boolean;
3333
/**
3434
* Whether to show the toolbar for cell or not
3535
*/
3636
showToolbar?: boolean;
37+
/**
38+
* Cell type
39+
*/
40+
type: 'code' | 'markdown' | 'raw';
3741
};
3842

3943
export const Cell = (props: ICellProps) => {
4044
const {
4145
autoStart,
42-
showToolbar=true,
46+
showToolbar,
4347
source = '',
44-
type='code',
48+
startDefaultKernel,
49+
type,
4550
} = props;
46-
const { defaultKernel, serverSettings } = useJupyter();
51+
const { defaultKernel, serverSettings } = useJupyter({
52+
startDefaultKernel,
53+
});
4754
const [id] = useState(props.id || newUuid());
4855
const [adapter, setAdapter] = useState<CellAdapter>();
4956
const cellsStore = useCellsStore();
@@ -155,8 +162,10 @@ export const Cell = (props: ICellProps) => {
155162
};
156163

157164
Cell.defaultProps = {
158-
source: '',
159165
autoStart: true,
166+
showToolbar:true,
167+
startDefaultKernel: true,
168+
type: 'code',
160169
} as Partial<ICellProps>;
161170

162171
export default Cell;

0 commit comments

Comments
 (0)