Skip to content

Commit e35a362

Browse files
committed
chore: custom service manager
1 parent 9621b70 commit e35a362

File tree

12 files changed

+121
-99
lines changed

12 files changed

+121
-99
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,5 @@ packages/*/content
169169
!.storybook
170170
!.vscode
171171
!.licenserc.yaml
172-
!**/static/README.md
172+
!packages/react/jupyter_react/static/README.md
173173
!docs/static/img
174-
!**/jupyter_react/static/README.md

packages/react/jupyter_react/static/README.md

Whitespace-only changes.

packages/react/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# MIT License
44

55
[build-system]
6-
requires = ["hatchling==1.21.1", "jupyterlab==4.1.0b0", "hatch-nodejs-version"]
6+
requires = ["hatchling==1.21.1", "jupyterlab==4.0.9", "hatch-nodejs-version"]
77
build-backend = "hatchling.build"
88

99
[project]

packages/react/src/components/console/ConsoleAdapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ConsoleAdapter {
4141
});
4242
}
4343

44-
protected setupConsole(serviceManager: ServiceManager, kernel?: Kernel) {
44+
protected setupConsole(serviceManager: ServiceManager.IManager, kernel?: Kernel) {
4545
// Set up a command registry.
4646
const commands = new CommandRegistry();
4747
this._panel.node.addEventListener('keydown', event => {
@@ -184,7 +184,7 @@ export namespace ConsoleAdapter {
184184
/**
185185
* Application service manager
186186
*/
187-
serviceManager: ServiceManager;
187+
serviceManager: ServiceManager.IManager;
188188
/**
189189
* Initial code to run.
190190
*/

packages/react/src/components/filebrowser/FileBrowser.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const FileBrowser = () => {
7979
};
8080
useEffect(() => {
8181
if (serviceManager) {
82-
const services = new Services(serviceManager!);
82+
const services = new Services(serviceManager);
8383
loadPath(services, initialTree, []);
8484
}
8585
}, [serviceManager]);

packages/react/src/components/filemanager/lab/FileManagerAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import './FileManagerAdapter.css';
2626
class FileBrowserAdapter {
2727
private _fileBrowserPanel: SplitPanel;
2828

29-
constructor(serviceManager: ServiceManager) {
29+
constructor(serviceManager: ServiceManager.IManager) {
3030
this._fileBrowserPanel = new SplitPanel();
3131
this._fileBrowserPanel.id = 'dla-jlab-FleBrowser';
3232
this._fileBrowserPanel.orientation = 'horizontal';

packages/react/src/components/jupyterlab/JupyterLabApp.tsx

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Box } from '@primer/react';
99
import { JupyterLab } from '@jupyterlab/application';
1010
import { PageConfig } from '@jupyterlab/coreutils';
1111
import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
12+
import { ServiceManager } from '@jupyterlab/services';
1213
import { useJupyter } from '../../jupyter/JupyterContext';
1314
import { ColorMode } from '../../jupyter/lab/JupyterLabColorMode';
1415
import { JupyterLabAppCorePlugins } from './JupyterLabAppPlugins';
@@ -22,39 +23,46 @@ import JupyterLabAppCss from './JupyterLabAppCss';
2223
PageConfig.getOption('fullStaticUrl') + '/';
2324

2425
export type JupyterLabAppProps = {
26+
PluginType?: any;
2527
devMode: boolean;
26-
headless: boolean;
27-
pluginPromises?: Array<Promise<JupyterLab.IPluginModule>>;
28-
plugins: Array<JupyterLab.IPluginModule>;
2928
disabledPlugins: Array<string>;
29+
headless: boolean;
30+
height: string | number;
31+
hostId: string;
3032
mimeRendererPromises?: Array<Promise<IRenderMime.IExtensionModule>>;
3133
mimeRenderers: Array<IRenderMime.IExtensionModule>;
32-
onPlugin?: (plugin: any) => void;
3334
onJupyterLab: (jupyterLabAppdapter: JupyterLabAppAdapter) => void;
34-
height: string | number;
35-
hostId: string;
35+
onPlugin?: (plugin: any) => void;
3636
pluginId?: string;
37-
PluginType?: any;
37+
pluginPromises?: Array<Promise<JupyterLab.IPluginModule>>;
38+
plugins: Array<JupyterLab.IPluginModule>;
3839
position: string;
40+
serviceManager: ServiceManager.IManager;
3941
splash: boolean;
42+
startDefaultKernel: boolean;
4043
theme: ColorMode;
4144
width: string | number;
4245
};
4346

4447
const JupyterLabAppComponent = (props: JupyterLabAppProps) => {
4548
const {
46-
hostId,
47-
position,
48-
height,
49-
width,
49+
PluginType,
5050
headless,
51-
theme,
51+
height,
52+
hostId,
5253
onJupyterLab,
53-
pluginId,
54-
PluginType,
5554
onPlugin,
55+
pluginId,
56+
position,
57+
serviceManager: propsServiceManager,
58+
startDefaultKernel,
59+
theme,
60+
width,
5661
} = props;
57-
const { serviceManager, collaborative } = useJupyter();
62+
const { serviceManager, collaborative } = useJupyter({
63+
serviceManager: propsServiceManager,
64+
startDefaultKernel,
65+
});
5866
const defaultMimeExtensionPromises = useMemo(
5967
() =>
6068
props.mimeRendererPromises ??
@@ -110,15 +118,16 @@ const JupyterLabAppComponent = (props: JupyterLabAppProps) => {
110118

111119
JupyterLabAppComponent.defaultProps = {
112120
devMode: false,
113-
plugins: [],
114121
disabledPlugins: [],
115-
mimeRenderers: [],
116122
headless: false,
117123
height: '100vh',
118124
hostId: 'app-example-id',
119-
onJupyterLab: (jupyterLabAppAdapter: JupyterLabAppAdapter) => {},
125+
mimeRenderers: [],
126+
onJupyterLab: (_: JupyterLabAppAdapter) => {},
127+
plugins: [],
120128
position: 'relative',
121129
splash: true,
130+
startDefaultKernel: false,
122131
theme: 'light',
123132
width: '100%',
124133
} as Partial<JupyterLabAppProps>;

packages/react/src/components/jupyterlab/JupyterLabAppAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type Plugin = JupyterFrontEndPlugin<any, any, any> & {
2525
type Plugins = Map<string, Plugin>;
2626

2727
type Props = JupyterLabAppProps & {
28-
serviceManager: ServiceManager;
28+
serviceManager: ServiceManager.IManager;
2929
collaborative?: boolean;
3030
};
3131

packages/react/src/components/notebook/NotebookAdapter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ export class NotebookAdapter {
8181
private _readOnly: boolean;
8282
private _renderers: IRenderMime.IRendererFactory[];
8383
private _rendermime?: RenderMimeRegistry;
84-
private _serviceManager: ServiceManager;
84+
private _serviceManager: ServiceManager.IManager;
8585
private _tracker?: NotebookTracker;
8686
private _id: string;
8787
private _CellSidebar?: (props: any) => JSX.Element;
8888

8989
constructor(
9090
props: INotebookProps,
91-
serviceManager: ServiceManager,
91+
serviceManager: ServiceManager.IManager,
9292
lite?: Lite
9393
) {
9494
// this._bundledIPyWidgets = props.bundledIPyWidgets;
@@ -508,7 +508,7 @@ export class NotebookAdapter {
508508
return this._boxPanel;
509509
}
510510

511-
get serviceManager(): ServiceManager {
511+
get serviceManager(): ServiceManager.IManager {
512512
return this._serviceManager;
513513
}
514514

packages/react/src/jupyter/JupyterContext.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export type JupyterContextType = {
7979
/**
8080
* Jupyter services manager
8181
*/
82-
serviceManager?: ServiceManager;
82+
serviceManager?: ServiceManager.IManager;
8383
/**
8484
* Jupyter Server base URL
8585
*
@@ -149,6 +149,10 @@ export const ensureJupyterAuth = async (
149149
};
150150

151151
export type JupyterContextPropsType = {
152+
/**
153+
* Optional service manager.
154+
*/
155+
serviceManager?: ServiceManager.IManager;
152156
/**
153157
* Whether the component is collaborative or not.
154158
*/

0 commit comments

Comments
 (0)