diff --git a/README.md b/README.md index f7d5ca0..e72179a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -

wayBetter for X, the first app built on wayBetter: three accounts side by side in one window

+

wayBetter, the framework, and wayBetter for X, the first app built on it

wayBetter

@@ -13,12 +13,6 @@ GPL-3.0-or-later · npm create waybetter

String packs · wayBetter for X

-

npm -license: GPL-3.0-or-later -runtime dependencies: 0 -Tauri 2 -platforms: macOS, Windows, Linux

- 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 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 +

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

+ 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. @@ -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: 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) +

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

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 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 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: @@ -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 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) + ## Packages @@ -87,8 +81,8 @@ mode reloads them as you save: - - + +
wayBetter for X in the Windows 98 theme, next to its Appearance settingswayBetter for X in four of its fourteen themes: Terminal, Paper, Frutiger Aero and NordwayBetter for X: a theme per pane, two accounts in one windowwayBetter for X: fourteen themes, each a full redesign
wayBetter for X (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); `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/ARCHITECTURE.md](docs/ARCHITECTURE.md): every module of the host, runtime and shell diff --git a/assets/readme/architecture.svg b/assets/readme/architecture.svg new file mode 100644 index 0000000..9d64aef --- /dev/null +++ b/assets/readme/architecture.svg @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + — ARCHITECTURE + One window, three layers, one small adapter. + + + + + The website you already use + loaded live from its exact https origin, never copied: x.com, kick.com, … + + + + TAURI 2 WINDOW · SYSTEM WEBVIEW + + + + Shell + packages/shell · local, trusted + + Tabs, split panes, address bar + Command palette, accounts, decks + Settings panel, theme builder + Store and the install screen + Workspaces, backup, updates + + the only webview allowed to change anything + + + + Site tabs + one webview + profile per tab · packages/runtime + + Plugin API + Theme engine + String packs + DOM hub + Fetch / XHR hub + Link routing + Accounts + UI kit + Deck columns + + untrusted: may only report about itself + + + + + + + NATIVE HOST · RUST + waybetter-host + crates/waybetter-host + + Every command re-checks its caller (webview label, exact origin) + Profiles, settings, plugins, themes, fonts, workspaces + Signed Store (Ed25519), backup, encrypted sync, signed updates + + + + all commands + a short, reviewed list + + + + YOUR APP + The adapter + what only your site knows + + site.rs · SiteSpec + hosts, account rules + + site.ts · SiteAdapter + selectors, API marks, links + + capabilities/*.json + who may call what + + + + + NPM · waybetter + The tooling + + npm create waybetter + waybetter dev --watch + waybetter store build|sign|verify + waybetter strings check + waybetter release + waybetter build-env + + diff --git a/assets/readme/create-terminal.svg b/assets/readme/create-terminal.svg new file mode 100644 index 0000000..1878c88 --- /dev/null +++ b/assets/readme/create-terminal.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + npm create waybetter + + $ 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 + $ ▍ + + diff --git a/assets/readme/hero.webp b/assets/readme/hero.webp index 3a86e23..ecb0081 100644 Binary files a/assets/readme/hero.webp and b/assets/readme/hero.webp differ diff --git a/assets/readme/make.mp4 b/assets/readme/make.mp4 new file mode 100644 index 0000000..1681e1b Binary files /dev/null and b/assets/readme/make.mp4 differ diff --git a/assets/readme/make.webp b/assets/readme/make.webp index 40d0740..313a2b4 100644 Binary files a/assets/readme/make.webp and b/assets/readme/make.webp differ diff --git a/assets/readme/showcase-panes.webp b/assets/readme/showcase-panes.webp new file mode 100644 index 0000000..ac4baaa Binary files /dev/null and b/assets/readme/showcase-panes.webp differ diff --git a/assets/readme/showcase-themes.webp b/assets/readme/showcase-themes.webp index 0700528..7f932c4 100644 Binary files a/assets/readme/showcase-themes.webp and b/assets/readme/showcase-themes.webp differ diff --git a/assets/readme/showcase-windows98.webp b/assets/readme/showcase-windows98.webp deleted file mode 100644 index f0896c9..0000000 Binary files a/assets/readme/showcase-windows98.webp and /dev/null differ diff --git a/assets/readme/term/create-app.txt b/assets/readme/term/create-app.txt deleted file mode 100644 index 6468a2d..0000000 --- a/assets/readme/term/create-app.txt +++ /dev/null @@ -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 diff --git a/assets/readme/term/create-app.webp b/assets/readme/term/create-app.webp deleted file mode 100644 index 1d5e274..0000000 Binary files a/assets/readme/term/create-app.webp and /dev/null differ diff --git a/assets/readme/term/create-plugin.txt b/assets/readme/term/create-plugin.txt deleted file mode 100644 index 8de0d1d..0000000 --- a/assets/readme/term/create-plugin.txt +++ /dev/null @@ -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 diff --git a/assets/readme/term/create-plugin.webp b/assets/readme/term/create-plugin.webp deleted file mode 100644 index bb5bacd..0000000 Binary files a/assets/readme/term/create-plugin.webp and /dev/null differ diff --git a/crates/waybetter-host/src/app.rs b/crates/waybetter-host/src/app.rs index dd47131..f91d0b6 100644 --- a/crates/waybetter-host/src/app.rs +++ b/crates/waybetter-host/src/app.rs @@ -1046,9 +1046,8 @@ async fn open_panel(webview: Webview, app: AppHandle, section: Option) - // --------------------------------------------------------------------------------------------- // Tab webviews -/// Linux and macOS: the page-level part of a tab's `on_navigation`, run when the main frame starts -/// loading `url` (WebKitGTK's navigation callback, and wry's WKWebView one, cannot tell iframes from -/// the page). Returns false when +/// Linux: the page-level part of a tab's `on_navigation`, run when the main frame starts loading +/// `url` (WebKitGTK's navigation callback cannot tell iframes from the page). Returns false when /// 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 { static ON_SITE: std::sync::OnceLock>> = std::sync::OnceLock::new(); @@ -1106,8 +1105,8 @@ fn tab_builder(app: &AppHandle, hooks: &Arc, tab: &NewTab, url: U if url.scheme() == "about" { return true; } - // WebKit (GTK and macOS): possibly an iframe's own document (see below). - if cfg!(any(target_os = "linux", target_os = "macos")) && matches!(url.scheme(), "blob" | "data") { + // WebKitGTK: possibly an iframe's own document (see below). + if cfg!(target_os = "linux") && matches!(url.scheme(), "blob" | "data") { return true; } open_external(app, url); @@ -1117,10 +1116,7 @@ fn tab_builder(app: &AppHandle, hooks: &Arc, tab: &NewTab, url: U // 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 // on_page_load (Started), which is the main frame only. - // macOS: wry asks this for every WKNavigationAction, iframes included (no targetFrame - // 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")) { + if cfg!(target_os = "linux") { return true; } if let Some(site_url) = nav_hooks.canonical_url(url) { @@ -1161,7 +1157,7 @@ fn tab_builder(app: &AppHandle, hooks: &Arc, tab: &NewTab, url: U }) .on_page_load(move |tab, payload| { let app = &load_app; - if cfg!(any(target_os = "linux", target_os = "macos")) + if cfg!(target_os = "linux") && matches!(payload.event(), PageLoadEvent::Started) && !main_frame_started(app, site, &*load_hooks, &tab, payload.url()) { diff --git a/crates/waybetter-host/src/profiles.rs b/crates/waybetter-host/src/profiles.rs index e077e72..92210bb 100644 --- a/crates/waybetter-host/src/profiles.rs +++ b/crates/waybetter-host/src/profiles.rs @@ -241,19 +241,19 @@ mod tests { } 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] 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() }; - 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(); - 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). - 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_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)); } @@ -266,7 +266,7 @@ mod tests { bare.avatar = None; settings.observe("default", AccountSeen::SignedIn(bare), RULES); 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] @@ -284,12 +284,12 @@ mod tests { #[test] fn a_shell_save_keeps_the_native_accounts() { 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() }; incoming.profiles[0].account = Some(account("forged")); let kept = incoming.keep_accounts_from(¤t); 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] diff --git a/packages/shell/src/panel/make.css b/packages/shell/src/panel/make.css index 04d3142..2a25c1b 100644 --- a/packages/shell/src/panel/make.css +++ b/packages/shell/src/panel/make.css @@ -4,11 +4,10 @@ .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-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; } -/* 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 { 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: minmax(0, 1fr) auto; } .bmk-commands li > span { grid-column: 1 / -1; } } +.bmk-commands li > code { overflow-x: auto; white-space: nowrap; background: transparent; border: 0; padding: 0; color: var(--c-text); scrollbar-width: none; } +@container panel (max-width: 560px) { .bmk-commands li { grid-template-columns: 1fr auto; } .bmk-commands li > span { grid-column: 1 / -1; } } .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:hover { text-decoration-color: currentColor; } diff --git a/tools/readme-term-shots.mjs b/tools/readme-term-shots.mjs deleted file mode 100644 index 6a4ee43..0000000 --- a/tools/readme-term-shots.mjs +++ /dev/null @@ -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/.txt the cleaned output (first line "$ ", no ANSI, temp paths made short) -// assets/readme/term/.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=) 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, '&').replace(//g, '>'); -function lineHtml(l) { - if (l.startsWith('$ ')) return `$ ${esc(l.slice(2))}`; - let h = esc(l); - h = h.replace(/\b(error|ERROR|failed)\b/g, m => `${m}`); - h = h.replace(/^(\s*)(Created|Wrote)\b/, (m, a, b) => `${a}${b}`); - h = h.replace(/^(\s{2,})(cd |npm |git |then )/, (m, a, b) => `${a}${b}`); - return h; -} -const page = (title, lines) => `
${esc(title)}
${lines.map(lineHtml).join('\n')}
`; - -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 }); }