@difizen/libro-jupyter 0.1.21 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"file-create-modal.d.ts","sourceRoot":"","sources":["../../src/file/file-create-modal.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAKnE,OAAO,cAAc,CAAC;AAWtB,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,KAAK,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEhE,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,aAAa,CAAC,CAuJ5E,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,SAAS,CAAC,aAAa,CAGpD,CAAC"}
1
+ {"version":3,"file":"file-create-modal.d.ts","sourceRoot":"","sources":["../../src/file/file-create-modal.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAKnE,OAAO,cAAc,CAAC;AAWtB,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,KAAK,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEhE,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,aAAa,CAAC,CA0J5E,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,SAAS,CAAC,aAAa,CAGpD,CAAC"}
@@ -21,7 +21,7 @@ export var FileCreateModalComponent = function FileCreateModalComponent(_ref) {
21
21
  data = _ref.data;
22
22
  var fileService = useInject(JupyterFileService);
23
23
  var viewManager = useInject(ViewManager);
24
- var _useState = useState(data.fileType),
24
+ var _useState = useState(data === null || data === void 0 ? void 0 : data.fileType),
25
25
  _useState2 = _slicedToArray(_useState, 2),
26
26
  fileType = _useState2[0],
27
27
  setFileType = _useState2[1];
@@ -44,7 +44,7 @@ export var FileCreateModalComponent = function FileCreateModalComponent(_ref) {
44
44
  close();
45
45
  _context.prev = 3;
46
46
  _context.next = 6;
47
- return fileService.newFile(values.fileName + (fileType || ''), new URI(data.path));
47
+ return fileService.newFile(values.fileName + (fileType || ''), new URI(data === null || data === void 0 ? void 0 : data.path));
48
48
  case 6:
49
49
  if (fileView) {
50
50
  fileView.model.refresh();
@@ -77,7 +77,7 @@ export var FileCreateModalComponent = function FileCreateModalComponent(_ref) {
77
77
  }
78
78
  throw new Error('请输入文件名');
79
79
  case 4:
80
- targetURI = new URI(data.path + value + (fileType || ''));
80
+ targetURI = new URI((data === null || data === void 0 ? void 0 : data.path) + value + (fileType || ''));
81
81
  _context2.next = 7;
82
82
  return fileService.resolve(targetURI);
83
83
  case 7:
@@ -126,7 +126,7 @@ export var FileCreateModalComponent = function FileCreateModalComponent(_ref) {
126
126
  children: "\u521B\u5EFA\u4F4D\u7F6E\uFF1A"
127
127
  }), /*#__PURE__*/_jsx("span", {
128
128
  className: "libro-create-file-path",
129
- children: data.path
129
+ children: data === null || data === void 0 ? void 0 : data.path
130
130
  })]
131
131
  }), /*#__PURE__*/_jsx("div", {
132
132
  className: "libro-create-file-des",
@@ -43,7 +43,7 @@ export var FileCreateDirModalComponent = function FileCreateDirModalComponent(_r
43
43
  close();
44
44
  _context.prev = 3;
45
45
  _context.next = 6;
46
- return fileService.newFileDir(values.dirName, new URI(data.path));
46
+ return fileService.newFileDir(values.dirName, new URI(data === null || data === void 0 ? void 0 : data.path));
47
47
  case 6:
48
48
  if (fileView) {
49
49
  fileView.model.refresh();
@@ -76,7 +76,7 @@ export var FileCreateDirModalComponent = function FileCreateDirModalComponent(_r
76
76
  }
77
77
  throw new Error('请输入文件夹名');
78
78
  case 4:
79
- targetURI = new URI(data.path + value);
79
+ targetURI = new URI((data === null || data === void 0 ? void 0 : data.path) + value);
80
80
  _context2.next = 7;
81
81
  return fileService.resolve(targetURI);
82
82
  case 7:
@@ -123,7 +123,7 @@ export var FileCreateDirModalComponent = function FileCreateDirModalComponent(_r
123
123
  children: "\u521B\u5EFA\u4F4D\u7F6E\uFF1A"
124
124
  }), /*#__PURE__*/_jsx("span", {
125
125
  className: "libro-create-file-path",
126
- children: data.path
126
+ children: data === null || data === void 0 ? void 0 : data.path
127
127
  }), /*#__PURE__*/_jsx(Form, {
128
128
  layout: "vertical",
129
129
  autoComplete: "off",
@@ -1 +1 @@
1
- {"version":3,"file":"file-rename-modal.d.ts","sourceRoot":"","sources":["../../src/file/file-rename-modal.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAOxE,OAAO,cAAc,CAAC;AAEtB,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,GAAG,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,aAAa,CAAC,CAkF5E,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,SAAS,CAAC,aAAa,CAGpD,CAAC"}
1
+ {"version":3,"file":"file-rename-modal.d.ts","sourceRoot":"","sources":["../../src/file/file-rename-modal.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAOxE,OAAO,cAAc,CAAC;AAEtB,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,GAAG,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,aAAa,CAAC,CAmF5E,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,SAAS,CAAC,aAAa,CAGpD,CAAC"}
@@ -49,23 +49,28 @@ export var FileRenameModalComponent = function FileRenameModalComponent(_ref) {
49
49
  case 2:
50
50
  close();
51
51
  _context.prev = 3;
52
- _context.next = 6;
52
+ if (!(data && data.resource)) {
53
+ _context.next = 8;
54
+ break;
55
+ }
56
+ _context.next = 7;
53
57
  return fileService.rename(data.resource, values.rename);
54
- case 6:
58
+ case 7:
55
59
  if (fileView) {
56
60
  fileView.model.refresh();
57
61
  }
58
- _context.next = 12;
62
+ case 8:
63
+ _context.next = 13;
59
64
  break;
60
- case 9:
61
- _context.prev = 9;
65
+ case 10:
66
+ _context.prev = 10;
62
67
  _context.t0 = _context["catch"](3);
63
68
  message.error('重命名文件/文件夹失败');
64
- case 12:
69
+ case 13:
65
70
  case "end":
66
71
  return _context.stop();
67
72
  }
68
- }, _callee, null, [[3, 9]]);
73
+ }, _callee, null, [[3, 10]]);
69
74
  }));
