jupyter-specta 0.2.1 → 0.3.0

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.
@@ -11,7 +11,7 @@ class CustomContext extends Context {
11
11
  }
12
12
  async saveAs() {
13
13
  await this.ready;
14
- return;
14
+ return true;
15
15
  }
16
16
  async revert() {
17
17
  await this.ready;
@@ -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>;
@@ -49,47 +49,82 @@ 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 (!path) {
59
- const browser = createFileBrowser({ defaultBrowser });
60
- app.shell.add(browser, 'main', { rank: 100 });
61
- hideAppLoadingIndicator();
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
+ await app.commands.execute('application:set-mode', {
65
+ mode: 'single-document'
66
+ });
67
+ labShell.collapseLeft();
68
+ labShell.collapseRight();
69
+ if (labShell.isSideTabBarVisible('right')) {
70
+ labShell.toggleSideTabBarVisibility('right');
71
+ }
72
+ if (labShell.isSideTabBarVisible('left')) {
73
+ labShell.toggleSideTabBarVisibility('left');
74
+ }
75
+ if (labShell.isTopInSimpleModeVisible()) {
76
+ await app.commands.execute('application:toggle-header');
77
+ }
78
+ const statusBar = document.getElementById('jp-bottom-panel');
79
+ if (statusBar && statusBar.clientHeight !== 0) {
80
+ await app.commands.execute('statusbar:toggle');
81
+ }
82
+ const widget = docManager.openOrReveal(path, 'specta');
83
+ if (widget) {
84
+ app.shell.add(widget, 'main');
85
+ }
86
+ }
87
+ });
88
+ // Not a specta app
89
+ return;
62
90
  }
