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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/lib/app.d.ts +61 -0
  4. package/lib/app.js +90 -0
  5. package/lib/create_notebook_panel.d.ts +9 -0
  6. package/lib/create_notebook_panel.js +14 -0
  7. package/lib/document/factory.d.ts +13 -0
  8. package/lib/document/factory.js +26 -0
  9. package/lib/document/plugin.d.ts +4 -0
  10. package/lib/document/plugin.js +60 -0
  11. package/lib/document/widget.d.ts +17 -0
  12. package/lib/document/widget.js +10 -0
  13. package/lib/extension_plugins.d.ts +4 -0
  14. package/lib/extension_plugins.js +5 -0
  15. package/lib/layout/default.d.ts +12 -0
  16. package/lib/layout/default.js +23 -0
  17. package/lib/layout/layout_registry.d.ts +22 -0
  18. package/lib/layout/layout_registry.js +44 -0
  19. package/lib/layout/plugin.d.ts +3 -0
  20. package/lib/layout/plugin.js +11 -0
  21. package/lib/plugins.d.ts +2 -0
  22. package/lib/plugins.js +2 -0
  23. package/lib/sharedscope.d.ts +3 -0
  24. package/lib/sharedscope.js +3 -0
  25. package/lib/shell.d.ts +57 -0
  26. package/lib/shell.js +206 -0
  27. package/lib/specta_cell_output.d.ts +14 -0
  28. package/lib/specta_cell_output.js +24 -0
  29. package/lib/specta_model.d.ts +42 -0
  30. package/lib/specta_model.js +116 -0
  31. package/lib/specta_widget.d.ts +29 -0
  32. package/lib/specta_widget.js +92 -0
  33. package/lib/specta_widget_factory.d.ts +25 -0
  34. package/lib/specta_widget_factory.js +30 -0
  35. package/lib/token.d.ts +31 -0
  36. package/lib/token.js +3 -0
  37. package/lib/tool.d.ts +23 -0
  38. package/lib/tool.js +96 -0
  39. package/package.json +231 -0
  40. package/style/base.css +56 -0
  41. package/style/index.css +1 -0
  42. package/style/index.js +1 -0
  43. package/style/style.css +29 -0
