@difizen/libro-jupyter 0.1.1 → 0.1.3
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/es/add-between-cell/add-between-cell.d.ts.map +1 -1
- package/es/add-between-cell/add-between-cell.js +7 -7
- package/es/add-between-cell/index.less +6 -0
- package/es/cell/jupyter-code-cell-model.d.ts +2 -2
- package/es/cell/jupyter-code-cell-model.d.ts.map +1 -1
- package/es/cell/jupyter-code-cell-model.js +7 -3
- package/es/cell/jupyter-code-cell-view.d.ts +9 -4
- package/es/cell/jupyter-code-cell-view.d.ts.map +1 -1
- package/es/cell/jupyter-code-cell-view.js +137 -100
- package/es/command/command-contribution.d.ts.map +1 -1
- package/es/command/command-contribution.js +9 -9
- package/es/components/cell-execution-tip.d.ts.map +1 -1
- package/es/components/cell-execution-tip.js +14 -1
- package/es/components/cell-input-bottom-blank.d.ts.map +1 -1
- package/es/components/cell-input-bottom-blank.js +4 -4
- package/es/config/config-contribution.d.ts +2 -2
- package/es/config/config-contribution.d.ts.map +1 -1
- package/es/config/config-contribution.js +7 -7
- package/es/config/config.d.ts +6 -1
- package/es/config/config.d.ts.map +1 -1
- package/es/config/config.js +15 -1
- package/es/config/index.d.ts +1 -0
- package/es/config/index.d.ts.map +1 -1
- package/es/config/index.js +2 -1
- package/es/file/file-command.d.ts.map +1 -1
- package/es/file/file-command.js +6 -2
- package/es/file/navigatable-view.d.ts +7 -2
- package/es/file/navigatable-view.d.ts.map +1 -1
- package/es/file/navigatable-view.js +41 -6
- package/es/file/open-handler-contribution.js +1 -1
- package/es/index.d.ts +17 -15
- package/es/index.d.ts.map +1 -1
- package/es/index.js +17 -15
- package/es/keybind-instructions/index.less +2 -2
- package/es/keybind-instructions/keybind-instructions-contribution.js +2 -2
- package/es/libro-jupyter-model.d.ts +8 -4
- package/es/libro-jupyter-model.d.ts.map +1 -1
- package/es/libro-jupyter-model.js +24 -17
- package/es/libro-jupyter-protocol.d.ts +4 -0
- package/es/libro-jupyter-protocol.d.ts.map +1 -1
- package/es/libro-jupyter-protocol.js +2 -1
- package/es/libro-jupyter-server-launch-manager.d.ts +3 -1
- package/es/libro-jupyter-server-launch-manager.d.ts.map +1 -1
- package/es/libro-jupyter-server-launch-manager.js +9 -2
- package/es/libro-jupyter-view.d.ts +2 -1
- package/es/libro-jupyter-view.d.ts.map +1 -1
- package/es/libro-jupyter-view.js +4 -2
- package/es/module.d.ts.map +1 -1
- package/es/module.js +12 -10
- package/es/output/libro-jupyter-outputarea.d.ts +3 -0
- package/es/output/libro-jupyter-outputarea.d.ts.map +1 -1
- package/es/output/libro-jupyter-outputarea.js +49 -4
- package/es/rendermime/index.less +12 -1
- package/es/rendermime/plotly-renderers.d.ts +15 -14
- package/es/rendermime/plotly-renderers.d.ts.map +1 -1
- package/es/rendermime/plotly-renderers.js +1 -3
- package/es/toolbar/kernel-selector-dropdown.d.ts.map +1 -1
- package/es/toolbar/kernel-selector-dropdown.js +2 -6
- package/es/typings/index.d.ts +7 -2
- package/package.json +16 -14
- package/src/add-between-cell/add-between-cell.tsx +17 -8
- package/src/add-between-cell/index.less +6 -0
- package/src/cell/jupyter-code-cell-model.ts +6 -4
- package/src/cell/jupyter-code-cell-view.tsx +81 -48
- package/src/command/command-contribution.ts +13 -9
- package/src/components/cell-execution-tip.tsx +8 -2
- package/src/components/cell-input-bottom-blank.tsx +10 -5
- package/src/config/config-contribution.ts +3 -3
- package/src/config/config.ts +17 -2
- package/src/config/index.ts +1 -0
- package/src/file/file-command.tsx +5 -2
- package/src/file/navigatable-view.tsx +39 -1
- package/src/file/open-handler-contribution.ts +1 -1
- package/src/index.spec.ts +1 -5
- package/src/index.ts +17 -16
- package/src/keybind-instructions/index.less +2 -2
- package/src/keybind-instructions/keybind-instructions-contribution.ts +2 -2
- package/src/libro-jupyter-model.ts +34 -20
- package/src/libro-jupyter-protocol.ts +5 -0
- package/src/libro-jupyter-server-launch-manager.ts +11 -2
- package/src/libro-jupyter-view.tsx +4 -1
- package/src/module.ts +23 -15
- package/src/output/libro-jupyter-outputarea.tsx +31 -3
- package/src/rendermime/index.less +12 -1
- package/src/rendermime/plotly-render.tsx +1 -1
- package/src/rendermime/plotly-renderers.ts +15 -17
- package/src/toolbar/kernel-selector-dropdown.tsx +2 -6
- package/src/typings/index.d.ts +7 -2
- package/es/configuration/index.d.ts +0 -3
- package/es/configuration/index.d.ts.map +0 -1
- package/es/configuration/index.js +0 -2
- package/es/configuration/libro-configuration-contribution.d.ts +0 -5
- package/es/configuration/libro-configuration-contribution.d.ts.map +0 -1
- package/es/configuration/libro-configuration-contribution.js +0 -24
- package/es/configuration/libro-configuration.d.ts +0 -3
- package/es/configuration/libro-configuration.d.ts.map +0 -1
- package/es/configuration/libro-configuration.js +0 -12
- package/src/configuration/index.ts +0 -2
- package/src/configuration/libro-configuration-contribution.ts +0 -11
- package/src/configuration/libro-configuration.ts +0 -14
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { LibroView } from '@difizen/libro-core';
|
|
2
2
|
import { LibroService, DocumentCommands } from '@difizen/libro-core';
|
|
3
3
|
import type { NavigatableView, Saveable } from '@difizen/mana-app';
|
|
4
|
+
import { ConfigurationService } from '@difizen/mana-app';
|
|
5
|
+
import { Disposable, DisposableCollection } from '@difizen/mana-app';
|
|
4
6
|
import {
|
|
5
7
|
BaseView,
|
|
6
8
|
inject,
|
|
@@ -21,6 +23,8 @@ import {
|
|
|
21
23
|
} from '@difizen/mana-app';
|
|
22
24
|
import { createRef, forwardRef } from 'react';
|
|
23
25
|
|
|
26
|
+
import { LibroConfigAutoSave } from '../config/config.js';
|
|
27
|
+
|
|
24
28
|
export const LibroEditorComponent = forwardRef(function LibroEditorComponent() {
|
|
25
29
|
const instance = useInject<LibroNavigatableView>(ViewInstance);
|
|
26
30
|
|
|
@@ -42,6 +46,8 @@ export class LibroNavigatableView
|
|
|
42
46
|
|
|
43
47
|
@inject(CommandRegistry) commandRegistry: CommandRegistry;
|
|
44
48
|
|
|
49
|
+
protected readonly toDisposeOnAutoSave = new DisposableCollection();
|
|
50
|
+
|
|
45
51
|
override view = LibroEditorComponent;
|
|
46
52
|
|
|
47
53
|
codeRef = createRef<HTMLDivElement>();
|
|
@@ -50,11 +56,13 @@ export class LibroNavigatableView
|
|
|
50
56
|
|
|
51
57
|
dirtyEmitter = new Emitter<void>();
|
|
52
58
|
|
|
59
|
+
autoSaveDelay = 1000;
|
|
60
|
+
|
|
53
61
|
get onDirtyChanged() {
|
|
54
62
|
return this.dirtyEmitter.event;
|
|
55
63
|
}
|
|
56
64
|
|
|
57
|
-
|
|
65
|
+
autoSave: 'on' | 'off' = 'off';
|
|
58
66
|
|
|
59
67
|
@prop()
|
|
60
68
|
dirty: boolean;
|
|
@@ -71,6 +79,7 @@ export class LibroNavigatableView
|
|
|
71
79
|
constructor(
|
|
72
80
|
@inject(ViewOption) options: { path: string },
|
|
73
81
|
@inject(LabelProvider) labelProvider: LabelProvider,
|
|
82
|
+
@inject(ConfigurationService) configurationService: ConfigurationService,
|
|
74
83
|
) {
|
|
75
84
|
super();
|
|
76
85
|
this.filePath = options.path;
|
|
@@ -81,6 +90,20 @@ export class LibroNavigatableView
|
|
|
81
90
|
const iconClass = labelProvider.getIcon(uriRef);
|
|
82
91
|
this.title.icon = <div className={iconClass} />;
|
|
83
92
|
this.title.label = uri.displayName;
|
|
93
|
+
configurationService
|
|
94
|
+
.get(LibroConfigAutoSave)
|
|
95
|
+
.then((value) => {
|
|
96
|
+
if (value) {
|
|
97
|
+
this.autoSave = 'on';
|
|
98
|
+
return;
|
|
99
|
+
} else {
|
|
100
|
+
this.autoSave = 'off';
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
.catch(() => {
|
|
105
|
+
//
|
|
106
|
+
});
|
|
84
107
|
}
|
|
85
108
|
|
|
86
109
|
override async onViewMount(): Promise<void> {
|
|
@@ -95,6 +118,18 @@ export class LibroNavigatableView
|
|
|
95
118
|
);
|
|
96
119
|
};
|
|
97
120
|
|
|
121
|
+
protected doAutoSave(): void {
|
|
122
|
+
this.toDisposeOnAutoSave.dispose();
|
|
123
|
+
const handle = window.setTimeout(() => {
|
|
124
|
+
this.save();
|
|
125
|
+
|
|
126
|
+
if (this.libroView) {
|
|
127
|
+
this.libroView.model.dirty = false;
|
|
128
|
+
}
|
|
129
|
+
}, this.autoSaveDelay);
|
|
130
|
+
this.toDisposeOnAutoSave.push(Disposable.create(() => window.clearTimeout(handle)));
|
|
131
|
+
}
|
|
132
|
+
|
|
98
133
|
protected async getOrCreateLibroView() {
|
|
99
134
|
const libroView = await this.libroService.getOrCreateView({
|
|
100
135
|
id: this.filePath,
|
|
@@ -107,6 +142,9 @@ export class LibroNavigatableView
|
|
|
107
142
|
this.libroView.model.onContentChanged(() => {
|
|
108
143
|
this.dirty = true;
|
|
109
144
|
this.dirtyEmitter.fire();
|
|
145
|
+
if (this.autoSave === 'on') {
|
|
146
|
+
this.doAutoSave();
|
|
147
|
+
}
|
|
110
148
|
});
|
|
111
149
|
this.libroView.onSave(() => {
|
|
112
150
|
this.dirty = false;
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
Priority,
|
|
8
8
|
} from '@difizen/mana-app';
|
|
9
9
|
|
|
10
|
-
import { LibroJupyterConfiguration } from '../
|
|
10
|
+
import { LibroJupyterConfiguration } from '../config/index.js';
|
|
11
11
|
|
|
12
12
|
import type { LibroNavigatableView } from './navigatable-view.js';
|
|
13
13
|
import { LibroNavigatableViewFactoryId } from './navigatable-view.js';
|
package/src/index.spec.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import assert from 'assert';
|
|
2
2
|
|
|
3
|
-
import { JupyterFileService, LibroJupyterModel } from './index.js';
|
|
4
|
-
import 'reflect-metadata';
|
|
5
|
-
|
|
6
3
|
describe('libro-jupyter', () => {
|
|
7
4
|
it('#import', () => {
|
|
8
|
-
assert(
|
|
9
|
-
assert(LibroJupyterModel);
|
|
5
|
+
assert(true);
|
|
10
6
|
});
|
|
11
7
|
});
|
package/src/index.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
+
export * from '@difizen/libro-code-cell';
|
|
2
|
+
export * from '@difizen/libro-code-editor';
|
|
3
|
+
export * from '@difizen/libro-common';
|
|
1
4
|
export * from '@difizen/libro-core';
|
|
5
|
+
export * from '@difizen/libro-cofine-editor';
|
|
2
6
|
export * from '@difizen/libro-kernel';
|
|
3
|
-
export * from '@difizen/libro-
|
|
7
|
+
export * from '@difizen/libro-l10n';
|
|
8
|
+
export * from '@difizen/libro-lsp';
|
|
9
|
+
export * from '@difizen/libro-markdown-cell';
|
|
4
10
|
export * from '@difizen/libro-output';
|
|
5
|
-
export * from '@difizen/libro-
|
|
6
|
-
export * from '@difizen/libro-codemirror
|
|
11
|
+
export * from '@difizen/libro-raw-cell';
|
|
12
|
+
export * from '@difizen/libro-codemirror';
|
|
7
13
|
export * from '@difizen/libro-rendermime';
|
|
8
|
-
export * from '@difizen/libro-l10n';
|
|
9
14
|
export * from '@difizen/libro-search';
|
|
10
|
-
export * from '@difizen/libro-search-
|
|
11
|
-
export * from '@difizen/libro-code-editor';
|
|
12
|
-
export * from '@difizen/libro-codemirror';
|
|
13
|
-
export * from '@difizen/libro-codemirror-raw-cell';
|
|
14
|
-
|
|
15
|
-
export * from './module.js';
|
|
15
|
+
export * from '@difizen/libro-search-code-cell';
|
|
16
16
|
export * from './add-between-cell/index.js';
|
|
17
17
|
export * from './cell/index.js';
|
|
18
18
|
export * from './command/index.js';
|
|
@@ -20,14 +20,15 @@ export * from './components/index.js';
|
|
|
20
20
|
export * from './config/index.js';
|
|
21
21
|
export * from './contents/index.js';
|
|
22
22
|
export * from './keybind-instructions/index.js';
|
|
23
|
+
export * from './libro-jupyter-file-service.js';
|
|
24
|
+
export * from './libro-jupyter-model.js';
|
|
25
|
+
export * from './libro-jupyter-protocol.js';
|
|
26
|
+
export * from './libro-jupyter-server-launch-manager.js';
|
|
27
|
+
export * from './module.js';
|
|
23
28
|
export * from './output/index.js';
|
|
24
29
|
export * from './rendermime/index.js';
|
|
25
30
|
export * from './theme/index.js';
|
|
26
31
|
export * from './toolbar/index.js';
|
|
27
|
-
export * from './libro-jupyter-protocol.js';
|
|
28
|
-
export * from './libro-jupyter-model.js';
|
|
29
|
-
export * from './libro-jupyter-view.js';
|
|
30
|
-
export * from './libro-jupyter-file-service.js';
|
|
31
|
-
export * from './libro-jupyter-server-launch-manager.js';
|
|
32
32
|
export * from './file/index.js';
|
|
33
|
-
export * from './
|
|
33
|
+
export * from './libro-jupyter-view.js';
|
|
34
|
+
export * from './config/index.js';
|
|
@@ -86,9 +86,9 @@
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
.libro-keybind-instructions-icon {
|
|
89
|
-
display: flex;
|
|
90
89
|
width: 18px;
|
|
91
90
|
height: 18px;
|
|
91
|
+
line-height: 22px;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
.libro-edit-mode-keybind-instructions-table {
|
|
@@ -126,8 +126,8 @@
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
.libro-keybind-search-match {
|
|
129
|
-
background-color: var(--mana-libro-search-match-background-color);
|
|
130
129
|
color: rgba(0, 10, 26, 89%);
|
|
130
|
+
background-color: var(--mana-libro-search-match-background-color);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
.libro-command-mode-keybind-instructions-table,
|
|
@@ -20,12 +20,12 @@ export class KeybindInstructionsContribution
|
|
|
20
20
|
|
|
21
21
|
registerCommands(command: CommandRegistry) {
|
|
22
22
|
this.libroCommand.registerLibroCommand(command, KeybindInstructionsCommand, {
|
|
23
|
-
execute: async (
|
|
23
|
+
execute: async (cell, libro) => {
|
|
24
24
|
if (!libro || !(libro instanceof LibroView)) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
|
-
isVisible: (
|
|
28
|
+
isVisible: (cell, libro, path) => {
|
|
29
29
|
return path === LibroToolbarArea.HeaderRight;
|
|
30
30
|
},
|
|
31
31
|
});
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import { LibroModel } from '@difizen/libro-core';
|
|
2
|
-
import type {
|
|
3
|
-
IContentsModel,
|
|
4
|
-
ExecutableNotebookModel,
|
|
5
|
-
IContentsCheckpointModel,
|
|
6
|
-
IKernelConnection,
|
|
7
|
-
} from '@difizen/libro-kernel';
|
|
1
|
+
import { LibroModel, VirtualizedManagerHelper } from '@difizen/libro-core';
|
|
2
|
+
import type { VirtualizedManager } from '@difizen/libro-core';
|
|
8
3
|
import {
|
|
9
|
-
LibroKernelConnectionManager,
|
|
10
|
-
ServerManager,
|
|
11
4
|
ContentsManager,
|
|
5
|
+
ExecutableNotebookModel,
|
|
6
|
+
LibroKernelConnectionManager,
|
|
12
7
|
ServerConnection,
|
|
8
|
+
ServerManager,
|
|
13
9
|
} from '@difizen/libro-kernel';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
10
|
+
import type { IKernelConnection } from '@difizen/libro-kernel';
|
|
11
|
+
import type { IContentsCheckpointModel, IContentsModel } from '@difizen/libro-kernel';
|
|
12
|
+
import { getOrigin, ModalService, prop } from '@difizen/mana-app';
|
|
16
13
|
import { Deferred } from '@difizen/mana-app';
|
|
14
|
+
import { inject, transient } from '@difizen/mana-app';
|
|
17
15
|
import { l10n } from '@difizen/mana-l10n';
|
|
18
16
|
|
|
19
17
|
import {
|
|
20
|
-
LibroFileService,
|
|
21
18
|
ExecutedWithKernelCellModel,
|
|
19
|
+
LibroFileService,
|
|
22
20
|
} from './libro-jupyter-protocol.js';
|
|
23
21
|
import { SaveFileErrorModal } from './toolbar/save-file-error.js';
|
|
24
22
|
import { getDefaultKernel } from './utils/index.js';
|
|
@@ -26,6 +24,17 @@ import { getDefaultKernel } from './utils/index.js';
|
|
|
26
24
|
type IModel = IContentsModel;
|
|
27
25
|
@transient()
|
|
28
26
|
export class LibroJupyterModel extends LibroModel implements ExecutableNotebookModel {
|
|
27
|
+
static is = (arg: Record<any, any> | undefined): arg is LibroJupyterModel => {
|
|
28
|
+
return (
|
|
29
|
+
!!arg &&
|
|
30
|
+
ExecutableNotebookModel.is(arg) &&
|
|
31
|
+
'kernelConnection' in arg &&
|
|
32
|
+
typeof (arg as any).kernelConnection === 'object' &&
|
|
33
|
+
'lspEnabled' in arg &&
|
|
34
|
+
typeof (arg as any).lspEnabled === 'boolean'
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
29
38
|
protected libroFileService: LibroFileService;
|
|
30
39
|
|
|
31
40
|
get fileService() {
|
|
@@ -42,13 +51,14 @@ export class LibroJupyterModel extends LibroModel implements ExecutableNotebookM
|
|
|
42
51
|
kernelConnection?: IKernelConnection;
|
|
43
52
|
|
|
44
53
|
@prop()
|
|
45
|
-
lspEnabled =
|
|
54
|
+
lspEnabled = true;
|
|
46
55
|
|
|
47
56
|
protected kernelConnectionManager: LibroKernelConnectionManager;
|
|
48
57
|
protected serverManager: ServerManager;
|
|
49
58
|
protected serverConnection: ServerConnection;
|
|
50
59
|
protected readonly contentsManager: ContentsManager;
|
|
51
60
|
protected readonly modalService: ModalService;
|
|
61
|
+
protected virtualizedManager: VirtualizedManager;
|
|
52
62
|
|
|
53
63
|
constructor(
|
|
54
64
|
@inject(LibroFileService) libroFileService: LibroFileService,
|
|
@@ -58,6 +68,8 @@ export class LibroJupyterModel extends LibroModel implements ExecutableNotebookM
|
|
|
58
68
|
@inject(ServerConnection) serverConnection: ServerConnection,
|
|
59
69
|
@inject(ContentsManager) contentsManager: ContentsManager,
|
|
60
70
|
@inject(ModalService) modalService: ModalService,
|
|
71
|
+
@inject(VirtualizedManagerHelper)
|
|
72
|
+
virtualizedManagerHelper: VirtualizedManagerHelper,
|
|
61
73
|
) {
|
|
62
74
|
super();
|
|
63
75
|
this.kernelSelection = getDefaultKernel();
|
|
@@ -68,6 +80,7 @@ export class LibroJupyterModel extends LibroModel implements ExecutableNotebookM
|
|
|
68
80
|
this.contentsManager = contentsManager;
|
|
69
81
|
this.modalService = modalService;
|
|
70
82
|
this.dndAreaNullEnable = true;
|
|
83
|
+
this.virtualizedManager = virtualizedManagerHelper.getOrCreate(this);
|
|
71
84
|
}
|
|
72
85
|
|
|
73
86
|
get isKernelIdle() {
|
|
@@ -154,9 +167,7 @@ export class LibroJupyterModel extends LibroModel implements ExecutableNotebookM
|
|
|
154
167
|
}
|
|
155
168
|
return;
|
|
156
169
|
})
|
|
157
|
-
.catch(
|
|
158
|
-
//
|
|
159
|
-
});
|
|
170
|
+
.catch(console.error);
|
|
160
171
|
}
|
|
161
172
|
|
|
162
173
|
override async saveNotebookContent(): Promise<void> {
|
|
@@ -257,9 +268,7 @@ export class LibroJupyterModel extends LibroModel implements ExecutableNotebookM
|
|
|
257
268
|
}
|
|
258
269
|
return;
|
|
259
270
|
})
|
|
260
|
-
.catch(
|
|
261
|
-
//
|
|
262
|
-
});
|
|
271
|
+
.catch(console.error);
|
|
263
272
|
return;
|
|
264
273
|
}
|
|
265
274
|
|
|
@@ -283,7 +292,12 @@ export class LibroJupyterModel extends LibroModel implements ExecutableNotebookM
|
|
|
283
292
|
});
|
|
284
293
|
if (runningCellIndex > -1) {
|
|
285
294
|
this.selectCell(this.cells[runningCellIndex]);
|
|
286
|
-
|
|
295
|
+
|
|
296
|
+
if (this.virtualizedManager.isVirtualized) {
|
|
297
|
+
this.scrollToCellView({ cellIndex: runningCellIndex });
|
|
298
|
+
} else {
|
|
299
|
+
this.scrollToView(this.cells[runningCellIndex]);
|
|
300
|
+
}
|
|
287
301
|
}
|
|
288
302
|
}
|
|
289
303
|
}
|
|
@@ -52,3 +52,8 @@ export interface LibroFileService {
|
|
|
52
52
|
currentFileContents: IContentsModel,
|
|
53
53
|
) => Promise<IContentsModel | undefined>;
|
|
54
54
|
}
|
|
55
|
+
|
|
56
|
+
export const ServerLaunchManager = Symbol('ServerLaunchManager');
|
|
57
|
+
export interface ServerLaunchManager {
|
|
58
|
+
launch: () => Promise<any>;
|
|
59
|
+
}
|
|
@@ -2,8 +2,12 @@ import { ServerManager, ServerConnection } from '@difizen/libro-kernel';
|
|
|
2
2
|
import { inject, singleton } from '@difizen/mana-app';
|
|
3
3
|
import { ApplicationContribution } from '@difizen/mana-app';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import { ServerLaunchManager } from './libro-jupyter-protocol.js';
|
|
6
|
+
|
|
7
|
+
@singleton({ contrib: [ServerLaunchManager, ApplicationContribution] })
|
|
8
|
+
export class JupyterServerLaunchManager
|
|
9
|
+
implements ServerLaunchManager, ApplicationContribution
|
|
10
|
+
{
|
|
7
11
|
protected serverManager: ServerManager;
|
|
8
12
|
protected serverConnection: ServerConnection;
|
|
9
13
|
|
|
@@ -23,5 +27,10 @@ export class JupyterServerLaunchManager implements ApplicationContribution {
|
|
|
23
27
|
baseUrl: `http://${host}`,
|
|
24
28
|
wsUrl: `ws://${host}`,
|
|
25
29
|
});
|
|
30
|
+
this.launch();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
launch() {
|
|
34
|
+
return this.serverManager.launch();
|
|
26
35
|
}
|
|
27
36
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { NotebookOption } from '@difizen/libro-core';
|
|
2
|
+
import { VirtualizedManagerHelper } from '@difizen/libro-core';
|
|
2
3
|
import { CollapseServiceFactory, NotebookService } from '@difizen/libro-core';
|
|
3
4
|
import { LibroView, notebookViewFactoryId } from '@difizen/libro-core';
|
|
4
5
|
import { URI, view, ViewOption } from '@difizen/mana-app';
|
|
@@ -12,8 +13,10 @@ export class LibroJupyterView extends LibroView {
|
|
|
12
13
|
@inject(ViewOption) options: NotebookOption,
|
|
13
14
|
@inject(CollapseServiceFactory) collapseServiceFactory: CollapseServiceFactory,
|
|
14
15
|
@inject(NotebookService) notebookService: NotebookService,
|
|
16
|
+
@inject(VirtualizedManagerHelper)
|
|
17
|
+
virtualizedManagerHelper: VirtualizedManagerHelper,
|
|
15
18
|
) {
|
|
16
|
-
super(options, collapseServiceFactory, notebookService);
|
|
19
|
+
super(options, collapseServiceFactory, notebookService, virtualizedManagerHelper);
|
|
17
20
|
const uri = new URI(options['resource']);
|
|
18
21
|
this.uri = uri;
|
|
19
22
|
this.title.label = uri.displayName;
|
package/src/module.ts
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CodeCellModule,
|
|
2
3
|
LibroCodeCellModel,
|
|
3
4
|
LibroCodeCellView,
|
|
4
|
-
|
|
5
|
-
} from '@difizen/libro-codemirror
|
|
6
|
-
import {
|
|
7
|
-
import { RawCellModule } from '@difizen/libro-codemirror-raw-cell';
|
|
5
|
+
} from '@difizen/libro-code-cell';
|
|
6
|
+
import { CodeMirrorEditorModule } from '@difizen/libro-codemirror';
|
|
7
|
+
import { LibroE2EditorModule } from '@difizen/libro-cofine-editor';
|
|
8
8
|
import {
|
|
9
|
-
LibroModule,
|
|
10
|
-
LibroToolbarModule,
|
|
11
|
-
LibroKeybindRegistry,
|
|
12
|
-
LibroModel,
|
|
13
|
-
LibroAddCellModule,
|
|
14
9
|
CellExecutionTimeProvider,
|
|
15
10
|
CellInputBottonBlankProvider,
|
|
11
|
+
LibroAddCellModule,
|
|
12
|
+
LibroKeybindRegistry,
|
|
13
|
+
LibroModel,
|
|
14
|
+
LibroModule,
|
|
15
|
+
LibroToolbarModule,
|
|
16
16
|
} from '@difizen/libro-core';
|
|
17
17
|
import { LibroKernelManageModule } from '@difizen/libro-kernel';
|
|
18
|
+
import { LibroLSPModule } from '@difizen/libro-lsp';
|
|
19
|
+
import { MarkdownCellModule } from '@difizen/libro-markdown-cell';
|
|
18
20
|
import {
|
|
19
21
|
DisplayDataOutputModule,
|
|
20
22
|
ErrorOutputModule,
|
|
21
23
|
StreamOutputModule,
|
|
22
24
|
} from '@difizen/libro-output';
|
|
25
|
+
import { RawCellModule } from '@difizen/libro-raw-cell';
|
|
23
26
|
import { LibroSearchModule } from '@difizen/libro-search';
|
|
24
|
-
import {
|
|
27
|
+
import { SearchCodeCellModule } from '@difizen/libro-search-code-cell';
|
|
25
28
|
import { ManaModule } from '@difizen/mana-app';
|
|
26
29
|
|
|
27
30
|
import { LibroBetweenCellModule } from './add-between-cell/index.js';
|
|
@@ -31,8 +34,10 @@ import {
|
|
|
31
34
|
LibroJupyterKeybindingContribution,
|
|
32
35
|
} from './command/index.js';
|
|
33
36
|
import { CellExecutionTip, CellInputBottomBlank } from './components/index.js';
|
|
34
|
-
import {
|
|
35
|
-
|
|
37
|
+
import {
|
|
38
|
+
ConfigAppContribution,
|
|
39
|
+
LibroJupyterSettingContribution,
|
|
40
|
+
} from './config/index.js';
|
|
36
41
|
import { LibroJupyterContentContribution } from './contents/index.js';
|
|
37
42
|
import { LibroJupyterFileModule } from './file/index.js';
|
|
38
43
|
import { KeybindInstructionsModule } from './keybind-instructions/index.js';
|
|
@@ -45,9 +50,9 @@ import { LibroJupyterOutputArea } from './output/index.js';
|
|
|
45
50
|
import { PlotlyModule } from './rendermime/index.js';
|
|
46
51
|
import { LibroJupyterColorContribution } from './theme/index.js';
|
|
47
52
|
import {
|
|
53
|
+
KernelStatusSelector,
|
|
48
54
|
LibroJupyterToolbarContribution,
|
|
49
55
|
SaveFileErrorContribution,
|
|
50
|
-
KernelStatusSelector,
|
|
51
56
|
} from './toolbar/index.js';
|
|
52
57
|
|
|
53
58
|
export const LibroJupyterModule = ManaModule.create()
|
|
@@ -62,9 +67,9 @@ export const LibroJupyterModule = ManaModule.create()
|
|
|
62
67
|
LibroJupyterContentContribution,
|
|
63
68
|
LibroJupyterOutputArea,
|
|
64
69
|
LibroJupyterColorContribution,
|
|
70
|
+
LibroJupyterSettingContribution,
|
|
65
71
|
JupyterServerLaunchManager,
|
|
66
72
|
LibroJupyterView,
|
|
67
|
-
LibroConfigurationContribution,
|
|
68
73
|
{
|
|
69
74
|
token: CellExecutionTimeProvider,
|
|
70
75
|
useValue: CellExecutionTip,
|
|
@@ -95,8 +100,11 @@ export const LibroJupyterModule = ManaModule.create()
|
|
|
95
100
|
LibroToolbarModule,
|
|
96
101
|
LibroKernelManageModule,
|
|
97
102
|
LibroSearchModule,
|
|
98
|
-
|
|
103
|
+
SearchCodeCellModule,
|
|
99
104
|
LibroAddCellModule,
|
|
105
|
+
LibroLSPModule,
|
|
106
|
+
LibroE2EditorModule,
|
|
107
|
+
CodeMirrorEditorModule,
|
|
100
108
|
// custom module
|
|
101
109
|
LibroBetweenCellModule,
|
|
102
110
|
KeybindInstructionsModule,
|
|
@@ -7,17 +7,19 @@ import type {
|
|
|
7
7
|
import { LibroOutputArea } from '@difizen/libro-core';
|
|
8
8
|
import {
|
|
9
9
|
isDisplayDataMsg,
|
|
10
|
-
isStreamMsg,
|
|
11
10
|
isErrorMsg,
|
|
12
|
-
isExecuteResultMsg,
|
|
13
11
|
isExecuteReplyMsg,
|
|
12
|
+
isExecuteResultMsg,
|
|
13
|
+
isStreamMsg,
|
|
14
|
+
isUpdateDisplayDataMsg,
|
|
14
15
|
} from '@difizen/libro-kernel';
|
|
15
|
-
import {
|
|
16
|
+
import { inject, transient, view, ViewOption } from '@difizen/mana-app';
|
|
16
17
|
|
|
17
18
|
@transient()
|
|
18
19
|
@view('libro-output-area')
|
|
19
20
|
export class LibroJupyterOutputArea extends LibroOutputArea {
|
|
20
21
|
declare cell: LibroExecutableCellView;
|
|
22
|
+
protected displayIdMap = new Map<string, number[]>();
|
|
21
23
|
|
|
22
24
|
constructor(@inject(ViewOption) option: IOutputAreaOption) {
|
|
23
25
|
super(option);
|
|
@@ -27,6 +29,8 @@ export class LibroJupyterOutputArea extends LibroOutputArea {
|
|
|
27
29
|
handleMsg() {
|
|
28
30
|
const cellModel = this.cell.model as ExecutableCellModel;
|
|
29
31
|
cellModel.msgChangeEmitter.event((msg) => {
|
|
32
|
+
const transientMsg = (msg.content.transient || {}) as nbformat.JSONObject;
|
|
33
|
+
const displayId = transientMsg['display_id'] as string;
|
|
30
34
|
if (msg.header.msg_type !== 'status') {
|
|
31
35
|
if (msg.header.msg_type === 'execute_input') {
|
|
32
36
|
cellModel.executeCount = msg.content.execution_count;
|
|
@@ -43,6 +47,20 @@ export class LibroJupyterOutputArea extends LibroOutputArea {
|
|
|
43
47
|
};
|
|
44
48
|
this.add(output);
|
|
45
49
|
}
|
|
50
|
+
if (isUpdateDisplayDataMsg(msg)) {
|
|
51
|
+
const output = { ...msg.content, output_type: 'display_data' };
|
|
52
|
+
const targets = this.displayIdMap.get(displayId);
|
|
53
|
+
if (targets) {
|
|
54
|
+
for (const index of targets) {
|
|
55
|
+
this.set(index, output);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (displayId && isDisplayDataMsg(msg)) {
|
|
60
|
+
const targets = this.displayIdMap.get(displayId) || [];
|
|
61
|
+
targets.push(this.outputs.length);
|
|
62
|
+
this.displayIdMap.set(displayId, targets);
|
|
63
|
+
}
|
|
46
64
|
//Handle an execute reply message.
|
|
47
65
|
if (isExecuteReplyMsg(msg)) {
|
|
48
66
|
const content = msg.content;
|
|
@@ -68,4 +86,14 @@ export class LibroJupyterOutputArea extends LibroOutputArea {
|
|
|
68
86
|
}
|
|
69
87
|
});
|
|
70
88
|
}
|
|
89
|
+
|
|
90
|
+
override dispose(): void {
|
|
91
|
+
this.displayIdMap.clear();
|
|
92
|
+
super.dispose();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
override clear(wait?: boolean | undefined): void {
|
|
96
|
+
super.clear(wait);
|
|
97
|
+
this.displayIdMap.clear();
|
|
98
|
+
}
|
|
71
99
|
}
|
|
@@ -1,12 +1,23 @@
|
|
|
1
|
+
/* stylelint-disable no-duplicate-selectors */
|
|
2
|
+
|
|
1
3
|
/* Base styles */
|
|
2
4
|
.libro-plotly-render {
|
|
3
5
|
width: 100%;
|
|
4
6
|
height: 100%;
|
|
5
7
|
padding: 0;
|
|
6
|
-
min-height: 360px;
|
|
7
8
|
overflow: hidden;
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
/* Document styles */
|
|
12
|
+
.libro-plotly-render {
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/* Output styles */
|
|
17
|
+
.libro-plotly-render {
|
|
18
|
+
min-height: 360px;
|
|
19
|
+
}
|
|
20
|
+
|
|
10
21
|
/* Document icon */
|
|
11
22
|
.libro-PlotlyIcon {
|
|
12
23
|
background-image: url('./assets/plotly.svg');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BaseOutputView } from '@difizen/libro-core';
|
|
2
|
-
import { RenderMimeRegistry } from '@difizen/libro-rendermime';
|
|
3
2
|
import type { IRenderMimeRegistry } from '@difizen/libro-rendermime';
|
|
3
|
+
import { RenderMimeRegistry } from '@difizen/libro-rendermime';
|
|
4
4
|
import { useInject } from '@difizen/mana-app';
|
|
5
5
|
import { useEffect, useRef } from 'react';
|
|
6
6
|
import type { FC } from 'react';
|
|
@@ -73,19 +73,19 @@ export class RenderedPlotly {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
protected hasGraphElement() {
|
|
77
77
|
// Check for the presence of the .plot-container element that plotly.js
|
|
78
78
|
// places at the top of the figure structure
|
|
79
79
|
return this.node.querySelector('.plot-container') !== null;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
protected updateImage(png_data: string) {
|
|
83
83
|
this.hideGraph();
|
|
84
84
|
this._img_el.src = 'data:image/png;base64,' + png_data;
|
|
85
85
|
this.showImage();
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
protected hideGraph() {
|
|
89
89
|
// Hide the graph if there is one
|
|
90
90
|
const el = <HTMLDivElement>this.node.querySelector('.plot-container');
|
|
91
91
|
if (el !== null && el !== undefined) {
|
|
@@ -93,7 +93,7 @@ export class RenderedPlotly {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
protected showGraph() {
|
|
97
97
|
// Show the graph if there is one
|
|
98
98
|
const el = <HTMLDivElement>this.node.querySelector('.plot-container');
|
|
99
99
|
if (el !== null && el !== undefined) {
|
|
@@ -101,7 +101,7 @@ export class RenderedPlotly {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
protected hideImage() {
|
|
105
105
|
// Hide the image element
|
|
106
106
|
const el = <HTMLImageElement>this.node.querySelector('.plot-img');
|
|
107
107
|
if (el !== null && el !== undefined) {
|
|
@@ -109,7 +109,7 @@ export class RenderedPlotly {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
protected showImage() {
|
|
113
113
|
// Show the image element
|
|
114
114
|
const el = <HTMLImageElement>this.node.querySelector('.plot-img');
|
|
115
115
|
if (el !== null && el !== undefined) {
|
|
@@ -117,7 +117,7 @@ export class RenderedPlotly {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
protected createGraph(model: BaseOutputView): Promise<void> {
|
|
121
121
|
const { data, layout, frames, config } = model.data[this._mimeType] as
|
|
122
122
|
| any
|
|
123
123
|
| IPlotlySpec;
|
|
@@ -158,21 +158,19 @@ export class RenderedPlotly {
|
|
|
158
158
|
}
|
|
159
159
|
return;
|
|
160
160
|
})
|
|
161
|
-
.catch(
|
|
162
|
-
//
|
|
163
|
-
});
|
|
161
|
+
.catch(console.error);
|
|
164
162
|
}
|
|
165
163
|
return;
|
|
166
164
|
});
|
|
167
165
|
}
|
|
168
166
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
167
|
+
protected _mimeType: string;
|
|
168
|
+
protected _img_el: HTMLImageElement;
|
|
169
|
+
protected _model: BaseOutputView;
|
|
170
|
+
protected node: HTMLElement;
|
|
171
|
+
protected static Plotly: typeof PlotlyType | null = null;
|
|
172
|
+
protected static _resolveLoadingPlotly: () => void;
|
|
173
|
+
protected static loadingPlotly = new Promise<void>((resolve) => {
|
|
176
174
|
RenderedPlotly._resolveLoadingPlotly = resolve;
|
|
177
175
|
});
|
|
178
176
|
}
|