63
91
  else {
64
- if (PathExt.extname(path) === '.ipynb') {
65
- app.shell.addClass('specta-document-viewer');
66
- const widget = docManager.openOrReveal(path, 'specta');
67
- if (widget) {
68
- app.shell.add(widget, 'main');
69
- }
92
+ if (!path) {
93
+ const browser = createFileBrowser({ defaultBrowser });
94
+ app.shell.add(browser, 'main', { rank: 100 });
95
+ hideAppLoadingIndicator();
70
96
  }
71
97
  else {
72
- let count = 0;
73
- const tryOpen = () => {
74
- const widget = docManager.openOrReveal(path, 'default');
98
+ if (PathExt.extname(path) === '.ipynb') {
99
+ app.shell.addClass('specta-document-viewer');
100
+ const widget = docManager.openOrReveal(path, 'specta');
75
101
  if (widget) {
76
102
  app.shell.add(widget, 'main');
77
- hideAppLoadingIndicator();
78
103
  }
79
- else {
80
- count++;
81
- if (count > 10) {
82
- console.error('Failed to open file', path);
83
- const widget = new Widget();
84
- widget.node.innerHTML = `<h2 style="text-align: center; margin-top: 200px;">Failed to open file ${path}</h2>`;
104
+ }
105
+ else {
106
+ let count = 0;
107
+ const tryOpen = () => {
108
+ const widget = docManager.openOrReveal(path, 'default');
109
+ if (widget) {
85
110
  app.shell.add(widget, 'main');
86
111
  hideAppLoadingIndicator();
87
- return;
88
112
  }
89
- setTimeout(tryOpen, 100);
90
- }
91
- };
92
- tryOpen();
113
+ else {
114
+ count++;
115
+ if (count > 10) {
116
+ console.error('Failed to open file', path);
117
+ const widget = new Widget();
118
+ widget.node.innerHTML = `<h2 style="text-align: center; margin-top: 200px;">Failed to open file ${path}</h2>`;
119
+ app.shell.add(widget, 'main');
120
+ hideAppLoadingIndicator();
121
+ return;
122
+ }
123
+ setTimeout(tryOpen, 100);
124
+ }
125
+ };
126
+ tryOpen();
127
+ }
93
128
  }
94
129
  }
95
130
  }
@@ -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;
@@ -1,3 +1,3 @@
1
1
  import '@jupyterlab/logconsole';
2
- import '@jupyterlite/server';
3
2
  import '@jupyterlab/console';
3
+ import '@jupyterlite/apputils';
@@ -1,3 +1,3 @@
1
1
  import '@jupyterlab/logconsole';
2
- import '@jupyterlite/server';
3
2
  import '@jupyterlab/console';
3
+ import '@jupyterlite/apputils';
@@ -35,6 +35,7 @@ export class AppWidget extends Panel {
35
35
  return this._model;
36
36
  }
37
37
  addSpinner() {
38
+ var _a;
38
39
  const loaderHost = (this._loaderHost = new Widget());
39
40
  loaderHost.addClass('specta-loader-host');
40
41
  const spinner = document.createElement('div');
@@ -42,7 +43,7 @@ export class AppWidget extends Panel {
42
43
  loaderHost.node.appendChild(spinner);
43
44
  const text = document.createElement('div');
44
45
  text.className = 'specta-loading-indicator-text';
45
- text.textContent = 'Loading Specta';
46
+ text.textContent = (_a = this._spectaAppConfig.loadingName) !== null && _a !== void 0 ? _a : 'Loading Specta';
46
47
  loaderHost.node.appendChild(text);
47
48
  this.addWidget(loaderHost);
48
49
  }
package/lib/token.d.ts CHANGED
@@ -49,6 +49,7 @@ export interface ISpectaAppConfig {
49
49
  defaultLayout?: string;
50
50
  hideTopbar?: boolean;
51
51
  slidesTheme?: string;
52
+ loadingName?: string;
52
53
  }
53
54
  export interface ISpectaCellConfig {
54
55
  showSource?: boolean;
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jupyter-specta",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
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.4.3",
53
+ "@jupyter-notebook/tree": "^7.5.0",
54
54
  "@jupyter-widgets/base": "^6.0.6",
55
- "@jupyterlab/application": "^4.4.2",
56
- "@jupyterlab/application-extension": "^4.4.2",
57
- "@jupyterlab/apputils": "^4.4.2",
58
- "@jupyterlab/apputils-extension": "^4.4.2",
59
- "@jupyterlab/console": "^4.4.2",
60
- "@jupyterlab/console-extension": "^4.4.2",
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.4.2",
63
- "@jupyterlab/docmanager-extension": "^4.4.2",
64
- "@jupyterlab/docregistry": "^4.4.2",
65
- "@jupyterlab/filebrowser": "^4.4.2",
66
- "@jupyterlab/filebrowser-extension": "^4.4.2",
67
- "@jupyterlab/imageviewer": "^4.4.2",
68
- "@jupyterlab/imageviewer-extension": "^4.4.2",
69
- "@jupyterlab/json-extension": "^4.4.2",
70
- "@jupyterlab/logconsole": "^4.4.2",
71
- "@jupyterlab/mainmenu": "^4.4.2",
72
- "@jupyterlab/markdownviewer-extension": "^4.4.2",
73
- "@jupyterlab/mathjax-extension": "^4.4.2",
74
- "@jupyterlab/nbconvert-css": "^4.4.2",
75
- "@jupyterlab/nbformat": "^4.4.2",
76
- "@jupyterlab/notebook": "^4.4.2",
77
- "@jupyterlab/notebook-extension": "^4.4.2",
78
- "@jupyterlab/outputarea": "^4.4.2",
79
- "@jupyterlab/rendermime": "^4.4.2",
80
- "@jupyterlab/rendermime-extension": "^4.4.2",
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.4.2",
83
- "@jupyterlab/settingeditor-extension": "^4.4.2",
84
- "@jupyterlab/settingregistry": "^4.4.2",
85
- "@jupyterlab/theme-dark-extension": "^4.4.2",
86
- "@jupyterlab/theme-light-extension": "^4.4.2",
87
- "@jupyterlab/translation": "^4.4.2",
88
- "@jupyterlab/translation-extension": "^4.4.2",
89
- "@jupyterlab/ui-components": "^4.4.2",
90
- "@jupyterlab/ui-components-extension": "~4.4.2",
91
- "@jupyterlite/application": "^0.6.2",
92
- "@jupyterlite/application-extension": "^0.6.2",
93
- "@jupyterlite/contents": "^0.6.2",
94
- "@jupyterlite/iframe-extension": "^0.6.2",
95
- "@jupyterlite/kernel": "^0.6.2",
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.4.2",
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",