waybetter/packages/runtime/README.md
CRT 264f69c745 packages: make runtime and shell publishable to npm
Drop private from @waybetter/runtime and @waybetter/shell (root stays
private), add per-module exports with types/import conditions backed by
a tsc build (rewriteRelativeImportExtensions rewrites .ts specifiers to
.js in dist), files/sideEffects/engines/keywords/publishConfig, a
prepublishOnly that builds and tests, and a README + copied LICENSE per
package. Root gains build:packages and pack:check scripts. dist/ is
gitignored; the desktop app keeps importing raw src/*.ts by relative
path, unaffected.
2026-09-27 22:41:01 +00:00

45 lines
1.9 KiB
Markdown

# @waybetter/runtime
Page runtime core for wayBetter: the shared pieces every
wayBetter site adapter builds on inside the page it extends — one DOM-mutation/animation-frame
hub, one fetch/XHR hub, a plugin API core, an OKLab theme color model, split-pane rail hiding,
link routing, and account change reporting. Zero runtime dependencies.
This package ships plain ESM with `.d.ts` types; there is no bundler-specific build step.
## Install
```sh
npm install @waybetter/runtime
```
## Usage
Each module is a separate subpath export, so you only pull in what you use:
```ts
import { configureRuntime, isSiteUrl, type SiteAdapter } from '@waybetter/runtime/site';
import { watchDom, type DomWatchHandle } from '@waybetter/runtime/domHub';
import { installLinkRouting } from '@waybetter/runtime/linkRouting';
import { buildColorModel, deriveColors } from '@waybetter/runtime/themeTokens';
```
`site.ts` is the composition root: a wayBetter app for one site is mostly a `SiteAdapter` object
built from these pieces, paired with a native `SiteSpec` (Rust) and its Tauri capability files.
See the source comments in `src/` for the contract of each module — they double as the
documentation.
## Modules
- `accountReport` — reports the signed-in account seen in the page's own UI.
- `domHub` — one `MutationObserver` + one animation frame shared by every DOM feature.
- `linkRouting` — routes clicks on the site's own links per the "links to site pages" setting.
- `netHub` — one shared fetch/XHR hook for URL rewrites, gates and passive JSON taps.
- `paneNav` — hides a redundant navigation rail when two panes show the same account.
- `pluginApi` — small helpers (`window.<Runtime>.api`) shared by user JS plugins.
- `site` — the page-side composition root for a site adapter.
- `themeTokens` — the OKLab color model themes are built on.
## License
GPL-3.0-or-later. See [LICENSE](./LICENSE).