jupyter-specta 0.1.4 → 0.1.5
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/document/plugin.js +39 -9
- package/lib/tool.d.ts +4 -6
- package/lib/tool.js +16 -17
- package/package.json +6 -1
- package/style/style.css +1 -1
package/lib/document/plugin.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { WidgetTracker } from '@jupyterlab/apputils';
|
|
2
2
|
import { IEditorServices } from '@jupyterlab/codeeditor';
|
|
3
|
+
import { PathExt } from '@jupyterlab/coreutils';
|
|
4
|
+
import { IDocumentManager } from '@jupyterlab/docmanager';
|
|
5
|
+
import { IDefaultFileBrowser } from '@jupyterlab/filebrowser';
|
|
3
6
|
import { INotebookTracker, NotebookPanel } from '@jupyterlab/notebook';
|
|
4
7
|
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
8
|
import { IKernelSpecManager } from '@jupyterlab/services';
|
|
9
|
+
import { ISpectaDocTracker, ISpectaLayoutRegistry } from '../token';
|
|
10
|
+
import { createFileBrowser, hideAppLoadingIndicator, isSpectaApp, registerDocumentFactory } from '../tool';
|
|
9
11
|
const activate = (app, rendermime, tracker, editorServices, contentFactory, spectaLayoutRegistry) => {
|
|
10
12
|
const namespace = 'specta';
|
|
11
13
|
const spectaTracker = new WidgetTracker({ namespace });
|
|
@@ -37,8 +39,13 @@ export const spectaDocument = {
|
|
|
37
39
|
export const spectaOpener = {
|
|
38
40
|
id: 'specta/application-extension:opener',
|
|
39
41
|
autoStart: true,
|
|
40
|
-
requires: [
|
|
41
|
-
|
|
42
|
+
requires: [
|
|
43
|
+
IDocumentManager,
|
|
44
|
+
IDefaultFileBrowser,
|
|
45
|
+
ISpectaDocTracker,
|
|
46
|
+
IKernelSpecManager
|
|
47
|
+
],
|
|
48
|
+
activate: async (app, docManager, defaultBrowser) => {
|
|
42
49
|
if (!isSpectaApp()) {
|
|
43
50
|
// Not a specta app, return
|
|
44
51
|
return;
|
|
@@ -46,14 +53,37 @@ export const spectaOpener = {
|
|
|
46
53
|
const urlParams = new URLSearchParams(window.location.search);
|
|
47
54
|
const path = urlParams.get('path');
|
|
48
55
|
if (!path) {
|
|
49
|
-
const browser = createFileBrowser({
|
|
56
|
+
const browser = createFileBrowser({ defaultBrowser });
|
|
50
57
|
app.shell.add(browser, 'main', { rank: 100 });
|
|
51
58
|
hideAppLoadingIndicator();
|
|
52
59
|
}
|
|
53
60
|
else {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
if (PathExt.extname(path) === '.ipynb') {
|
|
62
|
+
app.shell.addClass('specta-document-viewer');
|
|
63
|
+
const widget = docManager.openOrReveal(path, 'specta');
|
|
64
|
+
if (widget) {
|
|
65
|
+
app.shell.add(widget, 'main');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
let count = 0;
|
|
70
|
+
const tryOpen = () => {
|
|
71
|
+
const widget = docManager.openOrReveal(path);
|
|
72
|
+
if (widget) {
|
|
73
|
+
app.shell.add(widget, 'main');
|
|
74
|
+
hideAppLoadingIndicator();
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
count++;
|
|
78
|
+
if (count > 10) {
|
|
79
|
+
console.error('Failed to open file', path);
|
|
80
|
+
//TODO Open in text editor?
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
setTimeout(tryOpen, 100);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
tryOpen();
|
|
57
87
|
}
|
|
58
88
|
}
|
|
59
89
|
}
|
package/lib/tool.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { JupyterFrontEnd } from '@jupyterlab/application';
|
|
2
2
|
import { WidgetTracker } from '@jupyterlab/apputils';
|
|
3
3
|
import { IEditorServices } from '@jupyterlab/codeeditor';
|
|
4
|
+
import { IDefaultFileBrowser } from '@jupyterlab/filebrowser';
|
|
5
|
+
import { ICell, INotebookMetadata } from '@jupyterlab/nbformat';
|
|
4
6
|
import { INotebookTracker, NotebookPanel } from '@jupyterlab/notebook';
|
|
5
7
|
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
6
|
-
import { VoilaFileBrowser } from '@voila-dashboards/voila';
|
|
7
|
-
import { IDocumentManager } from '@jupyterlab/docmanager';
|
|
8
8
|
import { ISpectaAppConfig, ISpectaCellConfig, ISpectaLayoutRegistry } from './token';
|
|
9
|
-
import { INotebookMetadata } from '@jupyterlab/nbformat';
|
|
10
|
-
import { ICell } from '@jupyterlab/nbformat';
|
|
11
9
|
export declare function registerDocumentFactory(options: {
|
|
12
10
|
factoryName: string;
|
|
13
11
|
app: JupyterFrontEnd;
|
|
@@ -19,8 +17,8 @@ export declare function registerDocumentFactory(options: {
|
|
|
19
17
|
spectaLayoutRegistry: ISpectaLayoutRegistry;
|
|
20
18
|
}): void;
|
|
21
19
|
export declare function createFileBrowser(options: {
|
|
22
|
-
|
|
23
|
-
}):
|
|
20
|
+
defaultBrowser: IDefaultFileBrowser;
|
|
21
|
+
}): any;
|
|
24
22
|
export declare function hideAppLoadingIndicator(): void;
|
|
25
23
|
export declare function isSpectaApp(): boolean;
|
|
26
24
|
export declare function readSpectaConfig(nbMetadata?: INotebookMetadata): ISpectaAppConfig;
|
package/lib/tool.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { PageConfig, URLExt } from '@jupyterlab/coreutils';
|
|
2
|
-
import { FilterFileBrowserModel } from '@jupyterlab/filebrowser';
|
|
3
2
|
import { NotebookModelFactory } from '@jupyterlab/notebook';
|
|
4
|
-
import { VoilaFileBrowser } from '@voila-dashboards/voila';
|
|
5
3
|
import { NotebookGridWidgetFactory } from './document/factory';
|
|
6
4
|
import { SpectaWidgetFactory } from './specta_widget_factory';
|
|
7
5
|
export function registerDocumentFactory(options) {
|
|
@@ -43,11 +41,12 @@ export function registerDocumentFactory(options) {
|
|
|
43
41
|
});
|
|
44
42
|
}
|
|
45
43
|
export function createFileBrowser(options) {
|
|
46
|
-
const {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
const { defaultBrowser } = options;
|
|
45
|
+
const browser = defaultBrowser;
|
|
46
|
+
browser.singleClickNavigation = true;
|
|
47
|
+
browser.showFileCheckboxes = false;
|
|
48
|
+
browser.showLastModifiedColumn = false;
|
|
49
|
+
browser.addClass('specta-file-browser');
|
|
51
50
|
const urlFactory = (path) => {
|
|
52
51
|
const baseUrl = PageConfig.getBaseUrl();
|
|
53
52
|
let appUrl = PageConfig.getOption('appUrl');
|
|
@@ -63,16 +62,16 @@ export function createFileBrowser(options) {
|
|
|
63
62
|
});
|
|
64
63
|
return url.toString();
|
|
65
64
|
};
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
65
|
+
const oldHandler = browser.listing.handleOpen.bind(browser.listing);
|
|
66
|
+
browser.listing.handleOpen = (item) => {
|
|
67
|
+
if (item.type === 'directory') {
|
|
68
|
+
oldHandler(item);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
window.open(urlFactory(item.path), '_blank');
|
|
73
|
+
}
|
|
74
|
+
};
|
|
76
75
|
return browser;
|
|
77
76
|
}
|
|
78
77
|
export function hideAppLoadingIndicator() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jupyter-specta",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/trungleduc/specta",
|
|
@@ -41,6 +41,9 @@
|
|
|
41
41
|
"lint:eslint": "eslint --ext .ts,.tsx .",
|
|
42
42
|
"install:extension": "npm run build:lib && npm run build:labextension:dev"
|
|
43
43
|
},
|
|
44
|
+
"overrides": {
|
|
45
|
+
"@microsoft/fast-foundation": "~2.49.5"
|
|
46
|
+
},
|
|
44
47
|
"dependencies": {
|
|
45
48
|
"@jupyter-notebook/tree": "^7.4.3",
|
|
46
49
|
"@jupyter-widgets/base": "^6.0.6",
|
|
@@ -49,6 +52,7 @@
|
|
|
49
52
|
"@jupyterlab/apputils": "^4.4.2",
|
|
50
53
|
"@jupyterlab/apputils-extension": "^4.4.2",
|
|
51
54
|
"@jupyterlab/console": "^4.4.2",
|
|
55
|
+
"@jupyterlab/console-extension": "^4.4.2",
|
|
52
56
|
"@jupyterlab/coreutils": "^6.4.2",
|
|
53
57
|
"@jupyterlab/docmanager": "^4.4.2",
|
|
54
58
|
"@jupyterlab/docmanager-extension": "^4.4.2",
|
|
@@ -76,6 +80,7 @@
|
|
|
76
80
|
"@jupyterlab/translation": "^4.4.2",
|
|
77
81
|
"@jupyterlab/translation-extension": "^4.4.2",
|
|
78
82
|
"@jupyterlab/ui-components": "^4.4.2",
|
|
83
|
+
"@jupyterlab/ui-components-extension": "~4.4.2",
|
|
79
84
|
"@jupyterlite/application": "^0.6.2",
|
|
80
85
|
"@jupyterlite/application-extension": "^0.6.2",
|
|
81
86
|
"@jupyterlite/contents": "^0.6.2",
|