Widget Definition
Widgets are registered through makeWidgetDef(...).
Required Shape
import { makeWidgetDef } from "@ska-octopus-widget-sdk/widget-sdk";
export const definition = makeWidgetDef({
key: "my-widget",
label: "My Widget",
component: MyWidget,
layout: { w: 6, h: 4, minW: 4, minH: 3 },
config: { schema: mySchema },
polls: true,
docsUrl: "https://developer.skao.int/projects/my-widget/",
});
Field Guide
Field |
Required |
Notes |
|---|---|---|
|
Yes |
Stable unique identifier for the widget |
|
Yes (recommended) |
Display name in dashboard UI |
|
Yes |
React component rendered by host |
|
Yes (recommended) |
Default size and constraints |
|
Yes (recommended) |
Source for config form and defaults |
|
No |
Signals polling/subscription behavior |
|
No |
Backend stream dependencies |
|
No |
Link to widget docs |
|
No |
Usually inherited from package version |
Real Examples
From ska-octopus-components-table-widget/src/index.ts:
Uses
INPUT_DEVICES,INPUT_ATTRIBUTES, andINPUT_STRINGSPersists table config (
columnOrder,columnWidths,sortKey,sortDir)Sets
polls: trueand a widget specificdocsUrl
From ska-octopus-grid-widget/src/index.ts:
Uses
INPUT_TANGO_ATTRIBUTESandINPUT_MULTIPLE_TANGO_ATTRIBUTESUses dynamic selectors with
WORKSPACESandVARIABLESExposes click driven workspace and variable behavior
Host Registration
Many widgets use a guard loop so registration waits for Octopus.registerWidget:
(function wait(h: any) {
if (typeof h.registerWidget === "function") {
h.registerWidget(definition as any);
} else {
setTimeout(wait, 50, h);
}
})((globalThis as any).Octopus || ((globalThis as any).Octopus = {}));
Recommendations
Keep all defaults in schema fields whenever possible.
Keep
keyimmutable after release.Use
docsUrlfor user support and discoverability.Use
deriveConfigFields(schema)only when you need explicit inspection/debugging.