@difizen/libro-jupyter 0.2.11 → 0.2.12

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.
@@ -11,7 +11,7 @@ export declare class JupyterCodeCellView extends LibroCodeCellView {
11
11
  model: JupyterCodeCellModel;
12
12
  clearExecution: () => void;
13
13
  protected getEditorOption(): CodeEditorViewOptions;
14
- onViewMount(): void;
14
+ onViewMount(): Promise<void>;
15
15
  tooltipProvider: TooltipProvider;
16
16
  completionProvider: CompletionProvider;
17
17
  run(): Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"jupyter-code-cell-view.d.ts","sourceRoot":"","sources":["../../src/cell/jupyter-code-cell-view.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,KAAK,EACV,qBAAqB,EACrB,kBAAkB,EAElB,eAAe,EAEhB,MAAM,4BAA4B,CAAC;AAWpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAkBzE,qBAEa,mBAAoB,SAAQ,iBAAiB;IACxD,UAAkB,OAAO,EAAE,gBAAgB,CAAC;IAE5C,IAAa,MAAM,IAGQ,gBAAgB,CAD1C;IACD,IAAa,MAAM,CAAC,KAAK,EAAE,gBAAgB,EAG1C;IAEQ,IAAI,2FAA4B;IACjC,KAAK,EAAE,oBAAoB,CAAC;IAE3B,cAAc,aAQrB;cAEiB,eAAe,IAAI,qBAAqB;IAelD,WAAW,IAAI,IAAI;IAc5B,eAAe,EAAE,eAAe,CAqB9B;IAEF,kBAAkB,EAAE,kBAAkB,CA8BpC;IAEa,GAAG;CA8EnB"}
1
+ {"version":3,"file":"jupyter-code-cell-view.d.ts","sourceRoot":"","sources":["../../src/cell/jupyter-code-cell-view.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,KAAK,EACV,qBAAqB,EACrB,kBAAkB,EAElB,eAAe,EAEhB,MAAM,4BAA4B,CAAC;AAYpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAkBzE,qBAEa,mBAAoB,SAAQ,iBAAiB;IACxD,UAAkB,OAAO,EAAE,gBAAgB,CAAC;IAE5C,IAAa,MAAM,IAGQ,gBAAgB,CAD1C;IACD,IAAa,MAAM,CAAC,KAAK,EAAE,gBAAgB,EAG1C;IAEQ,IAAI,2FAA4B;IACjC,KAAK,EAAE,oBAAoB,CAAC;IAE3B,cAAc,aAQrB;cAEiB,eAAe,IAAI,qBAAqB;IAe5C,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAkB3C,eAAe,EAAE,eAAe,CAqB9B;IAEF,kBAAkB,EAAE,kBAAkB,CA8BpC;IAEa,GAAG;CA8EnB"}
@@ -177,37 +177,57 @@ export var JupyterCodeCellView = (_dec = transient(), _dec2 = view('jupyter-code
177
177
  }
178
178
  }, {
179
179
  key: "onViewMount",
180
- value: function onViewMount() {
181
- var _this2 = this;
182
- _get(_getPrototypeOf(JupyterCodeCellView.prototype), "onViewMount", this).call(this);
183
- var kernelConnection = getOrigin(this.parent.model.kernelConnection);
184
-
185
- // kernel重启后,清除执行状态,输出不变
186
- kernelConnection === null || kernelConnection === void 0 || kernelConnection.statusChanged(function (e) {
187
- if (e === 'starting') {
188
- _this2.model.clearExecution();
189
- }
190
- });
191
- }
180
+ value: function () {
181
+ var _onViewMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
182
+ var _this2 = this;
183
+ var kcReady, kernelConnection;
184
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
185
+ while (1) switch (_context3.prev = _context3.next) {
186
+ case 0:
187
+ _get(_getPrototypeOf(JupyterCodeCellView.prototype), "onViewMount", this).call(this);
188
+ kcReady = getOrigin(this.parent.model.kcReady);
189
+ _context3.next = 4;
190
+ return kcReady;
191
+ case 4:
192
+ kernelConnection = _context3.sent;
193
+ // kernel重启后,清除执行状态,输出不变
194
+ kernelConnection === null || kernelConnection === void 0 || kernelConnection.statusChanged(function (e) {
195
+ var terminateStatus = ['autorestarting', 'starting', 'restarting'];
196
+ if (terminateStatus.includes(e)) {
197
+ _this2.model.clearExecution();
198
+ _this2.model.executing = false;
199
+ }
200
+ });
201
+ case 6:
202
+ case "end":
203
+ return _context3.stop();
204
+ }
205
+ }, _callee3, this);
206
+ }));
207
+ function onViewMount() {
208
+ return _onViewMount.apply(this, arguments);
209
+ }
210
+ return onViewMount;
211
+ }()
192
212
  }, {
193
213
  key: "run",
194
214
  value: function () {
195
- var _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
215
+ var _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
196
216
  var libroModel, kernelConnection, cellContent, cellModel, future, startTimeStr, msgPromise, endTimeStr;
197
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
198
- while (1) switch (_context3.prev = _context3.next) {
217
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
218
+ while (1) switch (_context4.prev = _context4.next) {
199
219
  case 0:
200
220
  libroModel = this.parent.model;
201
221
  if (!(!libroModel || !(libroModel instanceof LibroJupyterModel) || !libroModel.kernelConnection || libroModel.kernelConnection.isDisposed)) {
202
- _context3.next = 3;
222
+ _context4.next = 3;
203
223
  break;
204
224
  }
205
- return _context3.abrupt("return", false);
225
+ return _context4.abrupt("return", false);
206
226
  case 3:
207
227
  kernelConnection = getOrigin(libroModel.kernelConnection);
208
228
  cellContent = this.model.source;
209
229
  cellModel = this.model;
210
- _context3.prev = 6;
230
+ _context4.prev = 6;
211
231
  // if (this.outputArea instanceof LibroOutputArea)
212
232
  // this.outputArea.lastOutputContainerHeight =
213
233
  // this.outputArea.container?.current?.clientHeight;
@@ -239,10 +259,10 @@ export var JupyterCodeCellView = (_dec = transient(), _dec2 = view('jupyter-code
239
259
  future.onReply = function (msg) {
240
260
  cellModel.msgChangeEmitter.fire(msg);
241
261
  };
242
- _context3.next = 15;
262
+ _context4.next = 15;
243
263
  return future.done;
244
264
  case 15:
245
- msgPromise = _context3.sent;
265
+ msgPromise = _context4.sent;
246
266
  cellModel.executing = false;
247
267
  cellModel.kernelExecuting = false;
248
268
  startTimeStr = msgPromise.metadata['started'];
@@ -250,36 +270,36 @@ export var JupyterCodeCellView = (_dec = transient(), _dec2 = view('jupyter-code
250
270
  cellModel.metadata.execution['shell.execute_reply.started'] = startTimeStr;
251
271
  cellModel.metadata.execution['shell.execute_reply.end'] = endTimeStr;
252
272
  if (msgPromise) {
253
- _context3.next = 24;
273
+ _context4.next = 24;
254
274
  break;
255
275
  }
256
- return _context3.abrupt("return", true);
276
+ return _context4.abrupt("return", true);
257
277
  case 24:
258
278
  if (!(msgPromise.content.status === 'ok')) {
259
- _context3.next = 28;
279
+ _context4.next = 28;
260
280
  break;
261
281
  }
262
- return _context3.abrupt("return", true);
282
+ return _context4.abrupt("return", true);
263
283
  case 28:
264
284
  throw new KernelError(msgPromise.content);
265
285
  case 29:
266
- _context3.next = 36;
286
+ _context4.next = 36;
267
287
  break;
268
288
  case 31:
269
- _context3.prev = 31;
270
- _context3.t0 = _context3["catch"](6);
271
- if (!_context3.t0.message.startsWith('Canceled')) {
272
- _context3.next = 35;
289
+ _context4.prev = 31;
290
+ _context4.t0 = _context4["catch"](6);
291
+ if (!_context4.t0.message.startsWith('Canceled')) {
292
+ _context4.next = 35;
273
293
  break;
274
294
  }
275
- return _context3.abrupt("return", false);
295
+ return _context4.abrupt("return", false);
276
296
  case 35:
277
- throw _context3.t0;
297
+ throw _context4.t0;
278
298
  case 36:
279
299
  case "end":
280
- return _context3.stop();
300
+ return _context4.stop();
281
301
  }
282
- }, _callee3, this, [[6, 31]]);
302
+ }, _callee4, this, [[6, 31]]);
283
303
  }));
284
304
  function run() {
285
305
  return _run.apply(this, arguments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-jupyter",
3
- "version": "0.2.11",
3
+ "version": "0.2.12",
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.11",
35
- "@difizen/libro-code-editor": "^0.2.11",
36
- "@difizen/libro-code-cell": "^0.2.11",
37
- "@difizen/libro-codemirror": "^0.2.11",
38
- "@difizen/libro-rendermime": "^0.2.11",
39
- "@difizen/libro-common": "^0.2.11",
40
- "@difizen/libro-core": "^0.2.11",
41
- "@difizen/libro-kernel": "^0.2.11",
42
- "@difizen/libro-l10n": "^0.2.11",
43
- "@difizen/libro-output": "^0.2.11",
44
- "@difizen/libro-search": "^0.2.11",
45
- "@difizen/libro-search-code-cell": "^0.2.11",
46
- "@difizen/libro-lsp": "^0.2.11",
47
- "@difizen/libro-markdown-cell": "^0.2.11",
48
- "@difizen/libro-raw-cell": "^0.2.11",
49
- "@difizen/libro-language-client": "^0.2.11",
34
+ "@difizen/libro-cofine-editor": "^0.2.12",
35
+ "@difizen/libro-code-editor": "^0.2.12",
36
+ "@difizen/libro-code-cell": "^0.2.12",
37
+ "@difizen/libro-codemirror": "^0.2.12",
38
+ "@difizen/libro-rendermime": "^0.2.12",
39
+ "@difizen/libro-common": "^0.2.12",
40
+ "@difizen/libro-core": "^0.2.12",
41
+ "@difizen/libro-kernel": "^0.2.12",
42
+ "@difizen/libro-l10n": "^0.2.12",
43
+ "@difizen/libro-output": "^0.2.12",
44
+ "@difizen/libro-search": "^0.2.12",
45
+ "@difizen/libro-search-code-cell": "^0.2.12",
46
+ "@difizen/libro-lsp": "^0.2.12",
47
+ "@difizen/libro-markdown-cell": "^0.2.12",
48
+ "@difizen/libro-raw-cell": "^0.2.12",
49
+ "@difizen/libro-language-client": "^0.2.12",
50
50
  "@difizen/mana-app": "latest",
51
51
  "@difizen/mana-l10n": "latest",
52
52
  "@ant-design/colors": "^7.0.0",
@@ -6,6 +6,7 @@ import type {
6
6
  TooltipProvider,
7
7
  TooltipProviderOption,
8
8
  } from '@difizen/libro-code-editor';
9
+ import type { KernelMessage } from '@difizen/libro-kernel';
9
10
  import { KernelError } from '@difizen/libro-kernel';
10
11
  import { getCellURI } from '@difizen/libro-language-client';
11
12
  import { transient } from '@difizen/mana-app';
@@ -77,16 +78,20 @@ export class JupyterCodeCellView extends LibroCodeCellView {
77
78
  };
78
79
  }
79
80
 
80
- override onViewMount(): void {
81
+ override async onViewMount(): Promise<void> {
81
82
  super.onViewMount();
82
- const kernelConnection = getOrigin(
83
- (this.parent.model as LibroJupyterModel).kernelConnection,
84
- );
85
-
83
+ const kcReady = getOrigin((this.parent.model as LibroJupyterModel).kcReady);
84
+ const kernelConnection = await kcReady;
86
85
  // kernel重启后,清除执行状态,输出不变
87
86
  kernelConnection?.statusChanged((e) => {
88
- if (e === 'starting') {
87
+ const terminateStatus: KernelMessage.Status[] = [
88
+ 'autorestarting',
89
+ 'starting',
90
+ 'restarting',
91
+ ];
92
+ if (terminateStatus.includes(e)) {
89
93
  this.model.clearExecution();
94
+ this.model.executing = false;
90
95
  }
91
96
  });
92
97
  }