@difizen/libro-jupyter 0.3.45 → 0.3.47
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,8 +1,10 @@
|
|
|
1
1
|
import type { LibroEditableExecutableCellView, IOutputAreaOption } from '@difizen/libro-core';
|
|
2
2
|
import { LibroOutputArea } from '@difizen/libro-core';
|
|
3
|
+
import { DisposableCollection } from '@difizen/mana-app';
|
|
3
4
|
export declare class LibroJupyterOutputArea extends LibroOutputArea {
|
|
4
5
|
cell: LibroEditableExecutableCellView;
|
|
5
6
|
protected displayIdMap: Map<string, number[]>;
|
|
7
|
+
protected toDispose: DisposableCollection;
|
|
6
8
|
constructor(option: IOutputAreaOption);
|
|
7
9
|
handleMsg(): void;
|
|
8
10
|
dispose(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-jupyter-outputarea.d.ts","sourceRoot":"","sources":["../../src/output/libro-jupyter-outputarea.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,+BAA+B,EAE/B,iBAAiB,EAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"libro-jupyter-outputarea.d.ts","sourceRoot":"","sources":["../../src/output/libro-jupyter-outputarea.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,+BAA+B,EAE/B,iBAAiB,EAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAWtD,OAAO,EAKL,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAE3B,qBAEa,sBAAuB,SAAQ,eAAe;IACjD,IAAI,EAAE,+BAA+B,CAAC;IAC9C,SAAS,CAAC,YAAY,wBAA+B;IACrD,SAAS,CAAC,SAAS,uBAA8B;gBAEjB,MAAM,EAAE,iBAAiB;IAKzD,SAAS;IAkEA,OAAO,IAAI,IAAI;IAMf,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI;CAMjD"}
|
|
@@ -22,7 +22,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
22
22
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
23
23
|
import { LibroOutputArea } from '@difizen/libro-core';
|
|
24
24
|
import { isClearOutputMsg, isDisplayDataMsg, isErrorMsg, isExecuteInputMsg, isExecuteReplyMsg, isExecuteResultMsg, isStreamMsg, isUpdateDisplayDataMsg } from '@difizen/libro-kernel';
|
|
25
|
-
import { inject, transient, view, ViewOption } from '@difizen/mana-app';
|
|
25
|
+
import { inject, transient, view, ViewOption, DisposableCollection } from '@difizen/mana-app';
|
|
26
26
|
export var LibroJupyterOutputArea = (_dec = transient(), _dec2 = view('libro-output-area'), _dec(_class = _dec2(_class = /*#__PURE__*/function (_LibroOutputArea) {
|
|
27
27
|
_inherits(LibroJupyterOutputArea, _LibroOutputArea);
|
|
28
28
|
var _super = _createSuper(LibroJupyterOutputArea);
|
|
@@ -31,6 +31,7 @@ export var LibroJupyterOutputArea = (_dec = transient(), _dec2 = view('libro-out
|
|
|
31
31
|
_classCallCheck(this, LibroJupyterOutputArea);
|
|
32
32
|
_this = _super.call(this, option);
|
|
33
33
|
_this.displayIdMap = new Map();
|
|
34
|
+
_this.toDispose = new DisposableCollection();
|
|
34
35
|
_this.handleMsg();
|
|
35
36
|
return _this;
|
|
36
37
|
}
|
|
@@ -40,7 +41,7 @@ export var LibroJupyterOutputArea = (_dec = transient(), _dec2 = view('libro-out
|
|
|
40
41
|
value: function handleMsg() {
|
|
41
42
|
var _this2 = this;
|
|
42
43
|
var cellModel = this.cell.model;
|
|
43
|
-
cellModel.msgChangeEmitter.event(function (msg) {
|
|
44
|
+
this.toDispose.push(cellModel.msgChangeEmitter.event(function (msg) {
|
|
44
45
|
var transientMsg = msg.content.transient || {};
|
|
45
46
|
var displayId = transientMsg['display_id'];
|
|
46
47
|
if (isExecuteInputMsg(msg)) {
|
|
@@ -105,11 +106,12 @@ export var LibroJupyterOutputArea = (_dec = transient(), _dec2 = view('libro-out
|
|
|
105
106
|
var wait = msg.content.wait;
|
|
106
107
|
_this2.clear(wait);
|
|
107
108
|
}
|
|
108
|
-
});
|
|
109
|
+
}));
|
|
109
110
|
}
|
|
110
111
|
}, {
|
|
111
112
|
key: "dispose",
|
|
112
113
|
value: function dispose() {
|
|
114
|
+
this.toDispose.dispose();
|
|
113
115
|
this.displayIdMap.clear();
|
|
114
116
|
_get(_getPrototypeOf(LibroJupyterOutputArea.prototype), "dispose", this).call(this);
|
|
115
117
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-jupyter",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.47",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro"
|
|
@@ -37,22 +37,22 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@ant-design/colors": "^7.0.0",
|
|
39
39
|
"@ant-design/icons": "^5.1.0",
|
|
40
|
-
"@difizen/libro-code-cell": "^0.3.
|
|
41
|
-
"@difizen/libro-code-editor": "^0.3.
|
|
42
|
-
"@difizen/libro-codemirror": "^0.3.
|
|
43
|
-
"@difizen/libro-cofine-editor": "^0.3.
|
|
44
|
-
"@difizen/libro-common": "^0.3.
|
|
45
|
-
"@difizen/libro-core": "^0.3.
|
|
46
|
-
"@difizen/libro-kernel": "^0.3.
|
|
47
|
-
"@difizen/libro-l10n": "^0.3.
|
|
48
|
-
"@difizen/libro-language-client": "^0.3.
|
|
49
|
-
"@difizen/libro-lsp": "^0.3.
|
|
50
|
-
"@difizen/libro-markdown-cell": "^0.3.
|
|
51
|
-
"@difizen/libro-output": "^0.3.
|
|
52
|
-
"@difizen/libro-raw-cell": "^0.3.
|
|
53
|
-
"@difizen/libro-rendermime": "^0.3.
|
|
54
|
-
"@difizen/libro-search": "^0.3.
|
|
55
|
-
"@difizen/libro-search-code-cell": "^0.3.
|
|
40
|
+
"@difizen/libro-code-cell": "^0.3.47",
|
|
41
|
+
"@difizen/libro-code-editor": "^0.3.47",
|
|
42
|
+
"@difizen/libro-codemirror": "^0.3.47",
|
|
43
|
+
"@difizen/libro-cofine-editor": "^0.3.47",
|
|
44
|
+
"@difizen/libro-common": "^0.3.47",
|
|
45
|
+
"@difizen/libro-core": "^0.3.47",
|
|
46
|
+
"@difizen/libro-kernel": "^0.3.47",
|
|
47
|
+
"@difizen/libro-l10n": "^0.3.47",
|
|
48
|
+
"@difizen/libro-language-client": "^0.3.47",
|
|
49
|
+
"@difizen/libro-lsp": "^0.3.47",
|
|
50
|
+
"@difizen/libro-markdown-cell": "^0.3.47",
|
|
51
|
+
"@difizen/libro-output": "^0.3.47",
|
|
52
|
+
"@difizen/libro-raw-cell": "^0.3.47",
|
|
53
|
+
"@difizen/libro-rendermime": "^0.3.47",
|
|
54
|
+
"@difizen/libro-search": "^0.3.47",
|
|
55
|
+
"@difizen/libro-search-code-cell": "^0.3.47",
|
|
56
56
|
"@difizen/mana-app": "latest",
|
|
57
57
|
"@difizen/mana-l10n": "latest",
|
|
58
58
|
"classnames": "^2.3.2",
|
|
@@ -15,13 +15,20 @@ import {
|
|
|
15
15
|
isStreamMsg,
|
|
16
16
|
isUpdateDisplayDataMsg,
|
|
17
17
|
} from '@difizen/libro-kernel';
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
inject,
|
|
20
|
+
transient,
|
|
21
|
+
view,
|
|
22
|
+
ViewOption,
|
|
23
|
+
DisposableCollection,
|
|
24
|
+
} from '@difizen/mana-app';
|
|
19
25
|
|
|
20
26
|
@transient()
|
|
21
27
|
@view('libro-output-area')
|
|
22
28
|
export class LibroJupyterOutputArea extends LibroOutputArea {
|
|
23
29
|
declare cell: LibroEditableExecutableCellView;
|
|
24
30
|
protected displayIdMap = new Map<string, number[]>();
|
|
31
|
+
protected toDispose = new DisposableCollection();
|
|
25
32
|
|
|
26
33
|
constructor(@inject(ViewOption) option: IOutputAreaOption) {
|
|
27
34
|
super(option);
|
|
@@ -30,69 +37,72 @@ export class LibroJupyterOutputArea extends LibroOutputArea {
|
|
|
30
37
|
|
|
31
38
|
handleMsg() {
|
|
32
39
|
const cellModel = this.cell.model as ExecutableCellModel;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (
|
|
40
|
-
isDisplayDataMsg(msg) ||
|
|
41
|
-
isStreamMsg(msg) ||
|
|
42
|
-
isErrorMsg(msg) ||
|
|
43
|
-
isExecuteResultMsg(msg)
|
|
44
|
-
) {
|
|
45
|
-
const output: nbformat.IOutput = {
|
|
46
|
-
...msg.content,
|
|
47
|
-
output_type: msg.header.msg_type,
|
|
48
|
-
};
|
|
49
|
-
this.add(output);
|
|
50
|
-
}
|
|
51
|
-
if (isUpdateDisplayDataMsg(msg)) {
|
|
52
|
-
const output = { ...msg.content, output_type: 'display_data' };
|
|
53
|
-
const targets = this.displayIdMap.get(displayId);
|
|
54
|
-
if (targets) {
|
|
55
|
-
for (const index of targets) {
|
|
56
|
-
this.set(index, output);
|
|
57
|
-
}
|
|
40
|
+
this.toDispose.push(
|
|
41
|
+
cellModel.msgChangeEmitter.event((msg: any) => {
|
|
42
|
+
const transientMsg = (msg.content.transient || {}) as nbformat.JSONObject;
|
|
43
|
+
const displayId = transientMsg['display_id'] as string;
|
|
44
|
+
if (isExecuteInputMsg(msg)) {
|
|
45
|
+
cellModel.executeCount = msg.content.execution_count;
|
|
58
46
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
47
|
+
if (
|
|
48
|
+
isDisplayDataMsg(msg) ||
|
|
49
|
+
isStreamMsg(msg) ||
|
|
50
|
+
isErrorMsg(msg) ||
|
|
51
|
+
isExecuteResultMsg(msg)
|
|
52
|
+
) {
|
|
53
|
+
const output: nbformat.IOutput = {
|
|
54
|
+
...msg.content,
|
|
55
|
+
output_type: msg.header.msg_type,
|
|
56
|
+
};
|
|
57
|
+
this.add(output);
|
|
58
|
+
}
|
|
59
|
+
if (isUpdateDisplayDataMsg(msg)) {
|
|
60
|
+
const output = { ...msg.content, output_type: 'display_data' };
|
|
61
|
+
const targets = this.displayIdMap.get(displayId);
|
|
62
|
+
if (targets) {
|
|
63
|
+
for (const index of targets) {
|
|
64
|
+
this.set(index, output);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
70
67
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
if (displayId && isDisplayDataMsg(msg)) {
|
|
69
|
+
const targets = this.displayIdMap.get(displayId) || [];
|
|
70
|
+
targets.push(this.outputs.length);
|
|
71
|
+
this.displayIdMap.set(displayId, targets);
|
|
74
72
|
}
|
|
75
|
-
|
|
76
|
-
if (
|
|
77
|
-
|
|
73
|
+
//Handle an execute reply message.
|
|
74
|
+
if (isExecuteReplyMsg(msg)) {
|
|
75
|
+
const content = msg.content;
|
|
76
|
+
if (content.status !== 'ok') {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const payload = content && content.payload;
|
|
80
|
+
if (!payload || !payload.length) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const pages = payload.filter((i: any) => i.source === 'page');
|
|
84
|
+
if (!pages.length) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const page = JSON.parse(JSON.stringify(pages[0]));
|
|
88
|
+
const output: nbformat.IOutput = {
|
|
89
|
+
output_type: 'display_data',
|
|
90
|
+
data: page.data as nbformat.IMimeBundle,
|
|
91
|
+
metadata: {},
|
|
92
|
+
};
|
|
93
|
+
this.add(output);
|
|
78
94
|
}
|
|
79
|
-
const page = JSON.parse(JSON.stringify(pages[0]));
|
|
80
|
-
const output: nbformat.IOutput = {
|
|
81
|
-
output_type: 'display_data',
|
|
82
|
-
data: page.data as nbformat.IMimeBundle,
|
|
83
|
-
metadata: {},
|
|
84
|
-
};
|
|
85
|
-
this.add(output);
|
|
86
|
-
}
|
|
87
95
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
96
|
+
if (isClearOutputMsg(msg)) {
|
|
97
|
+
const wait = msg.content.wait;
|
|
98
|
+
this.clear(wait);
|
|
99
|
+
}
|
|
100
|
+
}),
|
|
101
|
+
);
|
|
93
102
|
}
|
|
94
103
|
|
|
95
104
|
override dispose(): void {
|
|
105
|
+
this.toDispose.dispose();
|
|
96
106
|
this.displayIdMap.clear();
|
|
97
107
|
super.dispose();
|
|
98
108
|
}
|