Skip to content

Commit 0e75bed

Browse files
committed
Use plugins from voila
1 parent db68eed commit 0e75bed

File tree

7 files changed

+17
-263
lines changed

7 files changed

+17
-263
lines changed

packages/voila/index.js

Lines changed: 0 additions & 189 deletions
This file was deleted.

packages/voila/src/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,4 @@ export * from './app';
1111
export * from './manager';
1212
export * from './shell';
1313
export * from './output';
14-
15-
import * as plugins from './plugins';
16-
17-
export { plugins };
14+
export * from './plugins';

packages/voila/src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { PageConfig, URLExt } from '@jupyterlab/coreutils';
1818

1919
import { VoilaApp } from './app';
2020
import { VoilaShell } from './shell';
21+
import plugins from './plugins';
2122

2223
function loadScript(url: string): Promise<any> {
2324
return new Promise((resolve, reject) => {
@@ -68,9 +69,8 @@ async function main() {
6869
// This would also need the theme manager plugin and settings
6970
// require('@jupyterlab/theme-light-extension'),
7071
// require('@jupyterlab/theme-dark-extension'),
71-
require('./plugins')
72+
plugins
7273
];
73-
7474
const mimeExtensions = [require('@jupyterlab/json-extension')];
7575

7676
/**

packages/voila/src/plugins.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { WidgetManager as VoilaWidgetManager } from './manager';
3434
/**
3535
* The default paths.
3636
*/
37-
const paths: JupyterFrontEndPlugin<JupyterFrontEnd.IPaths> = {
37+
export const pathsPlugin: JupyterFrontEndPlugin<JupyterFrontEnd.IPaths> = {
3838
id: '@voila-dashboards/voila:paths',
3939
activate: (
4040
app: JupyterFrontEnd<JupyterFrontEnd.IShell>
@@ -51,7 +51,7 @@ const paths: JupyterFrontEndPlugin<JupyterFrontEnd.IPaths> = {
5151
* TODO: a cleaner solution would involve a custom ServiceManager to the VoilaApp
5252
* to prevent the default behavior of polling the /api endpoints.
5353
*/
54-
const stopPolling: JupyterFrontEndPlugin<void> = {
54+
export const stopPollingPlugin: JupyterFrontEndPlugin<void> = {
5555
id: '@voila-dashboards/voila:stop-polling',
5656
autoStart: true,
5757
activate: (app: JupyterFrontEnd): void => {
@@ -69,7 +69,7 @@ const stopPolling: JupyterFrontEndPlugin<void> = {
6969
/**
7070
* A simplified Translator
7171
*/
72-
const translator: JupyterFrontEndPlugin<ITranslator> = {
72+
export const translatorPlugin: JupyterFrontEndPlugin<ITranslator> = {
7373
id: '@voila-dashboards/voila:translator',
7474
activate: (app: JupyterFrontEnd<JupyterFrontEnd.IShell>): ITranslator => {
7575
const translationManager = new TranslationManager();
@@ -82,7 +82,7 @@ const translator: JupyterFrontEndPlugin<ITranslator> = {
8282
/**
8383
* The Voila widgets manager plugin.
8484
*/
85-
const widgetManager: JupyterFrontEndPlugin<IJupyterWidgetRegistry> = {
85+
export const widgetManager: JupyterFrontEndPlugin<IJupyterWidgetRegistry> = {
8686
id: '@voila-dashboards/voila:widget-manager',
8787
autoStart: true,
8888
requires: [IRenderMimeRegistry],
@@ -135,9 +135,9 @@ const widgetManager: JupyterFrontEndPlugin<IJupyterWidgetRegistry> = {
135135
* Export the plugins as default.
136136
*/
137137
const plugins: JupyterFrontEndPlugin<any>[] = [
138-
paths,
139-
stopPolling,
140-
translator,
138+
pathsPlugin,
139+
stopPollingPlugin,
140+
translatorPlugin,
141141
widgetManager
142142
];
143143

packages/voilite/src/global.d.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ interface ICellData {
99
cell_type: string;
1010
cell_source: string;
1111
}
12-
declare var cells: {
13-
[key: number]: ICellData;
14-
};
12+
1513
declare function update_loading_text(
1614
cell_index: number,
1715
cell_count: number,

packages/voilite/src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,14 @@ async function main() {
203203
litePluginsToRegister.push(plugin);
204204
}
205205
});
206-
console.log('start server');
207206

208207
// create the in-browser JupyterLite Server
209208
const jupyterLiteServer = new JupyterLiteServer({ shell: null as never });
210209

211210
jupyterLiteServer.registerPluginModules(litePluginsToRegister);
212211
// start the server
213212
await jupyterLiteServer.start();
214-
console.log('done server');
213+
215214
const serviceManager = jupyterLiteServer.serviceManager;
216215
const app = new VoiliteApp({
217216
serviceManager: serviceManager as any,

packages/voilite/src/plugins.ts

Lines changed: 5 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { PageConfig } from '@jupyterlab/coreutils';
21
/***************************************************************************
32
* Copyright (c) 2022, Voilà contributors *
43
* Copyright (c) 2022, QuantStack *
@@ -13,64 +12,15 @@ import {
1312
JupyterFrontEndPlugin
1413
} from '@jupyterlab/application';
1514
import { IThemeManager } from '@jupyterlab/apputils';
16-
import { ITranslator, TranslationManager } from '@jupyterlab/translation';
1715
import { PromiseDelegate } from '@lumino/coreutils';
18-
import { VoilaApp } from '@voila-dashboards/voila';
19-
16+
import { translatorPlugin, pathsPlugin } from '@voila-dashboards/voila';
17+
import { PageConfig } from '@jupyterlab/coreutils';
2018
import { VoiliteWidgetManager } from './manager';
2119

22-
/**
23-
* The default paths.
24-
*/
25-
const paths: JupyterFrontEndPlugin<JupyterFrontEnd.IPaths> = {
26-
id: '@voila-dashboards/voila:paths',
27-
activate: (
28-
app: JupyterFrontEnd<JupyterFrontEnd.IShell>
29-
): JupyterFrontEnd.IPaths => {
30-
return (app as VoilaApp).paths;
31-
},
32-
autoStart: true,
33-
provides: JupyterFrontEnd.IPaths
34-
};
35-
36-
/**
37-
* A plugin to stop polling the kernels, sessions and kernel specs.
38-
*
39-
* TODO: a cleaner solution would involve a custom ServiceManager to the VoilaApp
40-
* to prevent the default behavior of polling the /api endpoints.
41-
*/
42-
const stopPolling: JupyterFrontEndPlugin<void> = {
43-
id: '@voila-dashboards/voila:stop-polling',
44-
autoStart: true,
45-
activate: (app: JupyterFrontEnd): void => {
46-
app.serviceManager.sessions?.ready.then(value => {
47-
app.serviceManager.sessions['_kernelManager']['_pollModels']?.stop();
48-
void app.serviceManager.sessions['_pollModels'].stop();
49-
});
50-
51-
app.serviceManager.kernelspecs?.ready.then(value => {
52-
void app.serviceManager.kernelspecs.dispose();
53-
});
54-
}
55-
};
56-
57-
/**
58-
* A simplified Translator
59-
*/
60-
const translator: JupyterFrontEndPlugin<ITranslator> = {
61-
id: '@voila-dashboards/voila:translator',
62-
activate: (app: JupyterFrontEnd<JupyterFrontEnd.IShell>): ITranslator => {
63-
const translationManager = new TranslationManager();
64-
return translationManager;
65-
},
66-
autoStart: true,
67-
provides: ITranslator
68-
};
69-
7020
export const managerPromise = new PromiseDelegate<VoiliteWidgetManager>();
7121

7222
/**
73-
* The Voila widgets manager plugin.
23+
* The Voilite widgets manager plugin.
7424
*/
7525
const widgetManager = {
7626
id: '@voila-dashboards/voilite:widget-manager',
@@ -113,9 +63,8 @@ const themePlugin: JupyterFrontEndPlugin<void> = {
11363
* Export the plugins as default.
11464
*/
11565
const plugins: JupyterFrontEndPlugin<any>[] = [
116-
paths,
117-
stopPolling,
118-
translator,
66+
pathsPlugin,
67+
translatorPlugin,
11968
widgetManager,
12069
themePlugin
12170
];

0 commit comments

Comments
 (0)