Compare commits

..

No commits in common. "0e344ee1192e906e4f113cbef2aa8ed73d2f6e26" and "6d05240afcd93708137cb8957f9df9ef414e017d" have entirely different histories.

17 changed files with 180 additions and 161 deletions

View file

@ -1,4 +1,4 @@
<p align="center"><img src="assets/readme/hero.webp" width="880" alt="wayBetter for X, the first app built on wayBetter: three accounts side by side in one window"></p> <p align="center"><img src="assets/readme/hero.webp" width="880" alt="wayBetter, the framework, and wayBetter for X, the first app built on it"></p>
<h1 align="center">wayBetter</h1> <h1 align="center">wayBetter</h1>
@ -13,12 +13,6 @@ GPL-3.0-or-later · <code>npm create waybetter</code></p>
<a href="docs/STRING-PACKS.md">String packs</a> · <a href="docs/STRING-PACKS.md">String packs</a> ·
<a href="https://git.crt.fyi/CRT/waybetter-for-x">wayBetter for X</a></p> <a href="https://git.crt.fyi/CRT/waybetter-for-x">wayBetter for X</a></p>
<p align="center"><a href="https://www.npmjs.com/package/waybetter"><img src="https://img.shields.io/npm/v/waybetter?label=npm&color=cb3837" alt="npm"></a>
<a href="LICENSE"><img src="https://img.shields.io/badge/license-GPL--3.0--or--later-blue" alt="license: GPL-3.0-or-later"></a>
<a href="packages/waybetter/package.json"><img src="https://img.shields.io/badge/runtime%20dependencies-0-brightgreen" alt="runtime dependencies: 0"></a>
<img src="https://img.shields.io/badge/Tauri-2-24c8db" alt="Tauri 2">
<img src="https://img.shields.io/badge/platforms-macOS%20%7C%20Windows%20%7C%20Linux-informational" alt="platforms: macOS, Windows, Linux"></p>
You bring a site and a small adapter that says what the site is. wayBetter gives you the rest: a You bring a site and a small adapter that says what the site is. wayBetter gives you the rest: a
Tauri 2 window with tabs, split panes and every account signed in side by side; a page runtime with Tauri 2 window with tabs, split panes and every account signed in side by side; a page runtime with
a plugin API, a theme engine and string packs; a signed Store with a safe install screen; backups, a plugin API, a theme engine and string packs; a signed Store with a safe install screen; backups,
@ -35,6 +29,8 @@ encrypted sync and signed updates; and the tooling to scaffold, sign, scan and r
## How it fits together ## How it fits together
<p align="center"><img src="assets/readme/architecture.svg" width="880" alt="Architecture: a Tauri 2 window with a trusted shell webview and untrusted site-tab webviews running the page runtime, the Rust host underneath that re-checks every command, the app's adapter on the side and the waybetter tooling"></p>
A wayBetter app is one Tauri 2 window with several webviews. The framework has one piece for each A wayBetter app is one Tauri 2 window with several webviews. The framework has one piece for each
layer and does not need to know which site you wrap. layer and does not need to know which site you wrap.
@ -52,7 +48,7 @@ Details of every module are in [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md).
npm create waybetter app kickapp -- --site kick.com --name "wayBetter for Kick" --yes npm create waybetter app kickapp -- --site kick.com --name "wayBetter for Kick" --yes
``` ```
![npm create waybetter app: Created a wayBetter app in kickapp (32 files), then the next steps: cd kickapp, add the framework as a git submodule, npm install, npm run build, npm run tauri dev](assets/readme/term/create-app.webp) <p align="center"><img src="assets/readme/create-terminal.svg" width="820" alt="Terminal output: Created a wayBetter app in kickapp (32 files), then the next steps: cd kickapp, add the framework as a git submodule, npm install, npm run build, npm run tauri dev"></p>
The same tool starts a plugin or a theme: The same tool starts a plugin or a theme:
@ -61,8 +57,6 @@ npm create waybetter plugin -- --name "Hide Trends" # add --ts for Ty
npm create waybetter theme -- --name "Midnight Mint" --accent "#3ddc97" npm create waybetter theme -- --name "Midnight Mint" --accent "#3ddc97"
``` ```
![npm create waybetter plugin: a Hide Trends plugin file and how to install it](assets/readme/term/create-plugin.webp)
The app scaffold adds the framework as a git submodule at `waybetter/` by default (`--host-source The app scaffold adds the framework as a git submodule at `waybetter/` by default (`--host-source
path` and `--host-source git` are the alternatives). After `npm run tauri dev`, replace the path` and `--host-source git` are the alternatives). After `npm run tauri dev`, replace the
placeholder selectors in `src/site.ts` and `src-tauri/src/site.rs`. All flags: placeholder selectors in `src/site.ts` and `src-tauri/src/site.rs`. All flags:
@ -71,7 +65,7 @@ placeholder selectors in `src/site.ts` and `src-tauri/src/site.rs`. All flags:
Inside an app, plugins and themes are plain files, the docs and examples are built in, and developer Inside an app, plugins and themes are plain files, the docs and examples are built in, and developer
mode reloads them as you save: mode reloads them as you save:
![Settings, Make in wayBetter for X: one-line commands to start a plugin, a TypeScript plugin, a theme or a new app, and the example plugins next to the reference docs](assets/readme/make.webp) <video src="/CRT/waybetter/media/branch/main/assets/readme/make.mp4" poster="/CRT/waybetter/media/branch/main/assets/readme/make.webp" autoplay loop muted playsinline width="860"></video>
## Packages ## Packages
@ -87,8 +81,8 @@ mode reloads them as you save:
<table> <table>
<tr> <tr>
<td width="50%"><a href="https://git.crt.fyi/CRT/waybetter-for-x"><img src="assets/readme/showcase-windows98.webp" alt="wayBetter for X in the Windows 98 theme, next to its Appearance settings"></a></td> <td width="50%"><a href="https://git.crt.fyi/CRT/waybetter-for-x"><img src="assets/readme/showcase-panes.webp" alt="wayBetter for X: a theme per pane, two accounts in one window"></a></td>
<td width="50%"><a href="https://git.crt.fyi/CRT/waybetter-for-x"><img src="assets/readme/showcase-themes.webp" alt="wayBetter for X in four of its fourteen themes: Terminal, Paper, Frutiger Aero and Nord"></a></td> <td width="50%"><a href="https://git.crt.fyi/CRT/waybetter-for-x"><img src="assets/readme/showcase-themes.webp" alt="wayBetter for X: fourteen themes, each a full redesign"></a></td>
</tr> </tr>
<tr> <tr>
<td colspan="2"><b><a href="https://git.crt.fyi/CRT/waybetter-for-x">wayBetter for X</a></b> (x.com; macOS, Windows, Linux). Tabs, split panes, <td colspan="2"><b><a href="https://git.crt.fyi/CRT/waybetter-for-x">wayBetter for X</a></b> (x.com; macOS, Windows, Linux). Tabs, split panes,
@ -247,9 +241,6 @@ bun run test:create # scaffolds each kind into temp folders and checks them a
`test:create` also runs `cargo check` on a generated app (about a minute cold); `test:create` also runs `cargo check` on a generated app (about a minute cold);
`WAYBETTER_SKIP_CARGO_CHECK=1` skips that step. Requires Bun 1.4.2+, Node 24+ and Rust 1.88+. `WAYBETTER_SKIP_CARGO_CHECK=1` skips that step. Requires Bun 1.4.2+, Node 24+ and Rust 1.88+.
The README's terminal images are real output: `node tools/readme-term-shots.mjs` runs the commands and
redraws `assets/readme/term/` (Google Chrome and cwebp).
## Docs ## Docs
- [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md): every module of the host, runtime and shell - [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md): every module of the host, runtime and shell

