UNPKG

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