package/lib/shell.js ADDED
@@ -0,0 +1,206 @@
1
+ import { ArrayExt } from '@lumino/algorithm';
2
+ import { MessageLoop } from '@lumino/messaging';
3
+ import { Debouncer } from '@lumino/polling';
4
+ import { Signal } from '@lumino/signaling';
5
+ import { BoxLayout, BoxPanel, Panel, Widget } from '@lumino/widgets';
6
+ /**
7
+ * The class name added to AppShell instances.
8
+ */
9
+ const APPLICATION_SHELL_CLASS = 'jp-LabShell';
10
+ /**
11
+ * The default rank of items added to a sidebar.
12
+ */
13
+ const DEFAULT_RANK = 900;
14
+ /**
15
+ * The application shell.
16
+ */
17
+ export class SpectaShell extends Widget {
18
+ constructor() {
19
+ super();
20
+ this._layoutDebouncer = new Debouncer(() => {
21
+ this._layoutModified.emit(undefined);
22
+ }, 0);
23
+ this._layoutModified = new Signal(this);
24
+ this.id = 'main';
25
+ const rootLayout = new BoxLayout();
26
+ rootLayout.alignment = 'start';
27
+ rootLayout.spacing = 0;
28
+ this.addClass(APPLICATION_SHELL_CLASS);
29
+ const topHandler = (this._topHandler = new Private.PanelHandler());
30
+ topHandler.panel.id = 'specta-top-panel';
31
+ topHandler.panel.node.setAttribute('role', 'banner');
32
+ BoxLayout.setStretch(topHandler.panel, 0);
33
+ topHandler.panel.hide();
34
+ rootLayout.addWidget(topHandler.panel);
35
+ const hboxPanel = (this._mainPanel = new BoxPanel());
36
+ hboxPanel.id = 'jp-main-content-panel';
37
+ hboxPanel.direction = 'top-to-bottom';
38
+ BoxLayout.setStretch(hboxPanel, 1);
39
+ rootLayout.addWidget(hboxPanel);
40
+ const bottomPanel = (this._bottomPanel = new Panel());
41
+ bottomPanel.node.setAttribute('role', 'contentinfo');
42
+ bottomPanel.id = 'specta-bottom-panel';
43
+ BoxLayout.setStretch(bottomPanel, 0);
44
+ rootLayout.addWidget(bottomPanel);
45
+ bottomPanel.hide();
46
+ this.layout = rootLayout;
47
+ }
48
+ /**
49
+ * The current widget in the shell's main area.
50
+ */
51
+ get currentWidget() {
52
+ return this._mainPanel.widgets[0];
53
+ }
54
+ activateById(id) {
55
+ // no-op
56
+ }
57
+ /**
58
+ * Add a widget to the application shell.
59
+ *
60
+ * @param widget - The widget being added.
61
+ *
62
+ * @param area - Optional region in the shell into which the widget should
63
+ * be added.
64
+ *
65
+ */
66
+ add(widget, area, options) {
67
+ switch (area) {
68
+ case 'top':
69
+ this._addToTopArea(widget, options);
70
+ break;
71
+ case 'bottom':
72
+ this._addToBottomArea(widget, options);
73
+ break;
74
+ case 'main':
75
+ this._mainPanel.addWidget(widget);
76
+ break;
77
+ default:
78
+ console.warn(`Area ${area} is not implemented yet!`);
79
+ break;
80
+ }
81
+ }
82
+ widgets(area) {
83
+ switch (area) {
84
+ case 'top':
85
+ return this._topHandler.panel.children();
86
+ case 'bottom':
87
+ return this._bottomPanel.children();
88
+ case 'main':
89
+ this._mainPanel.children();
90
+ break;
91
+ default:
92
+ return [][Symbol.iterator]();
93
+ }
94
+ return [][Symbol.iterator]();
95
+ }
96
+ /**
97
+ * Add a widget to the top content area.
98
+ *
99
+ * #### Notes
100
+ * Widgets must have a unique `id` property, which will be used as the DOM id.
101
+ */
102
+ _addToTopArea(widget, options) {
103
+ var _a;
104
+ if (!widget.id) {
105
+ console.error('Widgets added to app shell must have unique id property.');
106
+ return;
107
+ }
108
+ options = options || {};
109
+ const rank = (_a = options.rank) !== null && _a !== void 0 ? _a : DEFAULT_RANK;
110
+ this._topHandler.addWidget(widget, rank);
111
+ this._onLayoutModified();
112
+ if (this._topHandler.panel.isHidden) {
113
+ this._topHandler.panel.show();
114
+ }
115
+ }
116
+ /**
117
+ * Add a widget to the bottom content area.
118
+ *
119
+ * #### Notes
120
+ * Widgets must have a unique `id` property, which will be used as the DOM id.
121
+ */
122
+ _addToBottomArea(widget, options) {
123
+ if (!widget.id) {
124
+ console.error('Widgets added to app shell must have unique id property.');
125
+ return;
126
+ }
127
+ this._bottomPanel.addWidget(widget);
128
+ this._onLayoutModified();
129
+ if (this._bottomPanel.isHidden) {
130
+ this._bottomPanel.show();
131
+ }
132
+ }
133
+ /**
134
+ * Handle a change to the layout.
135
+ */
136
+ _onLayoutModified() {
137
+ void this._layoutDebouncer.invoke();
138
+ }
139
+ }
140
+ var Private;
141
+ (function (Private) {
142
+ /**
143
+ * A less-than comparison function for side bar rank items.
144
+ */
145
+ function itemCmp(first, second) {
146
+ return first.rank - second.rank;
147
+ }
148
+ Private.itemCmp = itemCmp;
149
+ /**
150
+ * A class which manages a panel and sorts its widgets by rank.
151
+ */
152
+ class PanelHandler {
153
+ constructor() {
154
+ /**
155
+ * A message hook for child add/remove messages on the main area dock panel.
156
+ */
157
+ this._panelChildHook = (handler, msg) => {
158
+ switch (msg.type) {
159
+ case 'child-added':
160
+ {
161
+ const widget = msg.child;
162
+ // If we already know about this widget, we're done
163
+ if (this._items.find(v => v.widget === widget)) {
164
+ break;
165
+ }
166
+ // Otherwise, add to the end by default
167
+ const rank = this._items[this._items.length - 1].rank;
168
+ this._items.push({ widget, rank });
169
+ }
170
+ break;
171
+ case 'child-removed':
172
+ {
173
+ const widget = msg.child;
174
+ ArrayExt.removeFirstWhere(this._items, v => v.widget === widget);
175
+ }
176
+ break;
177
+ default:
178
+ break;
179
+ }
180
+ return true;
181
+ };
182
+ this._items = new Array();
183
+ this._panel = new Panel();
184
+ MessageLoop.installMessageHook(this._panel, this._panelChildHook);
185
+ }
186
+ /**
187
+ * Get the panel managed by the handler.
188
+ */
189
+ get panel() {
190
+ return this._panel;
191
+ }
192
+ /**
193
+ * Add a widget to the panel.
194
+ *
195
+ * If the widget is already added, it will be moved.
196
+ */
197
+ addWidget(widget, rank) {
198
+ widget.parent = null;
199
+ const item = { widget, rank };
200
+ const index = ArrayExt.upperBound(this._items, item, Private.itemCmp);
201
+ ArrayExt.insert(this._items, index, item);
202
+ this._panel.insertWidget(index, widget);
203
+ }
204
+ }
205
+ Private.PanelHandler = PanelHandler;
206
+ })(Private || (Private = {}));
@@ -0,0 +1,14 @@
1
+ import { Panel, Widget } from '@lumino/widgets';
2
+ import * as nbformat from '@jupyterlab/nbformat';
3
+ export interface ICellInfo {
4
+ hidden?: boolean;
5
+ cellModel?: nbformat.ICell;
6
+ }
7
+ export declare class SpectaCellOutput extends Panel {
8
+ constructor(cellIdentity: string, cell: Widget, info: ICellInfo);
9
+ readonly cellIdentity: string;
10
+ get cellOutput(): Widget;
11
+ get info(): ICellInfo;
12
+ private _info;
13
+ private _cellOutput;
14
+ }
@@ -0,0 +1,24 @@
1
+ import { Panel } from '@lumino/widgets';
2
+ export class SpectaCellOutput extends Panel {
3
+ constructor(cellIdentity, cell, info) {
4
+ super();
5
+ this._info = {};
6
+ this.removeClass('lm-Widget');
7
+ this.removeClass('p-Widget');
8
+ this.addClass('specta-cell-output');
9
+ const content = new Panel();
10
+ content.addClass('specta-cell-content');
11
+ cell.addClass('specta-item-widget');
12
+ content.addWidget(cell);
13
+ this.addWidget(content);
14
+ this._cellOutput = cell;
15
+ this.cellIdentity = cellIdentity;
16
+ this._info = info !== null && info !== void 0 ? info : {};
17
+ }
18
+ get cellOutput() {
19
+ return this._cellOutput;
20
+ }
21
+ get info() {
22
+ return this._info;
23
+ }
24
+ }
@@ -0,0 +1,42 @@
1
+ import { ICellModel } from '@jupyterlab/cells';
2
+ import { IEditorMimeTypeService, IEditorServices } from '@jupyterlab/codeeditor';
3
+ import { DocumentRegistry } from '@jupyterlab/docregistry';
4
+ import { CellList, INotebookModel, INotebookTracker, NotebookPanel, StaticNotebook } from '@jupyterlab/notebook';
5
+ import { SimplifiedOutputArea } from '@jupyterlab/outputarea';
6
+ import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
7
+ import { ServiceManager } from '@jupyterlab/services';
8
+ import { IExecuteReplyMsg } from '@jupyterlab/services/lib/kernel/messages';
9
+ import { SpectaCellOutput } from './specta_cell_output';
10
+ export declare const VIEW = "grid_default";
11
+ export declare class AppModel {
12
+ private options;
13
+ constructor(options: AppModel.IOptions);
14
+ /**
15
+ * Whether the handler is disposed.
16
+ */
17
+ get isDisposed(): boolean;
18
+ dispose(): void;
19
+ get rendermime(): IRenderMimeRegistry;
20
+ get cells(): CellList | undefined;
21
+ get context(): DocumentRegistry.IContext<INotebookModel>;
22
+ get panel(): NotebookPanel | undefined;
23
+ initialize(): Promise<void>;
24
+ createCell(cellModel: ICellModel): SpectaCellOutput;
25
+ executeCell(cell: ICellModel, output: SimplifiedOutputArea): Promise<IExecuteReplyMsg | undefined>;
26
+ private _notebookPanel?;
27
+ private _context;
28
+ private _isDisposed;
29
+ }
30
+ export declare namespace AppModel {
31
+ interface IOptions {
32
+ context: DocumentRegistry.IContext<INotebookModel>;
33
+ manager: ServiceManager.IManager;
34
+ rendermime: IRenderMimeRegistry;
35
+ tracker: INotebookTracker;
36
+ contentFactory: NotebookPanel.IContentFactory;
37
+ mimeTypeService: IEditorMimeTypeService;
38
+ editorConfig: StaticNotebook.IEditorConfig;
39
+ notebookConfig: StaticNotebook.INotebookConfig;
40
+ editorServices: IEditorServices;
41
+ }
42
+ }
@@ -0,0 +1,116 @@
1
+ import { MarkdownCell, RawCell } from '@jupyterlab/cells';
2
+ import { OutputAreaModel, SimplifiedOutputArea } from '@jupyterlab/outputarea';
3
+ import { createNotebookPanel } from './create_notebook_panel';
4
+ import { SpectaCellOutput } from './specta_cell_output';
5
+ export const VIEW = 'grid_default';
6
+ export class AppModel {
7
+ constructor(options) {
8
+ this.options = options;
9
+ this._isDisposed = false;
10
+ this._context = options.context;
11
+ }
12
+ /**
13
+ * Whether the handler is disposed.
14
+ */
15
+ get isDisposed() {
16
+ return this._isDisposed;
17
+ }
18
+ dispose() {
19
+ var _a, _b;
20
+ if (this.isDisposed) {
21
+ return;
22
+ }
23
+ this._isDisposed = true;
24
+ (_a = this._context) === null || _a === void 0 ? void 0 : _a.dispose();
25
+ (_b = this._notebookPanel) === null || _b === void 0 ? void 0 : _b.dispose();
26
+ }
27
+ get rendermime() {
28
+ return this.options.rendermime;
29
+ }
30
+ get cells() {
31
+ var _a;
32
+ return (_a = this._context) === null || _a === void 0 ? void 0 : _a.model.cells;
33
+ }
34
+ get context() {
35
+ return this._context;
36
+ }
37
+ get panel() {
38
+ return this._notebookPanel;
39
+ }
40
+ async initialize() {
41
+ var _a;
42
+ await ((_a = this._context) === null || _a === void 0 ? void 0 : _a.sessionContext.ready);
43
+ this._notebookPanel = createNotebookPanel({
44
+ context: this._context,
45
+ rendermime: this.options.rendermime,
46
+ editorServices: this.options.editorServices
47
+ });
48
+ this.options.tracker.widgetAdded.emit(this._notebookPanel);
49
+ }
50
+ createCell(cellModel) {
51
+ let item;
52
+ const cellModelJson = cellModel.toJSON();
53
+ const info = {
54
+ cellModel: cellModelJson
55
+ };
56
+ switch (cellModel.type) {
57
+ case 'code': {
58
+ const outputareamodel = new OutputAreaModel({ trusted: true });
59
+ const out = new SimplifiedOutputArea({
60
+ model: outputareamodel,
61
+ rendermime: this.options.rendermime
62
+ });
63
+ item = new SpectaCellOutput(cellModel.id, out, info);
64
+ break;
65
+ }
66
+ case 'markdown': {
67
+ const markdownCell = new MarkdownCell({
68
+ model: cellModel,
69
+ rendermime: this.options.rendermime,
70
+ contentFactory: this.options.contentFactory,
71
+ editorConfig: this.options.editorConfig.markdown
72
+ });
73
+ markdownCell.inputHidden = false;
74
+ markdownCell.rendered = true;
75
+ Private.removeElements(markdownCell.node, 'jp-Collapser');
76
+ Private.removeElements(markdownCell.node, 'jp-InputPrompt');
77
+ item = new SpectaCellOutput(cellModel.id, markdownCell, info);
78
+ break;
79
+ }
80
+ default: {
81
+ const rawCell = new RawCell({
82
+ model: cellModel,
83
+ contentFactory: this.options.contentFactory,
84
+ editorConfig: this.options.editorConfig.raw
85
+ });
86
+ rawCell.inputHidden = false;
87
+ Private.removeElements(rawCell.node, 'jp-Collapser');
88
+ Private.removeElements(rawCell.node, 'jp-InputPrompt');
89
+ item = new SpectaCellOutput(cellModel.id, rawCell, info);
90
+ break;
91
+ }
92
+ }
93
+ return item;
94
+ }
95
+ async executeCell(cell, output) {
96
+ if (cell.type !== 'code' || !this._context) {
97
+ return;
98
+ }
99
+ const source = cell.sharedModel.source;
100
+ const rep = await SimplifiedOutputArea.execute(source, output, this._context.sessionContext);
101
+ return rep;
102
+ }
103
+ }
104
+ var Private;
105
+ (function (Private) {
106
+ /**
107
+ * Remove children by className from an HTMLElement.
108
+ */
109
+ function removeElements(node, className) {
110
+ const elements = node.getElementsByClassName(className);
111
+ for (let i = 0; i < elements.length; i++) {
112
+ elements[i].remove();
113
+ }
114
+ }
115
+ Private.removeElements = removeElements;
116
+ })(Private || (Private = {}));
@@ -0,0 +1,29 @@
1
+ import { Message } from '@lumino/messaging';
2
+ import { Panel } from '@lumino/widgets';
3
+ import { AppModel } from './specta_model';
4
+ import { ISpectaLayoutRegistry } from './token';
5
+ export declare class AppWidget extends Panel {
6
+ constructor(options: AppWidget.IOptions);
7
+ /**
8
+ * A promise that is fulfilled when the model is ready.
9
+ */
10
+ get ready(): Promise<void>;
11
+ get model(): AppModel;
12
+ addSpinner(): void;
13
+ dispose(): void;
14
+ render(): Promise<void>;
15
+ protected onCloseRequest(msg: Message): void;
16
+ private _model;
17
+ private _ready;
18
+ private _host;
19
+ private _layoutRegistry;
20
+ private _loaderHost?;
21
+ }
22
+ export declare namespace AppWidget {
23
+ interface IOptions {
24
+ id: string;
25
+ label: string;
26
+ model: AppModel;
27
+ layoutRegistry: ISpectaLayoutRegistry;
28
+ }
29
+ }
@@ -0,0 +1,92 @@
1
+ import { PromiseDelegate } from '@lumino/coreutils';
2
+ import { Panel, Widget } from '@lumino/widgets';
3
+ import { hideAppLoadingIndicator, isSpectaApp } from './tool';
4
+ export class AppWidget extends Panel {
5
+ constructor(options) {
6
+ super();
7
+ this._ready = new PromiseDelegate();
8
+ this.node.id = options.id;
9
+ this.title.label = options.label;
10
+ this.title.closable = true;
11
+ this._model = options.model;
12
+ this._layoutRegistry = options.layoutRegistry;
13
+ this.node.style.padding = '5px';
14
+ this._host = new Panel();
15
+ this._host.addClass('specta-output-host');
16
+ this.addWidget(this._host);
17
+ this.node.style.overflow = 'auto';
18
+ if (!isSpectaApp()) {
19
+ // Not a specta app, add spinner
20
+ this.addSpinner();
21
+ }
22
+ this._model.initialize().then(() => {
23
+ this.render()
24
+ .catch(console.error)
25
+ .then(() => window.dispatchEvent(new Event('resize')));
26
+ });
27
+ }
28
+ /**
29
+ * A promise that is fulfilled when the model is ready.
30
+ */
31
+ get ready() {
32
+ return this._ready.promise;
33
+ }
34
+ get model() {
35
+ return this._model;
36
+ }
37
+ addSpinner() {
38
+ const loaderHost = (this._loaderHost = new Widget());
39
+ loaderHost.addClass('specta-loader-host');
40
+ const spinner = document.createElement('div');
41
+ spinner.className = 'specta-loader';
42
+ loaderHost.node.appendChild(spinner);
43
+ const text = document.createElement('div');
44
+ text.className = 'specta-loading-indicator-text';
45
+ text.textContent = 'Loading Specta';
46
+ loaderHost.node.appendChild(text);
47
+ this.addWidget(loaderHost);
48
+ }
49
+ dispose() {
50
+ if (this.isDisposed) {
51
+ return;
52
+ }
53
+ this._model.dispose();
54
+ super.dispose();
55
+ }
56
+ async render() {
57
+ var _a;
58
+ const cellList = (_a = this._model.cells) !== null && _a !== void 0 ? _a : [];
59
+ const outputs = [];
60
+ for (const cell of cellList) {
61
+ const src = cell.sharedModel.source;
62
+ if (src.length === 0) {
63
+ continue;
64
+ }
65
+ const el = this._model.createCell(cell);
66
+ await this._model.executeCell(cell, el.cellOutput);
67
+ outputs.push(el);
68
+ }
69
+ const readyCallback = async () => {
70
+ if (this._loaderHost) {
71
+ this._loaderHost.node.style.opacity = '0';
72
+ setTimeout(() => {
73
+ var _a;
74
+ (_a = this.layout) === null || _a === void 0 ? void 0 : _a.removeWidget(this._loaderHost);
75
+ }, 100);
76
+ }
77
+ else {
78
+ hideAppLoadingIndicator();
79
+ }
80
+ };
81
+ await this._layoutRegistry.selectedLayout.layout.render({
82
+ host: this._host,
83
+ items: outputs,
84
+ notebook: this._model.context.model.toJSON(),
85
+ readyCallback
86
+ });
87
+ }
88
+ onCloseRequest(msg) {
89
+ this._model.dispose();
90
+ super.onCloseRequest(msg);
91
+ }
92
+ }
@@ -0,0 +1,25 @@
1
+ import { IEditorMimeTypeService, IEditorServices } from '@jupyterlab/codeeditor';
2
+ import { INotebookTracker, NotebookPanel, INotebookModel } from '@jupyterlab/notebook';
3
+ import { DocumentRegistry } from '@jupyterlab/docregistry';
4
+ import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
5
+ import { ServiceManager } from '@jupyterlab/services';
6
+ import { AppWidget } from './specta_widget';
7
+ import { ISpectaLayoutRegistry } from './token';
8
+ export declare class SpectaWidgetFactory {
9
+ constructor(options: SpectaWidgetFactory.IOptions);
10
+ createNew(options: {
11
+ context: DocumentRegistry.IContext<INotebookModel>;
12
+ }): Promise<AppWidget>;
13
+ private _options;
14
+ }
15
+ export declare namespace SpectaWidgetFactory {
16
+ interface IOptions {
17
+ manager: ServiceManager.IManager;
18
+ rendermime: IRenderMimeRegistry;
19
+ tracker: INotebookTracker;
20
+ contentFactory: NotebookPanel.IContentFactory;
21
+ mimeTypeService: IEditorMimeTypeService;
22
+ editorServices: IEditorServices;
23
+ spectaLayoutRegistry: ISpectaLayoutRegistry;
24
+ }
25
+ }
@@ -0,0 +1,30 @@
1
+ import { StaticNotebook } from '@jupyterlab/notebook';
2
+ import { AppModel } from './specta_model';
3
+ import { AppWidget } from './specta_widget';
4
+ import { UUID } from '@lumino/coreutils';
5
+ export class SpectaWidgetFactory {
6
+ constructor(options) {
7
+ this._options = options;
8
+ }
9
+ async createNew(options) {
10
+ const { context } = options;
11
+ const model = new AppModel({
12
+ context,
13
+ manager: this._options.manager,
14
+ rendermime: this._options.rendermime,
15
+ tracker: this._options.tracker,
16
+ contentFactory: this._options.contentFactory,
17
+ mimeTypeService: this._options.mimeTypeService,
18
+ editorConfig: StaticNotebook.defaultEditorConfig,
19
+ notebookConfig: StaticNotebook.defaultNotebookConfig,
20
+ editorServices: this._options.editorServices
21
+ });
22
+ const panel = new AppWidget({
23
+ id: UUID.uuid4(),
24
+ label: '',
25
+ model,
26
+ layoutRegistry: this._options.spectaLayoutRegistry
27
+ });
28
+ return panel;
29
+ }
30
+ }
package/lib/token.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { Token } from '@lumino/coreutils';
2
+ import { Panel, Widget } from '@lumino/widgets';
3
+ import { SpectaCellOutput } from './specta_cell_output';
4
+ import * as nbformat from '@jupyterlab/nbformat';
5
+ import { ISignal } from '@lumino/signaling';
6
+ import { IWidgetTracker } from '@jupyterlab/apputils';
7
+ export interface ISpectaLayout {
8
+ render(options: {
9
+ host: Panel;
10
+ items: SpectaCellOutput[];
11
+ notebook: nbformat.INotebookContent;
12
+ readyCallback: () => Promise<void>;
13
+ }): Promise<void>;
14
+ }
15
+ export interface ISpectaLayoutRegistry {
16
+ get(name: string): ISpectaLayout | undefined;
17
+ register(name: string, layout: ISpectaLayout): void;
18
+ allLayouts(): string[];
19
+ layoutAdded: ISignal<ISpectaLayoutRegistry, string>;
20
+ selectedLayout: {
21
+ name: string;
22
+ layout: ISpectaLayout;
23
+ };
24
+ setSelectedLayout(name: string): void;
25
+ selectedLayoutChanged: ISignal<ISpectaLayoutRegistry, {
26
+ name: string;
27
+ layout: ISpectaLayout;
28
+ }>;
29
+ }
30
+ export declare const ISpectaLayoutRegistry: Token<ISpectaLayoutRegistry>;
31
+ export declare const ISpectaDocTracker: Token<IWidgetTracker<Widget>>;
package/lib/token.js ADDED
@@ -0,0 +1,3 @@
1
+ import { Token } from '@lumino/coreutils';
2
+ export const ISpectaLayoutRegistry = new Token('specta:ISpectaLayoutRegistry');
3
+ export const ISpectaDocTracker = new Token('exampleDocTracker');
package/lib/tool.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ import { JupyterFrontEnd } from '@jupyterlab/application';
2
+ import { WidgetTracker } from '@jupyterlab/apputils';
3
+ import { IEditorServices } from '@jupyterlab/codeeditor';
4
+ import { INotebookTracker, NotebookPanel } from '@jupyterlab/notebook';
5
+ import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
6
+ import { VoilaFileBrowser } from '@voila-dashboards/voila';
7
+ import { IDocumentManager } from '@jupyterlab/docmanager';
8
+ import { ISpectaLayoutRegistry } from './token';
9
+ export declare function registerDocumentFactory(options: {
10
+ factoryName: string;
11
+ app: JupyterFrontEnd;
12
+ rendermime: IRenderMimeRegistry;
13
+ tracker: INotebookTracker;
14
+ editorServices: IEditorServices;
15
+ contentFactory: NotebookPanel.IContentFactory;
16
+ spectaTracker: WidgetTracker;
17
+ spectaLayoutRegistry: ISpectaLayoutRegistry;
18
+ }): void;
19
+ export declare function createFileBrowser(options: {
20
+ docManager: IDocumentManager;
21
+ }): VoilaFileBrowser;
22
+ export declare function hideAppLoadingIndicator(): void;
23
+ export declare function isSpectaApp(): boolean;