|
@@ -24,44 +24,34 @@ export interface MimeBundle {
|
|
|
}
|
|
|
|
|
|
|
|
|
+/**
|
|
|
+ * The valid output type strings.
|
|
|
+ */
|
|
|
export
|
|
|
-enum OutputType {
|
|
|
- /**
|
|
|
- * The "execute_result" message type from the message spec.
|
|
|
- */
|
|
|
- ExecuteResult,
|
|
|
-
|
|
|
- /**
|
|
|
- * The "display_data" message type from the message spec.
|
|
|
- */
|
|
|
- DisplayData,
|
|
|
+type OutputType = "execute_result" | "display_data" | "stream" | "error";
|
|
|
|
|
|
- /**
|
|
|
- * The "stream" message type from the message spec.
|
|
|
- */
|
|
|
- Stream,
|
|
|
|
|
|
- /**
|
|
|
- * The "error" message type from the message spec.
|
|
|
- */
|
|
|
- Error
|
|
|
-}
|
|
|
+/**
|
|
|
+ * The valid stream type strings.
|
|
|
+ */
|
|
|
+export
|
|
|
+type StreamType = "stdout" | "stderr";
|
|
|
|
|
|
|
|
|
/**
|
|
|
-* The base interface for an output model.
|
|
|
-*/
|
|
|
+ * The base interface for an output model.
|
|
|
+ */
|
|
|
export
|
|
|
class OutputBaseModel {
|
|
|
|
|
|
/**
|
|
|
- * A signal emitted when state of the output changes.
|
|
|
- */
|
|
|
+ * A signal emitted when state of the output changes.
|
|
|
+ */
|
|
|
stateChanged: ISignal<OutputBaseModel, IChangedArgs<any>>;
|
|
|
|
|
|
/**
|
|
|
- * The output type.
|
|
|
- */
|
|
|
+ * The output type.
|
|
|
+ */
|
|
|
outputType: OutputType;
|
|
|
}
|
|
|
|
|
@@ -72,19 +62,19 @@ class OutputBaseModel {
|
|
|
export
|
|
|
class DisplayDataModel extends OutputBaseModel {
|
|
|
/**
|
|
|
- * The raw data for the output.
|
|
|
- */
|
|
|
+ * The raw data for the output.
|
|
|
+ */
|
|
|
data: MimeBundle;
|
|
|
|
|
|
/**
|
|
|
- * Metadata about the output.
|
|
|
- */
|
|
|
+ * Metadata about the output.
|
|
|
+ */
|
|
|
metadata: any;
|
|
|
|
|
|
/**
|
|
|
- * Output type
|
|
|
+ * The output type.
|
|
|
*/
|
|
|
- outputType: OutputType = OutputType.DisplayData;
|
|
|
+ outputType: "display_data";
|
|
|
}
|
|
|
|
|
|
|
|
@@ -92,33 +82,30 @@ class DisplayDataModel extends OutputBaseModel {
|
|
|
* An output model for an execute result.
|
|
|
*/
|
|
|
export
|
|
|
-class ExecuteResultModel extends DisplayDataModel {
|
|
|
+class ExecuteResultModel extends OutputBaseModel {
|
|
|
/**
|
|
|
- * The current execution count.
|
|
|
- */
|
|
|
- executionCount: number; // this is also a property on the cell?
|
|
|
+ * The raw data for the output.
|
|
|
+ */
|
|
|
+ data: MimeBundle;
|
|
|
|
|
|
/**
|
|
|
- * Output type
|
|
|
+ * Metadata about the output.
|
|
|
*/
|
|
|
- outputType: OutputType = OutputType.ExecuteResult;
|
|
|
-}
|
|
|
-
|
|
|
+ metadata: any;
|
|
|
|
|
|
-export
|
|
|
-enum StreamName {
|
|
|
/**
|
|
|
- * The "stdout" stream name from the message spec.
|
|
|
+ * The current execution count.
|
|
|
*/
|
|
|
- StdOut,
|
|
|
+ executionCount: number; // this is also a property on the cell?
|
|
|
|
|
|
/**
|
|
|
- * The "stderr" stream name from the message spec.
|
|
|
+ * The output type.
|
|
|
*/
|
|
|
- StdErr
|
|
|
+ outputType: "execute_result";
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* An output model for stream data.
|
|
|
*/
|
|
@@ -127,7 +114,7 @@ class StreamModel extends OutputBaseModel {
|
|
|
/**
|
|
|
* The type of stream.
|
|
|
*/
|
|
|
- name: StreamName;
|
|
|
+ name: StreamType;
|
|
|
|
|
|
/**
|
|
|
* The text from the stream.
|
|
@@ -135,14 +122,14 @@ class StreamModel extends OutputBaseModel {
|
|
|
text: string;
|
|
|
|
|
|
/**
|
|
|
- * Output type
|
|
|
+ * The output type.
|
|
|
*/
|
|
|
- outputType: OutputType = OutputType.Stream;
|
|
|
+ outputType: "stream";
|
|
|
}
|
|
|
|
|
|
|
|
|
function isStreamModel(model: OutputBaseModel): model is StreamModel {
|
|
|
- return model.outputType === OutputType.Stream;
|
|
|
+ return model.outputType === "stream";
|
|
|
}
|
|
|
|
|
|
|
|
@@ -172,7 +159,7 @@ class ExecuteErrorModel extends OutputBaseModel {
|
|
|
/**
|
|
|
* Output type
|
|
|
*/
|
|
|
- outputType: OutputType = OutputType.Error;
|
|
|
+ outputType: OutputType = "error";
|
|
|
}
|
|
|
|
|
|
|