CellOutput Class#
Represents the output produced by executing a notebook cell.
public sealed record CellOutput : System.IEquatable<Verso.Abstractions.CellOutput>
Inheritance System.Object → CellOutput
Implements System.IEquatable<CellOutput>
Constructors#
CellOutput(string, string, bool, string, string) Constructor#
Represents the output produced by executing a notebook cell.
public CellOutput(string MimeType, string Content, bool IsError=false, string? ErrorName=null, string? ErrorStackTrace=null);
Parameters#
MimeType System.String
The MIME type of Content (e.g. "text/plain", "text/html").
Content System.String
The output content in the format indicated by MimeType.
IsError System.Boolean
Whether this output is an execution failure: an uncaught exception, a compiler error, or a validation error that stopped the cell. Setting it marks the whole cell failed, which the status icon, the command line summary, and the process exit code all follow. Text is not a failure merely because it arrived on standard error, so record that with Channel instead. Defaults to false.
ErrorName System.String
The error type or exception name when IsError is true.
ErrorStackTrace System.String
The stack trace associated with the error, if available.
Fields#
ProgressMimeType Field#
The MIME type carrying a progress payload.
public const string ProgressMimeType = "text/x-verso-progress";
Field Value#
WidgetMimeType Field#
The MIME type of a self-contained widget document: a whole page, carrying its own state and loader, that draws itself once it is running in a browser.
It is kept apart from text/html because it is a document rather than a fragment,
and because its loader resolves paths against the location of the page it runs in. A
surface showing one has to give it a frame with a real address; a surface that cannot
says so rather than pasting the markup inline.
public const string WidgetMimeType = "text/x-verso-widget";
Field Value#
Properties#
Channel Property#
Which of the kernel's text streams this output came from, when it came from one at all. Null for outputs that are not stream text, such as a rendered image or an exception report. Declared here rather than as a constructor parameter so that adding it does not change the signature existing compiled extensions call.
public System.Nullable<Verso.Abstractions.OutputChannel> Channel { get; init; }
Property Value#
System.Nullable<OutputChannel>
Content Property#
The output content in the format indicated by MimeType.
public string Content { get; init; }
Property Value#
ErrorName Property#
The error type or exception name when IsError is true.
public string? ErrorName { get; init; }
Property Value#
ErrorStackTrace Property#
The stack trace associated with the error, if available.
public string? ErrorStackTrace { get; init; }
Property Value#
IsError Property#
Whether this output is an execution failure: an uncaught exception, a compiler error, or a validation error that stopped the cell. Setting it marks the whole cell failed, which the status icon, the command line summary, and the process exit code all follow. Text is not a failure merely because it arrived on standard error, so record that with Channel instead. Defaults to false.
public bool IsError { get; init; }
Property Value#
LiveChannelId Property#
The output channel keeping this output in conversation with the view that draws it, when there is one. Null for the ordinary case of an output that is finished the moment it is written, which is every output that is not live.
Unrelated to Channel despite the similar name: that one records which text stream a line of output came from, and this one names a two-way channel.
Session state rather than document content, so it is never written to a file. A saved notebook holds the last drawn state of a live output and no claim that it is still live, which is what lets the file open on a machine with no kernel for it.
public string? LiveChannelId { get; init; }
Property Value#
MimeType Property#
The MIME type of Content (e.g. "text/plain", "text/html").
public string MimeType { get; init; }
Property Value#
Methods#
Bmp(string) Method#
Creates an image/bmp output from a Base64-encoded string.
public static Verso.Abstractions.CellOutput Bmp(string base64);
Parameters#
base64 System.String
Returns#
Csv(string) Method#
Creates a text/csv output.
public static Verso.Abstractions.CellOutput Csv(string content);
Parameters#
content System.String
Returns#
DescribeProgress(string) Method#
Renders a progress payload as a single line of text, for surfaces with no live indicator to show: an exported page, a terminal, or anything read after the work has finished. Content that cannot be read is returned unchanged rather than throwing, because a progress report is never worth failing on.
public static string DescribeProgress(string content);
Parameters#
content System.String
Returns#
Error(string, string, string) Method#
Creates an error output with the specified message and optional error name.
public static Verso.Abstractions.CellOutput Error(string message, string? errorName=null, string? stackTrace=null);
Parameters#
message System.String
errorName System.String
stackTrace System.String
Returns#
Gif(string) Method#
Creates an image/gif output from a Base64-encoded string.
public static Verso.Abstractions.CellOutput Gif(string base64);
Parameters#
base64 System.String
Returns#
Html(string) Method#
Creates a text/html output.
public static Verso.Abstractions.CellOutput Html(string content);
Parameters#
content System.String
Returns#
Jpeg(string) Method#
Creates an image/jpeg output from a Base64-encoded string.
public static Verso.Abstractions.CellOutput Jpeg(string base64);
Parameters#
base64 System.String
Returns#
Json(string) Method#
Creates an application/json output.
public static Verso.Abstractions.CellOutput Json(string content);
Parameters#
content System.String
Returns#
Mermaid(string) Method#
Creates a text/x-verso-mermaid output.
public static Verso.Abstractions.CellOutput Mermaid(string content);
Parameters#
content System.String
Returns#
Plain(string) Method#
Creates a text/plain output.
public static Verso.Abstractions.CellOutput Plain(string content);
Parameters#
content System.String
Returns#
Png(string) Method#
Creates an image/png output from a Base64-encoded string.
public static Verso.Abstractions.CellOutput Png(string base64);
Parameters#
base64 System.String
Returns#
Progress(string, string, Nullable<int>, bool) Method#
Creates a progress output, which every surface renders as a progress indicator rather than as text.
Report progress by writing this to the same output block repeatedly through
UpdateOutputAsync, so the notebook shows one indicator that advances rather than a
column of stale ones. Send a final value with done set so the indicator
settles instead of appearing to stall.
public static Verso.Abstractions.CellOutput Progress(string activity, string? status=null, System.Nullable<int> percent=null, bool done=false);
Parameters#
activity System.String
What is being done, shown as the label.
status System.String
Optional detail about the current step.
percent System.Nullable<System.Int32>
Completion from 0 to 100, or null when it cannot be known.
done System.Boolean
Whether the work has finished.
Returns#
Stderr(string) Method#
Creates a text/plain output carrying text a kernel wrote to standard error. This does
not fail the cell; use Error(string, string, string) for that.
public static Verso.Abstractions.CellOutput Stderr(string content);
Parameters#
content System.String
Returns#
Stdout(string) Method#
Creates a text/plain output carrying text a kernel wrote to standard output.
public static Verso.Abstractions.CellOutput Stdout(string content);
Parameters#
content System.String
Returns#
Svg(string) Method#
Creates an image/svg+xml output.
public static Verso.Abstractions.CellOutput Svg(string content);
Parameters#
content System.String
Returns#
WebP(string) Method#
Creates an image/webp output from a Base64-encoded string.
public static Verso.Abstractions.CellOutput WebP(string base64);
Parameters#
base64 System.String
Returns#
Widget(string) Method#
Creates a text/x-verso-widget output.
public static Verso.Abstractions.CellOutput Widget(string document);
Parameters#
document System.String
Returns#
Widget(string, string) Method#
Creates a text/x-verso-widget output that stays in conversation with whatever draws
it, over the channel named by channelId.
public static Verso.Abstractions.CellOutput Widget(string document, string? channelId);
Parameters#
document System.String
channelId System.String
Returns#
Remarks#
A separate overload rather than an optional argument on the one above, so that code already compiled against the single-argument form keeps calling the method it was compiled against.
WidgetBody(string) Method#
The drawable part of a widget document: whatever its body element contains.
A surface that is itself a page at a real address, such as an exported file, can put this
straight into its own body instead of giving the widget a frame, and the widget's loader
then resolves against that page. A document this cannot make sense of is returned whole,
since a browser ignores a nested html element rather than choking on it.
public static string WidgetBody(string? document);
Parameters#
document System.String