@jupyterlab/rendermime 4.3.0-alpha.2 → 4.3.0-beta.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.
- package/lib/outputmodel.d.ts +7 -1
- package/lib/outputmodel.js +17 -6
- package/lib/outputmodel.js.map +1 -1
- package/package.json +9 -9
- package/src/outputmodel.ts +29 -7
package/lib/outputmodel.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as nbformat from '@jupyterlab/nbformat';
|
|
2
|
+
import { IObservableString } from '@jupyterlab/observables';
|
|
2
3
|
import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
|
|
3
4
|
import { PartialJSONObject, ReadonlyPartialJSONObject } from '@lumino/coreutils';
|
|
4
5
|
import { ISignal } from '@lumino/signaling';
|
|
@@ -18,6 +19,10 @@ export interface IOutputModel extends IRenderMime.IMimeModel {
|
|
|
18
19
|
* The execution count of the model.
|
|
19
20
|
*/
|
|
20
21
|
readonly executionCount: nbformat.ExecutionCount;
|
|
22
|
+
/**
|
|
23
|
+
* The observable text, present when the output `type` is set to `"stream"`.
|
|
24
|
+
*/
|
|
25
|
+
readonly streamText?: IObservableString;
|
|
21
26
|
/**
|
|
22
27
|
* Whether the output is trusted.
|
|
23
28
|
*/
|
|
@@ -81,6 +86,7 @@ export declare class OutputModel implements IOutputModel {
|
|
|
81
86
|
* The data associated with the model.
|
|
82
87
|
*/
|
|
83
88
|
get data(): ReadonlyPartialJSONObject;
|
|
89
|
+
get streamText(): IObservableString | undefined;
|
|
84
90
|
/**
|
|
85
91
|
* The metadata associated with the model.
|
|
86
92
|
*/
|
|
@@ -105,7 +111,7 @@ export declare class OutputModel implements IOutputModel {
|
|
|
105
111
|
private _raw;
|
|
106
112
|
private _rawMetadata;
|
|
107
113
|
private _rawData;
|
|
108
|
-
private
|
|
114
|
+
private _text?;
|
|
109
115
|
private _metadata;
|
|
110
116
|
}
|
|
111
117
|
/**
|
package/lib/outputmodel.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
| Distributed under the terms of the Modified BSD License.
|
|
4
4
|
|----------------------------------------------------------------------------*/
|
|
5
5
|
import * as nbformat from '@jupyterlab/nbformat';
|
|
6
|
-
import { ObservableJSON } from '@jupyterlab/observables';
|
|
6
|
+
import { ObservableJSON, ObservableString } from '@jupyterlab/observables';
|
|
7
7
|
import { JSONExt } from '@lumino/coreutils';
|
|
8
8
|
import { Signal } from '@lumino/signaling';
|
|
9
9
|
/**
|
|
@@ -16,9 +16,14 @@ export class OutputModel {
|
|
|
16
16
|
constructor(options) {
|
|
17
17
|
this._changed = new Signal(this);
|
|
18
18
|
this._raw = {};
|
|
19
|
+
this._text = undefined;
|
|
19
20
|
const { data, metadata, trusted } = Private.getBundleOptions(options);
|
|
20
|
-
this._data = new ObservableJSON({ values: data });
|
|
21
21
|
this._rawData = data;
|
|
22
|
+
if (options.value !== undefined && nbformat.isStream(options.value)) {
|
|
23
|
+
this._text = new ObservableString(typeof options.value.text === 'string'
|
|
24
|
+
? options.value.text
|
|
25
|
+
: options.value.text.join(''));
|
|
26
|
+
}
|
|
22
27
|
this._metadata = new ObservableJSON({ values: metadata });
|
|
23
28
|
this._rawMetadata = metadata;
|
|
24
29
|
this.trusted = trusted;
|
|
@@ -52,7 +57,8 @@ export class OutputModel {
|
|
|
52
57
|
* Dispose of the resources used by the output model.
|
|
53
58
|
*/
|
|
54
59
|
dispose() {
|
|
55
|
-
|
|
60
|
+
var _a;
|
|
61
|
+
(_a = this._text) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
56
62
|
this._metadata.dispose();
|
|
57
63
|
Signal.clearData(this);
|
|
58
64
|
}
|
|
@@ -60,7 +66,10 @@ export class OutputModel {
|
|
|
60
66
|
* The data associated with the model.
|
|
61
67
|
*/
|
|
62
68
|
get data() {
|
|
63
|
-
return this.
|
|
69
|
+
return Private.getData(this.toJSON());
|
|
70
|
+
}
|
|
71
|
+
get streamText() {
|
|
72
|
+
return this._text;
|
|
64
73
|
}
|
|
65
74
|
/**
|
|
66
75
|
* The metadata associated with the model.
|
|
@@ -77,7 +86,6 @@ export class OutputModel {
|
|
|
77
86
|
*/
|
|
78
87
|
setData(options) {
|
|
79
88
|
if (options.data) {
|
|
80
|
-
this._updateObservable(this._data, options.data);
|
|
81
89
|
this._rawData = options.data;
|
|
82
90
|
}
|
|
83
91
|
if (options.metadata) {
|
|
@@ -94,11 +102,14 @@ export class OutputModel {
|
|
|
94
102
|
for (const key in this._raw) {
|
|
95
103
|
output[key] = Private.extract(this._raw, key);
|
|
96
104
|
}
|
|
105
|
+
if (this._text !== undefined) {
|
|
106
|
+
output['text'] = this._text.text;
|
|
107
|
+
}
|
|
97
108
|
switch (this.type) {
|
|
98
109
|
case 'display_data':
|
|
99
110
|
case 'execute_result':
|
|
100
111
|
case 'update_display_data':
|
|
101
|
-
output['data'] = this.
|
|
112
|
+
output['data'] = this._rawData;
|
|
102
113
|
output['metadata'] = this.metadata;
|
|
103
114
|
break;
|
|
104
115
|
default:
|
package/lib/outputmodel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outputmodel.js","sourceRoot":"","sources":["../src/outputmodel.ts"],"names":[],"mappings":"AAAA;;;+EAG+E;AAC/E,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AACjD,OAAO,
|
|
1
|
+
{"version":3,"file":"outputmodel.js","sourceRoot":"","sources":["../src/outputmodel.ts"],"names":[],"mappings":"AAAA;;;+EAG+E;AAC/E,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAGL,cAAc,EACd,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,OAAO,EAMR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAW,MAAM,EAAE,MAAM,mBAAmB,CAAC;AA+DpD;;GAEG;AACH,MAAM,OAAO,WAAW;IACtB;;OAEG;IACH,YAAY,OAA8B;QAyJlC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AAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACnD,KAAK,MAAM,QAAQ,IAAI,MAAM,EAAE;YAC7B,GAAG,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;SAC3C;QACD,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC,EA5ES,OAAO,KAAP,OAAO,QA4EhB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyterlab/rendermime",
|
|
3
|
-
"version": "4.3.0-
|
|
3
|
+
"version": "4.3.0-beta.0",
|
|
4
4
|
"description": "JupyterLab - RenderMime",
|
|
5
5
|
"homepage": "https://github.com/jupyterlab/jupyterlab",
|
|
6
6
|
"bugs": {
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"watch": "tsc -b --watch"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@jupyterlab/apputils": "^4.4.0-
|
|
45
|
-
"@jupyterlab/coreutils": "^6.3.0-
|
|
46
|
-
"@jupyterlab/nbformat": "^4.3.0-
|
|
47
|
-
"@jupyterlab/observables": "^5.3.0-
|
|
48
|
-
"@jupyterlab/rendermime-interfaces": "^3.11.0-
|
|
49
|
-
"@jupyterlab/services": "^7.3.0-
|
|
50
|
-
"@jupyterlab/translation": "^4.3.0-
|
|
44
|
+
"@jupyterlab/apputils": "^4.4.0-beta.0",
|
|
45
|
+
"@jupyterlab/coreutils": "^6.3.0-beta.0",
|
|
46
|
+
"@jupyterlab/nbformat": "^4.3.0-beta.0",
|
|
47
|
+
"@jupyterlab/observables": "^5.3.0-beta.0",
|
|
48
|
+
"@jupyterlab/rendermime-interfaces": "^3.11.0-beta.0",
|
|
49
|
+
"@jupyterlab/services": "^7.3.0-beta.0",
|
|
50
|
+
"@jupyterlab/translation": "^4.3.0-beta.0",
|
|
51
51
|
"@lumino/coreutils": "^2.1.2",
|
|
52
52
|
"@lumino/messaging": "^2.0.1",
|
|
53
53
|
"@lumino/signaling": "^2.1.2",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"lodash.escape": "^4.0.1"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@jupyterlab/testing": "^4.3.0-
|
|
58
|
+
"@jupyterlab/testing": "^4.3.0-beta.0",
|
|
59
59
|
"@types/jest": "^29.2.0",
|
|
60
60
|
"@types/lodash.escape": "^4.0.6",
|
|
61
61
|
"fs-extra": "^10.1.0",
|
package/src/outputmodel.ts
CHANGED
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
| Distributed under the terms of the Modified BSD License.
|
|
4
4
|
|----------------------------------------------------------------------------*/
|
|
5
5
|
import * as nbformat from '@jupyterlab/nbformat';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
IObservableJSON,
|
|
8
|
+
IObservableString,
|
|
9
|
+
ObservableJSON,
|
|
10
|
+
ObservableString
|
|
11
|
+
} from '@jupyterlab/observables';
|
|
7
12
|
import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
|
|
8
13
|
import {
|
|
9
14
|
JSONExt,
|
|
@@ -35,6 +40,11 @@ export interface IOutputModel extends IRenderMime.IMimeModel {
|
|
|
35
40
|
*/
|
|
36
41
|
readonly executionCount: nbformat.ExecutionCount;
|
|
37
42
|
|
|
43
|
+
/**
|
|
44
|
+
* The observable text, present when the output `type` is set to `"stream"`.
|
|
45
|
+
*/
|
|
46
|
+
readonly streamText?: IObservableString;
|
|
47
|
+
|
|
38
48
|
/**
|
|
39
49
|
* Whether the output is trusted.
|
|
40
50
|
*/
|
|
@@ -80,8 +90,14 @@ export class OutputModel implements IOutputModel {
|
|
|
80
90
|
*/
|
|
81
91
|
constructor(options: IOutputModel.IOptions) {
|
|
82
92
|
const { data, metadata, trusted } = Private.getBundleOptions(options);
|
|
83
|
-
this._data = new ObservableJSON({ values: data as JSONObject });
|
|
84
93
|
this._rawData = data;
|
|
94
|
+
if (options.value !== undefined && nbformat.isStream(options.value)) {
|
|
95
|
+
this._text = new ObservableString(
|
|
96
|
+
typeof options.value.text === 'string'
|
|
97
|
+
? options.value.text
|
|
98
|
+
: options.value.text.join('')
|
|
99
|
+
);
|
|
100
|
+
}
|
|
85
101
|
this._metadata = new ObservableJSON({ values: metadata as JSONObject });
|
|
86
102
|
this._rawMetadata = metadata;
|
|
87
103
|
this.trusted = trusted;
|
|
@@ -131,7 +147,7 @@ export class OutputModel implements IOutputModel {
|
|
|
131
147
|
* Dispose of the resources used by the output model.
|
|
132
148
|
*/
|
|
133
149
|
dispose(): void {
|
|
134
|
-
this.
|
|
150
|
+
this._text?.dispose();
|
|
135
151
|
this._metadata.dispose();
|
|
136
152
|
Signal.clearData(this);
|
|
137
153
|
}
|
|
@@ -140,7 +156,11 @@ export class OutputModel implements IOutputModel {
|
|
|
140
156
|
* The data associated with the model.
|
|
141
157
|
*/
|
|
142
158
|
get data(): ReadonlyPartialJSONObject {
|
|
143
|
-
return this.
|
|
159
|
+
return Private.getData(this.toJSON());
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
get streamText(): IObservableString | undefined {
|
|
163
|
+
return this._text;
|
|
144
164
|
}
|
|
145
165
|
|
|
146
166
|
/**
|
|
@@ -159,7 +179,6 @@ export class OutputModel implements IOutputModel {
|
|
|
159
179
|
*/
|
|
160
180
|
setData(options: IRenderMime.IMimeModel.ISetDataOptions): void {
|
|
161
181
|
if (options.data) {
|
|
162
|
-
this._updateObservable(this._data, options.data);
|
|
163
182
|
this._rawData = options.data;
|
|
164
183
|
}
|
|
165
184
|
if (options.metadata) {
|
|
@@ -177,11 +196,14 @@ export class OutputModel implements IOutputModel {
|
|
|
177
196
|
for (const key in this._raw) {
|
|
178
197
|
output[key] = Private.extract(this._raw, key);
|
|
179
198
|
}
|
|
199
|
+
if (this._text !== undefined) {
|
|
200
|
+
output['text'] = this._text.text;
|
|
201
|
+
}
|
|
180
202
|
switch (this.type) {
|
|
181
203
|
case 'display_data':
|
|
182
204
|
case 'execute_result':
|
|
183
205
|
case 'update_display_data':
|
|
184
|
-
output['data'] = this.
|
|
206
|
+
output['data'] = this._rawData as PartialJSONObject;
|
|
185
207
|
output['metadata'] = this.metadata as PartialJSONObject;
|
|
186
208
|
break;
|
|
187
209
|
default:
|
|
@@ -223,7 +245,7 @@ export class OutputModel implements IOutputModel {
|
|
|
223
245
|
private _raw: PartialJSONObject = {};
|
|
224
246
|
private _rawMetadata: ReadonlyPartialJSONObject;
|
|
225
247
|
private _rawData: ReadonlyPartialJSONObject;
|
|
226
|
-
private
|
|
248
|
+
private _text?: IObservableString = undefined;
|
|
227
249
|
private _metadata: IObservableJSON;
|
|
228
250
|
}
|
|
229
251
|
|