WIT interface for the interaction between the host application and widgets Inspired by work-in-progress WASI Preview 2 WIT definitions (https://github.com/bytecodealliance/preview2-prototyping/tree/main/wit)
widget:widget/httpwidget:widget/randomwidget:widget/typeswidget:widget/clockswidget:widget/loggingwidget-contextwidget-resultget-nameget-versionget-config-schemaget-run-update-cycle-secondsrunHTTP interface for widgets. Allows them to make HTTP/HTTPS requests.
type statusu16
record responseHTTP status code
content-length, if known
response body as raw bytes
request: funcresponse>get-random: funcReturns a random number generated by a cryptographically secure pseudorandom number generator (CSPRNG)
record datetimerecord widget-contextConfiguration that the widget receives from the host.
last-invocation: datetime
Timestamp of the last widget invocation.
Widget specific configuration serialized as JSON Must comply with the widget's config schema obtained by get-config-schema
record widget-resultThe result of a widget invocation.
type datetime----
now: funcAllows widgets to write logs to the host
enum levellog: funcwidgettype widget-context#### `type widget-result` [`widget-result`](#widget_result)
## Exported functions from world `widget`
get-name: funcReturn the name of the widget
get-version: funcReturn the semantic version of the widget
get-config-schema: funcReturn the config JSON schema string
get-run-update-cycle-seconds: funcReturns the run update cycle in seconds. With this, widgets can control how frequently they shall be updated.
run: funcInvoke the widget with the given context
context: widget-context