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/http
widget:widget/random
widget:widget/types
widget:widget/clocks
widget:widget/logging
widget-context
widget-result
get-name
get-version
get-config-schema
get-run-update-cycle-seconds
run
HTTP interface for widgets. Allows them to make HTTP/HTTPS requests.
type status
u16
record response
HTTP status code
content-length, if known
response body as raw bytes
request: func
response
>get-random: func
Returns a random number generated by a cryptographically secure pseudorandom number generator (CSPRNG)
record datetime
record widget-context
Configuration 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-result
The result of a widget invocation.
type datetime
----
now: func
Allows widgets to write logs to the host
enum level
log: func
widget
type widget-context
#### `type widget-result` [`widget-result`](#widget_result)
## Exported functions from world `widget`
get-name: func
Return the name of the widget
get-version: func
Return the semantic version of the widget
get-config-schema: func
Return the config JSON schema string
get-run-update-cycle-seconds: func
Returns the run update cycle in seconds. With this, widgets can control how frequently they shall be updated.
run: func
Invoke the widget with the given context
context
: widget-context