UNPKG

3.64 kBTypeScriptView Raw
1import * as nbformat from '@jupyterlab/nbformat';
2import { IObservableString } from '@jupyterlab/observables';
3import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
4import { PartialJSONObject, ReadonlyPartialJSONObject } from '@lumino/coreutils';
5import { ISignal } from '@lumino/signaling';
6/**
7 * The interface for an output model.
8 */
9export interface IOutputModel extends IRenderMime.IMimeModel {
10 /**
11 * A signal emitted when the output model changes.
12 */
13 readonly changed: ISignal<this, void>;
14 /**
15 * The output type.
16 */
17 readonly type: string;
18 /**
19 * The execution count of the model.
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;
26 /**
27 * Whether the output is trusted.
28 */
29 trusted: boolean;
30 /**
31 * Dispose of the resources used by the output model.
32 */
33 dispose(): void;
34 /**
35 * Serialize the model to JSON.
36 */
37 toJSON(): nbformat.IOutput;
38}
39/**
40 * The namespace for IOutputModel sub-interfaces.
41 */
42export declare namespace IOutputModel {
43 /**
44 * The options used to create a notebook output model.
45 */
46 interface IOptions {
47 /**
48 * The raw output value.
49 */
50 value: nbformat.IOutput;
51 /**
52 * Whether the output is trusted. The default is false.
53 */
54 trusted?: boolean;
55 }
56}
57/**
58 * The default implementation of a notebook output model.
59 */
60export declare class OutputModel implements IOutputModel {
61 /**
62 * Construct a new output model.
63 */
64 constructor(options: IOutputModel.IOptions);
65 /**
66 * A signal emitted when the output model changes.
67 */
68 get changed(): ISignal<this, void>;
69 /**
70 * The output type.
71 */
72 readonly type: string;
73 /**
74 * The execution count.
75 */
76 readonly executionCount: nbformat.ExecutionCount;
77 /**
78 * Whether the model is trusted.
79 */
80 readonly trusted: boolean;
81 /**
82 * Dispose of the resources used by the output model.
83 */
84 dispose(): void;
85 /**
86 * The data associated with the model.
87 */
88 get data(): ReadonlyPartialJSONObject;
89 get streamText(): IObservableString | undefined;
90 /**
91 * The metadata associated with the model.
92 */
93 get metadata(): ReadonlyPartialJSONObject;
94 /**
95 * Set the data associated with the model.
96 *
97 * #### Notes
98 * Depending on the implementation of the mime model,
99 * this call may or may not have deferred effects,
100 */
101 setData(options: IRenderMime.IMimeModel.ISetDataOptions): void;
102 /**
103 * Serialize the model to JSON.
104 */
105 toJSON(): nbformat.IOutput;
106 /**
107 * Update an observable JSON object using a readonly JSON object.
108 */
109 private _updateObservable;
110 private _changed;
111 private _raw;
112 private _rawMetadata;
113 private _rawData;
114 private _text?;
115 private _metadata;
116}
117/**
118 * The namespace for OutputModel statics.
119 */
120export declare namespace OutputModel {
121 /**
122 * Get the data for an output.
123 *
124 * @param output - A kernel output message payload.
125 *
126 * @returns - The data for the payload.
127 */
128 function getData(output: nbformat.IOutput): PartialJSONObject;
129 /**
130 * Get the metadata from an output message.
131 *
132 * @param output - A kernel output message payload.
133 *
134 * @returns - The metadata for the payload.
135 */
136 function getMetadata(output: nbformat.IOutput): PartialJSONObject;
137}