@difizen/libro-jupyter 0.2.17 → 0.2.19
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/libro-jupyter-protocol.d.ts +14 -0
- package/es/libro-jupyter-protocol.d.ts.map +1 -1
- package/es/libro-jupyter-protocol.js +85 -1
- package/es/module.d.ts.map +1 -1
- package/es/module.js +1 -1
- package/es/toolbar/kernel-status-and-selector.d.ts +0 -14
- package/es/toolbar/kernel-status-and-selector.d.ts.map +1 -1
- package/es/toolbar/kernel-status-and-selector.js +3 -102
- package/es/toolbar/run-selector.d.ts.map +1 -1
- package/es/toolbar/run-selector.js +5 -3
- package/es/toolbar/side-toolbar-run-selector.d.ts.map +1 -1
- package/es/toolbar/side-toolbar-run-selector.js +5 -2
- package/es/utils/index.d.ts +5 -1
- package/es/utils/index.d.ts.map +1 -1
- package/es/utils/index.js +27 -1
- package/package.json +17 -17
- package/src/libro-jupyter-protocol.ts +94 -0
- package/src/module.ts +1 -0
- package/src/toolbar/kernel-status-and-selector.tsx +4 -124
- package/src/toolbar/run-selector.tsx +8 -5
- package/src/toolbar/side-toolbar-run-selector.tsx +8 -4
- package/src/utils/index.ts +57 -2
|
@@ -36,4 +36,18 @@ export interface ServerLaunchManager {
|
|
|
36
36
|
launch: () => Promise<any>;
|
|
37
37
|
}
|
|
38
38
|
export declare const libroArgsMimetype = "application/vnd.libro.args+json";
|
|
39
|
+
export interface ServerStatus {
|
|
40
|
+
category: string;
|
|
41
|
+
color: string;
|
|
42
|
+
text: string;
|
|
43
|
+
text_zh: string;
|
|
44
|
+
}
|
|
45
|
+
export declare const statusToColor: {
|
|
46
|
+
canRunImmediate: string;
|
|
47
|
+
canRun: string;
|
|
48
|
+
blocking: string;
|
|
49
|
+
error: string;
|
|
50
|
+
};
|
|
51
|
+
export declare const jupyterServiceStatus: Record<string, ServerStatus>;
|
|
52
|
+
export declare const kernelStatus: Record<string, ServerStatus>;
|
|
39
53
|
//# sourceMappingURL=libro-jupyter-protocol.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-jupyter-protocol.d.ts","sourceRoot":"","sources":["../src/libro-jupyter-protocol.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"libro-jupyter-protocol.d.ts","sourceRoot":"","sources":["../src/libro-jupyter-protocol.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAGrE,MAAM,WAAW,aAAc,SAAQ,iBAAiB;IACtD,6BAA6B,EAAE,MAAM,CAAC;IACtC,yBAAyB,EAAE,MAAM,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,SAAS,EAAE,aAAa,CAAC;CAC1B;AAED,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAAC,gBAAgB,GAAG,aAAa,CAAC,CAAC;AAEnF,MAAM,WAAW,2BAA4B,SAAQ,mBAAmB;IACtE,QAAQ,EAAE,0BAA0B,CAAC;IACrC,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,eAAO,MAAM,2BAA2B;cAC5B,OAAO,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS;CAOvC,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG,KAAK,CAAC,EAAE,CAAC;AACvD,eAAO,MAAM,+BAA+B,eAE3C,CAAC;AAEF,eAAO,MAAM,gBAAgB,eAA6B,CAAC;AAC3D,MAAM,WAAW,gBAAgB;IAC/B,aAAa,EAAE,SAAS,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;IAClD,oBAAoB,EAAE,OAAO,CAC3B,OAAO,CAAC,cAAc,CAAC,GAAG;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAC3D,CAAC;IACF,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;IAC5D,KAAK,EAAE,CACL,eAAe,EAAE,gBAAgB,EACjC,mBAAmB,EAAE,cAAc,KAChC,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,mBAAmB,eAAgC,CAAC;AACjE,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;CAC5B;AAED,eAAO,MAAM,iBAAiB,oCAAoC,CAAC;AAEnE,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,aAAa;;;;;CAKzB,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAmB7D,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAuDrD,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { blue, gold, green, red } from '@ant-design/colors';
|
|
1
2
|
import { ExecutableCellModel } from '@difizen/libro-core';
|
|
3
|
+
import { l10n } from '@difizen/mana-l10n';
|
|
2
4
|
export var ExecutedWithKernelCellModel = {
|
|
3
5
|
is: function is(arg) {
|
|
4
6
|
return ExecutableCellModel.is(arg) && 'kernelExecuting' in arg && typeof arg.kernelExecuting === 'boolean';
|
|
@@ -7,4 +9,86 @@ export var ExecutedWithKernelCellModel = {
|
|
|
7
9
|
export var KernelStatusAndSelectorProvider = Symbol('KernelStatusAndSelectorProvider');
|
|
8
10
|
export var LibroFileService = Symbol('LibroFileService');
|
|
9
11
|
export var ServerLaunchManager = Symbol('ServerLaunchManager');
|
|
10
|
-
export var libroArgsMimetype = 'application/vnd.libro.args+json';
|
|
12
|
+
export var libroArgsMimetype = 'application/vnd.libro.args+json';
|
|
13
|
+
export var statusToColor = {
|
|
14
|
+
canRunImmediate: green[5],
|
|
15
|
+
canRun: blue[5],
|
|
16
|
+
blocking: gold[5],
|
|
17
|
+
error: red[4]
|
|
18
|
+
};
|
|
19
|
+
export var jupyterServiceStatus = {
|
|
20
|
+
loading: {
|
|
21
|
+
category: 'JupyterService',
|
|
22
|
+
color: statusToColor.blocking,
|
|
23
|
+
text: 'loading',
|
|
24
|
+
text_zh: l10n.t('加载中')
|
|
25
|
+
},
|
|
26
|
+
failed: {
|
|
27
|
+
category: 'JupyterService',
|
|
28
|
+
color: statusToColor.error,
|
|
29
|
+
text: 'failed',
|
|
30
|
+
text_zh: l10n.t('加载失败')
|
|
31
|
+
},
|
|
32
|
+
loaded: {
|
|
33
|
+
category: 'JupyterService',
|
|
34
|
+
color: statusToColor.canRunImmediate,
|
|
35
|
+
text: 'loaded',
|
|
36
|
+
text_zh: l10n.t('加载完成')
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export var kernelStatus = {
|
|
40
|
+
connecting: {
|
|
41
|
+
category: 'Kernel',
|
|
42
|
+
color: statusToColor.blocking,
|
|
43
|
+
text: 'connecting',
|
|
44
|
+
text_zh: l10n.t('正在连接')
|
|
45
|
+
},
|
|
46
|
+
unknown: {
|
|
47
|
+
category: 'Kernel',
|
|
48
|
+
color: statusToColor.blocking,
|
|
49
|
+
text: 'unknown',
|
|
50
|
+
text_zh: l10n.t('未知')
|
|
51
|
+
},
|
|
52
|
+
starting: {
|
|
53
|
+
category: 'Kernel',
|
|
54
|
+
color: statusToColor.blocking,
|
|
55
|
+
text: 'starting',
|
|
56
|
+
text_zh: l10n.t('启动中')
|
|
57
|
+
},
|
|
58
|
+
idle: {
|
|
59
|
+
category: 'Kernel',
|
|
60
|
+
color: statusToColor.canRunImmediate,
|
|
61
|
+
text: 'idle',
|
|
62
|
+
text_zh: l10n.t('空闲')
|
|
63
|
+
},
|
|
64
|
+
busy: {
|
|
65
|
+
category: 'Kernel',
|
|
66
|
+
color: statusToColor.canRun,
|
|
67
|
+
text: 'busy',
|
|
68
|
+
text_zh: l10n.t('忙碌')
|
|
69
|
+
},
|
|
70
|
+
terminating: {
|
|
71
|
+
category: 'Kernel',
|
|
72
|
+
color: statusToColor.blocking,
|
|
73
|
+
text: 'terminating',
|
|
74
|
+
text_zh: l10n.t('终止中')
|
|
75
|
+
},
|
|
76
|
+
restarting: {
|
|
77
|
+
category: 'Kernel',
|
|
78
|
+
color: statusToColor.blocking,
|
|
79
|
+
text: 'restarting',
|
|
80
|
+
text_zh: l10n.t('重启中')
|
|
81
|
+
},
|
|
82
|
+
autorestarting: {
|
|
83
|
+
category: 'Kernel',
|
|
84
|
+
color: statusToColor.blocking,
|
|
85
|
+
text: 'autorestarting',
|
|
86
|
+
text_zh: l10n.t('自动重启中')
|
|
87
|
+
},
|
|
88
|
+
dead: {
|
|
89
|
+
category: 'Kernel',
|
|
90
|
+
color: statusToColor.error,
|
|
91
|
+
text: 'dead',
|
|
92
|
+
text_zh: l10n.t('死亡')
|
|
93
|
+
}
|
|
94
|
+
};
|
package/es/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAiC/C;;GAEG;AACH,eAAO,MAAM,0BAA0B,YAwDpC,CAAC;AAEJ,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAiC/C;;GAEG;AACH,eAAO,MAAM,0BAA0B,YAwDpC,CAAC;AAEJ,eAAO,MAAM,kBAAkB,YAK9B,CAAC"}
|
package/es/module.js
CHANGED
|
@@ -55,4 +55,4 @@ export var LibroJupyterNoEditorModule = ManaModule.create().register(JupyterWork
|
|
|
55
55
|
}).dependOn(LibroModule, CodeCellModule, MarkdownCellModule, RawCellModule, StreamOutputModule, ErrorOutputModule, DisplayDataOutputModule, LibroToolbarModule, LibroKernelManageModule, LibroSearchModule, SearchCodeCellModule, LibroAddCellModule,
|
|
56
56
|
// custom module
|
|
57
57
|
LibroBetweenCellModule, KeybindInstructionsModule, PlotlyModule, LibroJupyterFileModule, WidgetModule);
|
|
58
|
-
export var LibroJupyterModule = ManaModule.create().dependOn(LibroE2EditorModule, CodeMirrorEditorModule, LibroLanguageClientModule);
|
|
58
|
+
export var LibroJupyterModule = ManaModule.create().dependOn(LibroE2EditorModule, CodeMirrorEditorModule, LibroJupyterNoEditorModule, LibroLanguageClientModule);
|
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" resolution-mode="require"/>
|
|
2
2
|
import './index.less';
|
|
3
|
-
export interface ServerStatus {
|
|
4
|
-
category: string;
|
|
5
|
-
color: string;
|
|
6
|
-
text: string;
|
|
7
|
-
text_zh: string;
|
|
8
|
-
}
|
|
9
|
-
export declare const statusToColor: {
|
|
10
|
-
canRunImmediate: string;
|
|
11
|
-
canRun: string;
|
|
12
|
-
blocking: string;
|
|
13
|
-
error: string;
|
|
14
|
-
};
|
|
15
|
-
export declare const jupyterServiceStatus: Record<string, ServerStatus>;
|
|
16
|
-
export declare const kernelStatus: Record<string, ServerStatus>;
|
|
17
3
|
export declare const KernelStatusSelector: React.FC;
|
|
18
4
|
//# sourceMappingURL=kernel-status-and-selector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernel-status-and-selector.d.ts","sourceRoot":"","sources":["../../src/toolbar/kernel-status-and-selector.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"kernel-status-and-selector.d.ts","sourceRoot":"","sources":["../../src/toolbar/kernel-status-and-selector.tsx"],"names":[],"mappings":";AASA,OAAO,cAAc,CAAC;AAMtB,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EA2DxC,CAAC"}
|
|
@@ -1,114 +1,15 @@
|
|
|
1
|
-
import { red, green, gold, blue } from '@ant-design/colors';
|
|
2
1
|
import { LoadingOutlined, StopOutlined } from '@ant-design/icons';
|
|
3
2
|
import { ServerManager } from '@difizen/libro-kernel';
|
|
4
3
|
import { useInject, ViewInstance } from '@difizen/mana-app';
|
|
5
4
|
import { l10n } from '@difizen/mana-l10n';
|
|
6
5
|
import { Badge } from 'antd';
|
|
7
|
-
import { LibroJupyterModel } from "../libro-jupyter-model.js";
|
|
8
|
-
import { KernelSelector } from "./kernel-selector-dropdown.js";
|
|
9
6
|
import "./index.less";
|
|
7
|
+
import { kernelStatus } from "../libro-jupyter-protocol.js";
|
|
8
|
+
import { getServiceStatusInfo } from "../utils/index.js";
|
|
9
|
+
import { KernelSelector } from "./kernel-selector-dropdown.js";
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
12
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
-
export var statusToColor = {
|
|
14
|
-
canRunImmediate: green[5],
|
|
15
|
-
canRun: blue[5],
|
|
16
|
-
blocking: gold[5],
|
|
17
|
-
error: red[4]
|
|
18
|
-
};
|
|
19
|
-
export var jupyterServiceStatus = {
|
|
20
|
-
loading: {
|
|
21
|
-
category: 'JupyterService',
|
|
22
|
-
color: statusToColor.blocking,
|
|
23
|
-
text: 'loading',
|
|
24
|
-
text_zh: l10n.t('加载中')
|
|
25
|
-
},
|
|
26
|
-
failed: {
|
|
27
|
-
category: 'JupyterService',
|
|
28
|
-
color: statusToColor.error,
|
|
29
|
-
text: 'failed',
|
|
30
|
-
text_zh: l10n.t('加载失败')
|
|
31
|
-
},
|
|
32
|
-
loaded: {
|
|
33
|
-
category: 'JupyterService',
|
|
34
|
-
color: statusToColor.canRunImmediate,
|
|
35
|
-
text: 'loaded',
|
|
36
|
-
text_zh: l10n.t('加载完成')
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
export var kernelStatus = {
|
|
40
|
-
connecting: {
|
|
41
|
-
category: 'Kernel',
|
|
42
|
-
color: statusToColor.blocking,
|
|
43
|
-
text: 'connecting',
|
|
44
|
-
text_zh: l10n.t('正在连接')
|
|
45
|
-
},
|
|
46
|
-
unknown: {
|
|
47
|
-
category: 'Kernel',
|
|
48
|
-
color: statusToColor.blocking,
|
|
49
|
-
text: 'unknown',
|
|
50
|
-
text_zh: l10n.t('未知')
|
|
51
|
-
},
|
|
52
|
-
starting: {
|
|
53
|
-
category: 'Kernel',
|
|
54
|
-
color: statusToColor.blocking,
|
|
55
|
-
text: 'starting',
|
|
56
|
-
text_zh: l10n.t('启动中')
|
|
57
|
-
},
|
|
58
|
-
idle: {
|
|
59
|
-
category: 'Kernel',
|
|
60
|
-
color: statusToColor.canRunImmediate,
|
|
61
|
-
text: 'idle',
|
|
62
|
-
text_zh: l10n.t('空闲')
|
|
63
|
-
},
|
|
64
|
-
busy: {
|
|
65
|
-
category: 'Kernel',
|
|
66
|
-
color: statusToColor.canRun,
|
|
67
|
-
text: 'busy',
|
|
68
|
-
text_zh: l10n.t('忙碌')
|
|
69
|
-
},
|
|
70
|
-
terminating: {
|
|
71
|
-
category: 'Kernel',
|
|
72
|
-
color: statusToColor.blocking,
|
|
73
|
-
text: 'terminating',
|
|
74
|
-
text_zh: l10n.t('终止中')
|
|
75
|
-
},
|
|
76
|
-
restarting: {
|
|
77
|
-
category: 'Kernel',
|
|
78
|
-
color: statusToColor.blocking,
|
|
79
|
-
text: 'restarting',
|
|
80
|
-
text_zh: l10n.t('重启中')
|
|
81
|
-
},
|
|
82
|
-
autorestarting: {
|
|
83
|
-
category: 'Kernel',
|
|
84
|
-
color: statusToColor.blocking,
|
|
85
|
-
text: 'autorestarting',
|
|
86
|
-
text_zh: l10n.t('自动重启中')
|
|
87
|
-
},
|
|
88
|
-
dead: {
|
|
89
|
-
category: 'Kernel',
|
|
90
|
-
color: statusToColor.error,
|
|
91
|
-
text: 'dead',
|
|
92
|
-
text_zh: l10n.t('死亡')
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
var getServiceStatusInfo = function getServiceStatusInfo(serverManager, libroModel) {
|
|
96
|
-
if (!serverManager || serverManager.launching) {
|
|
97
|
-
return jupyterServiceStatus['loading'];
|
|
98
|
-
}
|
|
99
|
-
if (!libroModel || !(libroModel instanceof LibroJupyterModel) || libroModel.kernelConnecting === true || libroModel.kernelConnecting === undefined) {
|
|
100
|
-
return kernelStatus['connecting'];
|
|
101
|
-
}
|
|
102
|
-
if (!libroModel.kernelConnection) {
|
|
103
|
-
return {
|
|
104
|
-
color: statusToColor.blocking,
|
|
105
|
-
text: 'no kernel',
|
|
106
|
-
category: 'Kernel',
|
|
107
|
-
text_zh: l10n.t('无内核')
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
return kernelStatus[libroModel.kernelConnection.status];
|
|
111
|
-
};
|
|
112
13
|
export var KernelStatusSelector = function KernelStatusSelector() {
|
|
113
14
|
var libroView = useInject(ViewInstance);
|
|
114
15
|
var serverManager = useInject(ServerManager);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-selector.d.ts","sourceRoot":"","sources":["../../src/toolbar/run-selector.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"run-selector.d.ts","sourceRoot":"","sources":["../../src/toolbar/run-selector.tsx"],"names":[],"mappings":";AAqBA,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EA8G/B,CAAC"}
|
|
@@ -14,7 +14,8 @@ import { useInject, ToolbarInstance, getOrigin, CommandRegistry, ViewInstance, C
|
|
|
14
14
|
import { l10n } from '@difizen/mana-l10n';
|
|
15
15
|
import { Menu, Dropdown, Tooltip } from 'antd';
|
|
16
16
|
import { useEffect, useState } from 'react';
|
|
17
|
-
import { LibroJupyterConfiguration } from "../index.js";
|
|
17
|
+
import { LibroJupyterConfiguration, ServerManager } from "../index.js";
|
|
18
|
+
import { kernelPrepared } from "../utils/index.js";
|
|
18
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
20
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
20
21
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -22,12 +23,13 @@ export var RunSelector = function RunSelector() {
|
|
|
22
23
|
var libroView = useInject(ViewInstance);
|
|
23
24
|
var libroModel = libroView ? libroView.model : undefined;
|
|
24
25
|
var toolbar = useInject(ToolbarInstance);
|
|
26
|
+
var libroServerManager = useInject(ServerManager);
|
|
25
27
|
var data = toolbar.currentArgs;
|
|
26
28
|
var command = useInject(CommandRegistry);
|
|
27
29
|
var curCell = data === null || data === void 0 ? void 0 : data[0];
|
|
28
30
|
var configService = useInject(ConfigurationService);
|
|
29
31
|
var isRunVisible = ExecutableCellModel.is(curCell === null || curCell === void 0 ? void 0 : curCell.model) && !(curCell !== null && curCell !== void 0 && curCell.model.executing) ? true : false;
|
|
30
|
-
var
|
|
32
|
+
var isKernelPrepared = kernelPrepared(libroServerManager, libroModel);
|
|
31
33
|
var _useState = useState('kernel准备中,无法执行'),
|
|
32
34
|
_useState2 = _slicedToArray(_useState, 2),
|
|
33
35
|
kernelUnreadyBtnText = _useState2[0],
|
|
@@ -101,7 +103,7 @@ export var RunSelector = function RunSelector() {
|
|
|
101
103
|
})
|
|
102
104
|
}]
|
|
103
105
|
});
|
|
104
|
-
if (
|
|
106
|
+
if (isKernelPrepared) {
|
|
105
107
|
return /*#__PURE__*/_jsx(Dropdown, {
|
|
106
108
|
overlay: menu,
|
|
107
109
|
placement: "bottomLeft",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"side-toolbar-run-selector.d.ts","sourceRoot":"","sources":["../../src/toolbar/side-toolbar-run-selector.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"side-toolbar-run-selector.d.ts","sourceRoot":"","sources":["../../src/toolbar/side-toolbar-run-selector.tsx"],"names":[],"mappings":";AAmDA,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EA+C1C,CAAC"}
|
|
@@ -6,11 +6,13 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
7
|
import { PlayCircleOutlined } from '@ant-design/icons';
|
|
8
8
|
import { NotebookCommands, LibroSideToolbarMenu } from '@difizen/libro-core';
|
|
9
|
+
import { ServerManager } from '@difizen/libro-kernel';
|
|
9
10
|
import { ConfigurationService, useInject, ViewInstance } from '@difizen/mana-app';
|
|
10
11
|
import { l10n } from '@difizen/mana-l10n';
|
|
11
12
|
import { Popover, Tooltip } from 'antd';
|
|
12
13
|
import { useEffect, useState } from 'react';
|
|
13
14
|
import { LibroJupyterConfiguration } from "../index.js";
|
|
15
|
+
import { kernelPrepared } from "../utils/index.js";
|
|
14
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
17
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
16
18
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -53,9 +55,10 @@ var items = [{
|
|
|
53
55
|
}];
|
|
54
56
|
export var SideToolbarRunSelector = function SideToolbarRunSelector() {
|
|
55
57
|
var libroView = useInject(ViewInstance);
|
|
58
|
+
var libroServerManager = useInject(ServerManager);
|
|
56
59
|
var configService = useInject(ConfigurationService);
|
|
57
60
|
var libroModel = libroView ? libroView.model : undefined;
|
|
58
|
-
var
|
|
61
|
+
var isKernelPrepared = kernelPrepared(libroServerManager, libroModel);
|
|
59
62
|
var _useState = useState('kernel准备中,无法执行'),
|
|
60
63
|
_useState2 = _slicedToArray(_useState, 2),
|
|
61
64
|
kernelUnreadyBtnText = _useState2[0],
|
|
@@ -68,7 +71,7 @@ export var SideToolbarRunSelector = function SideToolbarRunSelector() {
|
|
|
68
71
|
//
|
|
69
72
|
});
|
|
70
73
|
});
|
|
71
|
-
if (
|
|
74
|
+
if (isKernelPrepared) {
|
|
72
75
|
return /*#__PURE__*/_jsx(Popover, {
|
|
73
76
|
placement: "leftTop",
|
|
74
77
|
content: /*#__PURE__*/_jsx(LibroSideToolbarMenu, {
|
package/es/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { CellModel } from '@difizen/libro-core';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ServerManager } from '@difizen/libro-kernel';
|
|
3
|
+
import { LibroJupyterModel } from '../libro-jupyter-model.js';
|
|
4
|
+
import type { ServerStatus } from '../libro-jupyter-protocol.js';
|
|
3
5
|
export declare const EXECUTE_INPUT = "to_execute";
|
|
4
6
|
export declare const EXECUTE_REPLY_START = "shell.execute_reply.started";
|
|
5
7
|
export declare const EXECUTE_REPLY_REPLY = "shell.execute_reply.end";
|
|
@@ -8,4 +10,6 @@ export declare const isWaitingExecute: (model: CellModel) => boolean;
|
|
|
8
10
|
export declare function formatTime(value: number): string;
|
|
9
11
|
export declare function parseExecutionInfoFromModel(model: CellModel): Record<string, string> | undefined;
|
|
10
12
|
export declare function isKernelIdle(libroModel?: LibroJupyterModel): boolean;
|
|
13
|
+
export declare const getServiceStatusInfo: (serverManager: ServerManager | undefined, libroModel: LibroJupyterModel | undefined) => ServerStatus;
|
|
14
|
+
export declare const kernelPrepared: (libroServerManager: ServerManager, libroModel: LibroJupyterModel | undefined) => boolean;
|
|
11
15
|
//# sourceMappingURL=index.d.ts.map
|
package/es/utils/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAI3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAEV,YAAY,EACb,MAAM,8BAA8B,CAAC;AAOtC,eAAO,MAAM,aAAa,eAAe,CAAC;AAC1C,eAAO,MAAM,mBAAmB,gCAAgC,CAAC;AACjE,eAAO,MAAM,mBAAmB,4BAA4B,CAAC;AAE7D,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,eAAO,MAAM,gBAAgB,UAAW,SAAS,YAIhD,CAAC;AAEF,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAgBhD;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,SAAS,GACf,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAgBpC;AAED,wBAAgB,YAAY,CAAC,UAAU,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAMpE;AAED,eAAO,MAAM,oBAAoB,kBAChB,aAAa,GAAG,SAAS,cAC5B,iBAAiB,GAAG,SAAS,KACxC,YAwBF,CAAC;AAGF,eAAO,MAAM,cAAc,uBACL,aAAa,cACrB,iBAAiB,GAAG,SAAS,YAW1C,CAAC"}
|
package/es/utils/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { l10n } from '@difizen/mana-l10n';
|
|
1
2
|
import { duration } from 'moment';
|
|
3
|
+
import { LibroJupyterModel } from "../libro-jupyter-model.js";
|
|
4
|
+
import { jupyterServiceStatus, kernelStatus, statusToColor } from "../libro-jupyter-protocol.js";
|
|
2
5
|
export var EXECUTE_INPUT = 'to_execute'; // 用户点击执行按钮的时间
|
|
3
6
|
export var EXECUTE_REPLY_START = 'shell.execute_reply.started'; // Kernel 开始执行任务时间在 metadata 中的 key
|
|
4
7
|
export var EXECUTE_REPLY_REPLY = 'shell.execute_reply.end'; // Kernel 结束执行任务时间在 metadata 中的 key
|
|
@@ -44,4 +47,27 @@ export function parseExecutionInfoFromModel(model) {
|
|
|
44
47
|
}
|
|
45
48
|
export function isKernelIdle(libroModel) {
|
|
46
49
|
return !!(libroModel && libroModel.kernelConnection && libroModel.kernelConnection.status === 'idle');
|
|
47
|
-
}
|
|
50
|
+
}
|
|
51
|
+
export var getServiceStatusInfo = function getServiceStatusInfo(serverManager, libroModel) {
|
|
52
|
+
if (!serverManager || serverManager.launching) {
|
|
53
|
+
return jupyterServiceStatus['loading'];
|
|
54
|
+
}
|
|
55
|
+
if (!libroModel || !(libroModel instanceof LibroJupyterModel) || libroModel.kernelConnecting === true || libroModel.kernelConnecting === undefined) {
|
|
56
|
+
return kernelStatus['connecting'];
|
|
57
|
+
}
|
|
58
|
+
if (!libroModel.kernelConnection) {
|
|
59
|
+
return {
|
|
60
|
+
color: statusToColor.blocking,
|
|
61
|
+
text: 'no kernel',
|
|
62
|
+
category: 'Kernel',
|
|
63
|
+
text_zh: l10n.t('无内核')
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return kernelStatus[libroModel.kernelConnection.status];
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// 判断服务未启动、kernel正在连接 -> return false
|
|
70
|
+
export var kernelPrepared = function kernelPrepared(libroServerManager, libroModel) {
|
|
71
|
+
var libroExecuteStatus = getServiceStatusInfo(libroServerManager, libroModel);
|
|
72
|
+
return !(libroExecuteStatus.category === 'Service' || libroExecuteStatus.category === 'Kernel' && libroExecuteStatus.text === 'connecting');
|
|
73
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-jupyter",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.19",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro"
|
|
@@ -31,22 +31,22 @@
|
|
|
31
31
|
"src"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@difizen/libro-cofine-editor": "^0.2.
|
|
35
|
-
"@difizen/libro-code-editor": "^0.2.
|
|
36
|
-
"@difizen/libro-code-cell": "^0.2.
|
|
37
|
-
"@difizen/libro-codemirror": "^0.2.
|
|
38
|
-
"@difizen/libro-rendermime": "^0.2.
|
|
39
|
-
"@difizen/libro-common": "^0.2.
|
|
40
|
-
"@difizen/libro-core": "^0.2.
|
|
41
|
-
"@difizen/libro-kernel": "^0.2.
|
|
42
|
-
"@difizen/libro-l10n": "^0.2.
|
|
43
|
-
"@difizen/libro-output": "^0.2.
|
|
44
|
-
"@difizen/libro-search": "^0.2.
|
|
45
|
-
"@difizen/libro-search-code-cell": "^0.2.
|
|
46
|
-
"@difizen/libro-lsp": "^0.2.
|
|
47
|
-
"@difizen/libro-markdown-cell": "^0.2.
|
|
48
|
-
"@difizen/libro-raw-cell": "^0.2.
|
|
49
|
-
"@difizen/libro-language-client": "^0.2.
|
|
34
|
+
"@difizen/libro-cofine-editor": "^0.2.19",
|
|
35
|
+
"@difizen/libro-code-editor": "^0.2.19",
|
|
36
|
+
"@difizen/libro-code-cell": "^0.2.19",
|
|
37
|
+
"@difizen/libro-codemirror": "^0.2.19",
|
|
38
|
+
"@difizen/libro-rendermime": "^0.2.19",
|
|
39
|
+
"@difizen/libro-common": "^0.2.19",
|
|
40
|
+
"@difizen/libro-core": "^0.2.19",
|
|
41
|
+
"@difizen/libro-kernel": "^0.2.19",
|
|
42
|
+
"@difizen/libro-l10n": "^0.2.19",
|
|
43
|
+
"@difizen/libro-output": "^0.2.19",
|
|
44
|
+
"@difizen/libro-search": "^0.2.19",
|
|
45
|
+
"@difizen/libro-search-code-cell": "^0.2.19",
|
|
46
|
+
"@difizen/libro-lsp": "^0.2.19",
|
|
47
|
+
"@difizen/libro-markdown-cell": "^0.2.19",
|
|
48
|
+
"@difizen/libro-raw-cell": "^0.2.19",
|
|
49
|
+
"@difizen/libro-language-client": "^0.2.19",
|
|
50
50
|
"@difizen/mana-app": "latest",
|
|
51
51
|
"@difizen/mana-l10n": "latest",
|
|
52
52
|
"@ant-design/colors": "^7.0.0",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { blue, gold, green, red } from '@ant-design/colors';
|
|
1
2
|
import type {
|
|
2
3
|
ICellMetadata,
|
|
3
4
|
ICodeCellMetadata,
|
|
@@ -7,6 +8,7 @@ import type {
|
|
|
7
8
|
import { ExecutableCellModel } from '@difizen/libro-core';
|
|
8
9
|
import type { IContentsModel } from '@difizen/libro-kernel';
|
|
9
10
|
import type { Event as ManaEvent, Emitter } from '@difizen/mana-app';
|
|
11
|
+
import { l10n } from '@difizen/mana-l10n';
|
|
10
12
|
|
|
11
13
|
export interface ExecutionMeta extends PartialJSONObject {
|
|
12
14
|
'shell.execute_reply.started': string; // Kernel 开始执行任务时间在 metadata 中的 key
|
|
@@ -59,3 +61,95 @@ export interface ServerLaunchManager {
|
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
export const libroArgsMimetype = 'application/vnd.libro.args+json';
|
|
64
|
+
|
|
65
|
+
export interface ServerStatus {
|
|
66
|
+
category: string;
|
|
67
|
+
color: string;
|
|
68
|
+
text: string;
|
|
69
|
+
text_zh: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const statusToColor = {
|
|
73
|
+
canRunImmediate: green[5],
|
|
74
|
+
canRun: blue[5],
|
|
75
|
+
blocking: gold[5],
|
|
76
|
+
error: red[4],
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const jupyterServiceStatus: Record<string, ServerStatus> = {
|
|
80
|
+
loading: {
|
|
81
|
+
category: 'JupyterService',
|
|
82
|
+
color: statusToColor.blocking,
|
|
83
|
+
text: 'loading',
|
|
84
|
+
text_zh: l10n.t('加载中'),
|
|
85
|
+
},
|
|
86
|
+
failed: {
|
|
87
|
+
category: 'JupyterService',
|
|
88
|
+
color: statusToColor.error,
|
|
89
|
+
text: 'failed',
|
|
90
|
+
text_zh: l10n.t('加载失败'),
|
|
91
|
+
},
|
|
92
|
+
loaded: {
|
|
93
|
+
category: 'JupyterService',
|
|
94
|
+
color: statusToColor.canRunImmediate,
|
|
95
|
+
text: 'loaded',
|
|
96
|
+
text_zh: l10n.t('加载完成'),
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const kernelStatus: Record<string, ServerStatus> = {
|
|
101
|
+
connecting: {
|
|
102
|
+
category: 'Kernel',
|
|
103
|
+
color: statusToColor.blocking,
|
|
104
|
+
text: 'connecting',
|
|
105
|
+
text_zh: l10n.t('正在连接'),
|
|
106
|
+
},
|
|
107
|
+
unknown: {
|
|
108
|
+
category: 'Kernel',
|
|
109
|
+
color: statusToColor.blocking,
|
|
110
|
+
text: 'unknown',
|
|
111
|
+
text_zh: l10n.t('未知'),
|
|
112
|
+
},
|
|
113
|
+
starting: {
|
|
114
|
+
category: 'Kernel',
|
|
115
|
+
color: statusToColor.blocking,
|
|
116
|
+
text: 'starting',
|
|
117
|
+
text_zh: l10n.t('启动中'),
|
|
118
|
+
},
|
|
119
|
+
idle: {
|
|
120
|
+
category: 'Kernel',
|
|
121
|
+
color: statusToColor.canRunImmediate,
|
|
122
|
+
text: 'idle',
|
|
123
|
+
text_zh: l10n.t('空闲'),
|
|
124
|
+
},
|
|
125
|
+
busy: {
|
|
126
|
+
category: 'Kernel',
|
|
127
|
+
color: statusToColor.canRun,
|
|
128
|
+
text: 'busy',
|
|
129
|
+
text_zh: l10n.t('忙碌'),
|
|
130
|
+
},
|
|
131
|
+
terminating: {
|
|
132
|
+
category: 'Kernel',
|
|
133
|
+
color: statusToColor.blocking,
|
|
134
|
+
text: 'terminating',
|
|
135
|
+
text_zh: l10n.t('终止中'),
|
|
136
|
+
},
|
|
137
|
+
restarting: {
|
|
138
|
+
category: 'Kernel',
|
|
139
|
+
color: statusToColor.blocking,
|
|
140
|
+
text: 'restarting',
|
|
141
|
+
text_zh: l10n.t('重启中'),
|
|
142
|
+
},
|
|
143
|
+
autorestarting: {
|
|
144
|
+
category: 'Kernel',
|
|
145
|
+
color: statusToColor.blocking,
|
|
146
|
+
text: 'autorestarting',
|
|
147
|
+
text_zh: l10n.t('自动重启中'),
|
|
148
|
+
},
|
|
149
|
+
dead: {
|
|
150
|
+
category: 'Kernel',
|
|
151
|
+
color: statusToColor.error,
|
|
152
|
+
text: 'dead',
|
|
153
|
+
text_zh: l10n.t('死亡'),
|
|
154
|
+
},
|
|
155
|
+
};
|
package/src/module.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { red, green, gold, blue } from '@ant-design/colors';
|
|
2
1
|
import { LoadingOutlined, StopOutlined } from '@ant-design/icons';
|
|
3
2
|
import type { LibroView } from '@difizen/libro-core';
|
|
4
3
|
import { ServerManager } from '@difizen/libro-kernel';
|
|
@@ -6,132 +5,13 @@ import { useInject, ViewInstance } from '@difizen/mana-app';
|
|
|
6
5
|
import { l10n } from '@difizen/mana-l10n';
|
|
7
6
|
import { Badge } from 'antd';
|
|
8
7
|
|
|
9
|
-
import { LibroJupyterModel } from '../libro-jupyter-model.js';
|
|
10
|
-
|
|
11
|
-
import { KernelSelector } from './kernel-selector-dropdown.js';
|
|
8
|
+
import type { LibroJupyterModel } from '../libro-jupyter-model.js';
|
|
12
9
|
|
|
13
10
|
import './index.less';
|
|
11
|
+
import { kernelStatus } from '../libro-jupyter-protocol.js';
|
|
12
|
+
import { getServiceStatusInfo } from '../utils/index.js';
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
category: string;
|
|
17
|
-
color: string;
|
|
18
|
-
text: string;
|
|
19
|
-
text_zh: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const statusToColor = {
|
|
23
|
-
canRunImmediate: green[5],
|
|
24
|
-
canRun: blue[5],
|
|
25
|
-
blocking: gold[5],
|
|
26
|
-
error: red[4],
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const jupyterServiceStatus: Record<string, ServerStatus> = {
|
|
30
|
-
loading: {
|
|
31
|
-
category: 'JupyterService',
|
|
32
|
-
color: statusToColor.blocking,
|
|
33
|
-
text: 'loading',
|
|
34
|
-
text_zh: l10n.t('加载中'),
|
|
35
|
-
},
|
|
36
|
-
failed: {
|
|
37
|
-
category: 'JupyterService',
|
|
38
|
-
color: statusToColor.error,
|
|
39
|
-
text: 'failed',
|
|
40
|
-
text_zh: l10n.t('加载失败'),
|
|
41
|
-
},
|
|
42
|
-
loaded: {
|
|
43
|
-
category: 'JupyterService',
|
|
44
|
-
color: statusToColor.canRunImmediate,
|
|
45
|
-
text: 'loaded',
|
|
46
|
-
text_zh: l10n.t('加载完成'),
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export const kernelStatus: Record<string, ServerStatus> = {
|
|
51
|
-
connecting: {
|
|
52
|
-
category: 'Kernel',
|
|
53
|
-
color: statusToColor.blocking,
|
|
54
|
-
text: 'connecting',
|
|
55
|
-
text_zh: l10n.t('正在连接'),
|
|
56
|
-
},
|
|
57
|
-
unknown: {
|
|
58
|
-
category: 'Kernel',
|
|
59
|
-
color: statusToColor.blocking,
|
|
60
|
-
text: 'unknown',
|
|
61
|
-
text_zh: l10n.t('未知'),
|
|
62
|
-
},
|
|
63
|
-
starting: {
|
|
64
|
-
category: 'Kernel',
|
|
65
|
-
color: statusToColor.blocking,
|
|
66
|
-
text: 'starting',
|
|
67
|
-
text_zh: l10n.t('启动中'),
|
|
68
|
-
},
|
|
69
|
-
idle: {
|
|
70
|
-
category: 'Kernel',
|
|
71
|
-
color: statusToColor.canRunImmediate,
|
|
72
|
-
text: 'idle',
|
|
73
|
-
text_zh: l10n.t('空闲'),
|
|
74
|
-
},
|
|
75
|
-
busy: {
|
|
76
|
-
category: 'Kernel',
|
|
77
|
-
color: statusToColor.canRun,
|
|
78
|
-
text: 'busy',
|
|
79
|
-
text_zh: l10n.t('忙碌'),
|
|
80
|
-
},
|
|
81
|
-
terminating: {
|
|
82
|
-
category: 'Kernel',
|
|
83
|
-
color: statusToColor.blocking,
|
|
84
|
-
text: 'terminating',
|
|
85
|
-
text_zh: l10n.t('终止中'),
|
|
86
|
-
},
|
|
87
|
-
restarting: {
|
|
88
|
-
category: 'Kernel',
|
|
89
|
-
color: statusToColor.blocking,
|
|
90
|
-
text: 'restarting',
|
|
91
|
-
text_zh: l10n.t('重启中'),
|
|
92
|
-
},
|
|
93
|
-
autorestarting: {
|
|
94
|
-
category: 'Kernel',
|
|
95
|
-
color: statusToColor.blocking,
|
|
96
|
-
text: 'autorestarting',
|
|
97
|
-
text_zh: l10n.t('自动重启中'),
|
|
98
|
-
},
|
|
99
|
-
dead: {
|
|
100
|
-
category: 'Kernel',
|
|
101
|
-
color: statusToColor.error,
|
|
102
|
-
text: 'dead',
|
|
103
|
-
text_zh: l10n.t('死亡'),
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const getServiceStatusInfo = (
|
|
108
|
-
serverManager: ServerManager | undefined,
|
|
109
|
-
libroModel: LibroJupyterModel | undefined,
|
|
110
|
-
): ServerStatus => {
|
|
111
|
-
if (!serverManager || serverManager.launching) {
|
|
112
|
-
return jupyterServiceStatus['loading'];
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (
|
|
116
|
-
!libroModel ||
|
|
117
|
-
!(libroModel instanceof LibroJupyterModel) ||
|
|
118
|
-
libroModel.kernelConnecting === true ||
|
|
119
|
-
libroModel.kernelConnecting === undefined
|
|
120
|
-
) {
|
|
121
|
-
return kernelStatus['connecting'];
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (!libroModel.kernelConnection) {
|
|
125
|
-
return {
|
|
126
|
-
color: statusToColor.blocking,
|
|
127
|
-
text: 'no kernel',
|
|
128
|
-
category: 'Kernel',
|
|
129
|
-
text_zh: l10n.t('无内核'),
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return kernelStatus[libroModel.kernelConnection.status];
|
|
134
|
-
};
|
|
14
|
+
import { KernelSelector } from './kernel-selector-dropdown.js';
|
|
135
15
|
|
|
136
16
|
export const KernelStatusSelector: React.FC = () => {
|
|
137
17
|
const libroView = useInject<LibroView>(ViewInstance);
|
|
@@ -15,22 +15,25 @@ import { Menu, Dropdown, Tooltip } from 'antd';
|
|
|
15
15
|
import type { MenuProps } from 'antd';
|
|
16
16
|
import { useEffect, useState } from 'react';
|
|
17
17
|
|
|
18
|
-
import { LibroJupyterConfiguration } from '../index.js';
|
|
18
|
+
import { LibroJupyterConfiguration, ServerManager } from '../index.js';
|
|
19
19
|
import type { LibroJupyterModel } from '../libro-jupyter-model.js';
|
|
20
|
+
import { kernelPrepared } from '../utils/index.js';
|
|
20
21
|
|
|
21
22
|
export const RunSelector: React.FC = () => {
|
|
22
23
|
const libroView = useInject<LibroView>(ViewInstance);
|
|
23
24
|
const libroModel = libroView ? libroView.model : undefined;
|
|
24
25
|
const toolbar = useInject<Toolbar>(ToolbarInstance);
|
|
26
|
+
const libroServerManager = useInject(ServerManager);
|
|
25
27
|
const data = toolbar.currentArgs as LibroToolbarArags;
|
|
26
28
|
const command = useInject(CommandRegistry);
|
|
27
29
|
const curCell = data?.[0];
|
|
28
30
|
const configService = useInject<ConfigurationService>(ConfigurationService);
|
|
29
31
|
const isRunVisible =
|
|
30
32
|
ExecutableCellModel.is(curCell?.model) && !curCell?.model.executing ? true : false;
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
const isKernelPrepared = kernelPrepared(
|
|
34
|
+
libroServerManager,
|
|
35
|
+
libroModel as LibroJupyterModel,
|
|
36
|
+
);
|
|
34
37
|
|
|
35
38
|
const [kernelUnreadyBtnText, setKernelUnreadyBtnText] =
|
|
36
39
|
useState<string>('kernel准备中,无法执行');
|
|
@@ -109,7 +112,7 @@ export const RunSelector: React.FC = () => {
|
|
|
109
112
|
/>
|
|
110
113
|
);
|
|
111
114
|
|
|
112
|
-
if (
|
|
115
|
+
if (isKernelPrepared) {
|
|
113
116
|
return (
|
|
114
117
|
<Dropdown overlay={menu} placement="bottomLeft">
|
|
115
118
|
<PlayCircleOutlined />
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PlayCircleOutlined } from '@ant-design/icons';
|
|
2
2
|
import type { LibroSideToolbarMenuItemType, LibroView } from '@difizen/libro-core';
|
|
3
3
|
import { NotebookCommands, LibroSideToolbarMenu } from '@difizen/libro-core';
|
|
4
|
+
import { ServerManager } from '@difizen/libro-kernel';
|
|
4
5
|
import { ConfigurationService, useInject, ViewInstance } from '@difizen/mana-app';
|
|
5
6
|
import { l10n } from '@difizen/mana-l10n';
|
|
6
7
|
import { Popover, Tooltip } from 'antd';
|
|
@@ -8,6 +9,7 @@ import { useEffect, useState } from 'react';
|
|
|
8
9
|
|
|
9
10
|
import { LibroJupyterConfiguration } from '../index.js';
|
|
10
11
|
import type { LibroJupyterModel } from '../libro-jupyter-model.js';
|
|
12
|
+
import { kernelPrepared } from '../utils/index.js';
|
|
11
13
|
|
|
12
14
|
const items: LibroSideToolbarMenuItemType[] = [
|
|
13
15
|
{
|
|
@@ -49,11 +51,13 @@ const items: LibroSideToolbarMenuItemType[] = [
|
|
|
49
51
|
|
|
50
52
|
export const SideToolbarRunSelector: React.FC = () => {
|
|
51
53
|
const libroView = useInject<LibroView>(ViewInstance);
|
|
54
|
+
const libroServerManager = useInject(ServerManager);
|
|
52
55
|
const configService = useInject<ConfigurationService>(ConfigurationService);
|
|
53
56
|
const libroModel = libroView ? libroView.model : undefined;
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
const isKernelPrepared = kernelPrepared(
|
|
58
|
+
libroServerManager,
|
|
59
|
+
libroModel as LibroJupyterModel,
|
|
60
|
+
);
|
|
57
61
|
|
|
58
62
|
const [kernelUnreadyBtnText, setKernelUnreadyBtnText] =
|
|
59
63
|
useState<string>('kernel准备中,无法执行');
|
|
@@ -70,7 +74,7 @@ export const SideToolbarRunSelector: React.FC = () => {
|
|
|
70
74
|
});
|
|
71
75
|
});
|
|
72
76
|
|
|
73
|
-
if (
|
|
77
|
+
if (isKernelPrepared) {
|
|
74
78
|
return (
|
|
75
79
|
<Popover
|
|
76
80
|
placement="leftTop"
|
package/src/utils/index.ts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import type { CellModel } from '@difizen/libro-core';
|
|
2
|
+
import type { ServerManager } from '@difizen/libro-kernel';
|
|
3
|
+
import { l10n } from '@difizen/mana-l10n';
|
|
2
4
|
import { duration } from 'moment';
|
|
3
5
|
|
|
4
|
-
import
|
|
5
|
-
import type {
|
|
6
|
+
import { LibroJupyterModel } from '../libro-jupyter-model.js';
|
|
7
|
+
import type {
|
|
8
|
+
ExecutedWithKernelCellModel,
|
|
9
|
+
ServerStatus,
|
|
10
|
+
} from '../libro-jupyter-protocol.js';
|
|
11
|
+
import {
|
|
12
|
+
jupyterServiceStatus,
|
|
13
|
+
kernelStatus,
|
|
14
|
+
statusToColor,
|
|
15
|
+
} from '../libro-jupyter-protocol.js';
|
|
6
16
|
|
|
7
17
|
export const EXECUTE_INPUT = 'to_execute'; // 用户点击执行按钮的时间
|
|
8
18
|
export const EXECUTE_REPLY_START = 'shell.execute_reply.started'; // Kernel 开始执行任务时间在 metadata 中的 key
|
|
@@ -63,3 +73,48 @@ export function isKernelIdle(libroModel?: LibroJupyterModel): boolean {
|
|
|
63
73
|
libroModel.kernelConnection.status === 'idle'
|
|
64
74
|
);
|
|
65
75
|
}
|
|
76
|
+
|
|
77
|
+
export const getServiceStatusInfo = (
|
|
78
|
+
serverManager: ServerManager | undefined,
|
|
79
|
+
libroModel: LibroJupyterModel | undefined,
|
|
80
|
+
): ServerStatus => {
|
|
81
|
+
if (!serverManager || serverManager.launching) {
|
|
82
|
+
return jupyterServiceStatus['loading'];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (
|
|
86
|
+
!libroModel ||
|
|
87
|
+
!(libroModel instanceof LibroJupyterModel) ||
|
|
88
|
+
libroModel.kernelConnecting === true ||
|
|
89
|
+
libroModel.kernelConnecting === undefined
|
|
90
|
+
) {
|
|
91
|
+
return kernelStatus['connecting'];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (!libroModel.kernelConnection) {
|
|
95
|
+
return {
|
|
96
|
+
color: statusToColor.blocking,
|
|
97
|
+
text: 'no kernel',
|
|
98
|
+
category: 'Kernel',
|
|
99
|
+
text_zh: l10n.t('无内核'),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return kernelStatus[libroModel.kernelConnection.status];
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// 判断服务未启动、kernel正在连接 -> return false
|
|
107
|
+
export const kernelPrepared = (
|
|
108
|
+
libroServerManager: ServerManager,
|
|
109
|
+
libroModel: LibroJupyterModel | undefined,
|
|
110
|
+
) => {
|
|
111
|
+
const libroExecuteStatus: ServerStatus = getServiceStatusInfo(
|
|
112
|
+
libroServerManager,
|
|
113
|
+
libroModel,
|
|
114
|
+
);
|
|
115
|
+
return !(
|
|
116
|
+
libroExecuteStatus.category === 'Service' ||
|
|
117
|
+
(libroExecuteStatus.category === 'Kernel' &&
|
|
118
|
+
libroExecuteStatus.text === 'connecting')
|
|
119
|
+
);
|
|
120
|
+
};
|