jupyter-specta 0.1.1
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/LICENSE +21 -0
- package/README.md +1 -0
- package/lib/app.d.ts +61 -0
- package/lib/app.js +90 -0
- package/lib/create_notebook_panel.d.ts +9 -0
- package/lib/create_notebook_panel.js +14 -0
- package/lib/document/factory.d.ts +13 -0
- package/lib/document/factory.js +26 -0
- package/lib/document/plugin.d.ts +4 -0
- package/lib/document/plugin.js +60 -0
- package/lib/document/widget.d.ts +17 -0
- package/lib/document/widget.js +10 -0
- package/lib/extension_plugins.d.ts +4 -0
- package/lib/extension_plugins.js +5 -0
- package/lib/layout/default.d.ts +12 -0
- package/lib/layout/default.js +23 -0
- package/lib/layout/layout_registry.d.ts +22 -0
- package/lib/layout/layout_registry.js +44 -0
- package/lib/layout/plugin.d.ts +3 -0
- package/lib/layout/plugin.js +11 -0
- package/lib/plugins.d.ts +2 -0
- package/lib/plugins.js +2 -0
- package/lib/sharedscope.d.ts +3 -0
- package/lib/sharedscope.js +3 -0
- package/lib/shell.d.ts +57 -0
- package/lib/shell.js +206 -0
- package/lib/specta_cell_output.d.ts +14 -0
- package/lib/specta_cell_output.js +24 -0
- package/lib/specta_model.d.ts +42 -0
- package/lib/specta_model.js +116 -0
- package/lib/specta_widget.d.ts +29 -0
- package/lib/specta_widget.js +92 -0
- package/lib/specta_widget_factory.d.ts +25 -0
- package/lib/specta_widget_factory.js +30 -0
- package/lib/token.d.ts +31 -0
- package/lib/token.js +3 -0
- package/lib/tool.d.ts +23 -0
- package/lib/tool.js +96 -0
- package/package.json +231 -0
- package/style/base.css +56 -0
- package/style/index.css +1 -0
- package/style/index.js +1 -0
- package/style/style.css +29 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Duc Trung Le
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# specta
|
package/lib/app.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application';
|
|
2
|
+
import { SpectaShell } from './shell';
|
|
3
|
+
import { IRenderMime } from '@jupyterlab/rendermime';
|
|
4
|
+
export declare class SpectaApp extends JupyterFrontEnd<SpectaShell> {
|
|
5
|
+
constructor(options: SpectaApp.IOptions);
|
|
6
|
+
/**
|
|
7
|
+
* The name of the application.
|
|
8
|
+
*/
|
|
9
|
+
readonly name: string;
|
|
10
|
+
/**
|
|
11
|
+
* A namespace/prefix plugins may use to denote their provenance.
|
|
12
|
+
*/
|
|
13
|
+
readonly namespace: string;
|
|
14
|
+
/**
|
|
15
|
+
* The version of the application.
|
|
16
|
+
*/
|
|
17
|
+
readonly version = "1.0.0";
|
|
18
|
+
/**
|
|
19
|
+
* The JupyterLab application paths dictionary.
|
|
20
|
+
*/
|
|
21
|
+
get paths(): JupyterFrontEnd.IPaths;
|
|
22
|
+
/**
|
|
23
|
+
* Register plugins from a plugin module.
|
|
24
|
+
*
|
|
25
|
+
* @param mod - The plugin module to register.
|
|
26
|
+
*/
|
|
27
|
+
registerPluginModule(mod: SpectaApp.IPluginModule): void;
|
|
28
|
+
/**
|
|
29
|
+
* Register the plugins from multiple plugin modules.
|
|
30
|
+
*
|
|
31
|
+
* @param mods - The plugin modules to register.
|
|
32
|
+
*/
|
|
33
|
+
registerPluginModules(mods: SpectaApp.IPluginModule[]): void;
|
|
34
|
+
}
|
|
35
|
+
export declare namespace SpectaApp {
|
|
36
|
+
/**
|
|
37
|
+
* The instantiation options for an App application.
|
|
38
|
+
*/
|
|
39
|
+
interface IOptions extends JupyterFrontEnd.IOptions<SpectaShell>, Partial<IInfo> {
|
|
40
|
+
paths?: Partial<JupyterFrontEnd.IPaths>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The information about a Specta application.
|
|
44
|
+
*/
|
|
45
|
+
interface IInfo {
|
|
46
|
+
/**
|
|
47
|
+
* The mime renderer extensions.
|
|
48
|
+
*/
|
|
49
|
+
readonly mimeExtensions: IRenderMime.IExtensionModule[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The interface for a module that exports a plugin or plugins as
|
|
53
|
+
* the default value.
|
|
54
|
+
*/
|
|
55
|
+
interface IPluginModule {
|
|
56
|
+
/**
|
|
57
|
+
* The default export.
|
|
58
|
+
*/
|
|
59
|
+
default: JupyterFrontEndPlugin<any> | JupyterFrontEndPlugin<any>[];
|
|
60
|
+
}
|
|
61
|
+
}
|
package/lib/app.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { JupyterFrontEnd, createRendermimePlugins } from '@jupyterlab/application';
|
|
2
|
+
import { SpectaShell } from './shell';
|
|
3
|
+
import { PageConfig } from '@jupyterlab/coreutils';
|
|
4
|
+
export class SpectaApp extends JupyterFrontEnd {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
var _a;
|
|
7
|
+
super(Object.assign(Object.assign({}, options), { shell: (_a = options.shell) !== null && _a !== void 0 ? _a : new SpectaShell() }));
|
|
8
|
+
/**
|
|
9
|
+
* The name of the application.
|
|
10
|
+
*/
|
|
11
|
+
this.name = 'Voila';
|
|
12
|
+
/**
|
|
13
|
+
* A namespace/prefix plugins may use to denote their provenance.
|
|
14
|
+
*/
|
|
15
|
+
this.namespace = this.name;
|
|
16
|
+
/**
|
|
17
|
+
* The version of the application.
|
|
18
|
+
*/
|
|
19
|
+
this.version = '1.0.0';
|
|
20
|
+
if (options.mimeExtensions) {
|
|
21
|
+
for (const plugin of createRendermimePlugins(options.mimeExtensions)) {
|
|
22
|
+
this.registerPlugin(plugin);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The JupyterLab application paths dictionary.
|
|
28
|
+
*/
|
|
29
|
+
get paths() {
|
|
30
|
+
return {
|
|
31
|
+
urls: {
|
|
32
|
+
base: PageConfig.getOption('baseUrl'),
|
|
33
|
+
notFound: PageConfig.getOption('notFoundUrl'),
|
|
34
|
+
app: PageConfig.getOption('appUrl'),
|
|
35
|
+
static: PageConfig.getOption('staticUrl'),
|
|
36
|
+
settings: PageConfig.getOption('settingsUrl'),
|
|
37
|
+
themes: PageConfig.getOption('themesUrl'),
|
|
38
|
+
doc: PageConfig.getOption('docUrl'),
|
|
39
|
+
translations: PageConfig.getOption('translationsApiUrl'),
|
|
40
|
+
hubHost: PageConfig.getOption('hubHost') || undefined,
|
|
41
|
+
hubPrefix: PageConfig.getOption('hubPrefix') || undefined,
|
|
42
|
+
hubUser: PageConfig.getOption('hubUser') || undefined,
|
|
43
|
+
hubServerName: PageConfig.getOption('hubServerName') || undefined
|
|
44
|
+
},
|
|
45
|
+
directories: {
|
|
46
|
+
appSettings: PageConfig.getOption('appSettingsDir'),
|
|
47
|
+
schemas: PageConfig.getOption('schemasDir'),
|
|
48
|
+
static: PageConfig.getOption('staticDir'),
|
|
49
|
+
templates: PageConfig.getOption('templatesDir'),
|
|
50
|
+
themes: PageConfig.getOption('themesDir'),
|
|
51
|
+
userSettings: PageConfig.getOption('userSettingsDir'),
|
|
52
|
+
serverRoot: PageConfig.getOption('serverRoot'),
|
|
53
|
+
workspaces: PageConfig.getOption('workspacesDir')
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Register plugins from a plugin module.
|
|
59
|
+
*
|
|
60
|
+
* @param mod - The plugin module to register.
|
|
61
|
+
*/
|
|
62
|
+
registerPluginModule(mod) {
|
|
63
|
+
let data = mod.default;
|
|
64
|
+
// Handle commonjs exports.
|
|
65
|
+
if (!Object.prototype.hasOwnProperty.call(mod, '__esModule')) {
|
|
66
|
+
data = mod;
|
|
67
|
+
}
|
|
68
|
+
if (!Array.isArray(data)) {
|
|
69
|
+
data = [data];
|
|
70
|
+
}
|
|
71
|
+
data.forEach(item => {
|
|
72
|
+
try {
|
|
73
|
+
this.registerPlugin(item);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error(error);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Register the plugins from multiple plugin modules.
|
|
82
|
+
*
|
|
83
|
+
* @param mods - The plugin modules to register.
|
|
84
|
+
*/
|
|
85
|
+
registerPluginModules(mods) {
|
|
86
|
+
mods.forEach(mod => {
|
|
87
|
+
this.registerPluginModule(mod);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IEditorServices } from '@jupyterlab/codeeditor';
|
|
2
|
+
import { DocumentRegistry } from '@jupyterlab/docregistry';
|
|
3
|
+
import { INotebookModel, NotebookPanel } from '@jupyterlab/notebook';
|
|
4
|
+
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
5
|
+
export declare function createNotebookPanel(options: {
|
|
6
|
+
context: DocumentRegistry.IContext<INotebookModel>;
|
|
7
|
+
rendermime: IRenderMimeRegistry;
|
|
8
|
+
editorServices: IEditorServices;
|
|
9
|
+
}): NotebookPanel;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Notebook, NotebookPanel } from '@jupyterlab/notebook';
|
|
2
|
+
export function createNotebookPanel(options) {
|
|
3
|
+
const { context, rendermime, editorServices } = options;
|
|
4
|
+
const editorFactory = editorServices.factoryService.newInlineEditor;
|
|
5
|
+
const content = new Notebook({
|
|
6
|
+
rendermime,
|
|
7
|
+
contentFactory: new Notebook.ContentFactory({ editorFactory }),
|
|
8
|
+
mimeTypeService: editorServices.mimeTypeService
|
|
9
|
+
});
|
|
10
|
+
return new NotebookPanel({
|
|
11
|
+
content,
|
|
12
|
+
context
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ABCWidgetFactory, DocumentRegistry } from '@jupyterlab/docregistry';
|
|
2
|
+
import { NotebookSpectaDocWidget } from './widget';
|
|
3
|
+
import { INotebookModel } from '@jupyterlab/notebook';
|
|
4
|
+
import { SpectaWidgetFactory } from '../specta_widget_factory';
|
|
5
|
+
interface IOptions extends DocumentRegistry.IWidgetFactoryOptions {
|
|
6
|
+
spectaWidgetFactory: SpectaWidgetFactory;
|
|
7
|
+
}
|
|
8
|
+
export declare class NotebookGridWidgetFactory extends ABCWidgetFactory<NotebookSpectaDocWidget, INotebookModel> {
|
|
9
|
+
constructor(options: IOptions);
|
|
10
|
+
protected createNewWidget(context: DocumentRegistry.IContext<INotebookModel>): NotebookSpectaDocWidget;
|
|
11
|
+
private _spectaWidgetFactory;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ABCWidgetFactory } from '@jupyterlab/docregistry';
|
|
2
|
+
import { NotebookSpectaDocWidget } from './widget';
|
|
3
|
+
import { Widget } from '@lumino/widgets';
|
|
4
|
+
export class NotebookGridWidgetFactory extends ABCWidgetFactory {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
super(options);
|
|
7
|
+
this._spectaWidgetFactory = options.spectaWidgetFactory;
|
|
8
|
+
}
|
|
9
|
+
createNewWidget(context) {
|
|
10
|
+
const content = new Widget();
|
|
11
|
+
content.addClass('jp-specta-notebook-panel');
|
|
12
|
+
context.ready.then(async () => {
|
|
13
|
+
const spectaWidget = await this._spectaWidgetFactory.createNew({
|
|
14
|
+
context
|
|
15
|
+
});
|
|
16
|
+
if (spectaWidget) {
|
|
17
|
+
Widget.attach(spectaWidget, content.node);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const widget = new NotebookSpectaDocWidget({
|
|
21
|
+
context,
|
|
22
|
+
content
|
|
23
|
+
});
|
|
24
|
+
return widget;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { WidgetTracker } from '@jupyterlab/apputils';
|
|
2
|
+
import { IEditorServices } from '@jupyterlab/codeeditor';
|
|
3
|
+
import { INotebookTracker, NotebookPanel } from '@jupyterlab/notebook';
|
|
4
|
+
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
5
|
+
import { IDocumentManager } from '@jupyterlab/docmanager';
|
|
6
|
+
import { createFileBrowser, hideAppLoadingIndicator, isSpectaApp, registerDocumentFactory } from '../tool';
|
|
7
|
+
import { ISpectaDocTracker, ISpectaLayoutRegistry } from '../token';
|
|
8
|
+
import { IKernelSpecManager } from '@jupyterlab/services';
|
|
9
|
+
const activate = (app, rendermime, tracker, editorServices, contentFactory, spectaLayoutRegistry) => {
|
|
10
|
+
const namespace = 'specta';
|
|
11
|
+
const spectaTracker = new WidgetTracker({ namespace });
|
|
12
|
+
registerDocumentFactory({
|
|
13
|
+
factoryName: 'specta',
|
|
14
|
+
app,
|
|
15
|
+
rendermime,
|
|
16
|
+
tracker,
|
|
17
|
+
editorServices,
|
|
18
|
+
contentFactory,
|
|
19
|
+
spectaTracker,
|
|
20
|
+
spectaLayoutRegistry
|
|
21
|
+
});
|
|
22
|
+
return spectaTracker;
|
|
23
|
+
};
|
|
24
|
+
export const spectaDocument = {
|
|
25
|
+
id: 'specta:notebook-doc',
|
|
26
|
+
autoStart: true,
|
|
27
|
+
requires: [
|
|
28
|
+
IRenderMimeRegistry,
|
|
29
|
+
INotebookTracker,
|
|
30
|
+
IEditorServices,
|
|
31
|
+
NotebookPanel.IContentFactory,
|
|
32
|
+
ISpectaLayoutRegistry
|
|
33
|
+
],
|
|
34
|
+
activate,
|
|
35
|
+
provides: ISpectaDocTracker
|
|
36
|
+
};
|
|
37
|
+
export const spectaOpener = {
|
|
38
|
+
id: 'specta/application-extension:opener',
|
|
39
|
+
autoStart: true,
|
|
40
|
+
requires: [IDocumentManager, ISpectaDocTracker, IKernelSpecManager],
|
|
41
|
+
activate: async (app, docManager) => {
|
|
42
|
+
if (!isSpectaApp()) {
|
|
43
|
+
// Not a specta app, return
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
47
|
+
const path = urlParams.get('path');
|
|
48
|
+
if (!path) {
|
|
49
|
+
const browser = createFileBrowser({ docManager });
|
|
50
|
+
app.shell.add(browser, 'main', { rank: 100 });
|
|
51
|
+
hideAppLoadingIndicator();
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const widget = docManager.openOrReveal(path, 'specta');
|
|
55
|
+
if (widget) {
|
|
56
|
+
app.shell.add(widget, 'main');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IEditorMimeTypeService } from '@jupyterlab/codeeditor';
|
|
2
|
+
import { DocumentWidget } from '@jupyterlab/docregistry';
|
|
3
|
+
import { INotebookModel, INotebookTracker, NotebookPanel } from '@jupyterlab/notebook';
|
|
4
|
+
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
5
|
+
import { ServiceManager } from '@jupyterlab/services';
|
|
6
|
+
import { Widget } from '@lumino/widgets';
|
|
7
|
+
export interface ISpectaOptions {
|
|
8
|
+
manager: ServiceManager;
|
|
9
|
+
rendermime: IRenderMimeRegistry;
|
|
10
|
+
tracker: INotebookTracker;
|
|
11
|
+
contentFactory: NotebookPanel.IContentFactory;
|
|
12
|
+
mimeTypeService: IEditorMimeTypeService;
|
|
13
|
+
}
|
|
14
|
+
export declare class NotebookSpectaDocWidget extends DocumentWidget<Widget, INotebookModel> {
|
|
15
|
+
constructor(options: DocumentWidget.IOptions<Widget, INotebookModel>);
|
|
16
|
+
dispose(): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from './tool';
|
|
2
|
+
export * from './token';
|
|
3
|
+
declare const _default: (import("@jupyterlab/application").JupyterFrontEndPlugin<import("@jupyterlab/apputils").IWidgetTracker<import("@lumino/widgets").Widget>> | import("@jupyterlab/application").JupyterFrontEndPlugin<void> | import("@jupyterlab/application").JupyterFrontEndPlugin<import("./token").ISpectaLayoutRegistry>)[];
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Panel } from '@lumino/widgets';
|
|
2
|
+
import { SpectaCellOutput } from '../specta_cell_output';
|
|
3
|
+
import * as nbformat from '@jupyterlab/nbformat';
|
|
4
|
+
import { ISpectaLayout } from '../token';
|
|
5
|
+
export declare class DefaultLayout implements ISpectaLayout {
|
|
6
|
+
render(options: {
|
|
7
|
+
host: Panel;
|
|
8
|
+
items: SpectaCellOutput[];
|
|
9
|
+
notebook: nbformat.INotebookContent;
|
|
10
|
+
readyCallback: () => Promise<void>;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export class DefaultLayout {
|
|
2
|
+
async render(options) {
|
|
3
|
+
const { host, items, readyCallback } = options;
|
|
4
|
+
for (const el of items) {
|
|
5
|
+
const outputNode = el.cellOutput.node;
|
|
6
|
+
const cellModel = el.info.cellModel;
|
|
7
|
+
const info = el.info;
|
|
8
|
+
if ((cellModel === null || cellModel === void 0 ? void 0 : cellModel.cell_type) === 'code') {
|
|
9
|
+
if (outputNode.childNodes.length > 0) {
|
|
10
|
+
if (!info.hidden) {
|
|
11
|
+
host.addWidget(el);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
if (!info.hidden) {
|
|
17
|
+
host.addWidget(el);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
await readyCallback();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ISignal } from '@lumino/signaling';
|
|
2
|
+
import { ISpectaLayout, ISpectaLayoutRegistry } from '../token';
|
|
3
|
+
export declare class SpectaLayoutRegistry implements ISpectaLayoutRegistry {
|
|
4
|
+
constructor();
|
|
5
|
+
get layoutAdded(): ISignal<SpectaLayoutRegistry, string>;
|
|
6
|
+
get selectedLayout(): {
|
|
7
|
+
name: string;
|
|
8
|
+
layout: ISpectaLayout;
|
|
9
|
+
};
|
|
10
|
+
get selectedLayoutChanged(): ISignal<SpectaLayoutRegistry, {
|
|
11
|
+
name: string;
|
|
12
|
+
layout: ISpectaLayout;
|
|
13
|
+
}>;
|
|
14
|
+
get(name: string): ISpectaLayout | undefined;
|
|
15
|
+
setSelectedLayout(name: string): void;
|
|
16
|
+
register(name: string, layout: ISpectaLayout): void;
|
|
17
|
+
allLayouts(): string[];
|
|
18
|
+
private _selectedLayout;
|
|
19
|
+
private _registry;
|
|
20
|
+
private _layoutAdded;
|
|
21
|
+
private _selectedLayoutChanged;
|
|
22
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Signal } from '@lumino/signaling';
|
|
2
|
+
import { DefaultLayout } from './default';
|
|
3
|
+
export class SpectaLayoutRegistry {
|
|
4
|
+
constructor() {
|
|
5
|
+
this._registry = new Map();
|
|
6
|
+
this._layoutAdded = new Signal(this);
|
|
7
|
+
this._selectedLayoutChanged = new Signal(this);
|
|
8
|
+
const defaultLayout = new DefaultLayout();
|
|
9
|
+
this._registry = new Map();
|
|
10
|
+
this._registry.set('default', defaultLayout);
|
|
11
|
+
this._selectedLayout = {
|
|
12
|
+
name: 'default',
|
|
13
|
+
layout: defaultLayout
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
get layoutAdded() {
|
|
17
|
+
return this._layoutAdded;
|
|
18
|
+
}
|
|
19
|
+
get selectedLayout() {
|
|
20
|
+
return this._selectedLayout;
|
|
21
|
+
}
|
|
22
|
+
get selectedLayoutChanged() {
|
|
23
|
+
return this._selectedLayoutChanged;
|
|
24
|
+
}
|
|
25
|
+
get(name) {
|
|
26
|
+
return this._registry.get(name);
|
|
27
|
+
}
|
|
28
|
+
setSelectedLayout(name) {
|
|
29
|
+
if (!this._registry.has(name)) {
|
|
30
|
+
throw new Error(`Layout with name ${name} does not exist`);
|
|
31
|
+
}
|
|
32
|
+
this._selectedLayout = { name, layout: this._registry.get(name) };
|
|
33
|
+
}
|
|
34
|
+
register(name, layout) {
|
|
35
|
+
if (this._registry.has(name)) {
|
|
36
|
+
throw new Error(`Layout with name ${name} already exists`);
|
|
37
|
+
}
|
|
38
|
+
this._registry.set(name, layout);
|
|
39
|
+
this._layoutAdded.emit(name);
|
|
40
|
+
}
|
|
41
|
+
allLayouts() {
|
|
42
|
+
return Array.from(this._registry.keys());
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SpectaLayoutRegistry } from './layout_registry';
|
|
2
|
+
import { ISpectaLayoutRegistry } from '../token';
|
|
3
|
+
export const spectaLayoutRegistry = {
|
|
4
|
+
id: 'specta:layout-registry',
|
|
5
|
+
autoStart: true,
|
|
6
|
+
provides: ISpectaLayoutRegistry,
|
|
7
|
+
activate: (app) => {
|
|
8
|
+
const layoutRegistry = new SpectaLayoutRegistry();
|
|
9
|
+
return layoutRegistry;
|
|
10
|
+
}
|
|
11
|
+
};
|
package/lib/plugins.d.ts
ADDED
package/lib/plugins.js
ADDED
package/lib/shell.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { JupyterFrontEnd } from '@jupyterlab/application';
|
|
2
|
+
import { DocumentRegistry } from '@jupyterlab/docregistry';
|
|
3
|
+
import { Widget } from '@lumino/widgets';
|
|
4
|
+
/**
|
|
5
|
+
* A namespace for Shell statics
|
|
6
|
+
*/
|
|
7
|
+
export declare namespace IShell {
|
|
8
|
+
/**
|
|
9
|
+
* The areas of the application shell where widgets can reside.
|
|
10
|
+
*/
|
|
11
|
+
type Area = 'main' | 'header' | 'top' | 'menu' | 'left' | 'right' | 'bottom' | 'down';
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The application shell.
|
|
15
|
+
*/
|
|
16
|
+
export declare class SpectaShell extends Widget implements JupyterFrontEnd.IShell {
|
|
17
|
+
constructor();
|
|
18
|
+
/**
|
|
19
|
+
* The current widget in the shell's main area.
|
|
20
|
+
*/
|
|
21
|
+
get currentWidget(): Widget | null;
|
|
22
|
+
activateById(id: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* Add a widget to the application shell.
|
|
25
|
+
*
|
|
26
|
+
* @param widget - The widget being added.
|
|
27
|
+
*
|
|
28
|
+
* @param area - Optional region in the shell into which the widget should
|
|
29
|
+
* be added.
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
add(widget: Widget, area?: IShell.Area, options?: DocumentRegistry.IOpenOptions): void;
|
|
33
|
+
widgets(area: IShell.Area): IterableIterator<Widget>;
|
|
34
|
+
/**
|
|
35
|
+
* Add a widget to the top content area.
|
|
36
|
+
*
|
|
37
|
+
* #### Notes
|
|
38
|
+
* Widgets must have a unique `id` property, which will be used as the DOM id.
|
|
39
|
+
*/
|
|
40
|
+
private _addToTopArea;
|
|
41
|
+
/**
|
|
42
|
+
* Add a widget to the bottom content area.
|
|
43
|
+
*
|
|
44
|
+
* #### Notes
|
|
45
|
+
* Widgets must have a unique `id` property, which will be used as the DOM id.
|
|
46
|
+
*/
|
|
47
|
+
private _addToBottomArea;
|
|
48
|
+
/**
|
|
49
|
+
* Handle a change to the layout.
|
|
50
|
+
*/
|
|
51
|
+
private _onLayoutModified;
|
|
52
|
+
private _topHandler;
|
|
53
|
+
private _mainPanel;
|
|
54
|
+
private _bottomPanel;
|
|
55
|
+
private _layoutDebouncer;
|
|
56
|
+
private _layoutModified;
|
|
57
|
+
}
|