@difizen/libro-jupyter 0.2.16 → 0.2.17
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/config/config-contribution.d.ts.map +1 -1
- package/es/config/config-contribution.js +1 -1
- package/es/config/config.d.ts +6 -0
- package/es/config/config.d.ts.map +1 -1
- package/es/config/config.js +34 -1
- package/es/toolbar/kernel-selector-dropdown.d.ts.map +1 -1
- package/es/toolbar/kernel-selector-dropdown.js +25 -5
- package/es/toolbar/kernel-status-and-selector.js +1 -1
- package/es/toolbar/run-selector.d.ts.map +1 -1
- package/es/toolbar/run-selector.js +22 -3
- package/es/toolbar/side-toolbar-run-selector.d.ts.map +1 -1
- package/es/toolbar/side-toolbar-run-selector.js +23 -2
- package/package.json +17 -17
- package/src/config/config-contribution.ts +3 -0
- package/src/config/config.ts +36 -0
- package/src/toolbar/kernel-selector-dropdown.tsx +30 -4
- package/src/toolbar/kernel-status-and-selector.tsx +1 -1
- package/src/toolbar/run-selector.tsx +20 -1
- package/src/toolbar/side-toolbar-run-selector.tsx +20 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-contribution.d.ts","sourceRoot":"","sources":["../../src/config/config-contribution.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAK5D,qBACa,+BAAgC,YAAW,yBAAyB;IAC/E,sBAAsB;
|
|
1
|
+
{"version":3,"file":"config-contribution.d.ts","sourceRoot":"","sources":["../../src/config/config-contribution.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAK5D,qBACa,+BAAgC,YAAW,yBAAyB;IAC/E,sBAAsB;CAWvB;AACD,qBACa,qBAAsB,YAAW,uBAAuB;IACrC,oBAAoB,EAAE,oBAAoB,CAAC;IACzE,WAAW;CAIZ"}
|
|
@@ -22,7 +22,7 @@ export var LibroJupyterSettingContribution = (_dec = singleton({
|
|
|
22
22
|
_createClass(LibroJupyterSettingContribution, [{
|
|
23
23
|
key: "registerConfigurations",
|
|
24
24
|
value: function registerConfigurations() {
|
|
25
|
-
return [LibroJupyterConfiguration.AutoSave, LibroJupyterConfiguration.OpenSlot, LibroJupyterConfiguration.AllowDownload, LibroJupyterConfiguration.AllowUpload];
|
|
25
|
+
return [LibroJupyterConfiguration.AutoSave, LibroJupyterConfiguration.OpenSlot, LibroJupyterConfiguration.AllowDownload, LibroJupyterConfiguration.AllowUpload, LibroJupyterConfiguration.AllowPreferredSession, LibroJupyterConfiguration.KernelUnreadyBtnText, LibroJupyterConfiguration.KernelUnreadyText];
|
|
26
26
|
}
|
|
27
27
|
}]);
|
|
28
28
|
return LibroJupyterSettingContribution;
|
package/es/config/config.d.ts
CHANGED
|
@@ -3,10 +3,16 @@ export declare const LibroConfigAutoSave: ConfigurationNode<boolean>;
|
|
|
3
3
|
export declare const LibroConfigOpenSlot: ConfigurationNode<string>;
|
|
4
4
|
export declare const LibroConfigAllowDownload: ConfigurationNode<boolean>;
|
|
5
5
|
export declare const LibroConfigAllowUpload: ConfigurationNode<boolean>;
|
|
6
|
+
export declare const LibroConfigAllowPreferredSession: ConfigurationNode<boolean>;
|
|
7
|
+
export declare const LibroConfigKernelUnreadyText: ConfigurationNode<string>;
|
|
8
|
+
export declare const LibroConfigKernelUnreadyBtnText: ConfigurationNode<string>;
|
|
6
9
|
export declare const LibroJupyterConfiguration: {
|
|
7
10
|
AutoSave: ConfigurationNode<boolean>;
|
|
8
11
|
OpenSlot: ConfigurationNode<string>;
|
|
9
12
|
AllowUpload: ConfigurationNode<boolean>;
|
|
13
|
+
AllowPreferredSession: ConfigurationNode<boolean>;
|
|
10
14
|
AllowDownload: ConfigurationNode<boolean>;
|
|
15
|
+
KernelUnreadyText: ConfigurationNode<string>;
|
|
16
|
+
KernelUnreadyBtnText: ConfigurationNode<string>;
|
|
11
17
|
};
|
|
12
18
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG3D,eAAO,MAAM,mBAAmB,EAAE,iBAAiB,CAAC,OAAO,CAS1D,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,iBAAiB,CAAC,MAAM,CASzD,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,iBAAiB,CAAC,OAAO,CAS/D,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,iBAAiB,CAAC,OAAO,CAS7D,CAAC;AAEF,eAAO,MAAM,yBAAyB
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG3D,eAAO,MAAM,mBAAmB,EAAE,iBAAiB,CAAC,OAAO,CAS1D,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,iBAAiB,CAAC,MAAM,CASzD,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,iBAAiB,CAAC,OAAO,CAS/D,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,iBAAiB,CAAC,OAAO,CAS7D,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE,iBAAiB,CAAC,OAAO,CASvE,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,iBAAiB,CAAC,MAAM,CASlE,CAAC;AAEF,eAAO,MAAM,+BAA+B,EAAE,iBAAiB,CAAC,MAAM,CASrE,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;CAQrC,CAAC"}
|
package/es/config/config.js
CHANGED
|
@@ -39,9 +39,42 @@ export var LibroConfigAllowUpload = {
|
|
|
39
39
|
type: 'boolean'
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
+
export var LibroConfigAllowPreferredSession = {
|
|
43
|
+
id: 'libro.jupyter.allow.prefer.session',
|
|
44
|
+
description: 'kernel切换是否显示Use Kernel from Preferred Session',
|
|
45
|
+
title: '允许 Preferred session切换显示',
|
|
46
|
+
type: 'checkbox',
|
|
47
|
+
defaultValue: true,
|
|
48
|
+
schema: {
|
|
49
|
+
type: 'boolean'
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export var LibroConfigKernelUnreadyText = {
|
|
53
|
+
id: 'libro.jupyter.kernel.unready.text',
|
|
54
|
+
description: 'kernel unready text',
|
|
55
|
+
title: 'kernel 处于 unready 时左上角提示文案',
|
|
56
|
+
type: 'string',
|
|
57
|
+
defaultValue: 'Kernel 准备中...',
|
|
58
|
+
schema: {
|
|
59
|
+
type: 'string'
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
export var LibroConfigKernelUnreadyBtnText = {
|
|
63
|
+
id: 'libro.jupyter.kernel.unready.btn.text',
|
|
64
|
+
description: 'kernel unready btn text',
|
|
65
|
+
title: 'kernel 处于 unready 时执行按钮提示文案',
|
|
66
|
+
type: 'string',
|
|
67
|
+
defaultValue: 'kernel准备中,无法执行',
|
|
68
|
+
schema: {
|
|
69
|
+
type: 'string'
|
|
70
|
+
}
|
|
71
|
+
};
|
|
42
72
|
export var LibroJupyterConfiguration = {
|
|
43
73
|
AutoSave: LibroConfigAutoSave,
|
|
44
74
|
OpenSlot: LibroConfigOpenSlot,
|
|
45
75
|
AllowUpload: LibroConfigAllowUpload,
|
|
46
|
-
|
|
76
|
+
AllowPreferredSession: LibroConfigAllowPreferredSession,
|
|
77
|
+
AllowDownload: LibroConfigAllowDownload,
|
|
78
|
+
KernelUnreadyText: LibroConfigKernelUnreadyText,
|
|
79
|
+
KernelUnreadyBtnText: LibroConfigKernelUnreadyBtnText
|
|
47
80
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernel-selector-dropdown.d.ts","sourceRoot":"","sources":["../../src/toolbar/kernel-selector-dropdown.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"kernel-selector-dropdown.d.ts","sourceRoot":"","sources":["../../src/toolbar/kernel-selector-dropdown.tsx"],"names":[],"mappings":";AASA,OAAO,cAAc,CAAC;AAEtB,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACtB;AA8FD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EA0HlC,CAAC"}
|
|
@@ -7,9 +7,10 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
7
7
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
8
|
import { CaretDownOutlined } from '@ant-design/icons';
|
|
9
9
|
import { LibroKernelConnectionManager, KernelSpecManager } from '@difizen/libro-kernel';
|
|
10
|
-
import { useInject, ViewInstance } from '@difizen/mana-app';
|
|
10
|
+
import { ConfigurationService, useInject, ViewInstance } from '@difizen/mana-app';
|
|
11
11
|
import { Dropdown, Space } from 'antd';
|
|
12
|
-
import { useCallback } from 'react';
|
|
12
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
13
|
+
import { LibroJupyterConfiguration } from "../config/index.js";
|
|
13
14
|
import { LibroJupyterModel } from "../libro-jupyter-model.js";
|
|
14
15
|
import "./index.less";
|
|
15
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -47,8 +48,8 @@ function getKernelList(kernelConnectionManager, kernelSpecManager) {
|
|
|
47
48
|
}
|
|
48
49
|
return [preferredSessionKernelList, otherKernelList];
|
|
49
50
|
}
|
|
50
|
-
function getKernelListItems(preferredSessionKernelList, otherKernelList) {
|
|
51
|
-
|
|
51
|
+
function getKernelListItems(preferredSessionKernelList, otherKernelList, allowPreferredSession) {
|
|
52
|
+
var array = [{
|
|
52
53
|
key: 'StartPreferredKernel',
|
|
53
54
|
type: 'group',
|
|
54
55
|
label: 'Start Preferred Kernel',
|
|
@@ -86,10 +87,29 @@ function getKernelListItems(preferredSessionKernelList, otherKernelList) {
|
|
|
86
87
|
key: 'ShutDownKernel',
|
|
87
88
|
label: 'Shut Down the Kernel'
|
|
88
89
|
}];
|
|
90
|
+
if (!allowPreferredSession) {
|
|
91
|
+
array = array.filter(function (item) {
|
|
92
|
+
return item.key !== 'UseKernelFromPreferredSession';
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return array;
|
|
89
96
|
}
|
|
90
97
|
export var KernelSelector = function KernelSelector() {
|
|
91
98
|
var _kernelConnection, _kernelConnection2;
|
|
92
99
|
var libroView = useInject(ViewInstance);
|
|
100
|
+
var configService = useInject(ConfigurationService);
|
|
101
|
+
var _useState = useState(true),
|
|
102
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
103
|
+
allowPreferredSession = _useState2[0],
|
|
104
|
+
setAllowPreferredSession = _useState2[1];
|
|
105
|
+
useEffect(function () {
|
|
106
|
+
configService.get(LibroJupyterConfiguration['AllowPreferredSession']).then(function (value) {
|
|
107
|
+
setAllowPreferredSession(value);
|
|
108
|
+
return;
|
|
109
|
+
}).catch(function () {
|
|
110
|
+
//
|
|
111
|
+
});
|
|
112
|
+
});
|
|
93
113
|
var libroModel = libroView ? libroView.model : undefined;
|
|
94
114
|
var kernelConnectionManager = useInject(LibroKernelConnectionManager);
|
|
95
115
|
var kernelSpecManager = useInject(KernelSpecManager);
|
|
@@ -156,7 +176,7 @@ export var KernelSelector = function KernelSelector() {
|
|
|
156
176
|
return /*#__PURE__*/_jsx(Dropdown, {
|
|
157
177
|
overlayClassName: "libro-kernel-dropdown",
|
|
158
178
|
menu: {
|
|
159
|
-
items: getKernelListItems(preferredSessionKernelList, otherKernelList),
|
|
179
|
+
items: getKernelListItems(preferredSessionKernelList, otherKernelList, allowPreferredSession),
|
|
160
180
|
onClick: function onClick(_ref) {
|
|
161
181
|
var key = _ref.key;
|
|
162
182
|
return handleChange(key);
|
|
@@ -120,7 +120,7 @@ export var KernelStatusSelector = function KernelStatusSelector() {
|
|
|
120
120
|
category = _getServiceStatusInfo.category;
|
|
121
121
|
if (serverManager.loaded) {
|
|
122
122
|
var showBadge = libroModel.kernelConnection && !libroModel.kernelConnection.isDisposed || text === 'connecting';
|
|
123
|
-
var isKernelBusy = text === '
|
|
123
|
+
var isKernelBusy = text === 'busy';
|
|
124
124
|
return /*#__PURE__*/_jsx("div", {
|
|
125
125
|
className: "libro-kernel-and-container-status",
|
|
126
126
|
children: /*#__PURE__*/_jsxs("div", {
|
|
@@ -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":";AAoBA,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EA4G/B,CAAC"}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
2
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
3
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
4
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
8
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
11
|
import { PlayCircleOutlined } from '@ant-design/icons';
|
|
8
12
|
import { NotebookCommands, ExecutableCellModel } from '@difizen/libro-core';
|
|
9
|
-
import { useInject, ToolbarInstance, getOrigin, CommandRegistry, ViewInstance } from '@difizen/mana-app';
|
|
13
|
+
import { useInject, ToolbarInstance, getOrigin, CommandRegistry, ViewInstance, ConfigurationService } from '@difizen/mana-app';
|
|
10
14
|
import { l10n } from '@difizen/mana-l10n';
|
|
11
15
|
import { Menu, Dropdown, Tooltip } from 'antd';
|
|
16
|
+
import { useEffect, useState } from 'react';
|
|
17
|
+
import { LibroJupyterConfiguration } from "../index.js";
|
|
12
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
19
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
20
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -19,8 +25,21 @@ export var RunSelector = function RunSelector() {
|
|
|
19
25
|
var data = toolbar.currentArgs;
|
|
20
26
|
var command = useInject(CommandRegistry);
|
|
21
27
|
var curCell = data === null || data === void 0 ? void 0 : data[0];
|
|
28
|
+
var configService = useInject(ConfigurationService);
|
|
22
29
|
var isRunVisible = ExecutableCellModel.is(curCell === null || curCell === void 0 ? void 0 : curCell.model) && !(curCell !== null && curCell !== void 0 && curCell.model.executing) ? true : false;
|
|
23
30
|
var isKernelIdle = libroModel ? libroModel.isKernelIdle : false;
|
|
31
|
+
var _useState = useState('kernel准备中,无法执行'),
|
|
32
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
33
|
+
kernelUnreadyBtnText = _useState2[0],
|
|
34
|
+
setKernelUnreadyBtnText = _useState2[1];
|
|
35
|
+
useEffect(function () {
|
|
36
|
+
configService.get(LibroJupyterConfiguration['KernelUnreadyBtnText']).then(function (value) {
|
|
37
|
+
setKernelUnreadyBtnText(value);
|
|
38
|
+
return;
|
|
39
|
+
}).catch(function () {
|
|
40
|
+
//
|
|
41
|
+
});
|
|
42
|
+
});
|
|
24
43
|
var handleChange = function handleChange(e) {
|
|
25
44
|
var args = getOrigin(data) || [];
|
|
26
45
|
if (e.key === 'runCell') {
|
|
@@ -92,7 +111,7 @@ export var RunSelector = function RunSelector() {
|
|
|
92
111
|
return /*#__PURE__*/_jsx(Tooltip, {
|
|
93
112
|
overlayClassName: "libro-tooltip-placement-bottom",
|
|
94
113
|
placement: "bottom",
|
|
95
|
-
title: l10n.t(
|
|
114
|
+
title: l10n.t(kernelUnreadyBtnText),
|
|
96
115
|
children: /*#__PURE__*/_jsx(PlayCircleOutlined, {})
|
|
97
116
|
});
|
|
98
117
|
};
|
|
@@ -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":";AAiDA,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EA6C1C,CAAC"}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
1
7
|
import { PlayCircleOutlined } from '@ant-design/icons';
|
|
2
8
|
import { NotebookCommands, LibroSideToolbarMenu } from '@difizen/libro-core';
|
|
3
|
-
import { useInject, ViewInstance } from '@difizen/mana-app';
|
|
9
|
+
import { ConfigurationService, useInject, ViewInstance } from '@difizen/mana-app';
|
|
4
10
|
import { l10n } from '@difizen/mana-l10n';
|
|
5
11
|
import { Popover, Tooltip } from 'antd';
|
|
12
|
+
import { useEffect, useState } from 'react';
|
|
13
|
+
import { LibroJupyterConfiguration } from "../index.js";
|
|
6
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
15
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
8
16
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -45,8 +53,21 @@ var items = [{
|
|
|
45
53
|
}];
|
|
46
54
|
export var SideToolbarRunSelector = function SideToolbarRunSelector() {
|
|
47
55
|
var libroView = useInject(ViewInstance);
|
|
56
|
+
var configService = useInject(ConfigurationService);
|
|
48
57
|
var libroModel = libroView ? libroView.model : undefined;
|
|
49
58
|
var isKernelIdle = libroModel ? libroModel.isKernelIdle : false;
|
|
59
|
+
var _useState = useState('kernel准备中,无法执行'),
|
|
60
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
61
|
+
kernelUnreadyBtnText = _useState2[0],
|
|
62
|
+
setKernelUnreadyBtnText = _useState2[1];
|
|
63
|
+
useEffect(function () {
|
|
64
|
+
configService.get(LibroJupyterConfiguration['KernelUnreadyBtnText']).then(function (value) {
|
|
65
|
+
setKernelUnreadyBtnText(value);
|
|
66
|
+
return;
|
|
67
|
+
}).catch(function () {
|
|
68
|
+
//
|
|
69
|
+
});
|
|
70
|
+
});
|
|
50
71
|
if (isKernelIdle) {
|
|
51
72
|
return /*#__PURE__*/_jsx(Popover, {
|
|
52
73
|
placement: "leftTop",
|
|
@@ -61,7 +82,7 @@ export var SideToolbarRunSelector = function SideToolbarRunSelector() {
|
|
|
61
82
|
return /*#__PURE__*/_jsx(Tooltip, {
|
|
62
83
|
overlayClassName: "libro-tooltip-placement-right",
|
|
63
84
|
placement: "right",
|
|
64
|
-
title: l10n.t(
|
|
85
|
+
title: l10n.t(kernelUnreadyBtnText),
|
|
65
86
|
children: /*#__PURE__*/_jsx(PlayCircleOutlined, {})
|
|
66
87
|
});
|
|
67
88
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-jupyter",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
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.17",
|
|
35
|
+
"@difizen/libro-code-editor": "^0.2.17",
|
|
36
|
+
"@difizen/libro-code-cell": "^0.2.17",
|
|
37
|
+
"@difizen/libro-codemirror": "^0.2.17",
|
|
38
|
+
"@difizen/libro-rendermime": "^0.2.17",
|
|
39
|
+
"@difizen/libro-common": "^0.2.17",
|
|
40
|
+
"@difizen/libro-core": "^0.2.17",
|
|
41
|
+
"@difizen/libro-kernel": "^0.2.17",
|
|
42
|
+
"@difizen/libro-l10n": "^0.2.17",
|
|
43
|
+
"@difizen/libro-output": "^0.2.17",
|
|
44
|
+
"@difizen/libro-search": "^0.2.17",
|
|
45
|
+
"@difizen/libro-search-code-cell": "^0.2.17",
|
|
46
|
+
"@difizen/libro-lsp": "^0.2.17",
|
|
47
|
+
"@difizen/libro-markdown-cell": "^0.2.17",
|
|
48
|
+
"@difizen/libro-raw-cell": "^0.2.17",
|
|
49
|
+
"@difizen/libro-language-client": "^0.2.17",
|
|
50
50
|
"@difizen/mana-app": "latest",
|
|
51
51
|
"@difizen/mana-l10n": "latest",
|
|
52
52
|
"@ant-design/colors": "^7.0.0",
|
|
@@ -13,6 +13,9 @@ export class LibroJupyterSettingContribution implements ConfigurationContributio
|
|
|
13
13
|
LibroJupyterConfiguration.OpenSlot,
|
|
14
14
|
LibroJupyterConfiguration.AllowDownload,
|
|
15
15
|
LibroJupyterConfiguration.AllowUpload,
|
|
16
|
+
LibroJupyterConfiguration.AllowPreferredSession,
|
|
17
|
+
LibroJupyterConfiguration.KernelUnreadyBtnText,
|
|
18
|
+
LibroJupyterConfiguration.KernelUnreadyText,
|
|
16
19
|
];
|
|
17
20
|
}
|
|
18
21
|
}
|
package/src/config/config.ts
CHANGED
|
@@ -45,9 +45,45 @@ export const LibroConfigAllowUpload: ConfigurationNode<boolean> = {
|
|
|
45
45
|
},
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
+
export const LibroConfigAllowPreferredSession: ConfigurationNode<boolean> = {
|
|
49
|
+
id: 'libro.jupyter.allow.prefer.session',
|
|
50
|
+
description: 'kernel切换是否显示Use Kernel from Preferred Session',
|
|
51
|
+
title: '允许 Preferred session切换显示',
|
|
52
|
+
type: 'checkbox',
|
|
53
|
+
defaultValue: true,
|
|
54
|
+
schema: {
|
|
55
|
+
type: 'boolean',
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const LibroConfigKernelUnreadyText: ConfigurationNode<string> = {
|
|
60
|
+
id: 'libro.jupyter.kernel.unready.text',
|
|
61
|
+
description: 'kernel unready text',
|
|
62
|
+
title: 'kernel 处于 unready 时左上角提示文案',
|
|
63
|
+
type: 'string',
|
|
64
|
+
defaultValue: 'Kernel 准备中...',
|
|
65
|
+
schema: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const LibroConfigKernelUnreadyBtnText: ConfigurationNode<string> = {
|
|
71
|
+
id: 'libro.jupyter.kernel.unready.btn.text',
|
|
72
|
+
description: 'kernel unready btn text',
|
|
73
|
+
title: 'kernel 处于 unready 时执行按钮提示文案',
|
|
74
|
+
type: 'string',
|
|
75
|
+
defaultValue: 'kernel准备中,无法执行',
|
|
76
|
+
schema: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
|
|
48
81
|
export const LibroJupyterConfiguration = {
|
|
49
82
|
AutoSave: LibroConfigAutoSave,
|
|
50
83
|
OpenSlot: LibroConfigOpenSlot,
|
|
51
84
|
AllowUpload: LibroConfigAllowUpload,
|
|
85
|
+
AllowPreferredSession: LibroConfigAllowPreferredSession,
|
|
52
86
|
AllowDownload: LibroConfigAllowDownload,
|
|
87
|
+
KernelUnreadyText: LibroConfigKernelUnreadyText,
|
|
88
|
+
KernelUnreadyBtnText: LibroConfigKernelUnreadyBtnText,
|
|
53
89
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { CaretDownOutlined } from '@ant-design/icons';
|
|
2
2
|
import type { LibroView } from '@difizen/libro-core';
|
|
3
3
|
import { LibroKernelConnectionManager, KernelSpecManager } from '@difizen/libro-kernel';
|
|
4
|
-
import { useInject, ViewInstance } from '@difizen/mana-app';
|
|
4
|
+
import { ConfigurationService, useInject, ViewInstance } from '@difizen/mana-app';
|
|
5
5
|
import { Dropdown, Space } from 'antd';
|
|
6
|
-
import { useCallback } from 'react';
|
|
6
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
7
7
|
|
|
8
|
+
import { LibroJupyterConfiguration } from '../config/index.js';
|
|
8
9
|
import { LibroJupyterModel } from '../libro-jupyter-model.js';
|
|
9
10
|
import './index.less';
|
|
10
11
|
|
|
@@ -54,8 +55,9 @@ function getKernelList(
|
|
|
54
55
|
function getKernelListItems(
|
|
55
56
|
preferredSessionKernelList: PreferredSessionKernelListElem[],
|
|
56
57
|
otherKernelList: OtherKernelListElem[],
|
|
58
|
+
allowPreferredSession: boolean,
|
|
57
59
|
) {
|
|
58
|
-
|
|
60
|
+
let array = [
|
|
59
61
|
{
|
|
60
62
|
key: 'StartPreferredKernel',
|
|
61
63
|
type: 'group',
|
|
@@ -102,10 +104,30 @@ function getKernelListItems(
|
|
|
102
104
|
label: 'Shut Down the Kernel',
|
|
103
105
|
},
|
|
104
106
|
];
|
|
107
|
+
if (!allowPreferredSession) {
|
|
108
|
+
array = array.filter((item) => {
|
|
109
|
+
return item.key !== 'UseKernelFromPreferredSession';
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return array;
|
|
105
113
|
}
|
|
106
114
|
|
|
107
115
|
export const KernelSelector: React.FC = () => {
|
|
108
116
|
const libroView = useInject<LibroView>(ViewInstance);
|
|
117
|
+
const configService = useInject<ConfigurationService>(ConfigurationService);
|
|
118
|
+
const [allowPreferredSession, setAllowPreferredSession] = useState<boolean>(true);
|
|
119
|
+
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
configService
|
|
122
|
+
.get(LibroJupyterConfiguration['AllowPreferredSession'])
|
|
123
|
+
.then((value) => {
|
|
124
|
+
setAllowPreferredSession(value);
|
|
125
|
+
return;
|
|
126
|
+
})
|
|
127
|
+
.catch(() => {
|
|
128
|
+
//
|
|
129
|
+
});
|
|
130
|
+
});
|
|
109
131
|
|
|
110
132
|
const libroModel = libroView ? libroView.model : undefined;
|
|
111
133
|
|
|
@@ -195,7 +217,11 @@ export const KernelSelector: React.FC = () => {
|
|
|
195
217
|
<Dropdown
|
|
196
218
|
overlayClassName="libro-kernel-dropdown"
|
|
197
219
|
menu={{
|
|
198
|
-
items: getKernelListItems(
|
|
220
|
+
items: getKernelListItems(
|
|
221
|
+
preferredSessionKernelList,
|
|
222
|
+
otherKernelList,
|
|
223
|
+
allowPreferredSession,
|
|
224
|
+
),
|
|
199
225
|
onClick: ({ key }) => handleChange(key),
|
|
200
226
|
}}
|
|
201
227
|
trigger={['click']}
|
|
@@ -146,7 +146,7 @@ export const KernelStatusSelector: React.FC = () => {
|
|
|
146
146
|
const showBadge =
|
|
147
147
|
(libroModel.kernelConnection && !libroModel.kernelConnection.isDisposed) ||
|
|
148
148
|
text === 'connecting';
|
|
149
|
-
const isKernelBusy = text === '
|
|
149
|
+
const isKernelBusy = text === 'busy';
|
|
150
150
|
|
|
151
151
|
return (
|
|
152
152
|
<div className="libro-kernel-and-container-status">
|
|
@@ -7,12 +7,15 @@ import {
|
|
|
7
7
|
getOrigin,
|
|
8
8
|
CommandRegistry,
|
|
9
9
|
ViewInstance,
|
|
10
|
+
ConfigurationService,
|
|
10
11
|
} from '@difizen/mana-app';
|
|
11
12
|
import type { Toolbar } from '@difizen/mana-app';
|
|
12
13
|
import { l10n } from '@difizen/mana-l10n';
|
|
13
14
|
import { Menu, Dropdown, Tooltip } from 'antd';
|
|
14
15
|
import type { MenuProps } from 'antd';
|
|
16
|
+
import { useEffect, useState } from 'react';
|
|
15
17
|
|
|
18
|
+
import { LibroJupyterConfiguration } from '../index.js';
|
|
16
19
|
import type { LibroJupyterModel } from '../libro-jupyter-model.js';
|
|
17
20
|
|
|
18
21
|
export const RunSelector: React.FC = () => {
|
|
@@ -22,12 +25,28 @@ export const RunSelector: React.FC = () => {
|
|
|
22
25
|
const data = toolbar.currentArgs as LibroToolbarArags;
|
|
23
26
|
const command = useInject(CommandRegistry);
|
|
24
27
|
const curCell = data?.[0];
|
|
28
|
+
const configService = useInject<ConfigurationService>(ConfigurationService);
|
|
25
29
|
const isRunVisible =
|
|
26
30
|
ExecutableCellModel.is(curCell?.model) && !curCell?.model.executing ? true : false;
|
|
27
31
|
const isKernelIdle = libroModel
|
|
28
32
|
? (libroModel as LibroJupyterModel).isKernelIdle
|
|
29
33
|
: false;
|
|
30
34
|
|
|
35
|
+
const [kernelUnreadyBtnText, setKernelUnreadyBtnText] =
|
|
36
|
+
useState<string>('kernel准备中,无法执行');
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
configService
|
|
40
|
+
.get(LibroJupyterConfiguration['KernelUnreadyBtnText'])
|
|
41
|
+
.then((value) => {
|
|
42
|
+
setKernelUnreadyBtnText(value);
|
|
43
|
+
return;
|
|
44
|
+
})
|
|
45
|
+
.catch(() => {
|
|
46
|
+
//
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
31
50
|
const handleChange: MenuProps['onClick'] = (e) => {
|
|
32
51
|
const args = getOrigin(data) || [];
|
|
33
52
|
if (e.key === 'runCell') {
|
|
@@ -102,7 +121,7 @@ export const RunSelector: React.FC = () => {
|
|
|
102
121
|
<Tooltip
|
|
103
122
|
overlayClassName="libro-tooltip-placement-bottom"
|
|
104
123
|
placement="bottom"
|
|
105
|
-
title={l10n.t(
|
|
124
|
+
title={l10n.t(kernelUnreadyBtnText)}
|
|
106
125
|
>
|
|
107
126
|
<PlayCircleOutlined />
|
|
108
127
|
</Tooltip>
|
|
@@ -1,10 +1,12 @@
|
|
|
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 { useInject, ViewInstance } from '@difizen/mana-app';
|
|
4
|
+
import { ConfigurationService, useInject, ViewInstance } from '@difizen/mana-app';
|
|
5
5
|
import { l10n } from '@difizen/mana-l10n';
|
|
6
6
|
import { Popover, Tooltip } from 'antd';
|
|
7
|
+
import { useEffect, useState } from 'react';
|
|
7
8
|
|
|
9
|
+
import { LibroJupyterConfiguration } from '../index.js';
|
|
8
10
|
import type { LibroJupyterModel } from '../libro-jupyter-model.js';
|
|
9
11
|
|
|
10
12
|
const items: LibroSideToolbarMenuItemType[] = [
|
|
@@ -47,11 +49,27 @@ const items: LibroSideToolbarMenuItemType[] = [
|
|
|
47
49
|
|
|
48
50
|
export const SideToolbarRunSelector: React.FC = () => {
|
|
49
51
|
const libroView = useInject<LibroView>(ViewInstance);
|
|
52
|
+
const configService = useInject<ConfigurationService>(ConfigurationService);
|
|
50
53
|
const libroModel = libroView ? libroView.model : undefined;
|
|
51
54
|
const isKernelIdle = libroModel
|
|
52
55
|
? (libroModel as LibroJupyterModel).isKernelIdle
|
|
53
56
|
: false;
|
|
54
57
|
|
|
58
|
+
const [kernelUnreadyBtnText, setKernelUnreadyBtnText] =
|
|
59
|
+
useState<string>('kernel准备中,无法执行');
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
configService
|
|
63
|
+
.get(LibroJupyterConfiguration['KernelUnreadyBtnText'])
|
|
64
|
+
.then((value) => {
|
|
65
|
+
setKernelUnreadyBtnText(value);
|
|
66
|
+
return;
|
|
67
|
+
})
|
|
68
|
+
.catch(() => {
|
|
69
|
+
//
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
55
73
|
if (isKernelIdle) {
|
|
56
74
|
return (
|
|
57
75
|
<Popover
|
|
@@ -69,7 +87,7 @@ export const SideToolbarRunSelector: React.FC = () => {
|
|
|
69
87
|
<Tooltip
|
|
70
88
|
overlayClassName="libro-tooltip-placement-right"
|
|
71
89
|
placement="right"
|
|
72
|
-
title={l10n.t(
|
|
90
|
+
title={l10n.t(kernelUnreadyBtnText)}
|
|
73
91
|
>
|
|
74
92
|
<PlayCircleOutlined />
|
|
75
93
|
</Tooltip>
|