jupyter-specta 0.2.2 → 0.3.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/lib/create_notebook_panel.js +1 -1
- package/lib/document/plugin.d.ts +2 -2
- package/lib/document/plugin.js +54 -30
- package/lib/extension_plugins.d.ts +1 -1
- package/lib/sharedscope.d.ts +1 -1
- package/lib/sharedscope.js +1 -1
- package/lib/token.d.ts +7 -0
- package/lib/tool.d.ts +7 -1
- package/lib/tool.js +47 -1
- package/package.json +42 -44
package/lib/document/plugin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { JupyterFrontEndPlugin } from '@jupyterlab/application';
|
|
1
|
+
import { ILabShell, JupyterFrontEndPlugin } from '@jupyterlab/application';
|
|
2
2
|
import { IWidgetTracker } from '@jupyterlab/apputils';
|
|
3
3
|
import { ISpectaShell } from '../token';
|
|
4
4
|
export declare const spectaDocument: JupyterFrontEndPlugin<IWidgetTracker, ISpectaShell>;
|
|
5
|
-
export declare const spectaOpener: JupyterFrontEndPlugin<void>;
|
|
5
|
+
export declare const spectaOpener: JupyterFrontEndPlugin<void, ILabShell>;
|
package/lib/document/plugin.js
CHANGED
|
@@ -8,7 +8,7 @@ import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
|
8
8
|
import { IKernelSpecManager } from '@jupyterlab/services';
|
|
9
9
|
import { Widget } from '@lumino/widgets';
|
|
10
10
|
import { ISpectaDocTracker, ISpectaLayoutRegistry } from '../token';
|
|
11
|
-
import { createFileBrowser, hideAppLoadingIndicator, isSpectaApp, registerDocumentFactory } from '../tool';
|
|
11
|
+
import { configLabLayout, createFileBrowser, hideAppLoadingIndicator, isSpectaApp, readSpectaConfig, registerDocumentFactory } from '../tool';
|
|
12
12
|
const activate = (app, rendermime, tracker, editorServices, contentFactory, spectaLayoutRegistry, themeManager) => {
|
|
13
13
|
const namespace = 'specta';
|
|
14
14
|
const spectaTracker = new WidgetTracker({ namespace });
|
|
@@ -49,47 +49,71 @@ export const spectaOpener = {
|
|
|
49
49
|
IKernelSpecManager
|
|
50
50
|
],
|
|
51
51
|
activate: async (app, docManager, defaultBrowser) => {
|
|
52
|
-
if (!isSpectaApp()) {
|
|
53
|
-
// Not a specta app, return
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
52
|
const urlParams = new URLSearchParams(window.location.search);
|
|
57
53
|
const path = urlParams.get('path');
|
|
58
|
-
if (!
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
if (!isSpectaApp()) {
|
|
55
|
+
if (!path) {
|
|
56
|
+
app.restored.then(async () => {
|
|
57
|
+
await app.commands.execute('application:reset-layout');
|
|
58
|
+
});
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
app.restored.then(async () => {
|
|
62
|
+
const labShell = app.shell;
|
|
63
|
+
if (PathExt.extname(path) === '.ipynb') {
|
|
64
|
+
const commands = app.commands;
|
|
65
|
+
const spectaConfig = readSpectaConfig({});
|
|
66
|
+
await configLabLayout({
|
|
67
|
+
config: spectaConfig.labConfig,
|
|
68
|
+
labShell,
|
|
69
|
+
commands
|
|
70
|
+
});
|
|
71
|
+
const widget = docManager.openOrReveal(path, 'specta');
|
|
72
|
+
if (widget) {
|
|
73
|
+
app.shell.add(widget, 'main');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
// Not a specta app
|
|
78
|
+
return;
|
|
62
79
|
}
|
|
63
80
|
else {
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
app.shell.add(widget, 'main');
|
|
69
|
-
}
|
|
81
|
+
if (!path) {
|
|
82
|
+
const browser = createFileBrowser({ defaultBrowser });
|
|
83
|
+
app.shell.add(browser, 'main', { rank: 100 });
|
|
84
|
+
hideAppLoadingIndicator();
|
|
70
85
|
}
|
|
71
86
|
else {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const widget = docManager.openOrReveal(path, '
|
|
87
|
+
if (PathExt.extname(path) === '.ipynb') {
|
|
88
|
+
app.shell.addClass('specta-document-viewer');
|
|
89
|
+
const widget = docManager.openOrReveal(path, 'specta');
|
|
75
90
|
if (widget) {
|
|
76
91
|
app.shell.add(widget, 'main');
|
|
77
|
-
hideAppLoadingIndicator();
|
|
78
92
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
let count = 0;
|
|
96
|
+
const tryOpen = () => {
|
|
97
|
+
const widget = docManager.openOrReveal(path, 'default');
|
|
98
|
+
if (widget) {
|
|
85
99
|
app.shell.add(widget, 'main');
|
|
86
100
|
hideAppLoadingIndicator();
|
|
87
|
-
return;
|
|
88
101
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
102
|
+
else {
|
|
103
|
+
count++;
|
|
104
|
+
if (count > 10) {
|
|
105
|
+
console.error('Failed to open file', path);
|
|
106
|
+
const widget = new Widget();
|
|
107
|
+
widget.node.innerHTML = `<h2 style="text-align: center; margin-top: 200px;">Failed to open file ${path}</h2>`;
|
|
108
|
+
app.shell.add(widget, 'main');
|
|
109
|
+
hideAppLoadingIndicator();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
setTimeout(tryOpen, 100);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
tryOpen();
|
|
116
|
+
}
|
|
93
117
|
}
|
|
94
118
|
}
|
|
95
119
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from './tool';
|
|
2
2
|
export * from './token';
|
|
3
|
-
declare const _default: (import("@jupyterlab/application").JupyterFrontEndPlugin<import("@jupyterlab/apputils").IWidgetTracker<import("@lumino/widgets").Widget>, import("./token").ISpectaShell> | import("@jupyterlab/application").JupyterFrontEndPlugin<import("./token").ISpectaLayoutRegistry> | import("@jupyterlab/application").JupyterFrontEndPlugin<void, import("./token").ISpectaShell>)[];
|
|
3
|
+
declare const _default: (import("@jupyterlab/application").JupyterFrontEndPlugin<import("@jupyterlab/apputils").IWidgetTracker<import("@lumino/widgets").Widget>, import("./token").ISpectaShell> | import("@jupyterlab/application").JupyterFrontEndPlugin<void, import("@jupyterlab/application").ILabShell> | import("@jupyterlab/application").JupyterFrontEndPlugin<import("./token").ISpectaLayoutRegistry> | import("@jupyterlab/application").JupyterFrontEndPlugin<void, import("./token").ISpectaShell>)[];
|
|
4
4
|
export default _default;
|
package/lib/sharedscope.d.ts
CHANGED
package/lib/sharedscope.js
CHANGED
package/lib/token.d.ts
CHANGED
|
@@ -50,6 +50,13 @@ export interface ISpectaAppConfig {
|
|
|
50
50
|
hideTopbar?: boolean;
|
|
51
51
|
slidesTheme?: string;
|
|
52
52
|
loadingName?: string;
|
|
53
|
+
labConfig?: {
|
|
54
|
+
setSingleMode?: boolean;
|
|
55
|
+
hideLeftPanel?: boolean;
|
|
56
|
+
hideRightPanel?: boolean;
|
|
57
|
+
hideStatusbar?: boolean;
|
|
58
|
+
hideHeader?: boolean;
|
|
59
|
+
};
|
|
53
60
|
}
|
|
54
61
|
export interface ISpectaCellConfig {
|
|
55
62
|
showSource?: boolean;
|
package/lib/tool.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { JupyterFrontEnd } from '@jupyterlab/application';
|
|
1
|
+
import { ILabShell, JupyterFrontEnd } from '@jupyterlab/application';
|
|
2
2
|
import { IThemeManager, WidgetTracker } from '@jupyterlab/apputils';
|
|
3
3
|
import { IEditorServices } from '@jupyterlab/codeeditor';
|
|
4
4
|
import { IDefaultFileBrowser } from '@jupyterlab/filebrowser';
|
|
5
5
|
import { ICell, INotebookMetadata } from '@jupyterlab/nbformat';
|
|
6
6
|
import { INotebookTracker, NotebookPanel } from '@jupyterlab/notebook';
|
|
7
7
|
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
8
|
+
import { CommandRegistry } from '@lumino/commands';
|
|
8
9
|
import { ISpectaAppConfig, ISpectaCellConfig, ISpectaLayoutRegistry, ISpectaShell } from './token';
|
|
9
10
|
export declare function registerDocumentFactory(options: {
|
|
10
11
|
factoryName: string;
|
|
@@ -32,3 +33,8 @@ export declare function readCellConfig(cell?: ICell): Required<ISpectaCellConfig
|
|
|
32
33
|
export declare function debounce<T extends (...args: any[]) => void>(fn: T, delay?: number): (...args: Parameters<T>) => void;
|
|
33
34
|
export declare const emitResizeEvent: () => void;
|
|
34
35
|
export declare function setRevealTheme(themeName: string): void;
|
|
36
|
+
export declare function configLabLayout(options: {
|
|
37
|
+
config?: ISpectaAppConfig['labConfig'];
|
|
38
|
+
labShell: ILabShell;
|
|
39
|
+
commands: CommandRegistry;
|
|
40
|
+
}): Promise<void>;
|
package/lib/tool.js
CHANGED
|
@@ -122,13 +122,21 @@ export function readSpectaConfig({ nbMetadata, nbPath }) {
|
|
|
122
122
|
if (perFileConfig && pathWithoutDrive && perFileConfig[pathWithoutDrive]) {
|
|
123
123
|
spectaConfig = Object.assign(Object.assign({}, spectaConfig), perFileConfig[pathWithoutDrive]);
|
|
124
124
|
}
|
|
125
|
-
const spectaMetadata = ((_a = nbMetadata === null || nbMetadata === void 0 ? void 0 : nbMetadata.specta) !== null && _a !== void 0 ? _a : {});
|
|
125
|
+
const spectaMetadata = JSON.parse(JSON.stringify((_a = nbMetadata === null || nbMetadata === void 0 ? void 0 : nbMetadata.specta) !== null && _a !== void 0 ? _a : {}));
|
|
126
126
|
if (spectaMetadata.hideTopbar === 'Yes') {
|
|
127
127
|
spectaMetadata.hideTopbar = true;
|
|
128
128
|
}
|
|
129
129
|
else if (spectaMetadata.hideTopbar === 'No') {
|
|
130
130
|
spectaMetadata.hideTopbar = false;
|
|
131
131
|
}
|
|
132
|
+
else {
|
|
133
|
+
if (spectaConfig.hideTopbar === null ||
|
|
134
|
+
spectaConfig.hideTopbar === undefined) {
|
|
135
|
+
// Hide topbar by default if not specified in the global config
|
|
136
|
+
// and notebook metadata
|
|
137
|
+
spectaMetadata.hideTopbar = true;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
132
140
|
return mergeObjects(spectaConfig, spectaMetadata);
|
|
133
141
|
}
|
|
134
142
|
export function readCellConfig(cell) {
|
|
@@ -170,3 +178,41 @@ export function setRevealTheme(themeName) {
|
|
|
170
178
|
// Set or update href to new theme
|
|
171
179
|
themeLink.href = getSpectaAssetUrl(`reveal.js/${themeName}.css`);
|
|
172
180
|
}
|
|
181
|
+
export async function configLabLayout(options) {
|
|
182
|
+
const { config, labShell, commands } = options;
|
|
183
|
+
if (!config) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
console.log('vvvvvvvvvvv', config);
|
|
187
|
+
const { setSingleMode, hideLeftPanel, hideRightPanel, hideStatusbar, hideHeader } = config;
|
|
188
|
+
if (setSingleMode) {
|
|
189
|
+
await commands.execute('application:set-mode', {
|
|
190
|
+
mode: 'single-document'
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
if (hideLeftPanel) {
|
|
194
|
+
labShell.collapseLeft();
|
|
195
|
+
if (labShell.isSideTabBarVisible('left')) {
|
|
196
|
+
labShell.toggleSideTabBarVisibility('left');
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (hideRightPanel) {
|
|
200
|
+
labShell.collapseRight();
|
|
201
|
+
if (labShell.isSideTabBarVisible('right')) {
|
|
202
|
+
labShell.toggleSideTabBarVisibility('right');
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (hideHeader) {
|
|
206
|
+
if (labShell.isTopInSimpleModeVisible()) {
|
|
207
|
+
await commands.execute('application:toggle-header');
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (hideStatusbar) {
|
|
211
|
+
const statusBar = document.getElementById('jp-main-statusbar');
|
|
212
|
+
console.log('statusBar.clientHeight', statusBar === null || statusBar === void 0 ? void 0 : statusBar.clientHeight);
|
|
213
|
+
if (statusBar && !statusBar.classList.contains('lm-mod-hidden')) {
|
|
214
|
+
console.log('toggle status');
|
|
215
|
+
await commands.execute('statusbar:toggle');
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jupyter-specta",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/trungleduc/specta",
|
|
@@ -50,51 +50,49 @@
|
|
|
50
50
|
"@microsoft/fast-foundation": "~2.49.5"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@jupyter-notebook/tree": "^7.
|
|
53
|
+
"@jupyter-notebook/tree": "^7.5.0",
|
|
54
54
|
"@jupyter-widgets/base": "^6.0.6",
|
|
55
|
-
"@jupyterlab/application": "^4.
|
|
56
|
-
"@jupyterlab/application-extension": "^4.
|
|
57
|
-
"@jupyterlab/apputils": "^4.
|
|
58
|
-
"@jupyterlab/apputils-extension": "^4.
|
|
59
|
-
"@jupyterlab/console": "^4.
|
|
60
|
-
"@jupyterlab/console-extension": "^4.
|
|
55
|
+
"@jupyterlab/application": "^4.5.0",
|
|
56
|
+
"@jupyterlab/application-extension": "^4.5.0",
|
|
57
|
+
"@jupyterlab/apputils": "^4.5.0",
|
|
58
|
+
"@jupyterlab/apputils-extension": "^4.5.0",
|
|
59
|
+
"@jupyterlab/console": "^4.5.0",
|
|
60
|
+
"@jupyterlab/console-extension": "^4.5.0",
|
|
61
61
|
"@jupyterlab/coreutils": "^6.4.2",
|
|
62
|
-
"@jupyterlab/docmanager": "^4.
|
|
63
|
-
"@jupyterlab/docmanager-extension": "^4.
|
|
64
|
-
"@jupyterlab/docregistry": "^4.
|
|
65
|
-
"@jupyterlab/filebrowser": "^4.
|
|
66
|
-
"@jupyterlab/filebrowser-extension": "^4.
|
|
67
|
-
"@jupyterlab/imageviewer": "^4.
|
|
68
|
-
"@jupyterlab/imageviewer-extension": "^4.
|
|
69
|
-
"@jupyterlab/json-extension": "^4.
|
|
70
|
-
"@jupyterlab/logconsole": "^4.
|
|
71
|
-
"@jupyterlab/mainmenu": "^4.
|
|
72
|
-
"@jupyterlab/markdownviewer-extension": "^4.
|
|
73
|
-
"@jupyterlab/mathjax-extension": "^4.
|
|
74
|
-
"@jupyterlab/nbconvert-css": "^4.
|
|
75
|
-
"@jupyterlab/nbformat": "^4.
|
|
76
|
-
"@jupyterlab/notebook": "^4.
|
|
77
|
-
"@jupyterlab/notebook-extension": "^4.
|
|
78
|
-
"@jupyterlab/outputarea": "^4.
|
|
79
|
-
"@jupyterlab/rendermime": "^4.
|
|
80
|
-
"@jupyterlab/rendermime-extension": "^4.
|
|
62
|
+
"@jupyterlab/docmanager": "^4.5.0",
|
|
63
|
+
"@jupyterlab/docmanager-extension": "^4.5.0",
|
|
64
|
+
"@jupyterlab/docregistry": "^4.5.0",
|
|
65
|
+
"@jupyterlab/filebrowser": "^4.5.0",
|
|
66
|
+
"@jupyterlab/filebrowser-extension": "^4.5.0",
|
|
67
|
+
"@jupyterlab/imageviewer": "^4.5.0",
|
|
68
|
+
"@jupyterlab/imageviewer-extension": "^4.5.0",
|
|
69
|
+
"@jupyterlab/json-extension": "^4.5.0",
|
|
70
|
+
"@jupyterlab/logconsole": "^4.5.0",
|
|
71
|
+
"@jupyterlab/mainmenu": "^4.5.0",
|
|
72
|
+
"@jupyterlab/markdownviewer-extension": "^4.5.0",
|
|
73
|
+
"@jupyterlab/mathjax-extension": "^4.5.0",
|
|
74
|
+
"@jupyterlab/nbconvert-css": "^4.5.0",
|
|
75
|
+
"@jupyterlab/nbformat": "^4.5.0",
|
|
76
|
+
"@jupyterlab/notebook": "^4.5.0",
|
|
77
|
+
"@jupyterlab/notebook-extension": "^4.5.0",
|
|
78
|
+
"@jupyterlab/outputarea": "^4.5.0",
|
|
79
|
+
"@jupyterlab/rendermime": "^4.5.0",
|
|
80
|
+
"@jupyterlab/rendermime-extension": "^4.5.0",
|
|
81
81
|
"@jupyterlab/services": "^7.2.4",
|
|
82
|
-
"@jupyterlab/services-extension": "^4.
|
|
83
|
-
"@jupyterlab/settingeditor-extension": "^4.
|
|
84
|
-
"@jupyterlab/settingregistry": "^4.
|
|
85
|
-
"@jupyterlab/theme-dark-extension": "^4.
|
|
86
|
-
"@jupyterlab/theme-light-extension": "^4.
|
|
87
|
-
"@jupyterlab/translation": "^4.
|
|
88
|
-
"@jupyterlab/translation-extension": "^4.
|
|
89
|
-
"@jupyterlab/ui-components": "^4.
|
|
90
|
-
"@jupyterlab/ui-components-extension": "
|
|
91
|
-
"@jupyterlite/application": "^0.
|
|
92
|
-
"@jupyterlite/application-extension": "^0.
|
|
93
|
-
"@jupyterlite/
|
|
94
|
-
"@jupyterlite/iframe-extension": "^0.
|
|
95
|
-
"@jupyterlite/
|
|
96
|
-
"@jupyterlite/server": "^0.6.2",
|
|
97
|
-
"@jupyterlite/services-extension": "^0.6.2",
|
|
82
|
+
"@jupyterlab/services-extension": "^4.5.0",
|
|
83
|
+
"@jupyterlab/settingeditor-extension": "^4.5.0",
|
|
84
|
+
"@jupyterlab/settingregistry": "^4.5.0",
|
|
85
|
+
"@jupyterlab/theme-dark-extension": "^4.5.0",
|
|
86
|
+
"@jupyterlab/theme-light-extension": "^4.5.0",
|
|
87
|
+
"@jupyterlab/translation": "^4.5.0",
|
|
88
|
+
"@jupyterlab/translation-extension": "^4.5.0",
|
|
89
|
+
"@jupyterlab/ui-components": "^4.5.0",
|
|
90
|
+
"@jupyterlab/ui-components-extension": "^4.5.0",
|
|
91
|
+
"@jupyterlite/application": "^0.7.0",
|
|
92
|
+
"@jupyterlite/application-extension": "^0.7.0",
|
|
93
|
+
"@jupyterlite/apputils": "^0.7.0",
|
|
94
|
+
"@jupyterlite/iframe-extension": "^0.7.0",
|
|
95
|
+
"@jupyterlite/services-extension": "^0.7.0",
|
|
98
96
|
"@lumino/algorithm": "^2.0.0",
|
|
99
97
|
"@lumino/application": "^2.0.0",
|
|
100
98
|
"@lumino/commands": "^2.0.0",
|
|
@@ -117,7 +115,7 @@
|
|
|
117
115
|
"reveal.js": "^5.2.1"
|
|
118
116
|
},
|
|
119
117
|
"devDependencies": {
|
|
120
|
-
"@jupyterlab/builder": "~4.
|
|
118
|
+
"@jupyterlab/builder": "~4.5.0",
|
|
121
119
|
"@types/react": "^18.0.26",
|
|
122
120
|
"@typescript-eslint/eslint-plugin": "^6.1.0",
|
|
123
121
|
"@typescript-eslint/parser": "^6.1.0",
|