@dodona/papyros
Version:
Scratchpad for multiple programming languages in the browser.
91 lines (90 loc) • 2.75 kB
TypeScript
import { BackendEvent } from "./BackendEvent";
import { Renderable, RenderOptions } from "./util/Rendering";
/**
* Shape of Error objects that are easy to interpret
*/
export interface FriendlyError {
/**
* The name of the Error
*/
name: string;
/**
* Traceback for where in the code the Error occurred
*/
traceback?: string;
/**
* General information about this type of Error
*/
info?: string;
/**
* Information about what went wrong in this case
*/
what?: string;
/**
* Information about why this is wrong and how to fix it
*/
why?: string;
/**
* Where specifically in the source code the Error occurred
*/
where?: string;
}
/**
* Component for displaying code output or errors to the user
*/
export declare class OutputManager extends Renderable {
/**
* Store the HTML that is rendered to restore when changing language/theme
*/
private content;
/**
* Whether overflow has occurred
*/
private overflown;
/**
* Function to call when the user wants to download overflow results
*/
private downloadCallback;
private _debugMode;
set debugMode(value: boolean);
constructor();
/**
* Retrieve the parent element containing all output parts
*/
private get outputArea();
/**
* Render an element in the next position of the output area
* @param {string} html Safe string version of the next child to render
* @param {boolean} isNewElement Whether this a newly generated element
*/
private renderNextElement;
/**
* Convert a piece of text to a span element for displaying
* @param {string} text The text content for the span
* @param {boolean} ignoreEmpty Whether to remove empty lines in the text
* @param {string} className Optional class name for the span
* @return {string} String version of the created span
*/
private spanify;
/**
* Display output to the user, based on its content type
* @param {BackendEvent} output Event containing the output data
*/
showOutput(output: BackendEvent): void;
/**
* Display to the user that overflow has occurred, limiting the shown output
* @param {function():void | null} downloadCallback Optional callback to download overflow
*/
onOverflow(downloadCallback: (() => void) | null): void;
/**
* Display an error to the user
* @param {BackendEvent} error Event containing the error data
*/
showError(error: BackendEvent): void;
protected _render(options: RenderOptions): void;
/**
* Clear the contents of the output area
*/
reset(): void;
private onRunEnd;
}