Skip to content

windows.check_widget

Renders a widget out of sight in a window and returns what it rendered: the name resolves in the window’s workspace (workspaceId, else the one the window shows), then among the user’s init file’s widgets, so a window without a workspace checks the user’s (PRT-124, PRT-610, DMN-1440).

/** `windows.check_widget` params (PRT-124, PRT-610). */
export type CheckWidgetParams = {
/**
* The widget: `./widgets/<name>`, `omfp:<name>` or a bare `<name>`, resolved in the window's workspace first, then
* among the user's init file's widgets (DMN-1440).
*/
widget: string;
/**
* The window; default: the most recently focused window showing `workspaceId`, else the most recently focused one,
* with or without a workspace.
*/
windowId?: number | null;
/** The workspace whose widgets come first; default: the one the window shows (none: only the user's widgets). */
workspaceId?: string | null;
};
/** `windows.check_widget` result (PRT-124). */
export type WidgetChecked = {
/** The out-of-sight instance as the window saw it when it rendered, failed or ran out of time. */
report: WidgetReport;
/** `false` when the window ran out of time before the widget rendered or failed (`report.state` is `loading`). */
settled: boolean;
windowId: number;
};
/** One widget instance as a window shows it (PRT-043). */
export type WidgetReport = {
/** Console errors and uncaught errors whose stack names the widget's module, oldest first. */
console: string[];
/** The compile stand-in's, import's and error boundary's errors (`file:line:column: message` when known). */
errors: string[];
/** The node's `instance` prop when it is a string, else its reference. */
instance: string;
/** Its `useJob` jobs (AGT-019). */
jobs: WidgetJobReport[];
/** The widget folder's name. */
name: string;
/** The view node's reference (`./widgets/tests`, or `omfp:<name>` overridden by the workspace). */
reference: string;
source: WidgetSource;
state: WidgetReportState;
/** The text the widget renders. */
text: string;
/** The folder version the window imported; `null` while nothing is imported. */
version?: string | null;
};
/** A `useJob` job of a widget instance (AGT-019). */
export type WidgetJobReport = {
command: string;
exitCode?: number | null;
/** How many jobs the instance started for the command. */
runs: number;
signal?: number | null;
startedAt?: number | null;
/** `pending`, `running`, `succeeded` or `failed`. */
status: string;
/** The last output lines (stdout and stderr), oldest first. */
tail: string[];
};
/**
* Where a widget comes from: `workspace` a workspace's declarations (its `views/<id>` topic, served under its id),
* `user` the user host's (the `index` topic's `widgets`, served under the `user` scope, DMN-1290).
*/
export type WidgetSource = "workspace" | "user";
/** Where a widget instance stands in a window (PRT-043). */
export type WidgetReportState = "loading" | "rendered" | "compile_error" | "load_error" | "render_error";