The plugin's context
What a running plugin can do.
Every part of a plugin gets the context: run and components as plugin, the others as their first
argument.
| Member | What it does |
|---|---|
pluginId, namespace | |
dataDir | A folder for the plugin's own files. Needs no permission. |
log(...) | Writes to the app's log |
settings() | The plugin's settings, secrets included |
onSettings(listener) | Called after they change. Returns how to stop. |
secrets.get(key), secrets.set(key, value) | Values kept outside the config. undefined deletes one. |
status(text, level) | A line under the plugin: "ok", "info" or "error" |
state.set(id, value) | Publishes a live value |
state.get(key), state.watch(keys, listener) | Reads live values. Those of other plugins need state. |
buttons.list(), buttons.watch(listener) | The buttons that have the plugin's actions |
overlays.show(id, overlay), overlays.hide(id) | Draws over the user's buttons. Needs overlay. |
emit(event, payload) | Sends <namespace>:<event>, which workflows can start on |
vars.get(name), vars.set(name, value) | The user's variables. Needs variables. |
oauth.start(service, { scopes }) | Starts a sign-in. Needs network. |
oauth.refresh(service, refreshToken) | A new access token. Needs network. |
In run
| Field | What it is |
|---|---|
settings | The action's settings, with templates filled in |
plugin | The context |
source | What started the run |
signal | Aborts when the run is canceled |
event | What the trigger sent |
deck | navigate(to, page), brightness() and setBrightness(level) |
It may return { result, undo, label }: what later steps get, how to take it back, and what the history
calls it.