@difizen/libro-jupyter 0.2.0 → 0.2.2
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.js +1 -1
- package/es/cell/jupyter-code-cell-view.d.ts +3 -1
- package/es/cell/jupyter-code-cell-view.d.ts.map +1 -1
- package/es/cell/jupyter-code-cell-view.js +12 -5
- package/es/command/command-contribution.d.ts.map +1 -1
- package/es/command/command-contribution.js +5 -5
- package/es/components/icons.js +1 -1
- package/es/contents/content-contribution.js +1 -1
- package/es/contents/save-content-contribution.d.ts +10 -0
- package/es/contents/save-content-contribution.d.ts.map +1 -0
- package/es/contents/save-content-contribution.js +110 -0
- package/es/file/file-create-modal.d.ts.map +1 -1
- package/es/file/file-create-modal.js +16 -5
- package/es/file/file-service.js +1 -1
- package/es/file/index.d.ts +1 -0
- package/es/file/index.d.ts.map +1 -1
- package/es/file/index.js +2 -1
- package/es/index.d.ts +1 -0
- package/es/index.d.ts.map +1 -1
- package/es/index.js +2 -1
- package/es/keybind-instructions/index.less +9 -9
- package/es/keybind-instructions/keybind-instructions-view.d.ts +2 -2
- package/es/keybind-instructions/keybind-instructions-view.d.ts.map +1 -1
- package/es/keybind-instructions/keybind-instructions-view.js +69 -63
- package/es/libro-jupyter-model.d.ts +2 -4
- package/es/libro-jupyter-model.d.ts.map +1 -1
- package/es/libro-jupyter-model.js +35 -120
- package/es/libro-jupyter-workspace.d.ts +18 -0
- package/es/libro-jupyter-workspace.d.ts.map +1 -0
- package/es/libro-jupyter-workspace.js +108 -0
- package/es/module.d.ts.map +1 -1
- package/es/module.js +5 -2
- package/es/output/libro-jupyter-outputarea.d.ts.map +1 -1
- package/es/output/libro-jupyter-outputarea.js +60 -56
- package/es/toolbar/save-file-error.d.ts.map +1 -1
- package/es/toolbar/save-file-error.js +20 -13
- package/es/widget/box/contribution.d.ts +10 -0
- package/es/widget/box/contribution.d.ts.map +1 -0
- package/es/widget/box/contribution.js +48 -0
- package/es/widget/box/index.d.ts +3 -0
- package/es/widget/box/index.d.ts.map +1 -0
- package/es/widget/box/index.js +2 -0
- package/es/widget/box/index.less +3 -0
- package/es/widget/box/view.d.ts +19 -0
- package/es/widget/box/view.d.ts.map +1 -0
- package/es/widget/box/view.js +114 -0
- package/es/widget/comm.d.ts +65 -0
- package/es/widget/comm.d.ts.map +1 -0
- package/es/widget/comm.js +153 -0
- package/es/widget/index.d.ts +10 -0
- package/es/widget/index.d.ts.map +1 -0
- package/es/widget/index.js +9 -0
- package/es/widget/index.less +7 -0
- package/es/widget/instance-progress/contribution.d.ts +10 -0
- package/es/widget/instance-progress/contribution.d.ts.map +1 -0
- package/es/widget/instance-progress/contribution.js +39 -0
- package/es/widget/instance-progress/index.d.ts +3 -0
- package/es/widget/instance-progress/index.d.ts.map +1 -0
- package/es/widget/instance-progress/index.js +2 -0
- package/es/widget/instance-progress/view.d.ts +30 -0
- package/es/widget/instance-progress/view.d.ts.map +1 -0
- package/es/widget/instance-progress/view.js +180 -0
- package/es/widget/libro-widgets.d.ts +84 -0
- package/es/widget/libro-widgets.d.ts.map +1 -0
- package/es/widget/libro-widgets.js +307 -0
- package/es/widget/module.d.ts +4 -0
- package/es/widget/module.d.ts.map +1 -0
- package/es/widget/module.js +38 -0
- package/es/widget/progress/contribution.d.ts +10 -0
- package/es/widget/progress/contribution.d.ts.map +1 -0
- package/es/widget/progress/contribution.js +39 -0
- package/es/widget/progress/index.d.ts +3 -0
- package/es/widget/progress/index.d.ts.map +1 -0
- package/es/widget/progress/index.js +2 -0
- package/es/widget/progress/progressBar.d.ts +15 -0
- package/es/widget/progress/progressBar.d.ts.map +1 -0
- package/es/widget/progress/progressBar.js +20 -0
- package/es/widget/progress/view.d.ts +19 -0
- package/es/widget/progress/view.d.ts.map +1 -0
- package/es/widget/progress/view.js +74 -0
- package/es/widget/protocol.d.ts +193 -0
- package/es/widget/protocol.d.ts.map +1 -0
- package/es/widget/protocol.js +33 -0
- package/es/widget/utils.d.ts +27 -0
- package/es/widget/utils.d.ts.map +1 -0
- package/es/widget/utils.js +59 -0
- package/es/widget/version.d.ts +3 -0
- package/es/widget/version.d.ts.map +1 -0
- package/es/widget/version.js +2 -0
- package/es/widget/widget-manager.d.ts +19 -0
- package/es/widget/widget-manager.d.ts.map +1 -0
- package/es/widget/widget-manager.js +77 -0
- package/es/widget/widget-render.d.ts +7 -0
- package/es/widget/widget-render.d.ts.map +1 -0
- package/es/widget/widget-render.js +46 -0
- package/es/widget/widget-rendermime-contribution.d.ts +16 -0
- package/es/widget/widget-rendermime-contribution.d.ts.map +1 -0
- package/es/widget/widget-rendermime-contribution.js +50 -0
- package/es/widget/widget-view-contribution.d.ts +10 -0
- package/es/widget/widget-view-contribution.d.ts.map +1 -0
- package/es/widget/widget-view-contribution.js +36 -0
- package/es/widget/widget-view.d.ts +71 -0
- package/es/widget/widget-view.d.ts.map +1 -0
- package/es/widget/widget-view.js +273 -0
- package/package.json +18 -18
- package/src/add-between-cell/add-between-cell.tsx +1 -1
- package/src/cell/jupyter-code-cell-view.tsx +14 -6
- package/src/command/command-contribution.ts +11 -10
- package/src/components/icons.tsx +1 -1
- package/src/contents/content-contribution.ts +1 -1
- package/src/contents/save-content-contribution.ts +67 -0
- package/src/file/file-create-modal.tsx +10 -1
- package/src/file/file-service.ts +1 -1
- package/src/file/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/keybind-instructions/index.less +9 -9
- package/src/keybind-instructions/keybind-instructions-view.tsx +72 -62
- package/src/libro-jupyter-model.ts +1 -69
- package/src/libro-jupyter-workspace.ts +49 -0
- package/src/module.ts +6 -0
- package/src/output/libro-jupyter-outputarea.tsx +56 -49
- package/src/toolbar/save-file-error.tsx +25 -15
- package/src/widget/box/contribution.ts +29 -0
- package/src/widget/box/index.less +3 -0
- package/src/widget/box/index.ts +2 -0
- package/src/widget/box/view.tsx +112 -0
- package/src/widget/comm.ts +152 -0
- package/src/widget/index.less +7 -0
- package/src/widget/index.ts +9 -0
- package/src/widget/instance-progress/contribution.ts +20 -0
- package/src/widget/instance-progress/index.ts +2 -0
- package/src/widget/instance-progress/view.tsx +155 -0
- package/src/widget/libro-widgets.ts +223 -0
- package/src/widget/module.ts +73 -0
- package/src/widget/progress/contribution.ts +24 -0
- package/src/widget/progress/index.ts +2 -0
- package/src/widget/progress/progressBar.tsx +29 -0
- package/src/widget/progress/view.tsx +70 -0
- package/src/widget/protocol.ts +255 -0
- package/src/widget/utils.ts +67 -0
- package/src/widget/version.ts +2 -0
- package/src/widget/widget-manager.ts +45 -0
- package/src/widget/widget-render.tsx +52 -0
- package/src/widget/widget-rendermime-contribution.ts +36 -0
- package/src/widget/widget-view-contribution.ts +14 -0
- package/src/widget/widget-view.tsx +259 -0
|
@@ -7,6 +7,13 @@
|
|
|
7
7
|
.@{ant-prefix}-input-group-wrapper {
|
|
8
8
|
background-color: var(--mana-libro-filtered-background-color) !important;
|
|
9
9
|
border-radius: 6px;
|
|
10
|
+
.@{ant-prefix}-input {
|
|
11
|
+
color: var(--mana-libro-drawer-title-color);
|
|
12
|
+
|
|
13
|
+
&::placeholder {
|
|
14
|
+
color: var(--mana-libro-keybind-tag-text-color);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
10
17
|
}
|
|
11
18
|
|
|
12
19
|
.@{ant-prefix}-input-group-addon {
|
|
@@ -19,6 +26,7 @@
|
|
|
19
26
|
}
|
|
20
27
|
|
|
21
28
|
.libro-keybind-instructions-drawer {
|
|
29
|
+
background: var(--mana-libro-popover-background-color) !important;
|
|
22
30
|
.@{ant-prefix}-drawer-content-wrapper {
|
|
23
31
|
box-shadow:
|
|
24
32
|
0 0 16px -8px rgba(0, 0, 0, 8%),
|
|
@@ -34,17 +42,9 @@
|
|
|
34
42
|
.@{ant-prefix}-segmented-item-label {
|
|
35
43
|
color: var(--mana-libro-drawer-title-color);
|
|
36
44
|
}
|
|
37
|
-
.@{ant-prefix}-segmented-item-selected {
|
|
38
|
-
.@{ant-prefix}-segmented-item-label {
|
|
39
|
-
color: rgba(0, 10, 26, 89%);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
45
|
.@{ant-prefix}-drawer-mask {
|
|
43
46
|
opacity: 0;
|
|
44
47
|
}
|
|
45
|
-
.@{ant-prefix}-drawer-content {
|
|
46
|
-
background: var(--mana-libro-popover-background-color);
|
|
47
|
-
}
|
|
48
48
|
.@{ant-prefix}-drawer-close {
|
|
49
49
|
color: var(--mana-libro-drawer-close-color);
|
|
50
50
|
}
|
|
@@ -135,6 +135,7 @@
|
|
|
135
135
|
.libro-magic-table {
|
|
136
136
|
.@{ant-prefix}-table-thead > tr > th {
|
|
137
137
|
background: var(--mana-libro-popover-background-color);
|
|
138
|
+
color: var(--mana-libro-table-title-color);
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
.@{ant-prefix}-table-tbody > tr.@{ant-prefix}-table-row:hover > td {
|
|
@@ -148,7 +149,6 @@
|
|
|
148
149
|
|
|
149
150
|
thead tr th {
|
|
150
151
|
height: 30px;
|
|
151
|
-
color: var(--mana-libro-table-title-color);
|
|
152
152
|
font-weight: 600;
|
|
153
153
|
font-size: 14px;
|
|
154
154
|
font-family: PingFangSC;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { inject, singleton } from '@difizen/mana-app';
|
|
1
|
+
import { LibroContextKey } from '@difizen/libro-core';
|
|
2
|
+
import { inject, singleton, ThemeService } from '@difizen/mana-app';
|
|
3
3
|
import { getOrigin, prop, useInject } from '@difizen/mana-app';
|
|
4
4
|
import type { ModalItem, ModalItemProps } from '@difizen/mana-app';
|
|
5
5
|
import type { Disposable } from '@difizen/mana-app';
|
|
6
6
|
import { l10n } from '@difizen/mana-l10n';
|
|
7
|
-
import { Input, Drawer, Table, Segmented } from 'antd';
|
|
7
|
+
import { Input, Drawer, Table, Segmented, ConfigProvider, theme } from 'antd';
|
|
8
8
|
import { forwardRef, useCallback, useState } from 'react';
|
|
9
9
|
|
|
10
10
|
import type { DataType } from './keybind-instructions-items.js';
|
|
@@ -49,7 +49,7 @@ const getSearchResult = (
|
|
|
49
49
|
|
|
50
50
|
@singleton()
|
|
51
51
|
export class KeybindInstrutionsService implements Disposable {
|
|
52
|
-
@inject(
|
|
52
|
+
@inject(LibroContextKey) contextKey: LibroContextKey;
|
|
53
53
|
isKeybindInstructionsMask = false;
|
|
54
54
|
@prop() searchCommandModeData: DataType[] = [];
|
|
55
55
|
@prop() searchEditModeData: DataType[] = [];
|
|
@@ -132,6 +132,7 @@ export const KeybindInstrutionsComponent = forwardRef<
|
|
|
132
132
|
const keybindInstrutionsService = useInject<KeybindInstrutionsService>(
|
|
133
133
|
KeybindInstrutionsService,
|
|
134
134
|
);
|
|
135
|
+
const themeService = useInject(ThemeService);
|
|
135
136
|
const libroKeybindItems = useInject(LibroKeybindItems);
|
|
136
137
|
const handleClose = useCallback(() => {
|
|
137
138
|
close();
|
|
@@ -166,70 +167,79 @@ export const KeybindInstrutionsComponent = forwardRef<
|
|
|
166
167
|
);
|
|
167
168
|
|
|
168
169
|
return (
|
|
169
|
-
<
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
maskClosable={true}
|
|
188
|
-
>
|
|
189
|
-
{segment === 'magic' && (
|
|
190
|
-
<div className="libro-magic-table">
|
|
191
|
-
<Table
|
|
192
|
-
size="small"
|
|
193
|
-
columns={magicColumns}
|
|
194
|
-
dataSource={magics}
|
|
195
|
-
pagination={false}
|
|
196
|
-
rowKey="key"
|
|
170
|
+
<ConfigProvider
|
|
171
|
+
theme={{
|
|
172
|
+
algorithm:
|
|
173
|
+
themeService.getCurrentTheme().type === 'dark'
|
|
174
|
+
? theme.darkAlgorithm
|
|
175
|
+
: theme.defaultAlgorithm,
|
|
176
|
+
}}
|
|
177
|
+
>
|
|
178
|
+
<div className="libro-keybind-instructions-command" ref={ref}>
|
|
179
|
+
<Drawer
|
|
180
|
+
title={
|
|
181
|
+
<Segmented
|
|
182
|
+
value={segment}
|
|
183
|
+
onChange={(value) => setSegment(value as Segment)}
|
|
184
|
+
options={[
|
|
185
|
+
{ label: l10n.t('快捷键'), value: 'keybind' },
|
|
186
|
+
{ label: 'Magic 命令', value: 'magic' },
|
|
187
|
+
]}
|
|
197
188
|
/>
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
189
|
+
}
|
|
190
|
+
placement="right"
|
|
191
|
+
onClose={handleClose}
|
|
192
|
+
width="360px"
|
|
193
|
+
open={visible}
|
|
194
|
+
mask={true}
|
|
195
|
+
className="libro-keybind-instructions-drawer"
|
|
196
|
+
maskClosable={true}
|
|
197
|
+
>
|
|
198
|
+
{segment === 'magic' && (
|
|
199
|
+
<div className="libro-magic-table">
|
|
200
|
+
<Table
|
|
201
|
+
size="small"
|
|
202
|
+
columns={magicColumns}
|
|
203
|
+
dataSource={magics}
|
|
204
|
+
pagination={false}
|
|
205
|
+
rowKey="key"
|
|
209
206
|
/>
|
|
210
207
|
</div>
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
208
|
+
)}
|
|
209
|
+
{segment === 'keybind' && (
|
|
210
|
+
<>
|
|
211
|
+
<div className="libro-keybind-instructions-command-search">
|
|
212
|
+
<Search
|
|
213
|
+
placeholder={l10n.t('搜索功能关键字')}
|
|
214
|
+
allowClear
|
|
215
|
+
bordered={false}
|
|
216
|
+
size="middle"
|
|
217
|
+
onSearch={handleSearch}
|
|
218
218
|
/>
|
|
219
219
|
</div>
|
|
220
|
-
<div className="libro-
|
|
221
|
-
<
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
220
|
+
<div className="libro-keybind-instructions-table">
|
|
221
|
+
<div className="libro-command-mode-keybind-instructions-table">
|
|
222
|
+
<Table
|
|
223
|
+
rowKey="key"
|
|
224
|
+
columns={libroKeybindItems.commandModeActionColumns}
|
|
225
|
+
dataSource={commandModeDataSource}
|
|
226
|
+
pagination={false}
|
|
227
|
+
/>
|
|
228
|
+
</div>
|
|
229
|
+
<div className="libro-edit-mode-keybind-instructions-table">
|
|
230
|
+
<Table
|
|
231
|
+
rowKey="key"
|
|
232
|
+
columns={libroKeybindItems.editModeActionColumns}
|
|
233
|
+
dataSource={editModeDataSource}
|
|
234
|
+
pagination={false}
|
|
235
|
+
/>
|
|
236
|
+
</div>
|
|
227
237
|
</div>
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
</
|
|
232
|
-
</
|
|
238
|
+
</>
|
|
239
|
+
)}
|
|
240
|
+
</Drawer>
|
|
241
|
+
</div>
|
|
242
|
+
</ConfigProvider>
|
|
233
243
|
);
|
|
234
244
|
});
|
|
235
245
|
|
|
@@ -2,13 +2,12 @@ import type { VirtualizedManager } from '@difizen/libro-core';
|
|
|
2
2
|
import { LibroModel, VirtualizedManagerHelper } from '@difizen/libro-core';
|
|
3
3
|
import {
|
|
4
4
|
ContentsManager,
|
|
5
|
-
ExecutableNotebookModel,
|
|
6
5
|
isDisplayDataMsg,
|
|
7
6
|
LibroKernelConnectionManager,
|
|
8
7
|
ServerConnection,
|
|
9
8
|
ServerManager,
|
|
10
9
|
} from '@difizen/libro-kernel';
|
|
11
|
-
import type { IKernelConnection } from '@difizen/libro-kernel';
|
|
10
|
+
import type { IKernelConnection, ExecutableNotebookModel } from '@difizen/libro-kernel';
|
|
12
11
|
import type { IContentsCheckpointModel, IContentsModel } from '@difizen/libro-kernel';
|
|
13
12
|
import { getOrigin, ModalService, prop } from '@difizen/mana-app';
|
|
14
13
|
import { Deferred } from '@difizen/mana-app';
|
|
@@ -20,23 +19,11 @@ import {
|
|
|
20
19
|
libroArgsMimetype,
|
|
21
20
|
LibroFileService,
|
|
22
21
|
} from './libro-jupyter-protocol.js';
|
|
23
|
-
import { SaveFileErrorModal } from './toolbar/save-file-error.js';
|
|
24
22
|
import { getDefaultKernel } from './utils/index.js';
|
|
25
23
|
|
|
26
24
|
type IModel = IContentsModel;
|
|
27
25
|
@transient()
|
|
28
26
|
export class LibroJupyterModel extends LibroModel implements ExecutableNotebookModel {
|
|
29
|
-
static is = (arg: Record<any, any> | undefined): arg is LibroJupyterModel => {
|
|
30
|
-
return (
|
|
31
|
-
!!arg &&
|
|
32
|
-
ExecutableNotebookModel.is(arg) &&
|
|
33
|
-
'kernelConnection' in arg &&
|
|
34
|
-
typeof (arg as any).kernelConnection === 'object' &&
|
|
35
|
-
'lspEnabled' in arg &&
|
|
36
|
-
typeof (arg as any).lspEnabled === 'boolean'
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
27
|
protected libroFileService: LibroFileService;
|
|
41
28
|
protected virtualizedManager: VirtualizedManager;
|
|
42
29
|
|
|
@@ -187,61 +174,6 @@ export class LibroJupyterModel extends LibroModel implements ExecutableNotebookM
|
|
|
187
174
|
.catch(console.error);
|
|
188
175
|
}
|
|
189
176
|
|
|
190
|
-
override async saveNotebookContent(): Promise<void> {
|
|
191
|
-
const notebookContent = this.toJSON();
|
|
192
|
-
if (!this.currentFileContents) {
|
|
193
|
-
throw new Error('currentFileContents is undefined');
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
let res = {} as IModel | undefined;
|
|
197
|
-
|
|
198
|
-
try {
|
|
199
|
-
res = await this.libroFileService.write(
|
|
200
|
-
notebookContent,
|
|
201
|
-
this.currentFileContents,
|
|
202
|
-
);
|
|
203
|
-
if (!res) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
// 文件保存失败
|
|
207
|
-
if (res.last_modified === this.last_modified || res.size === 0) {
|
|
208
|
-
const errorMsg = `File Save Error: ${res?.message} `;
|
|
209
|
-
this.libroFileService.fileSaveErrorEmitter.fire({
|
|
210
|
-
cause: res.message,
|
|
211
|
-
msg: errorMsg,
|
|
212
|
-
name: res.name,
|
|
213
|
-
path: res.path,
|
|
214
|
-
created: res.created,
|
|
215
|
-
last_modified: res.last_modified,
|
|
216
|
-
size: res.size,
|
|
217
|
-
type: res.type,
|
|
218
|
-
});
|
|
219
|
-
this.modalService.openModal(SaveFileErrorModal);
|
|
220
|
-
|
|
221
|
-
throw new Error(errorMsg);
|
|
222
|
-
}
|
|
223
|
-
} catch (e: any) {
|
|
224
|
-
if (!res) {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
this.libroFileService.fileSaveErrorEmitter.fire({
|
|
228
|
-
cause: e.errorCause,
|
|
229
|
-
msg: e.message,
|
|
230
|
-
name: res.name || this.currentFileContents.name,
|
|
231
|
-
path: res.path || this.currentFileContents.path,
|
|
232
|
-
created: res.created || this.currentFileContents.created,
|
|
233
|
-
last_modified: res.last_modified || this.currentFileContents.last_modified,
|
|
234
|
-
size: res.size || this.currentFileContents.size,
|
|
235
|
-
type: res.type || this.currentFileContents.type,
|
|
236
|
-
});
|
|
237
|
-
this.modalService.openModal(SaveFileErrorModal);
|
|
238
|
-
|
|
239
|
-
throw new Error('File Save Error');
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
await this.createCheckpoint();
|
|
243
|
-
}
|
|
244
|
-
|
|
245
177
|
override canRun() {
|
|
246
178
|
if (!this.kernelConnection) {
|
|
247
179
|
alert(l10n.t('Kernel Connection 还没有建立'));
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { URL } from '@difizen/libro-common';
|
|
2
|
+
import { BaseWorkspaceService, ILibroWorkspaceService } from '@difizen/libro-core';
|
|
3
|
+
import { ServerConnection, ServerManager } from '@difizen/libro-kernel';
|
|
4
|
+
import { ApplicationContribution } from '@difizen/mana-app';
|
|
5
|
+
import { URI } from '@difizen/mana-app';
|
|
6
|
+
import { inject, singleton } from '@difizen/mana-app';
|
|
7
|
+
|
|
8
|
+
interface JupyterWorkspaceData {
|
|
9
|
+
rootUri: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@singleton({ contrib: [ILibroWorkspaceService, ApplicationContribution] })
|
|
13
|
+
export class JupyterWorkspaceService
|
|
14
|
+
extends BaseWorkspaceService
|
|
15
|
+
implements ILibroWorkspaceService, ApplicationContribution
|
|
16
|
+
{
|
|
17
|
+
@inject(ServerConnection) serverConnection: ServerConnection;
|
|
18
|
+
@inject(ServerManager) serverManager: ServerManager;
|
|
19
|
+
|
|
20
|
+
protected workspaceData: JupyterWorkspaceData;
|
|
21
|
+
|
|
22
|
+
onViewStart() {
|
|
23
|
+
this.serverManager.ready
|
|
24
|
+
.then(() => {
|
|
25
|
+
const settings = { ...this.serverConnection.settings };
|
|
26
|
+
const url = URL.join(settings.baseUrl, '/libro/api/workspace');
|
|
27
|
+
return this.serverConnection.makeRequest(url, {});
|
|
28
|
+
})
|
|
29
|
+
.then(async (res) => {
|
|
30
|
+
const data = await res.json();
|
|
31
|
+
this.workspaceData = data;
|
|
32
|
+
this.deferred.resolve();
|
|
33
|
+
return;
|
|
34
|
+
})
|
|
35
|
+
.catch(() => {
|
|
36
|
+
return;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
override get workspaceRoot() {
|
|
41
|
+
return new URI(this.workspaceData.rootUri);
|
|
42
|
+
}
|
|
43
|
+
override get notebooks() {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
override get files() {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/module.ts
CHANGED
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
LibroJupyterSettingContribution,
|
|
40
40
|
} from './config/index.js';
|
|
41
41
|
import { LibroJupyterContentContribution } from './contents/index.js';
|
|
42
|
+
import { LibroJupyterContentSaveContribution } from './contents/save-content-contribution.js';
|
|
42
43
|
import { LibroJupyterFileModule } from './file/index.js';
|
|
43
44
|
import { KeybindInstructionsModule } from './keybind-instructions/index.js';
|
|
44
45
|
import { LibroJupyterFileService } from './libro-jupyter-file-service.js';
|
|
@@ -46,6 +47,7 @@ import { LibroJupyterModel } from './libro-jupyter-model.js';
|
|
|
46
47
|
import { KernelStatusAndSelectorProvider } from './libro-jupyter-protocol.js';
|
|
47
48
|
import { JupyterServerLaunchManager } from './libro-jupyter-server-launch-manager.js';
|
|
48
49
|
import { LibroJupyterView } from './libro-jupyter-view.js';
|
|
50
|
+
import { JupyterWorkspaceService } from './libro-jupyter-workspace.js';
|
|
49
51
|
import { LibroJupyterOutputArea } from './output/index.js';
|
|
50
52
|
import { PlotlyModule } from './rendermime/index.js';
|
|
51
53
|
import { LibroJupyterColorContribution } from './theme/index.js';
|
|
@@ -54,9 +56,11 @@ import {
|
|
|
54
56
|
LibroJupyterToolbarContribution,
|
|
55
57
|
SaveFileErrorContribution,
|
|
56
58
|
} from './toolbar/index.js';
|
|
59
|
+
import { WidgetModule } from './widget/index.js';
|
|
57
60
|
|
|
58
61
|
export const LibroJupyterModule = ManaModule.create()
|
|
59
62
|
.register(
|
|
63
|
+
JupyterWorkspaceService,
|
|
60
64
|
LibroJupyterFileService,
|
|
61
65
|
LibroJupyterCommandContribution,
|
|
62
66
|
LibroJupyterKeybindingContribution,
|
|
@@ -65,6 +69,7 @@ export const LibroJupyterModule = ManaModule.create()
|
|
|
65
69
|
SaveFileErrorContribution,
|
|
66
70
|
LibroKeybindRegistry,
|
|
67
71
|
LibroJupyterContentContribution,
|
|
72
|
+
LibroJupyterContentSaveContribution,
|
|
68
73
|
LibroJupyterOutputArea,
|
|
69
74
|
LibroJupyterColorContribution,
|
|
70
75
|
LibroJupyterSettingContribution,
|
|
@@ -110,4 +115,5 @@ export const LibroJupyterModule = ManaModule.create()
|
|
|
110
115
|
PlotlyModule,
|
|
111
116
|
LibroJupyterFileModule,
|
|
112
117
|
LibroLanguageClientModule,
|
|
118
|
+
WidgetModule,
|
|
113
119
|
);
|
|
@@ -6,8 +6,10 @@ import type {
|
|
|
6
6
|
} from '@difizen/libro-core';
|
|
7
7
|
import { LibroOutputArea } from '@difizen/libro-core';
|
|
8
8
|
import {
|
|
9
|
+
isClearOutputMsg,
|
|
9
10
|
isDisplayDataMsg,
|
|
10
11
|
isErrorMsg,
|
|
12
|
+
isExecuteInputMsg,
|
|
11
13
|
isExecuteReplyMsg,
|
|
12
14
|
isExecuteResultMsg,
|
|
13
15
|
isStreamMsg,
|
|
@@ -31,58 +33,61 @@ export class LibroJupyterOutputArea extends LibroOutputArea {
|
|
|
31
33
|
cellModel.msgChangeEmitter.event((msg) => {
|
|
32
34
|
const transientMsg = (msg.content.transient || {}) as nbformat.JSONObject;
|
|
33
35
|
const displayId = transientMsg['display_id'] as string;
|
|
34
|
-
if (msg
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
this.set(index, output);
|
|
56
|
-
}
|
|
36
|
+
if (isExecuteInputMsg(msg)) {
|
|
37
|
+
cellModel.executeCount = msg.content.execution_count;
|
|
38
|
+
}
|
|
39
|
+
if (
|
|
40
|
+
isDisplayDataMsg(msg) ||
|
|
41
|
+
isStreamMsg(msg) ||
|
|
42
|
+
isErrorMsg(msg) ||
|
|
43
|
+
isExecuteResultMsg(msg)
|
|
44
|
+
) {
|
|
45
|
+
const output: nbformat.IOutput = {
|
|
46
|
+
...msg.content,
|
|
47
|
+
output_type: msg.header.msg_type,
|
|
48
|
+
};
|
|
49
|
+
this.add(output);
|
|
50
|
+
}
|
|
51
|
+
if (isUpdateDisplayDataMsg(msg)) {
|
|
52
|
+
const output = { ...msg.content, output_type: 'display_data' };
|
|
53
|
+
const targets = this.displayIdMap.get(displayId);
|
|
54
|
+
if (targets) {
|
|
55
|
+
for (const index of targets) {
|
|
56
|
+
this.set(index, output);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
}
|
|
60
|
+
if (displayId && isDisplayDataMsg(msg)) {
|
|
61
|
+
const targets = this.displayIdMap.get(displayId) || [];
|
|
62
|
+
targets.push(this.outputs.length);
|
|
63
|
+
this.displayIdMap.set(displayId, targets);
|
|
64
|
+
}
|
|
65
|
+
//Handle an execute reply message.
|
|
66
|
+
if (isExecuteReplyMsg(msg)) {
|
|
67
|
+
const content = msg.content;
|
|
68
|
+
if (content.status !== 'ok') {
|
|
69
|
+
return;
|
|
63
70
|
}
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (!payload || !payload.length) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
const pages = payload.filter((i: any) => i.source === 'page');
|
|
75
|
-
if (!pages.length) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
const page = JSON.parse(JSON.stringify(pages[0]));
|
|
79
|
-
const output: nbformat.IOutput = {
|
|
80
|
-
output_type: 'display_data',
|
|
81
|
-
data: page.data as nbformat.IMimeBundle,
|
|
82
|
-
metadata: {},
|
|
83
|
-
};
|
|
84
|
-
this.add(output);
|
|
71
|
+
const payload = content && content.payload;
|
|
72
|
+
if (!payload || !payload.length) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const pages = payload.filter((i: any) => i.source === 'page');
|
|
76
|
+
if (!pages.length) {
|
|
77
|
+
return;
|
|
85
78
|
}
|
|
79
|
+
const page = JSON.parse(JSON.stringify(pages[0]));
|
|
80
|
+
const output: nbformat.IOutput = {
|
|
81
|
+
output_type: 'display_data',
|
|
82
|
+
data: page.data as nbformat.IMimeBundle,
|
|
83
|
+
metadata: {},
|
|
84
|
+
};
|
|
85
|
+
this.add(output);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (isClearOutputMsg(msg)) {
|
|
89
|
+
const wait = msg.content.wait;
|
|
90
|
+
this.clear(wait);
|
|
86
91
|
}
|
|
87
92
|
});
|
|
88
93
|
}
|
|
@@ -94,6 +99,8 @@ export class LibroJupyterOutputArea extends LibroOutputArea {
|
|
|
94
99
|
|
|
95
100
|
override clear(wait?: boolean | undefined): void {
|
|
96
101
|
super.clear(wait);
|
|
97
|
-
|
|
102
|
+
if (!wait) {
|
|
103
|
+
this.displayIdMap.clear();
|
|
104
|
+
}
|
|
98
105
|
}
|
|
99
106
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { LibroView } from '@difizen/libro-core';
|
|
2
2
|
import type { ModalItemProps, ModalItem } from '@difizen/mana-app';
|
|
3
|
+
import { ThemeService } from '@difizen/mana-app';
|
|
3
4
|
import { useInject, ViewInstance } from '@difizen/mana-app';
|
|
4
|
-
import { Modal } from 'antd';
|
|
5
|
+
import { ConfigProvider, Modal, theme } from 'antd';
|
|
5
6
|
|
|
6
7
|
import type { LibroJupyterModel } from '../libro-jupyter-model.js';
|
|
7
8
|
|
|
@@ -10,22 +11,31 @@ export const SaveFileModalComponent: React.FC<ModalItemProps<void>> = ({
|
|
|
10
11
|
close,
|
|
11
12
|
}: ModalItemProps<void>) => {
|
|
12
13
|
const libroView = useInject<LibroView>(ViewInstance);
|
|
13
|
-
|
|
14
|
+
const themeService = useInject(ThemeService);
|
|
14
15
|
return (
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
<ConfigProvider
|
|
17
|
+
theme={{
|
|
18
|
+
algorithm:
|
|
19
|
+
themeService.getCurrentTheme().type === 'dark'
|
|
20
|
+
? theme.darkAlgorithm
|
|
21
|
+
: theme.defaultAlgorithm,
|
|
22
|
+
}}
|
|
22
23
|
>
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
<Modal
|
|
25
|
+
title="File Save Error"
|
|
26
|
+
open={visible}
|
|
27
|
+
onOk={() => close()}
|
|
28
|
+
onCancel={() => close()}
|
|
29
|
+
width={'400px'}
|
|
30
|
+
centered={true}
|
|
31
|
+
>
|
|
32
|
+
<p>{`File Save Error for: "${
|
|
33
|
+
libroView && libroView.model
|
|
34
|
+
? (libroView.model as LibroJupyterModel).currentFileContents.name
|
|
35
|
+
: ''
|
|
36
|
+
}"`}</p>
|
|
37
|
+
</Modal>
|
|
38
|
+
</ConfigProvider>
|
|
29
39
|
);
|
|
30
40
|
};
|
|
31
41
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ViewManager, inject, singleton } from '@difizen/mana-app';
|
|
2
|
+
|
|
3
|
+
import type { IWidgetViewProps } from '../protocol.js';
|
|
4
|
+
import { WidgetViewContribution } from '../protocol.js';
|
|
5
|
+
|
|
6
|
+
import { VBoxWidget } from './view.js';
|
|
7
|
+
|
|
8
|
+
@singleton({ contrib: WidgetViewContribution })
|
|
9
|
+
export class VBoxWidgetContribution implements WidgetViewContribution {
|
|
10
|
+
@inject(ViewManager) viewManager: ViewManager;
|
|
11
|
+
canHandle = (attributes: any) => {
|
|
12
|
+
if (attributes._model_name === 'VBoxModel') {
|
|
13
|
+
return 100;
|
|
14
|
+
}
|
|
15
|
+
if (attributes.__view_name === 'VBoxView') {
|
|
16
|
+
return 100;
|
|
17
|
+
}
|
|
18
|
+
if (attributes._model_name === 'HBoxModel') {
|
|
19
|
+
return 100;
|
|
20
|
+
}
|
|
21
|
+
if (attributes.__view_name === 'HBoxView') {
|
|
22
|
+
return 100;
|
|
23
|
+
}
|
|
24
|
+
return 1;
|
|
25
|
+
};
|
|
26
|
+
factory(props: IWidgetViewProps) {
|
|
27
|
+
return this.viewManager.getOrCreateView(VBoxWidget, props);
|
|
28
|
+
}
|
|
29
|
+
}
|