|
| 1 | +// Removed Widget import as we're no longer using @lumino/widgets |
1 | 2 | import { JupyterLiteServer, JupyterLiteServerPlugin } from '@jupyterlite/server'; |
2 | 3 | import { IKernel, IKernelSpecs } from '@jupyterlite/kernel'; |
3 | | -import { INotebookTracker } from '@jupyterlab/notebook'; |
4 | 4 | import { EmbeddedKernel } from './kernel'; |
5 | 5 | import WelcomePanel from './panel'; |
6 | 6 | import { ServiceContainer } from './services/ServiceContainer'; |
7 | 7 | import { DeviceService } from './services/DeviceService'; |
8 | 8 |
|
| 9 | +// Variable for saving the DeviceService instance so we can restore it if kernel is restarted |
9 | 10 | var devService: DeviceService | null = null; |
10 | 11 |
|
| 12 | +// Kernel plugin for the embedded kernel |
11 | 13 | const kernelPlugin: JupyterLiteServerPlugin<void> = { |
12 | 14 | id: 'jupyterlite-embedded-kernel:kernel', |
13 | 15 | autoStart: true, |
14 | | - requires: [IKernelSpecs, INotebookTracker], // Add INotebookTracker here |
15 | | - activate: ( |
16 | | - app: JupyterLiteServer, |
17 | | - kernelspecs: IKernelSpecs, |
18 | | - notebookTracker: INotebookTracker // Add notebookTracker parameter |
19 | | - ) => { |
| 16 | + requires: [IKernelSpecs], |
| 17 | + activate: (app: JupyterLiteServer, kernelspecs: IKernelSpecs) => { |
20 | 18 | const activeKernels = new Map<string, EmbeddedKernel>(); |
21 | 19 |
|
| 20 | + // print the app to console |
| 21 | + console.log("JupyterLite Embedded Kernel Plugin Activated. App:", app); |
| 22 | + |
22 | 23 | app.router.post('/api/kernels/(.*)/interrupt', async (req, kernelId: string) => { |
23 | 24 | const kernel = activeKernels.get(kernelId); |
24 | 25 | if (kernel) { |
@@ -50,17 +51,19 @@ const kernelPlugin: JupyterLiteServerPlugin<void> = { |
50 | 51 | const serviceContainer = new ServiceContainer(devService); |
51 | 52 | await serviceContainer.init(); |
52 | 53 |
|
| 54 | + // Save the DeviceService instance so we can restore it if kernel is restarted |
53 | 55 | devService = serviceContainer.deviceService; |
54 | 56 |
|
55 | 57 | const welcomePanel = new WelcomePanel( |
56 | | - serviceContainer, |
57 | | - notebookTracker // Pass notebookTracker here |
| 58 | + serviceContainer |
58 | 59 | ); |
59 | 60 | document.body.appendChild(welcomePanel.getElement()); |
60 | 61 | const kernel = new EmbeddedKernel(options, serviceContainer); |
61 | 62 |
|
| 63 | + // welcomePanel.show(); |
62 | 64 | welcomePanel.initialShow(); |
63 | 65 |
|
| 66 | + // If the deivce is already connected, update the welcome panel |
64 | 67 | if (serviceContainer.deviceService.isConnected()) { |
65 | 68 | welcomePanel.updateOnConnection("Connected"); |
66 | 69 | } |
|
0 commit comments