Widgets¶
A widget is a module exporting render, typed from the endpoint it draws:
// src/widgets/open-count.ts
import type { Scene, WidgetData } from "initiative-plugin-sdk/widget";
import type { openTickets } from "../plugin.js";
export function render(data: WidgetData<typeof openTickets>): Scene {
return { v: 1, scene: { kind: "metric", value: data.values.total ?? 0, label: "Open" } };
}
data.rows holds one entry per index across the endpoint's list returns,
and data.values its single-valued returns. render also receives the tile's
options and { locale, slots }.
The build bundles each widget, with everything it imports, into the one script Initiative runs in a sandbox with no network, DOM or timers, and checks the contract's size cap. A widget imports nothing at run time.