View file

@ -0,0 +1,127 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 760" width="1200" height="760" role="img" aria-label="wayBetter architecture: one Tauri 2 window with a trusted shell webview and one webview per site tab, a Rust host underneath, your adapter on the side, and the waybetter command for store, release and build tooling">
<defs>
<linearGradient id="bg" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="#0b1020"/>
<stop offset="1" stop-color="#06070c"/>
</linearGradient>
<radialGradient id="glow" cx="0.5" cy="0" r="0.7">
<stop offset="0" stop-color="#1d3a8a" stop-opacity="0.55"/>
<stop offset="1" stop-color="#1d3a8a" stop-opacity="0"/>
</radialGradient>
<linearGradient id="accent" x1="0" y1="0" x2="1" y2="0">
<stop offset="0" stop-color="#3b82f6"/>
<stop offset="0.55" stop-color="#22d3ee"/>
<stop offset="1" stop-color="#a855f7"/>
</linearGradient>
<marker id="arr" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M0 0L10 5L0 10z" fill="#64748b"/>
</marker>
<style>
.t{font-family:ui-sans-serif,"Segoe UI",system-ui,-apple-system,Helvetica,Arial,sans-serif;fill:#e6e9f2}
.m{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace}
.h{font-size:22px;font-weight:700;letter-spacing:-0.01em}
.k{font-size:12px;font-weight:600;letter-spacing:0.14em;fill:#7dd3fc}
.s{font-size:14px;fill:#a3acc2}
.c{font-size:13px;fill:#cbd5e1}
.box{fill:#0f1626;stroke:#24304a;stroke-width:1.2}
.trust{fill:#101b33;stroke:#3b82f6;stroke-width:1.4}
.site{fill:#140f26;stroke:#7c3aed;stroke-width:1.4}
.chip{fill:#17213a;stroke:#2b3a5c}
.ln{stroke:#64748b;stroke-width:1.4;fill:none}
.dash{stroke-dasharray:5 5}
</style>
</defs>
<rect width="1200" height="760" rx="18" fill="url(#bg)"/>
<rect width="1200" height="380" rx="18" fill="url(#glow)"/>
<!-- title -->
<text class="t k" x="48" y="54">— ARCHITECTURE</text>
<text class="t" x="48" y="92" font-size="32" font-weight="760" letter-spacing="-0.02em">One window, three layers, one small adapter.</text>
<rect x="48" y="104" width="560" height="3" rx="1.5" fill="url(#accent)"/>
<!-- the site -->
<rect x="48" y="138" width="760" height="64" rx="12" fill="none" stroke="#334155" stroke-dasharray="6 6"/>
<text class="t h" x="72" y="170" font-size="18">The website you already use</text>
<text class="t s" x="72" y="190">loaded live from its exact https origin, never copied: x.com, kick.com, …</text>
<!-- window -->
<rect x="48" y="226" width="760" height="300" rx="16" class="box"/>
<text class="t k" x="72" y="256">TAURI 2 WINDOW · SYSTEM WEBVIEW</text>
<!-- shell -->
<rect x="72" y="272" width="300" height="234" rx="12" class="trust"/>
<text class="t h" x="92" y="304">Shell</text>
<text class="t m s" x="92" y="326" font-size="12">packages/shell · local, trusted</text>
<g class="t c">
<text x="92" y="356">Tabs, split panes, address bar</text>
<text x="92" y="380">Command palette, accounts, decks</text>
<text x="92" y="404">Settings panel, theme builder</text>
<text x="92" y="428">Store and the install screen</text>
<text x="92" y="452">Workspaces, backup, updates</text>
</g>
<text class="t s" x="92" y="488" font-size="12">the only webview allowed to change anything</text>
<!-- tabs -->
<rect x="392" y="272" width="396" height="234" rx="12" class="site"/>
<text class="t h" x="412" y="304">Site tabs</text>
<text class="t m s" x="412" y="326" font-size="12">one webview + profile per tab · packages/runtime</text>
<g>
<rect x="412" y="342" width="110" height="30" rx="8" class="chip"/><text class="t c" x="425" y="362">Plugin API</text>
<rect x="530" y="342" width="106" height="30" rx="8" class="chip"/><text class="t c" x="543" y="362">Theme engine</text>
<rect x="644" y="342" width="124" height="30" rx="8" class="chip"/><text class="t c" x="657" y="362">String packs</text>
<rect x="412" y="380" width="110" height="30" rx="8" class="chip"/><text class="t c" x="425" y="400">DOM hub</text>
<rect x="530" y="380" width="106" height="30" rx="8" class="chip"/><text class="t c" x="543" y="400">Fetch / XHR hub</text>
<rect x="644" y="380" width="124" height="30" rx="8" class="chip"/><text class="t c" x="657" y="400">Link routing</text>
<rect x="412" y="418" width="110" height="30" rx="8" class="chip"/><text class="t c" x="425" y="438">Accounts</text>
<rect x="530" y="418" width="106" height="30" rx="8" class="chip"/><text class="t c" x="543" y="438">UI kit</text>
<rect x="644" y="418" width="124" height="30" rx="8" class="chip"/><text class="t c" x="657" y="438">Deck columns</text>
</g>
<text class="t s" x="412" y="488" font-size="12">untrusted: may only report about itself</text>
<!-- arrows site -> tabs -->
<path class="ln" d="M590 202 V268" marker-end="url(#arr)"/>
<!-- host -->
<rect x="48" y="550" width="760" height="166" rx="16" class="box"/>
<text class="t k" x="72" y="580">NATIVE HOST · RUST</text>
<text class="t h" x="72" y="612">waybetter-host</text>
<text class="t m s" x="258" y="612" font-size="12">crates/waybetter-host</text>
<g class="t c">
<text x="72" y="644">Every command re-checks its caller (webview label, exact origin)</text>
<text x="72" y="668">Profiles, settings, plugins, themes, fonts, workspaces</text>
<text x="72" y="692">Signed Store (Ed25519), backup, encrypted sync, signed updates</text>
</g>
<path class="ln" d="M222 506 V546" marker-end="url(#arr)" marker-start="url(#arr)"/>
<path class="ln dash" d="M590 506 V546" marker-end="url(#arr)"/>
<text class="t s" x="236" y="532" font-size="12">all commands</text>
<text class="t s" x="604" y="532" font-size="12">a short, reviewed list</text>
<!-- adapter -->
<rect x="836" y="138" width="316" height="300" rx="16" fill="#0f1a1a" stroke="#14b8a6" stroke-width="1.4"/>
<text class="t k" x="860" y="168" style="fill:#5eead4">YOUR APP</text>
<text class="t h" x="860" y="200">The adapter</text>
<text class="t s" x="860" y="222">what only your site knows</text>
<rect x="860" y="242" width="268" height="52" rx="10" class="chip"/>
<text class="t m c" x="876" y="264">site.rs · SiteSpec</text>
<text class="t s" x="876" y="283" font-size="12">hosts, account rules</text>
<rect x="860" y="304" width="268" height="52" rx="10" class="chip"/>
<text class="t m c" x="876" y="326">site.ts · SiteAdapter</text>
<text class="t s" x="876" y="345" font-size="12">selectors, API marks, links</text>
<rect x="860" y="366" width="268" height="52" rx="10" class="chip"/>
<text class="t m c" x="876" y="388">capabilities/*.json</text>
<text class="t s" x="876" y="407" font-size="12">who may call what</text>
<path class="ln dash" d="M836 290 H812" marker-end="url(#arr)"/>
<!-- tooling -->
<rect x="836" y="462" width="316" height="254" rx="16" fill="#151022" stroke="#a855f7" stroke-width="1.4"/>
<text class="t k" x="860" y="492" style="fill:#d8b4fe">NPM · waybetter</text>
<text class="t h" x="860" y="524">The tooling</text>
<g class="t m c">
<text x="860" y="558">npm create waybetter</text>
<text x="860" y="584">waybetter dev --watch</text>
<text x="860" y="610">waybetter store build|sign|verify</text>
<text x="860" y="636">waybetter strings check</text>
<text x="860" y="662">waybetter release</text>
<text x="860" y="688">waybetter build-env</text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.4 KiB

View file

@ -0,0 +1,29 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 400" width="1000" height="400" role="img" aria-label="Terminal: npm create waybetter app kickapp creates a wayBetter app in kickapp (32 files) and prints the next steps">
<defs>
<linearGradient id="bg" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="#0d1222"/>
<stop offset="1" stop-color="#080a12"/>
</linearGradient>
<style>
.m{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace;font-size:15px;fill:#cbd5e1}
.p{fill:#22c55e}.d{fill:#7c8aa5}.o{fill:#e6e9f2;font-weight:600}.a{fill:#7dd3fc}
</style>
</defs>
<rect width="1000" height="400" rx="14" fill="url(#bg)" stroke="#24304a"/>
<rect width="1000" height="36" rx="14" fill="#121a2e"/>
<rect y="22" width="1000" height="14" fill="#121a2e"/>
<circle cx="22" cy="18" r="6" fill="#ef4444" opacity=".8"/><circle cx="42" cy="18" r="6" fill="#f59e0b" opacity=".8"/><circle cx="62" cy="18" r="6" fill="#22c55e" opacity=".8"/>
<text class="m d" x="500" y="23" text-anchor="middle" font-size="13">npm create waybetter</text>
<g class="m">
<text x="28" y="76"><tspan class="p">$</tspan> npm create waybetter app kickapp -- --site kick.com --name "wayBetter for Kick" --yes</text>
<text x="28" y="120" class="o">Created a wayBetter app in kickapp (32 files).</text>
<text x="28" y="160">Next:</text>
<text x="52" y="186"><tspan class="a">cd kickapp</tspan></text>
<text x="52" y="210"><tspan class="a">git init &amp;&amp; git submodule add https://git.crt.fyi/CRT/waybetter.git waybetter</tspan></text>
<text x="52" y="234"><tspan class="a">npm install</tspan></text>
<text x="52" y="258"><tspan class="a">npm run build</tspan></text>
<text x="52" y="282"><tspan class="a">npm run tauri dev</tspan></text>
<text x="52" y="306" class="d">then replace the PLACEHOLDER selectors in src/site.ts and src-tauri/src/site.rs</text>
<text x="28" y="356"><tspan class="p">$</tspan> <tspan class="d">▍</tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Before After
Before After

BIN
assets/readme/make.mp4 Normal file

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 43 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

View file

@ -1,11 +0,0 @@
$ npm create waybetter app kickapp -- --site kick.com --name "wayBetter for Kick" --yes
Created a wayBetter app in kickapp (32 files).
Next:
cd kickapp
git init && git submodule add https://git.crt.fyi/CRT/waybetter.git waybetter
npm install
npm run build
npm run tauri dev
then replace the PLACEHOLDER selectors in src/site.ts and src-tauri/src/site.rs

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

View file

@ -1,7 +0,0 @@
$ npm create waybetter plugin -- --name "Hide Trends"
Created a wayBetter plugin in hide-trends (2 files).
Next:
cd hide-trends
copy hide-trends.plugin.js into wayBetter → Plugins → Open folder, then Rescan

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

View file

@ -1046,9 +1046,8 @@ async fn open_panel(webview: Webview, app: AppHandle, section: Option<String>) -
// --------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------
// Tab webviews // Tab webviews
/// Linux and macOS: the page-level part of a tab's `on_navigation`, run when the main frame starts /// Linux: the page-level part of a tab's `on_navigation`, run when the main frame starts loading
/// loading `url` (WebKitGTK's navigation callback, and wry's WKWebView one, cannot tell iframes from /// `url` (WebKitGTK's navigation callback cannot tell iframes from the page). Returns false when
/// the page). Returns false when
/// the load was redirected (a legacy domain) or stopped and handed to the browser. /// the load was redirected (a legacy domain) or stopped and handed to the browser.
fn main_frame_started(app: &AppHandle, site: &SiteSpec, hooks: &dyn SiteHooks, tab: &Webview, url: &Url) -> bool { fn main_frame_started(app: &AppHandle, site: &SiteSpec, hooks: &dyn SiteHooks, tab: &Webview, url: &Url) -> bool {
static ON_SITE: std::sync::OnceLock<Mutex<HashMap<String, bool>>> = std::sync::OnceLock::new(); static ON_SITE: std::sync::OnceLock<Mutex<HashMap<String, bool>>> = std::sync::OnceLock::new();
@ -1106,8 +1105,8 @@ fn tab_builder(app: &AppHandle, hooks: &Arc<dyn SiteHooks>, tab: &NewTab, url: U
if url.scheme() == "about" { if url.scheme() == "about" {
return true; return true;
} }
// WebKit (GTK and macOS): possibly an iframe's own document (see below). // WebKitGTK: possibly an iframe's own document (see below).
if cfg!(any(target_os = "linux", target_os = "macos")) && matches!(url.scheme(), "blob" | "data") { if cfg!(target_os = "linux") && matches!(url.scheme(), "blob" | "data") {
return true; return true;
} }
open_external(app, url); open_external(app, url);
@ -1117,10 +1116,7 @@ fn tab_builder(app: &AppHandle, hooks: &Arc<dyn SiteHooks>, tab: &NewTab, url: U
// asks only for the page): a signed-out page embedding a sign-in iframe would get that // asks only for the page): a signed-out page embedding a sign-in iframe would get that
// iframe's URL as the tab's address. On Linux the page-level work below runs from // iframe's URL as the tab's address. On Linux the page-level work below runs from
// on_page_load (Started), which is the main frame only. // on_page_load (Started), which is the main frame only.
// macOS: wry asks this for every WKNavigationAction, iframes included (no targetFrame if cfg!(target_os = "linux") {
// check), so an embedded player's URL became the tab's address and its loading flag never
// cleared (found 2026-10-11 with Chat+ link previews' YouTube frame). Same treatment.
if cfg!(any(target_os = "linux", target_os = "macos")) {
return true; return true;
} }
if let Some(site_url) = nav_hooks.canonical_url(url) { if let Some(site_url) = nav_hooks.canonical_url(url) {
@ -1161,7 +1157,7 @@ fn tab_builder(app: &AppHandle, hooks: &Arc<dyn SiteHooks>, tab: &NewTab, url: U
}) })
.on_page_load(move |tab, payload| { .on_page_load(move |tab, payload| {
let app = &load_app; let app = &load_app;
if cfg!(any(target_os = "linux", target_os = "macos")) if cfg!(target_os = "linux")
&& matches!(payload.event(), PageLoadEvent::Started) && matches!(payload.event(), PageLoadEvent::Started)
&& !main_frame_started(app, site, &*load_hooks, &tab, payload.url()) && !main_frame_started(app, site, &*load_hooks, &tab, payload.url())
{ {

View file

@ -241,19 +241,19 @@ mod tests {
} }
fn account(handle: &str) -> Account { fn account(handle: &str) -> Account {
Account { handle: handle.into(), name: "Sample".into(), avatar: Some("https://pbs.twimg.com/profile_images/1/a_normal.jpg".into()), signed_in: false } Account { handle: handle.into(), name: "Fishies".into(), avatar: Some("https://pbs.twimg.com/profile_images/1/a_normal.jpg".into()), signed_in: false }
} }
#[test] #[test]
fn a_seen_login_names_the_profile_and_persists_a_sign_out() { fn a_seen_login_names_the_profile_and_persists_a_sign_out() {
let mut settings = ProfileSettings { profiles: vec![profile("default"), profile("p1")], active: "default".into() }; let mut settings = ProfileSettings { profiles: vec![profile("default"), profile("p1")], active: "default".into() };
assert!(settings.observe("p1", AccountSeen::SignedIn(account("@otheraccount")), RULES)); assert!(settings.observe("p1", AccountSeen::SignedIn(account("@playfishies")), RULES));
let seen = settings.profiles[1].account.clone().unwrap(); let seen = settings.profiles[1].account.clone().unwrap();
assert_eq!((seen.handle.as_str(), seen.signed_in, settings.profiles[1].name.as_str()), ("otheraccount", true, "Sample")); assert_eq!((seen.handle.as_str(), seen.signed_in, settings.profiles[1].name.as_str()), ("playfishies", true, "Fishies"));
// The same report again changes nothing (no disk write). // The same report again changes nothing (no disk write).
assert!(!settings.observe("p1", AccountSeen::SignedIn(account("otheraccount")), RULES)); assert!(!settings.observe("p1", AccountSeen::SignedIn(account("playfishies")), RULES));
assert!(settings.observe("p1", AccountSeen::SignedOut, RULES)); assert!(settings.observe("p1", AccountSeen::SignedOut, RULES));
assert_eq!(settings.profiles[1].account.as_ref().map(|a| (a.handle.as_str(), a.signed_in)), Some(("otheraccount", false))); assert_eq!(settings.profiles[1].account.as_ref().map(|a| (a.handle.as_str(), a.signed_in)), Some(("playfishies", false)));
assert!(!settings.observe("nope", AccountSeen::SignedOut, RULES)); assert!(!settings.observe("nope", AccountSeen::SignedOut, RULES));
} }
@ -266,7 +266,7 @@ mod tests {
bare.avatar = None; bare.avatar = None;
settings.observe("default", AccountSeen::SignedIn(bare), RULES); settings.observe("default", AccountSeen::SignedIn(bare), RULES);
let kept = settings.profiles[0].account.clone().unwrap(); let kept = settings.profiles[0].account.clone().unwrap();
assert_eq!((kept.name.as_str(), kept.avatar.is_some()), ("Sample", true)); assert_eq!((kept.name.as_str(), kept.avatar.is_some()), ("Fishies", true));
} }
#[test] #[test]
@ -284,12 +284,12 @@ mod tests {
#[test] #[test]
fn a_shell_save_keeps_the_native_accounts() { fn a_shell_save_keeps_the_native_accounts() {
let mut current = ProfileSettings { profiles: vec![profile("default"), profile("p1")], active: "default".into() }; let mut current = ProfileSettings { profiles: vec![profile("default"), profile("p1")], active: "default".into() };
current.observe("p1", AccountSeen::SignedIn(account("otheraccount")), RULES); current.observe("p1", AccountSeen::SignedIn(account("playfishies")), RULES);
let mut incoming = ProfileSettings { profiles: vec![profile("default"), profile("p1")], active: "p1".into() }; let mut incoming = ProfileSettings { profiles: vec![profile("default"), profile("p1")], active: "p1".into() };
incoming.profiles[0].account = Some(account("forged")); incoming.profiles[0].account = Some(account("forged"));
let kept = incoming.keep_accounts_from(&current); let kept = incoming.keep_accounts_from(&current);
assert_eq!(kept.profiles[0].account, None); assert_eq!(kept.profiles[0].account, None);
assert_eq!(kept.profiles[1].account.as_ref().map(|a| a.handle.as_str()), Some("otheraccount")); assert_eq!(kept.profiles[1].account.as_ref().map(|a| a.handle.as_str()), Some("playfishies"));
} }
#[test] #[test]

View file

@ -4,11 +4,10 @@
.bmk-intro p { margin: 0 0 10px; max-width: 70ch; line-height: 1.55; } .bmk-intro p { margin: 0 0 10px; max-width: 70ch; line-height: 1.55; }
.bmk-muted, .bmk-intro .bmk-muted { color: var(--c-muted); font-size: 12px; } .bmk-muted, .bmk-intro .bmk-muted { color: var(--c-muted); font-size: 12px; }
.bmk-commands { display: grid; gap: 6px; margin: 0 0 10px; padding: 0; list-style: none; } .bmk-commands { display: grid; gap: 6px; margin: 0 0 10px; padding: 0; list-style: none; }
.bmk-commands li { display: grid; grid-template-columns: minmax(120px, 190px) minmax(0, 1fr) auto; align-items: center; gap: 10px; padding-block: 6px; padding-inline: 12px 6px; border: 1px solid var(--c-line-soft); border-radius: calc(10px * var(--bt-rs, 1)); background: var(--c-card); } .bmk-commands li { display: grid; grid-template-columns: minmax(120px, 190px) 1fr auto; align-items: center; gap: 10px; padding-block: 6px; padding-inline: 12px 6px; border: 1px solid var(--c-line-soft); border-radius: calc(10px * var(--bt-rs, 1)); background: var(--c-card); }
.bmk-commands li > span { color: var(--c-muted); font-size: 12px; } .bmk-commands li > span { color: var(--c-muted); font-size: 12px; }
/* The whole command stays visible: it wraps (a hidden scrollbar used to cut it off with no sign more was there). */ .bmk-commands li > code { overflow-x: auto; white-space: nowrap; background: transparent; border: 0; padding: 0; color: var(--c-text); scrollbar-width: none; }
.bmk-commands li > code { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; background: transparent; border: 0; padding: 0; color: var(--c-text); } @container panel (max-width: 560px) { .bmk-commands li { grid-template-columns: 1fr auto; } .bmk-commands li > span { grid-column: 1 / -1; } }
@container panel (max-width: 560px) { .bmk-commands li { grid-template-columns: minmax(0, 1fr) auto; } .bmk-commands li > span { grid-column: 1 / -1; } }
.bmk-tabs { margin: 0 2px 16px; } .bmk-tabs { margin: 0 2px 16px; }
.bmk-doc-link { display: inline; padding: 0; border: 0; background: none; color: var(--c-accent); font: inherit; cursor: pointer; text-decoration: underline; text-decoration-color: rgb(var(--c-accent-rgb) / .35); text-underline-offset: 2px; } .bmk-doc-link { display: inline; padding: 0; border: 0; background: none; color: var(--c-accent); font: inherit; cursor: pointer; text-decoration: underline; text-decoration-color: rgb(var(--c-accent-rgb) / .35); text-underline-offset: 2px; }
.bmk-doc-link:hover { text-decoration-color: currentColor; } .bmk-doc-link:hover { text-decoration-color: currentColor; }

View file

@ -1,105 +0,0 @@
#!/usr/bin/env node
// Terminal shots for the README: runs real `create-waybetter` commands in a throwaway folder and saves, per shot,
// assets/readme/term/<name>.txt the cleaned output (first line "$ <command>", no ANSI, temp paths made short)
// assets/readme/term/<name>.webp that text drawn as a terminal (dark), rendered by headless Google Chrome and
// encoded with cwebp (the smaller of lossy q80 and lossless)
// Fails when a command exits non-zero, its output lacks its expected marker, or Chrome / cwebp hang.
// node tools/readme-term-shots.mjs all shots
// node tools/readme-term-shots.mjs --text only the .txt files (no browser)
// node tools/readme-term-shots.mjs app only these shots
// Needs Google Chrome (or CHROME=<path>) and cwebp on PATH for the images.
import { spawnSync } from 'node:child_process';
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
const CLI = join(ROOT, 'packages', 'create-waybetter', 'bin', 'create-waybetter.js');
const OUT = join(ROOT, 'assets', 'readme', 'term');
const CHROME = process.env.CHROME || '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
const TIMEOUT_MS = 60_000;
const log = m => console.log(`${new Date().toISOString().slice(11, 19)} [term-shots] ${m}`);
const SHOTS = [
{ name: 'create-app', title: 'npm create waybetter', marker: 'Created a wayBetter app',
shown: 'npm create waybetter app kickapp -- --site kick.com --name "wayBetter for Kick" --yes',
argv: ['app', 'kickapp', '--site', 'kick.com', '--name', 'wayBetter for Kick', '--yes'] },
{ name: 'create-plugin', title: 'npm create waybetter', marker: 'hide-trends',
shown: 'npm create waybetter plugin -- --name "Hide Trends"',
argv: ['plugin', '--name', 'Hide Trends'] },
];
const esc = s => s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
function lineHtml(l) {
if (l.startsWith('$ ')) return `<span class="p">$</span> <span class="cmd">${esc(l.slice(2))}</span>`;
let h = esc(l);
h = h.replace(/\b(error|ERROR|failed)\b/g, m => `<span class="bad">${m}</span>`);
h = h.replace(/^(\s*)(Created|Wrote)\b/, (m, a, b) => `${a}<span class="ok">${b}</span>`);
h = h.replace(/^(\s{2,})(cd |npm |git |then )/, (m, a, b) => `${a}<span class="cmd">${b}</span>`);
return h;
}
const page = (title, lines) => `<!doctype html><html><head><meta charset="utf-8"><style>
:root { --code-bg: #060a14; --code-ink: #e2e8f0; --code-muted: #64748b; --radius: 14px;
--shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -16px rgba(0, 0, 0, .7);
--mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; }
html, body { margin: 0; background: #0b1120; }
body { padding: 24px; width: 960px; box-sizing: content-box; }
.term { background: var(--code-bg); color: var(--code-ink); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid color-mix(in srgb, var(--code-ink) 10%, transparent); overflow: hidden; }
.term-bar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-bottom: 1px solid color-mix(in srgb, var(--code-ink) 10%, transparent); }
.term-bar span { width: 10px; height: 10px; border-radius: 50%; background: #334155; }
.term-bar em { margin-left: 8px; font: 12px var(--mono); color: var(--code-muted); font-style: normal; }
.term pre { margin: 0; padding: 16px 18px 20px; color: var(--code-ink); font: 13.5px/1.75 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.p { color: #818cf8; } .cmd { color: #a5b4fc; } .c { color: var(--code-muted); }
.bad { color: #fca5a5; font-weight: 600; } .ok { color: #86efac; }
</style></head><body><div class="term"><div class="term-bar"><span></span><span></span><span></span><em>${esc(title)}</em></div><pre><code>${lines.map(lineHtml).join('\n')}</code></pre></div></body></html>`;
function run(cmd, args, opts = {}) {
const r = spawnSync(cmd, args, { encoding: 'utf8', timeout: TIMEOUT_MS, ...opts });
if (r.error) throw new Error(`${cmd}: ${r.error.message}`);
return r;
}
function shoot(shot, work) {
const r = run(process.execPath, [CLI, ...shot.argv], { cwd: work, input: '', env: { ...process.env, NO_COLOR: '1', FORCE_COLOR: '0' } });
const out = `${r.stdout}${r.stderr}`.replace(/\x1b\[[0-9;]*m/g, '').replaceAll(work + '/', '').replaceAll(work, '.').trimEnd();
if (r.status !== 0) throw new Error(`${shot.name}: exit ${r.status}\n${out}`);
if (!out.includes(shot.marker)) throw new Error(`${shot.name}: output lacks "${shot.marker}"\n${out}`);
return [`$ ${shot.shown}`, ...out.split('\n')];
}
function render(shot, lines) {
const tmp = mkdtempSync(join(tmpdir(), 'wb-term-'));
try {
const html = join(tmp, 'page.html'), png = join(tmp, 'shot.png');
writeFileSync(html, page(shot.title, lines));
// Height: bar + padding + lines; a little spare, the page background is the frame.
const height = Math.ceil(24 * 2 + 38 + 36 + lines.length * 13.5 * 1.75 + 8);
run(CHROME, ['--headless=new', '--disable-gpu', '--hide-scrollbars', '--force-device-scale-factor=2', `--window-size=1008,${height}`, `--screenshot=${png}`, `file://${html}`]);
if (!existsSync(png)) throw new Error(`${shot.name}: Chrome wrote no screenshot`);
const best = ['q80', 'lossless'].map(mode => {
const file = join(tmp, `${mode}.webp`);
const args = mode === 'q80' ? ['-q', '80', '-m', '6'] : ['-lossless', '-z', '9'];
const c = run('cwebp', ['-quiet', ...args, '-resize', '1600', '0', png, '-o', file]);
if (c.status !== 0) throw new Error(`cwebp ${mode}: ${c.stderr}`);
return { file, bytes: statSync(file).size };
}).reduce((a, b) => (b.bytes < a.bytes ? b : a));
writeFileSync(join(OUT, `${shot.name}.webp`), readFileSync(best.file));
return best.bytes;
} finally { rmSync(tmp, { recursive: true, force: true }); }
}
const args = process.argv.slice(2);
const textOnly = args.includes('--text');
const only = args.filter(a => !a.startsWith('--'));
const shots = only.length ? SHOTS.filter(s => only.includes(s.name)) : SHOTS;
if (only.length && shots.length !== only.length) throw new Error(`unknown shot(s); known: ${SHOTS.map(s => s.name).join(', ')}`);
mkdirSync(OUT, { recursive: true });
const work = mkdtempSync(join(tmpdir(), 'wb-readme-'));
try {
for (const shot of shots) {
const lines = shoot(shot, work);
writeFileSync(join(OUT, `${shot.name}.txt`), lines.join('\n') + '\n');
log(`${shot.name}: ${lines.length} lines${textOnly ? '' : `, ${Math.round(render(shot, lines) / 1024)} KB webp`}`);
}
} finally { rmSync(work, { recursive: true, force: true }); }