53 lines
2.3 KiB
Markdown
53 lines
2.3 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.
|
|
|
|
## Projects using wayBetter
|
|
|
|
| Project | Target | What it is |
|
|
| --- | --- | --- |
|
|
| [wayBetter for X](https://waybetter.crt.fyi/twttr/) | x.com (website) | Desktop app around the live X: tabs, split panes, real accounts side by side, themes, plugins, drafts and fixes for X's own bugs. The first wayBetter app. |
|
|
|
|
Built something on wayBetter? Add it to this list with a pull request: name and link, what it extends, one line on what it does.
|
|
|
|
## License
|
|
|
|
GPL-3.0-or-later. See [LICENSE](./LICENSE).
|