@jupyterlite/application 0.1.0-alpha.23
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/lib/index.d.ts +2 -0
- package/lib/index.js +4 -0
- package/lib/singleWidgetApp.d.ts +76 -0
- package/lib/singleWidgetApp.js +109 -0
- package/lib/singleWidgetShell.d.ts +62 -0
- package/lib/singleWidgetShell.js +82 -0
- package/package.json +65 -0
- package/style/base.css +22 -0
- package/style/index.css +8 -0
- package/style/index.js +8 -0
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application';
|
|
2
|
+
import { LabStatus } from '@jupyterlab/application/lib/status';
|
|
3
|
+
import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
|
|
4
|
+
import { ISingleWidgetShell } from './singleWidgetShell';
|
|
5
|
+
/**
|
|
6
|
+
* App is the main application class. It is instantiated once and shared.
|
|
7
|
+
*/
|
|
8
|
+
export declare class SingleWidgetApp extends JupyterFrontEnd<ISingleWidgetShell> {
|
|
9
|
+
/**
|
|
10
|
+
* Construct a new SingleWidgetApp object.
|
|
11
|
+
*
|
|
12
|
+
* @param options The instantiation options for an application.
|
|
13
|
+
*/
|
|
14
|
+
constructor(options?: SingleWidgetApp.IOptions);
|
|
15
|
+
/**
|
|
16
|
+
* The name of the application.
|
|
17
|
+
*/
|
|
18
|
+
readonly name = "Single Widget Application";
|
|
19
|
+
/**
|
|
20
|
+
* A namespace/prefix plugins may use to denote their provenance.
|
|
21
|
+
*/
|
|
22
|
+
readonly namespace = "Single Widget Application";
|
|
23
|
+
/**
|
|
24
|
+
* The application busy and dirty status signals and flags.
|
|
25
|
+
*/
|
|
26
|
+
readonly status: LabStatus;
|
|
27
|
+
/**
|
|
28
|
+
* The version of the application.
|
|
29
|
+
*/
|
|
30
|
+
readonly version: string;
|
|
31
|
+
/**
|
|
32
|
+
* The JupyterLab application paths dictionary.
|
|
33
|
+
*/
|
|
34
|
+
get paths(): JupyterFrontEnd.IPaths;
|
|
35
|
+
/**
|
|
36
|
+
* Register plugins from a plugin module.
|
|
37
|
+
*
|
|
38
|
+
* @param mod - The plugin module to register.
|
|
39
|
+
*/
|
|
40
|
+
registerPluginModule(mod: SingleWidgetApp.IPluginModule): void;
|
|
41
|
+
/**
|
|
42
|
+
* Register the plugins from multiple plugin modules.
|
|
43
|
+
*
|
|
44
|
+
* @param mods - The plugin modules to register.
|
|
45
|
+
*/
|
|
46
|
+
registerPluginModules(mods: SingleWidgetApp.IPluginModule[]): void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A namespace for App statics.
|
|
50
|
+
*/
|
|
51
|
+
export declare namespace SingleWidgetApp {
|
|
52
|
+
/**
|
|
53
|
+
* The instantiation options for an App application.
|
|
54
|
+
*/
|
|
55
|
+
interface IOptions extends JupyterFrontEnd.IOptions<ISingleWidgetShell>, Partial<IInfo> {
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The information about a Jupyter Notebook application.
|
|
59
|
+
*/
|
|
60
|
+
interface IInfo {
|
|
61
|
+
/**
|
|
62
|
+
* The mime renderer extensions.
|
|
63
|
+
*/
|
|
64
|
+
readonly mimeExtensions: IRenderMime.IExtensionModule[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The interface for a module that exports a plugin or plugins as
|
|
68
|
+
* the default value.
|
|
69
|
+
*/
|
|
70
|
+
interface IPluginModule {
|
|
71
|
+
/**
|
|
72
|
+
* The default export.
|
|
73
|
+
*/
|
|
74
|
+
default: JupyterFrontEndPlugin<any> | JupyterFrontEndPlugin<any>[];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
import { JupyterFrontEnd } from '@jupyterlab/application';
|
|
4
|
+
import { createRendermimePlugins } from '@jupyterlab/application/lib/mimerenderers';
|
|
5
|
+
import { LabStatus } from '@jupyterlab/application/lib/status';
|
|
6
|
+
import { PageConfig } from '@jupyterlab/coreutils';
|
|
7
|
+
import { SingleWidgetShell } from './singleWidgetShell';
|
|
8
|
+
/**
|
|
9
|
+
* App is the main application class. It is instantiated once and shared.
|
|
10
|
+
*/
|
|
11
|
+
export class SingleWidgetApp extends JupyterFrontEnd {
|
|
12
|
+
/**
|
|
13
|
+
* Construct a new SingleWidgetApp object.
|
|
14
|
+
*
|
|
15
|
+
* @param options The instantiation options for an application.
|
|
16
|
+
*/
|
|
17
|
+
constructor(options = { shell: new SingleWidgetShell() }) {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
super({
|
|
20
|
+
...options,
|
|
21
|
+
shell: (_a = options.shell) !== null && _a !== void 0 ? _a : new SingleWidgetShell(),
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* The name of the application.
|
|
25
|
+
*/
|
|
26
|
+
this.name = 'Single Widget Application';
|
|
27
|
+
/**
|
|
28
|
+
* A namespace/prefix plugins may use to denote their provenance.
|
|
29
|
+
*/
|
|
30
|
+
this.namespace = this.name;
|
|
31
|
+
/**
|
|
32
|
+
* The application busy and dirty status signals and flags.
|
|
33
|
+
*/
|
|
34
|
+
this.status = new LabStatus(this);
|
|
35
|
+
/**
|
|
36
|
+
* The version of the application.
|
|
37
|
+
*/
|
|
38
|
+
this.version = (_b = PageConfig.getOption('appVersion')) !== null && _b !== void 0 ? _b : 'unknown';
|
|
39
|
+
if (options.mimeExtensions) {
|
|
40
|
+
for (const plugin of createRendermimePlugins(options.mimeExtensions)) {
|
|
41
|
+
this.registerPlugin(plugin);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The JupyterLab application paths dictionary.
|
|
47
|
+
*/
|
|
48
|
+
get paths() {
|
|
49
|
+
return {
|
|
50
|
+
urls: {
|
|
51
|
+
base: PageConfig.getOption('baseUrl'),
|
|
52
|
+
notFound: PageConfig.getOption('notFoundUrl'),
|
|
53
|
+
app: PageConfig.getOption('appUrl'),
|
|
54
|
+
static: PageConfig.getOption('staticUrl'),
|
|
55
|
+
settings: PageConfig.getOption('settingsUrl'),
|
|
56
|
+
themes: PageConfig.getOption('themesUrl'),
|
|
57
|
+
doc: PageConfig.getOption('docUrl'),
|
|
58
|
+
translations: PageConfig.getOption('translationsApiUrl'),
|
|
59
|
+
hubHost: PageConfig.getOption('hubHost') || undefined,
|
|
60
|
+
hubPrefix: PageConfig.getOption('hubPrefix') || undefined,
|
|
61
|
+
hubUser: PageConfig.getOption('hubUser') || undefined,
|
|
62
|
+
hubServerName: PageConfig.getOption('hubServerName') || undefined,
|
|
63
|
+
},
|
|
64
|
+
directories: {
|
|
65
|
+
appSettings: PageConfig.getOption('appSettingsDir'),
|
|
66
|
+
schemas: PageConfig.getOption('schemasDir'),
|
|
67
|
+
static: PageConfig.getOption('staticDir'),
|
|
68
|
+
templates: PageConfig.getOption('templatesDir'),
|
|
69
|
+
themes: PageConfig.getOption('themesDir'),
|
|
70
|
+
userSettings: PageConfig.getOption('userSettingsDir'),
|
|
71
|
+
serverRoot: PageConfig.getOption('serverRoot'),
|
|
72
|
+
workspaces: PageConfig.getOption('workspacesDir'),
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Register plugins from a plugin module.
|
|
78
|
+
*
|
|
79
|
+
* @param mod - The plugin module to register.
|
|
80
|
+
*/
|
|
81
|
+
registerPluginModule(mod) {
|
|
82
|
+
let data = mod.default;
|
|
83
|
+
// Handle commonjs exports.
|
|
84
|
+
if (!Object.prototype.hasOwnProperty.call(mod, '__esModule')) {
|
|
85
|
+
data = mod;
|
|
86
|
+
}
|
|
87
|
+
if (!Array.isArray(data)) {
|
|
88
|
+
data = [data];
|
|
89
|
+
}
|
|
90
|
+
data.forEach((item) => {
|
|
91
|
+
try {
|
|
92
|
+
this.registerPlugin(item);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
console.error(error);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Register the plugins from multiple plugin modules.
|
|
101
|
+
*
|
|
102
|
+
* @param mods - The plugin modules to register.
|
|
103
|
+
*/
|
|
104
|
+
registerPluginModules(mods) {
|
|
105
|
+
mods.forEach((mod) => {
|
|
106
|
+
this.registerPluginModule(mod);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { JupyterFrontEnd } from '@jupyterlab/application';
|
|
2
|
+
import { DocumentRegistry } from '@jupyterlab/docregistry';
|
|
3
|
+
import { IIterator } from '@lumino/algorithm';
|
|
4
|
+
import { Token } from '@lumino/coreutils';
|
|
5
|
+
import { ISignal } from '@lumino/signaling';
|
|
6
|
+
import { Widget } from '@lumino/widgets';
|
|
7
|
+
/**
|
|
8
|
+
* The single widget application shell token.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ISingleWidgetShell: Token<ISingleWidgetShell>;
|
|
11
|
+
/**
|
|
12
|
+
* The single widget application shell interface.
|
|
13
|
+
*/
|
|
14
|
+
export interface ISingleWidgetShell extends SingleWidgetShell {
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The application shell.
|
|
18
|
+
*/
|
|
19
|
+
export declare class SingleWidgetShell extends Widget implements JupyterFrontEnd.IShell {
|
|
20
|
+
constructor();
|
|
21
|
+
/**
|
|
22
|
+
* A signal emitted when the current widget changes.
|
|
23
|
+
*/
|
|
24
|
+
get currentChanged(): ISignal<ISingleWidgetShell, void>;
|
|
25
|
+
/**
|
|
26
|
+
* The current widget in the shell's main area.
|
|
27
|
+
*/
|
|
28
|
+
get currentWidget(): Widget | null;
|
|
29
|
+
/**
|
|
30
|
+
* Activate a widget in its area.
|
|
31
|
+
*/
|
|
32
|
+
activateById(id: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Add a widget to the application shell.
|
|
35
|
+
*
|
|
36
|
+
* @param widget - The widget being added.
|
|
37
|
+
*
|
|
38
|
+
* @param area - Optional region in the shell into which the widget should
|
|
39
|
+
* be added.
|
|
40
|
+
*
|
|
41
|
+
* @param options - Optional open options.
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
add(widget: Widget, area?: Shell.Area, options?: DocumentRegistry.IOpenOptions): void;
|
|
45
|
+
/**
|
|
46
|
+
* Return the list of widgets for the given area.
|
|
47
|
+
*
|
|
48
|
+
* @param area The area
|
|
49
|
+
*/
|
|
50
|
+
widgets(area: Shell.Area): IIterator<Widget>;
|
|
51
|
+
private _main;
|
|
52
|
+
private _currentChanged;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A namespace for Shell statics
|
|
56
|
+
*/
|
|
57
|
+
export declare namespace Shell {
|
|
58
|
+
/**
|
|
59
|
+
* The areas of the application shell where widgets can reside.
|
|
60
|
+
*/
|
|
61
|
+
type Area = 'main';
|
|
62
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
import { find, iter } from '@lumino/algorithm';
|
|
4
|
+
import { Token } from '@lumino/coreutils';
|
|
5
|
+
import { Signal } from '@lumino/signaling';
|
|
6
|
+
import { Panel, Widget, PanelLayout } from '@lumino/widgets';
|
|
7
|
+
/**
|
|
8
|
+
* The single widget application shell token.
|
|
9
|
+
*/
|
|
10
|
+
export const ISingleWidgetShell = new Token('@jupyterlite/application:ISingleWidgetShell');
|
|
11
|
+
/**
|
|
12
|
+
* The application shell.
|
|
13
|
+
*/
|
|
14
|
+
export class SingleWidgetShell extends Widget {
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
this._currentChanged = new Signal(this);
|
|
18
|
+
this.id = 'main';
|
|
19
|
+
const rootLayout = new PanelLayout();
|
|
20
|
+
this._main = new Panel();
|
|
21
|
+
this._main.id = 'single-widget-panel';
|
|
22
|
+
rootLayout.addWidget(this._main);
|
|
23
|
+
this.layout = rootLayout;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A signal emitted when the current widget changes.
|
|
27
|
+
*/
|
|
28
|
+
get currentChanged() {
|
|
29
|
+
return this._currentChanged;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The current widget in the shell's main area.
|
|
33
|
+
*/
|
|
34
|
+
get currentWidget() {
|
|
35
|
+
var _a;
|
|
36
|
+
return (_a = this._main.widgets[0]) !== null && _a !== void 0 ? _a : null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Activate a widget in its area.
|
|
40
|
+
*/
|
|
41
|
+
activateById(id) {
|
|
42
|
+
const widget = find(this.widgets('main'), (w) => w.id === id);
|
|
43
|
+
if (widget) {
|
|
44
|
+
widget.activate();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Add a widget to the application shell.
|
|
49
|
+
*
|
|
50
|
+
* @param widget - The widget being added.
|
|
51
|
+
*
|
|
52
|
+
* @param area - Optional region in the shell into which the widget should
|
|
53
|
+
* be added.
|
|
54
|
+
*
|
|
55
|
+
* @param options - Optional open options.
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
add(widget, area, options) {
|
|
59
|
+
if (area === 'main' || area === undefined) {
|
|
60
|
+
if (this._main.widgets.length > 0) {
|
|
61
|
+
// do not add the widget if there is already one
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this._main.addWidget(widget);
|
|
65
|
+
this._main.update();
|
|
66
|
+
this._currentChanged.emit(void 0);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Return the list of widgets for the given area.
|
|
71
|
+
*
|
|
72
|
+
* @param area The area
|
|
73
|
+
*/
|
|
74
|
+
widgets(area) {
|
|
75
|
+
switch (area !== null && area !== void 0 ? area : 'main') {
|
|
76
|
+
case 'main':
|
|
77
|
+
return iter(this._main.widgets);
|
|
78
|
+
default:
|
|
79
|
+
throw new Error(`Invalid area: ${area}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jupyterlite/application",
|
|
3
|
+
"version": "0.1.0-alpha.23",
|
|
4
|
+
"description": "JupyterLite - Application",
|
|
5
|
+
"homepage": "https://github.com/jupyterlite/jupyterlite",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/jupyterlite/jupyterlite/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/jupyterlite/jupyterlite.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "BSD-3-Clause",
|
|
14
|
+
"author": "JupyterLite Contributors",
|
|
15
|
+
"sideEffects": [
|
|
16
|
+
"style/*.css",
|
|
17
|
+
"style/index.js"
|
|
18
|
+
],
|
|
19
|
+
"main": "lib/index.js",
|
|
20
|
+
"types": "lib/index.d.ts",
|
|
21
|
+
"style": "style/index.css",
|
|
22
|
+
"directories": {
|
|
23
|
+
"lib": "lib/"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"lib/*.d.ts",
|
|
27
|
+
"lib/*.js.map",
|
|
28
|
+
"lib/*.js",
|
|
29
|
+
"style/*.css",
|
|
30
|
+
"style/index.js"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsc -b",
|
|
34
|
+
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
|
|
35
|
+
"docs": "typedoc src",
|
|
36
|
+
"prepublishOnly": "npm run build",
|
|
37
|
+
"watch": "tsc -b --watch"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@jupyterlab/application": "~3.2.9",
|
|
41
|
+
"@jupyterlab/coreutils": "~5.2.9",
|
|
42
|
+
"@jupyterlab/docregistry": "~3.2.9",
|
|
43
|
+
"@jupyterlab/rendermime-interfaces": "~3.2.9",
|
|
44
|
+
"@lumino/coreutils": "^1.12.0",
|
|
45
|
+
"@lumino/signaling": "^1.10.1",
|
|
46
|
+
"@lumino/widgets": "^1.31.1"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@babel/core": "^7.11.6",
|
|
50
|
+
"@babel/preset-env": "^7.12.1",
|
|
51
|
+
"@jupyterlab/testutils": "~3.2.9",
|
|
52
|
+
"@types/jest": "^26.0.10",
|
|
53
|
+
"jest": "^26.4.2",
|
|
54
|
+
"rimraf": "~3.0.0",
|
|
55
|
+
"ts-jest": "^26.3.0",
|
|
56
|
+
"typescript": "~4.5.2"
|
|
57
|
+
},
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public"
|
|
60
|
+
},
|
|
61
|
+
"jupyterlab": {
|
|
62
|
+
"coreDependency": true
|
|
63
|
+
},
|
|
64
|
+
"styleModule": "style/index.js"
|
|
65
|
+
}
|
package/style/base.css
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*-----------------------------------------------------------------------------
|
|
2
|
+
| Copyright (c) Jupyter Development Team.
|
|
3
|
+
| Distributed under the terms of the Modified BSD License.
|
|
4
|
+
|----------------------------------------------------------------------------*/
|
|
5
|
+
|
|
6
|
+
body {
|
|
7
|
+
margin: 0;
|
|
8
|
+
padding: 0;
|
|
9
|
+
background: var(--jp-layout-color2);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
#main {
|
|
13
|
+
position: absolute;
|
|
14
|
+
top: 0;
|
|
15
|
+
left: 0;
|
|
16
|
+
right: 0;
|
|
17
|
+
bottom: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#single-widget-panel {
|
|
21
|
+
height: 100%;
|
|
22
|
+
}
|
package/style/index.css
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*-----------------------------------------------------------------------------
|
|
2
|
+
| Copyright (c) Jupyter Development Team.
|
|
3
|
+
| Distributed under the terms of the Modified BSD License.
|
|
4
|
+
|----------------------------------------------------------------------------*/
|
|
5
|
+
|
|
6
|
+
@import url('~@jupyterlab/application/style/index.css');
|
|
7
|
+
|
|
8
|
+
@import url('./base.css');
|
package/style/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*-----------------------------------------------------------------------------
|
|
2
|
+
| Copyright (c) Jupyter Development Team.
|
|
3
|
+
| Distributed under the terms of the Modified BSD License.
|
|
4
|
+
|----------------------------------------------------------------------------*/
|
|
5
|
+
|
|
6
|
+
import '@jupyterlab/application/style/index.js';
|
|
7
|
+
|
|
8
|
+
import './base.css';
|