The SDK for CodeWork desktop widgets. A widget has two halves: a view, a React component in the UI, and an optional backend, an Effect program that runs inside the app server. They talk over the event bus. Built-in widgets in apps/web/src/widgets use it, and third-party widgets will too.
| Import | What it is |
|---|---|
@codeworksh/widget/view |
defineWidget, the shell and frame contexts, useBus, useKv |
@codeworksh/widget/backend |
defineBackend and the Bus, Kv, Codework and Sync services |
@codeworksh/widget/event |
the event log's wire schemas, shared by both halves |
@codeworksh/widget/codework |
host wire records from @codeworksh/schema/host/records, type Api, and helpers |
- Topics are
<package>/<name>, and a widget publishes only under its own package. A backend that tries another package dies, because that is a bug. - A backend reaches CodeWork through the
Codeworkservice, the app's one long-lived connection, rather than its own socket.runis given onlyBus,Kv,CodeworkandSync. react,effectand@phosphor-icons/reactare peer dependencies, so a widget shares the app's copies.
src/view.ts,src/view: the view half.src/backend.ts: the backend half.src/event.ts: the event contract.src/codework.ts: the host wire records (@codeworksh/schema/host/records) andtype Api, re-exported with the helpers clients share.
See desktop internals for how the app server runs backends and the bus replays events.