70
75
  return function onFinish(_x) {
71
76
  return _ref2.apply(this, arguments);
@@ -82,7 +87,7 @@ export var FileRenameModalComponent = function FileRenameModalComponent(_ref) {
82
87
  }
83
88
  throw new Error('请输入文件夹名');
84
89
  case 4:
85
- if (!(value === data.fileName)) {
90
+ if (!(value === (data === null || data === void 0 ? void 0 : data.fileName))) {
86
91
  _context2.next = 6;
87
92
  break;
88
93
  }
@@ -118,7 +123,7 @@ export var FileRenameModalComponent = function FileRenameModalComponent(_ref) {
118
123
  required: true,
119
124
  validator: validateRename
120
125
  }],
121
- initialValue: data.fileName,
126
+ initialValue: data === null || data === void 0 ? void 0 : data.fileName,
122
127
  children: /*#__PURE__*/_jsx(Input, {
123
128
  ref: inputRef,
124
129
  onKeyDown: ( /*#__PURE__*/function () {
@@ -6,6 +6,6 @@ export declare class KeybindInstructionsContribution implements CommandContribut
6
6
  protected readonly libroCommand: LibroCommandRegister;
7
7
  registerCommands(command: CommandRegistry): void;
8
8
  registerToolbarItems(registry: ToolbarRegistry): void;
9
- registerModal(): import("@difizen/mana-app").ModalItem<void>;
9
+ registerModal(): import("@difizen/mana-app").ModalItem<any>;
10
10
  }
11
11
  //# sourceMappingURL=keybind-instructions-contribution.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"kernel-selector-dropdown.d.ts","sourceRoot":"","sources":["../../src/toolbar/kernel-selector-dropdown.tsx"],"names":[],"mappings":";AAQA,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;AAmFD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAiGlC,CAAC"}
1
+ {"version":3,"file":"kernel-selector-dropdown.d.ts","sourceRoot":"","sources":["../../src/toolbar/kernel-selector-dropdown.tsx"],"names":[],"mappings":";AAQA,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;AAuFD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAwGlC,CAAC"}
@@ -79,6 +79,9 @@ function getKernelListItems(preferredSessionKernelList, otherKernelList) {
79
79
  }, {
80
80
  key: 'divider1',
81
81
  type: 'divider' // Must have
82
+ }, {
83
+ key: 'RestartKernel',
84
+ label: 'Restart the Kernel'
82
85
  }, {
83
86
  key: 'ShutDownKernel',
84
87
  label: 'Shut Down the Kernel'
@@ -108,6 +111,12 @@ export var KernelSelector = function KernelSelector() {
108
111
  libroView.model.shutdown();
109
112
  }
110
113
  }
114
+ if (selectValue === 'RestartKernel') {
115
+ libroView.model.kernelConnecting = false;
116
+ if (libroView.model.restart) {
117
+ libroView.model.restart();
118
+ }
119
+ }
111
120
  var kernelInfoFromOtherKernelList = otherKernelList.filter(function (k) {
112
121
  return k.name === selectValue;
113
122
  });
@@ -1,5 +1,5 @@
1
1
  import { ModalContribution } from '@difizen/mana-app';
2
2
  export declare class SaveFileErrorContribution implements ModalContribution {
3
- registerModal(): import("@difizen/mana-app").ModalItem<void>;
3
+ registerModal(): import("@difizen/mana-app").ModalItem<any>;
4
4
  }
5
5
  //# sourceMappingURL=save-file-error-contribution.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-jupyter",
3
- "version": "0.1.21",
3
+ "version": "0.2.0",
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.1.21",
35
- "@difizen/libro-code-editor": "^0.1.21",
36
- "@difizen/libro-code-cell": "^0.1.21",
37
- "@difizen/libro-codemirror": "^0.1.21",
38
- "@difizen/libro-rendermime": "^0.1.21",
39
- "@difizen/libro-common": "^0.1.21",
40
- "@difizen/libro-core": "^0.1.21",
41
- "@difizen/libro-kernel": "^0.1.21",
42
- "@difizen/libro-l10n": "^0.1.21",
43
- "@difizen/libro-output": "^0.1.21",
44
- "@difizen/libro-search": "^0.1.21",
45
- "@difizen/libro-search-code-cell": "^0.1.21",
46
- "@difizen/libro-lsp": "^0.1.21",
47
- "@difizen/libro-markdown-cell": "^0.1.21",
48
- "@difizen/libro-raw-cell": "^0.1.21",
49
- "@difizen/libro-language-client": "^0.1.21",
34
+ "@difizen/libro-cofine-editor": "^0.2.0",
35
+ "@difizen/libro-code-editor": "^0.2.0",
36
+ "@difizen/libro-code-cell": "^0.2.0",
37
+ "@difizen/libro-codemirror": "^0.2.0",
38
+ "@difizen/libro-rendermime": "^0.2.0",
39
+ "@difizen/libro-common": "^0.2.0",
40
+ "@difizen/libro-core": "^0.2.0",
41
+ "@difizen/libro-kernel": "^0.2.0",
42
+ "@difizen/libro-l10n": "^0.2.0",
43
+ "@difizen/libro-output": "^0.2.0",
44
+ "@difizen/libro-search": "^0.2.0",
45
+ "@difizen/libro-search-code-cell": "^0.2.0",
46
+ "@difizen/libro-lsp": "^0.2.0",
47
+ "@difizen/libro-markdown-cell": "^0.2.0",
48
+ "@difizen/libro-raw-cell": "^0.2.0",
49
+ "@difizen/libro-language-client": "^0.2.0",
50
50
  "@difizen/mana-app": "latest",
51
51
  "@difizen/mana-l10n": "latest",
52
52
  "@ant-design/colors": "^7.0.0",
@@ -28,7 +28,7 @@ export const FileCreateModalComponent: React.FC<ModalItemProps<ModalItemType>> =
28
28
  }: ModalItemProps<ModalItemType>) => {
29
29
  const fileService = useInject(JupyterFileService);
30
30
  const viewManager = useInject(ViewManager);
31
- const [fileType, setFileType] = useState<FileType>(data.fileType);
31
+ const [fileType, setFileType] = useState<FileType>(data?.fileType);
32
32
  const [fileView, setFileView] = useState<FileView>();
33
33
  const inputRef = useRef<InputRef>(null);
34
34
  const [form] = Form.useForm();
@@ -37,7 +37,10 @@ export const FileCreateModalComponent: React.FC<ModalItemProps<ModalItemType>> =
37
37
  await form.validateFields();
38
38
  close();
39
39
  try {
40
- await fileService.newFile(values.fileName + (fileType || ''), new URI(data.path));
40
+ await fileService.newFile(
41
+ values.fileName + (fileType || ''),
42
+ new URI(data?.path),
43
+ );
41
44
  if (fileView) {
42
45
  fileView.model.refresh();
43
46
  }
@@ -50,7 +53,7 @@ export const FileCreateModalComponent: React.FC<ModalItemProps<ModalItemType>> =
50
53
  if (!value || !value.length) {
51
54
  throw new Error('请输入文件名');
52
55
  } else {
53
- const targetURI = new URI(data.path + value + (fileType || ''));
56
+ const targetURI = new URI(data?.path + value + (fileType || ''));
54
57
  const fileRes = await fileService.resolve(targetURI);
55
58
  if (fileRes.isFile) {
56
59
  throw new Error('文件名称已存在,请重新输入');
@@ -86,7 +89,7 @@ export const FileCreateModalComponent: React.FC<ModalItemProps<ModalItemType>> =
86
89
  >
87
90
  <div className="libro-create-file-path-container">
88
91
  <div className="libro-create-file-des">创建位置:</div>
89
- <span className="libro-create-file-path">{data.path}</span>
92
+ <span className="libro-create-file-path">{data?.path}</span>
90
93
  </div>
91
94
  <div className="libro-create-file-des">文件类型:</div>
92
95
  <Row>
@@ -27,7 +27,7 @@ export const FileCreateDirModalComponent: React.FC<
27
27
  await form.validateFields();
28
28
  close();
29
29
  try {
30
- await fileService.newFileDir(values.dirName, new URI(data.path));
30
+ await fileService.newFileDir(values.dirName, new URI(data?.path));
31
31
  if (fileView) {
32
32
  fileView.model.refresh();
33
33
  }
@@ -40,7 +40,7 @@ export const FileCreateDirModalComponent: React.FC<
40
40
  if (!value || !value.length) {
41
41
  throw new Error('请输入文件夹名');
42
42
  } else {
43
- const targetURI = new URI(data.path + value);
43
+ const targetURI = new URI(data?.path + value);
44
44
  const fileRes = await fileService.resolve(targetURI);
45
45
  if (fileRes.isDirectory) {
46
46
  throw new Error('文件夹名称已存在,请重新输入');
@@ -75,7 +75,7 @@ export const FileCreateDirModalComponent: React.FC<
75
75
  width={524}
76
76
  >
77
77
  <div className="libro-create-file-des">创建位置:</div>
78
- <span className="libro-create-file-path">{data.path}</span>
78
+ <span className="libro-create-file-path">{data?.path}</span>
79
79
  <Form
80
80
  layout="vertical"
81
81
  autoComplete="off"
@@ -40,10 +40,11 @@ export const FileRenameModalComponent: React.FC<ModalItemProps<ModalItemType>> =
40
40
  await form.validateFields();
41
41
  close();
42
42
  try {
43
- await fileService.rename(data.resource, values.rename);
44
-
45
- if (fileView) {
46
- fileView.model.refresh();
43
+ if (data && data.resource) {
44
+ await fileService.rename(data.resource, values.rename);
45
+ if (fileView) {
46
+ fileView.model.refresh();
47
+ }
47
48
  }
48
49
  } catch {
49
50
  message.error('重命名文件/文件夹失败');
@@ -54,7 +55,7 @@ export const FileRenameModalComponent: React.FC<ModalItemProps<ModalItemType>> =
54
55
  if (!value || !value.length) {
55
56
  throw new Error('请输入文件夹名');
56
57
  } else {
57
- if (value === data.fileName) {
58
+ if (value === data?.fileName) {
58
59
  throw new Error('文件/文件夹名称已存在,请重新输入');
59
60
  }
60
61
  }
@@ -81,7 +82,7 @@ export const FileRenameModalComponent: React.FC<ModalItemProps<ModalItemType>> =
81
82
  name="rename"
82
83
  label="文件/文件夹名称"
83
84
  rules={[{ required: true, validator: validateRename }]}
84
- initialValue={data.fileName}
85
+ initialValue={data?.fileName}
85
86
  >
86
87
  <Input
87
88
  ref={inputRef}
@@ -93,6 +93,10 @@ function getKernelListItems(
93
93
  key: 'divider1',
94
94
  type: 'divider', // Must have
95
95
  },
96
+ {
97
+ key: 'RestartKernel',
98
+ label: 'Restart the Kernel',
99
+ },
96
100
  {
97
101
  key: 'ShutDownKernel',
98
102
  label: 'Shut Down the Kernel',
@@ -130,6 +134,13 @@ export const KernelSelector: React.FC = () => {
130
134
  }
131
135
  }
132
136
 
137
+ if (selectValue === 'RestartKernel') {
138
+ libroView.model.kernelConnecting = false;
139
+ if (libroView.model.restart) {
140
+ libroView.model.restart();
141
+ }
142
+ }
143
+
133
144
  const kernelInfoFromOtherKernelList = otherKernelList.filter(
134
145
  (k) => k.name === selectValue,
135
146
  );