Docs menu@domicile-desktop/react
@domicile-desktop/react
React for a Domicile shell or app: mount it on the desktop, read the desktop
from context, and follow its state with hooks. See
With React. Every hook's full
signature and docs ship in the package's .d.ts, so your editor shows them.
Usage
import { mount } from "@domicile-desktop/react/mount";import { useFocusedWindow } from "@domicile-desktop/react/windows";const Focused = () => <p>{useFocusedWindow() ?? "the shell"}</p>;export const Shell = mount(Focused);./elements: JSX types for the engine's<app>and<webview>. Load them once with/// <reference types="@domicile-desktop/react/elements" />../mount:mount(App)is a shell'sShellor an app'smain. DrawsAppsynchronously (the page draws nothing untilShellreturns) in an element of its own withdisplay: contents, underStrictMode, an error boundary that shows what threw, and<DomicileProvider>../nested-shell:<NestedShell shell>runs another shell, such as an npm package'sShellorrunManganese(), inside this one, on the same desktop. It sizes against the element it is placed in. Both shells see every window and bind keys, so draw windows and bind keys in only one of them../domicile-provider:<DomicileProvider domicile>,useDomicile()(a shell'sDomicile; throws under an app's) anduseAppDomicile()../use-watch:useWatch(namespace, type, read),readagain on eachtypeevent, viauseSyncExternalStore.readmust answer the same value until the event; the desktop's lists keep their identity between changes.- Hooks over the desktop's core state, each rerendering on change:
./windows:useWindows,useFocusedWindow./displays:useDisplays./appearance:useAppearance./session:useIdle,useLocked./portals:usePortalRequests,useCapturing,useBoundShortcuts,usePortalWallpaper
- Shared watches, for state a library watches (UPower, BlueZ,
pactl):./shared-watch:sharedWatch(start)runs one watch for every subscriber, from the first to the last../per-desktop:perDesktop(make), one value per desktop../use-shared-watch:useSharedWatch(watch), anduseDeskWatch(desk)for aperDesktopwatch of the desktop above../watch-presence:watchPresence(read, onPresent)looks for hardware in/sysevery 10 seconds;isAbsentsays whether to hide for want of it.- The
system-*packages'/reactuse these:useBattery,useBluetooth,useNetwork,useAudioand more.
./fake-domicile:<FakeDomicile fake>for tests.fakeis aFakeDomicileHost(@domicile-desktop/sdk/fake-host) the test drives; without it, a desktop no test drives.
Dependencies
@domicile-desktop/sdkfor the desktop's types andFakeDomicileHost.@cprussin/option-resultforwatchPresence'sResult.reactandreact-domare peers: the shell's own copies.
Working on this package
For contributors to this repository. Shell authors don't need it.
bun run turbo test --filter @domicile-desktop/react