Skip to content

Latest commit

 

History

History

widget

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Widget

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.

Entry Points

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

Boundaries

  • 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 Codework service, the app's one long-lived connection, rather than its own socket. run is given only Bus, Kv, Codework and Sync.
  • react, effect and @phosphor-icons/react are peer dependencies, so a widget shares the app's copies.

Code Map

See desktop internals for how the app server runs backends and the bus replays events.