app: cherry-pick rune's pause and sound fixes onto the checkout

Rune comes from app/vendor/rune now, a checkout of 63ad0209 on branch
ported, carrying the four commits of upstream issues 1320 (a pause while
a clip is layered holds the layer's picture and time) and 1325 (a video's
sound is read ahead of the clock and leads it). Both were written against
eb9f1104 and ported across the refactors since. The faults are the first
two and the third in docs/rune-upstream.md; the app's workarounds in
review.rs stay until the fixes arrive upstream.
This commit is contained in:
vhaudiquet committed 2026-11-22 22:16:30 +01:00
1 parent 80fef698ce
commit 5bf262b82b
3795 files changed
+663463 -28

No files matched your search

+173
View File
@@ -0,0 +1,173 @@
import { useEffect, useState, type JSX, type MouseEvent } from "react"
import { Wordmark } from "./brand/Wordmark"
import { layers, milestones, principles, risks } from "./content"
import { FastAppsView } from "./FastApps"
import { ArchitectureView, HomeView, HowItWorksView, LaunchFastView, NotFoundView, PrinciplesView, RoadmapView, num } from "./pages"
import { stripBase, withBase } from "./base"
import { REPO, normalizePath } from "./routes"
import signature from "./footer-signature.svg"
import { Frame, type NavGroup, type NavItem } from "./system/Frame"
function Brand() {
return (
<a className="brand" href={withBase("/")} aria-label="Rune, overview">
<Wordmark />
</a>
)
}
function navGroups(pathname: string): NavGroup[] {
const page = (path: string, label: string, children: NavItem[]): NavItem => ({
href: withBase(path),
label,
current: pathname === path,
children: pathname === path ? children : undefined,
})
const spy = (id: string, label: string, n?: string): NavItem => ({ href: `#${id}`, label, spy: id, num: n })
const heading = (id: string, label: string): NavItem => ({ href: `#${id}`, label, heading: true })
return [
{
label: "Rune",
items: [
page("/", "Overview", [
spy("app", "A Rune app"),
spy("frame", "From code to screen"),
spy("how", "How do I…"),
spy("build", "What you can build"),
spy("next", "Next"),
]),
page("/how-it-works", "How it works", [
spy("frame", "A frame"),
spy("app", "A window and a view"),
spy("state", "State changes in handlers"),
spy("springs", "Springs keep their velocity"),
spy("live", "Values that skip the view"),
spy("threads", "Threads"),
spy("testing", "Tests without a window"),
spy("crates", "Where the code lives"),
]),
page("/launch-fast", "Launch fast", [
spy("prewarm", "prewarm_gpu"),
spy("metallib", "Precompiled shaders"),
spy("first-frame", "First frame at creation"),
spy("defer", "Defer setup"),
spy("still", "Keep the first second still"),
spy("idle", "Draw nothing when idle"),
spy("reuse", "Reuse a hidden window"),
spy("measure", "Measure it"),
spy("numbers", "Measured"),
]),
page("/fast-apps", "Fast apps", [
spy("main-thread", "The main thread never waits"),
spy("first-frame", "The first frame comes first"),
spy("lists", "Long lists"),
spy("memo", "Memo whole panels"),
spy("idle", "An idle window"),
spy("poll", "poll is cheap"),
spy("reads", "Read the size"),
spy("live-only", "live_only"),
spy("scrolling", "Smooth scrolling"),
spy("caches", "Bounded caches"),
spy("audit", "Audit a repo"),
]),
page("/architecture", "Architecture", [
spy("overview", "Overview"),
spy("channel", "The command channel"),
heading("layers", "Layers"),
...layers.map((l, i) => spy(l.slug, l.title, num(i))),
heading("choices", "Choices"),
spy("decisions", "Decisions"),
spy("gpui", "Why not fork GPUI"),
]),
page(
"/principles",
"Principles",
principles.map((p, i) => spy(p.slug, p.title, num(i))),
),
page("/roadmap", "Roadmap", [
heading("milestones", "Milestones"),
...milestones.map(m => spy(m.id, m.title)),
heading("risks", "Risks"),
...risks.map(r => spy(r.slug, r.title)),
]),
],
},
{
label: "Source",
items: [
{ href: REPO, label: "GitHub" },
{ href: `${REPO}/blob/dev/PLAN.md`, label: "Plan" },
{ href: `${REPO}/tree/dev/research`, label: "Research notes" },
],
},
]
}
function Footer() {
return (
<footer className="site-footer">
<div className="copyright">
<img src={signature} alt="" aria-hidden="true" width={163} height={64} />
<p>
©2026 <a href="https://anoma.ly">Anomaly</a>. MIT licence
</p>
</div>
</footer>
)
}
// The site path for a browser path under the base; paths outside it fall through to the not-found view.
function sitePath(pathname: string): string {
return normalizePath(stripBase(pathname) ?? pathname)
}
export function App({ pathname: initial }: { pathname?: string }) {
const [pathname, setPathname] = useState(() =>
sitePath(initial ?? (typeof window !== "undefined" ? window.location.pathname : "/")),
)
useEffect(() => {
const onPopState = () => setPathname(sitePath(window.location.pathname))
window.addEventListener("popstate", onPopState)
return () => window.removeEventListener("popstate", onPopState)
}, [])
const onClick = (e: MouseEvent<HTMLDivElement>) => {
if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return
const href = (e.target as HTMLElement | null)?.closest("a")?.getAttribute("href")
if (!href || !href.startsWith("/") || /\.\w+$/.test(href)) return
const url = new URL(href, window.location.origin)
const next = sitePath(url.pathname)
if (next === pathname) return
e.preventDefault()
window.history.pushState(null, "", `${url.pathname}${url.hash}`)
setPathname(next)
if (url.hash) requestAnimationFrame(() => document.getElementById(url.hash.slice(1))?.scrollIntoView())
else window.scrollTo(0, 0)
}
const views: Record<string, () => JSX.Element> = {
"/": HomeView,
"/how-it-works": HowItWorksView,
"/launch-fast": LaunchFastView,
"/fast-apps": FastAppsView,
"/principles": PrinciplesView,
"/architecture": ArchitectureView,
"/roadmap": RoadmapView,
}
const View = views[pathname] ?? NotFoundView
return (
<div className="site" onClick={onClick}>
<Frame
brand={<Brand />}
groups={navGroups(pathname)}
revealBrandAfter={pathname === "/" ? "home-hero" : undefined}
footer={<Footer />}
>
<View />
</Frame>
</div>
)
}
+23
View File
@@ -0,0 +1,23 @@
import snippets from "virtual:snippets"
import { REPO } from "./routes"
/** A code example cut from Rune's source at build time (scripts/snippets.ts), with a link to the lines it came from. */
export function Code({ id }: { id: string }) {
const s = snippets[id]
if (!s) throw new Error(`Unknown snippet "${id}"; add it to scripts/snippets.ts`)
const href = `${REPO}/blob/dev/${s.file}${s.start ? `#L${s.start}-L${s.end}` : ""}`
return (
<figure className="code-block">
<figcaption className="code-head">
<a href={href}>
{s.file}
{s.start > 0 && <span className="code-lines">:{s.start}–{s.end}</span>}
</a>
<span className="code-lang">{s.label}</span>
</figcaption>
<pre className="code">
<code dangerouslySetInnerHTML={{ __html: s.html }} />
</pre>
</figure>
)
}
+374
View File
@@ -0,0 +1,374 @@
import type { CSSProperties, ReactNode } from "react"
/** The architecture in one figure: the app side and the render thread, the command channel between them, and the
* platform shell under both. Plain HTML so the text stays crisp and the layout can stack on a phone. */
export function ArchitectureDiagram() {
return (
<figure className="arch" aria-labelledby="arch-caption">
<div className="arch-grid">
<section className="arch-box" data-area="app">
<p className="arch-kicker">Main thread</p>
<h3>App side</h3>
<ul>
<li>Models: typed state, keyed by stable ids</li>
<li>View functions → keyed tree → diff</li>
<li>Taffy layout at the target state</li>
<li>Parley shaping and line cache</li>
<li>Handlers, queued between frames</li>
<li>Accessibility tree updates</li>
</ul>
</section>
<div className="arch-channel" data-area="channel">
<p className="arch-channel-label">Command channel</p>
<div className="arch-flow" data-dir="fwd">
<span className="arch-arrow" aria-hidden="true" />
<span className="arch-flow-text">tree diffs, target rects, text runs, spring targets</span>
</div>
<div className="arch-flow" data-dir="back">
<span className="arch-arrow" aria-hidden="true" />
<span className="arch-flow-text">hits, gestures, settles, frame ids</span>
</div>
</div>
<section className="arch-box" data-area="render">
<p className="arch-kicker">Paced by the display</p>
<h3>Render thread</h3>
<ul>
<li>Presented tree: what's on screen now</li>
<li>Spring tracks that retarget with velocity</li>
<li>Exiting nodes, edge-by-edge layout motion</li>
<li>Scroll physics, drags applied 1:1</li>
</ul>
<div className="arch-inner">
<p className="arch-inner-title">Renderer · wgpu</p>
<ul>
<li>One instanced pass: rects, shadows, glyphs, vectors</li>
<li>Soft-edge clip on every instance</li>
</ul>
</div>
</section>
<section className="arch-box arch-shell" data-area="shell">
<div>
<p className="arch-kicker">Per platform</p>
<h3>Shell</h3>
<p className="arch-line">Windows and panels, menus, clipboard, text input protocol, accessibility adapter, lifecycle</p>
</div>
<div data-optional>
<p className="arch-kicker">Apple, optional</p>
<h3>Native layers</h3>
<p className="arch-line">System glass and video behind Rune's layer, masked by the render thread each frame</p>
</div>
</section>
</div>
<figcaption id="arch-caption">
The app side states targets and the render thread animates toward them. Everything that crosses between them
goes through the command channel.
</figcaption>
</figure>
)
}
type Step = { name: string; does: string; at: string }
const everyFrameBefore: Step[] = [
{ name: "Input", does: "The window queues clicks, keys and scrolls; poll() reads outside data.", at: "window.rs" },
{ name: "Handlers", does: "Queued handlers run with &mut access to the app's state.", at: "runtime.rs" },
]
const onChange: Step[] = [
{ name: "View", does: "The view function returns a keyed El tree, matched to the last one by key.", at: "fn view(&S, &mut Cx<S>) -> El" },
{ name: "Layout", does: "Taffy lays the tree out at its target state; Parley shapes the text.", at: "Taffy, Parley" },
{ name: "Targets", does: "Each changed rect, colour or opacity retargets its spring.", at: "rune-motion Scene" },
]
const everyFrameAfter: Step[] = [
{ name: "Springs", does: "Every track is sampled at the frame's time; scroll and reveals step too.", at: "rune-motion" },
{ name: "Draw", does: "Rects, shadows and glyphs become instances in one wgpu pipeline.", at: "render.rs" },
]
function Steps({ steps, from }: { steps: Step[]; from: number }) {
return steps.map((s, i) => (
<li key={s.name} className="dg-step">
<span className="dg-num">{String(from + i).padStart(2, "0")}</span>
<span className="dg-name">{s.name}</span>
<span className="dg-does">{s.does}</span>
<code className="dg-at">{s.at}</code>
</li>
))
}
/** One frame, top to bottom, as `Runtime::frame` and the window's redraw run it today. */
export function FrameDiagram() {
return (
<figure className="dg" aria-labelledby="frame-caption">
<ol className="dg-flow">
<Steps steps={everyFrameBefore} from={1} />
<li className="dg-group">
<p className="dg-group-label">Only when state changed</p>
<ol className="dg-flow">
<Steps steps={onChange} from={3} />
</ol>
</li>
<Steps steps={everyFrameAfter} from={6} />
</ol>
<figcaption id="frame-caption">
Steps 3–5 run only after a handler or <code>poll()</code> changes state. A frame that is only animating runs
1, 2, 6 and 7, and a settled window doesn't draw at all.
</figcaption>
</figure>
)
}
/** Who runs what: one thread today, and the split PLAN.md §3 describes. */
export function ThreadDiagram() {
return (
<figure className="dg" aria-labelledby="threads-caption">
<div className="dg-pair">
<section className="dg-panel">
<p className="dg-kicker">Today</p>
<div className="dg-box">
<h3>Main thread, winit event loop</h3>
<ul>
<li>Input and handlers</li>
<li>View, Taffy and Parley, on a change</li>
<li>Springs: the Runtime's Scene, sampled each frame</li>
<li>wgpu encode and present</li>
</ul>
</div>
<div className="dg-feeds">
<div className="dg-box dg-small">
<h3>Your threads</h3>
<p><code>Live&lt;T&gt;::set</code> writes an atomic and wakes the window, without re-running the view</p>
</div>
<div className="dg-box dg-small">
<h3>rune-images</h3>
<p>Decodes images, then wakes the window</p>
</div>
</div>
</section>
<section className="dg-panel" data-planned>
<p className="dg-kicker">Planned</p>
<div className="dg-box">
<h3>App side, main thread</h3>
<ul>
<li>Handlers, view, diff</li>
<li>Taffy and Parley</li>
</ul>
</div>
<p className="dg-link">
<span className="dg-arrow" aria-hidden="true" />
Command channel: diffs, rects, spring targets down; hits and settles back
</p>
<div className="dg-box">
<h3>Render thread, paced by the display</h3>
<ul>
<li>Owns the springs, scroll and drags</li>
<li>wgpu encode and present</li>
</ul>
</div>
</section>
</div>
<figcaption id="threads-caption">
Today one thread runs every step. Animation still skips app code, because the view only re-runs when state
changes. The plan moves springs and drawing to a render thread, so a slow handler can't stall an animation
that's already moving.
</figcaption>
</figure>
)
}
type Crate = { name: string; does: string }
const crateRows: { label: string; crates: Crate[] }[] = [
{
label: "Apps",
crates: [{ name: "examples/*", does: "settings, opencode, kit-gallery, live-values, shapes and others" }],
},
{
label: "Components",
crates: [
{ name: "rune-kit", does: "Button, Switch, Select, Menu, TextField…, reading only semantic tokens" },
{ name: "themes/opencode", does: "OpenCode's tokens, fonts and icons as a rune-kit theme" },
],
},
{
label: "Framework",
crates: [
{
name: "rune",
does: "El tree, runtime, renderer, windows, overlays and headless tooling; re-exports the crates below",
},
],
},
{
label: "Subsystems",
crates: [
{ name: "rune-text", does: "Parley shaping and layout, font discovery, glyph atlas, icons" },
{ name: "rune-media", does: "Video and audio playback, zero-copy native surfaces, recording" },
{ name: "rune-image", does: "Content-addressed image decoding, linear-light mips, SVG/AVIF, app icons" },
{ name: "rune-spell", does: "Platform spellchecking (Windows, macOS, web Hunspell)" },
],
},
{
label: "Foundations",
crates: [
{ name: "rune-core", does: "Colour, tokens, themes, shapes, state machines, tasks, live values" },
{ name: "rune-gpu", does: "Adapter selection, backend dispatch, native Metal backend, GPU springs" },
{ name: "rune-motion · rune-staging · rune-taffy", does: "Springs and presence, GPU staging, compact layout store" },
{ name: "wgpu · winit · Taffy · Parley", does: "GPU, windows, layout, text" },
],
},
]
const crateSide: Crate[] = [
{ name: "rune-ref", does: "CPU reference renderer and golden hashes" },
{ name: "rune-fx", does: "Effect layers: glow, fire, motion blur" },
{ name: "rune-light", does: "Lighting: soft shadows, god rays, GI" },
]
/** The workspace: each row builds on the rows below it; the side column is optional. */
export function CrateMap() {
return (
<figure className="dg" aria-labelledby="crates-caption">
<div className="dg-crates">
<ol className="dg-layers">
{crateRows.map(row => (
<li key={row.label} className="dg-layer">
<p className="dg-kicker">{row.label}</p>
<div className="dg-layer-row">
{row.crates.map(c => (
<div key={c.name} className="dg-box dg-small">
<h3><code>{c.name}</code></h3>
<p>{c.does}</p>
</div>
))}
</div>
</li>
))}
</ol>
<aside className="dg-side">
<p className="dg-kicker">Beside the core</p>
{crateSide.map(c => (
<div key={c.name} className="dg-box dg-small">
<h3><code>{c.name}</code></h3>
<p>{c.does}</p>
</div>
))}
</aside>
</div>
<figcaption id="crates-caption">
Apps depend on <code>rune</code>, which re-exports the subsystem and foundation crates below it. The crates
beside the core are optional.
</figcaption>
</figure>
)
}
/** How a test drives the same runtime the window uses, and what it can check. */
export function TestDiagram() {
return (
<figure className="dg" aria-labelledby="tests-caption">
<div className="dg-test">
<div className="dg-box dg-small" data-area="in">
<h3>Start</h3>
<p>A state, often a named scene, and an optional <code>--script</code> of taps at exact times</p>
</div>
<span className="dg-arrow" data-area="a1" aria-hidden="true" />
<div className="dg-box dg-small" data-area="rt">
<h3><code>Runtime</code></h3>
<p>The window's runtime, stepped by <code>frame(dt)</code> on a virtual clock, with no window</p>
</div>
<span className="dg-arrow" data-area="a2" aria-hidden="true" />
<ul className="dg-outs" data-area="out">
<li className="dg-box dg-small">
<h3><code>elements()</code></h3>
<p>Rects, text and opacity for <code>assert!</code> in <code>cargo test</code>, no GPU</p>
</li>
<li className="dg-box dg-small">
<h3><code>--snap</code>, <code>--frames</code></h3>
<p>Offscreen wgpu to PNG, compared byte for byte with pinned images</p>
</li>
<li className="dg-box dg-small">
<h3><code>--trace</code></h3>
<p>Per-frame rects and opacity as JSONL; motion-lint fails pops, jumps and jitter</p>
</li>
</ul>
</div>
<figcaption id="tests-caption">
Tests and agents run the same code path as the window, minus the window. Time only moves when the test steps it,
so a run repeats exactly.
</figcaption>
</figure>
)
}
type Link = { name: ReactNode; does: ReactNode }
/** Boxes left to right with an arrow between each (top to bottom on a phone), and an optional line back from the end
* to the start for a loop. */
function Chain({ id, links, back, caption }: { id: string; links: Link[]; back?: ReactNode; caption: ReactNode }) {
return (
<figure className="dg" aria-labelledby={`${id}-caption`}>
<ol className="dg-chain" style={{ "--links": links.length } as CSSProperties}>
{links.map((l, i) => (
<li key={i} className="dg-box dg-small">
<h3>{l.name}</h3>
<p>{l.does}</p>
</li>
))}
</ol>
{back && (
<p className="dg-back">
<span className="dg-back-line" aria-hidden="true" />
<span className="dg-back-label">{back}</span>
</p>
)}
<figcaption id={`${id}-caption`}>{caption}</figcaption>
</figure>
)
}
/** From the code you write to pixels, for one frame. */
export function PipelineDiagram() {
return (
<Chain
id="pipeline"
links={[
{ name: "Your state", does: <>A plain struct, changed only by handlers with <code>&amp;mut</code> access</> },
{ name: <code>view()</code>, does: <>Returns a keyed <code>El</code> tree: what should be on screen</> },
{ name: "Layout", does: "Taffy places every node at its target; Parley shapes the text" },
{ name: "Springs", does: "Each moved rect, colour or opacity animates from where it is now" },
{ name: "GPU", does: "Rects, shadows and glyphs as instances, usually one wgpu draw call" },
]}
back="A tap runs a handler, the state changes, and the view runs again"
caption={
<>
Your code runs in the first two boxes. Rune does the rest, and while something animates it repeats only the
last two, so your view isn't called again until the state changes.
</>
}
/>
)
}
/** One state change, from the event to the spring targets. */
export function StateLoopDiagram() {
return (
<Chain
id="state-loop"
links={[
{ name: "Event", does: "A tap, key or poll() result is queued by the window" },
{ name: "Handler", does: <><code>|s: &amp;mut State|</code> runs between frames</> },
{ name: <code>view(&amp;State)</code>, does: "Builds the whole tree again from the new state" },
{ name: "Diff by key", does: "Nodes with the same key are the same node, so they move instead of popping" },
{ name: "Targets", does: <>Changed properties retarget their springs, using the node's <code>.motion()</code></> },
]}
caption={
<>
A view never animates anything itself. It says where things are, and the diff turns the difference into
spring targets.
</>
}
/>
)
}
+396
View File
@@ -0,0 +1,396 @@
import { withBase } from "./base"
import { PageHead, SectionHead } from "./system/Frame"
import { Pager, Sample } from "./pages"
const blockingBefore = `// Before: a socket round trip on every keystroke, on the main thread.
.on_input_change(|s: &mut Search, _| {
s.hits = index.search(&s.query.text); // blocks the window for the whole round trip
})`
const blockingAfter = `// After: init builds it once; the handler asks, poll collects.
results: Latest::default().debounce(Duration::from_millis(60)), // init
s.results.set_waker(waker); // setup
.on_input_change(|s: &mut Search, _| {
let q = s.query.text.clone();
s.results.request(q, move |q| index.search(&q)); // runs on a worker
})
fn poll(s: &mut Search, _: f64, _: &mut Tx) -> bool {
let Some(hits) = s.results.take() else { return false }; // newest answer only
s.hits = hits;
true
}`
const listBefore = `// Before: every message is built each commit, then virtualized.
col().key("rows").growth(GrowthSpec::default())
.virtualize(72.0)
.children(s.messages.iter().map(|m| message(m)))`
const listAfter = `// After: only the rows in the mounted window are built.
col().key("rows").growth(GrowthSpec::default()).virtual_rows(
s.messages.len(),
72.0,
|s: &Chat, i| s.messages[i].id.as_str().into(),
|s: &Chat, i| {
let m = &s.messages[i];
memo(&m.id, m.revision, || message(m))
},
)`
const memoBefore = `// Before: the version is the whole document, hashed on every frame.
memo("reader", s.markdown.clone(), || render_markdown(&s.markdown))`
const memoAfter = `// After: an id and a counter the edit bumps.
memo("reader", (s.note_id, s.edits), || render_markdown(&s.markdown))`
const loopBefore = `// Before: asks for a frame every 16 ms for as long as the window is open.
fn poll(s: &mut App, _: f64, tx: &mut Tx) -> bool {
tx.wake_after(Duration::from_millis(16));
s.tick();
true
}`
const loopAfter = `// After: the loop runs while something moves, then stops.
fn poll(s: &mut App, _: f64, tx: &mut Tx) -> bool {
if !s.recording { return false }
tx.wake_after(Duration::from_millis(16));
s.tick();
true
}`
const pollBefore = `// Before: always "changed", so every wake draws.
fn poll(s: &mut App, _: f64, _: &mut Tx) -> bool {
s.reload_from_disk();
true
}`
const pollAfter = `// After: cheap when nothing happened, true only on a change.
fn poll(s: &mut App, _: f64, _: &mut Tx) -> bool {
let Some(next) = s.updates.take() else { return false };
s.apply(next);
true
}`
const rectBefore = `// Before: the view re-runs every frame the feed scrolls.
let height = cx.window_layout("feed").map(|r| r[3]);`
const rectAfter = `// After: it re-runs when the height changes.
let height = cx.layout_size("feed").map(|[_, h]| h);`
const liveBefore = `// Before: each scroll or zoom event re-runs the view.
.on_magnify(|s: &mut Canvas, e, _| {
s.camera.zoom_about(e.x, e.y, 1.0 + e.delta);
true
})`
const liveAfter = `// After: the handler moves Live values and skips the view.
.on_magnify(|s: &mut Canvas, e, tx| {
s.camera.zoom_about(e.x, e.y, 1.0 + e.delta); // sets Live values only
tx.live_only();
true
})`
const cacheBefore = `// Before: one entry per size ever asked for.
thread_local! { static SIZES: RefCell<HashMap<String, [f32; 2]>> = Default::default(); }`
const cacheAfter = `// After: a bound in entries; evict when it is passed.
const MAX: usize = 256;
fn remember(key: String, size: [f32; 2]) {
SIZES.with_borrow_mut(|m| {
if m.len() >= MAX { m.clear() }
m.insert(key, size);
})
}`
const hoverBefore = `// Before: every row the pointer crosses commits the view.
row().on_hover_change(move |s: &mut Inbox, inside, _| s.hovered = inside.then_some(id))
.fill(if s.hovered == Some(id) { theme.hover } else { theme.row })`
const hoverAfter = `// After: Rune paints the hover; no state, no commit.
row().fill(theme.row).hover(theme.hover)`
const glideBefore = `// Before: the app steps its own glide, one commit a frame.
fn poll(s: &mut Reader, _: f64, tx: &mut Tx) -> bool {
if s.y == s.target { return false }
s.y += (s.target - s.y) * 0.2;
tx.scroll_to_instant("page", 0.0, s.y);
tx.wake_after(Duration::from_millis(16));
true
}`
const glideAfter = `// After: one request; Rune glides on its own clock.
tx.scroll_to_with("page", 0.0, target, Spring::smooth(0.35, 0.0));`
const anchorBefore = `// Before: older messages load above and push the one being read down.
col().key("thread").scroll(ScrollSpec { stick_bottom: true }).child(messages(s))`
const anchorAfter = `// After: the message at the top of the view stays put.
col().key("thread").scroll(ScrollSpec { stick_bottom: true }).scroll_anchor().child(messages(s))`
function Pair({ before, after }: { before: string; after: string }) {
return (
<div className="code-stack">
<Sample>{before}</Sample>
<Sample>{after}</Sample>
</div>
)
}
export function FastAppsView() {
return (
<>
<PageHead eyebrow={<span>Fast apps</span>} title="Fast apps">
<p>
A Rune app feels fast when its main thread is free, its first frame is small, its lists build only what is on
screen and an idle window draws nothing. Each rule below is one way a slow app breaks it, with a before and
after. Where Rune can see the mistake, debug builds print a warning once per call site on stderr;{" "}
<code>RUNE_PERF_WARN=0</code> silences them, and release builds contain none of it.
</p>
<p>
Getting the first window up fast is its own page: <a href={withBase("/launch-fast")}>Launch fast</a>, which
has <code>rune::prewarm_gpu()</code> and the measured numbers.
</p>
</PageHead>
<section className="doc-section">
<SectionHead id="main-thread" title="The main thread never waits">
<p>
A socket, an HTTP request, a database query, a spawned process or a large file read does not belong in{" "}
<code>view</code>, a handler, <code>poll</code> or <code>init</code>. The window stops for the whole wait.
</p>
</SectionHead>
<div className="prose">
<p>
Debug builds warn when a handler, <code>poll</code> or <code>init</code> spends over 8 ms waiting rather
than computing: "blocked on the main thread". Do the work on a thread and bring the answer back through{" "}
<code>poll</code>. For a search box or any request where only the newest answer matters, use{" "}
<code>rune::Latest</code>: it supersedes older requests, debounces, and wakes the window once per answer.
</p>
</div>
<Pair before={blockingBefore} after={blockingAfter} />
</section>
<section className="doc-section">
<SectionHead id="first-frame" title="The first frame comes first">
<p>
<code>init</code> builds what the first frame shows from memory or a small file. Everything else, such as
status items, network and indexing, starts in <code>on_ready</code>, after the first frame. The details are
on <a href={withBase("/launch-fast#defer")}>Launch fast</a>.
</p>
</SectionHead>
<div className="prose">
<p>
Debug builds warn when setup in <code>main</code> before <code>run</code>, <code>init</code> and the first{" "}
<code>view</code> take over 100 ms between them before the first frame, and name the slowest. Rune's own
window and GPU time doesn't count toward it.
</p>
</div>
</section>
<section className="doc-section">
<SectionHead id="lists" title="Long lists build only what is on screen">
<p>
<code>virtualize</code> mounts only the visible rows, but it takes rows you have already built, so a
thousand-message list still builds a thousand messages on every commit.{" "}
<code>virtual_rows</code> takes a count and a closure and builds only the mounted window, with row content
built inside the closure.
</p>
</SectionHead>
<div className="prose">
<p>
Debug builds warn when a <code>virtualize</code> list is handed over 200 rows and more than four times what
it mounts, and name the call site. Use <code>virtualize</code> for short lists only. Handlers in a row find
their item by key or id, never by index.
</p>
</div>
<Pair before={listBefore} after={listAfter} />
</section>
<section className="doc-section">
<SectionHead id="memo" title="Memo whole panels, keyed small">
<p>
<code>memo(id, version, build)</code> reuses a subtree until its version changes. A hit no longer deep
clones the subtree, and layout and apply are reused for unchanged subtrees, so wrapping a whole panel pays
off, not only the rows of a list.
</p>
</SectionHead>
<div className="prose">
<p>
The version is hashed every frame, so keep it small: an id plus an edit counter that the edit bumps. Never
key a memo by a large value such as a Markdown source. Hashing or comparing it costs what the memo saves.
Anything the closure reads that can change belongs in the version, except <code>Cx::layout</code> reads,
which Rune tracks.
</p>
</div>
<Pair before={memoBefore} after={memoAfter} />
</section>
<section className="doc-section">
<SectionHead id="idle" title="An idle window draws nothing">
<p>
<code>poll</code> returns true only when visible state changed, and a <code>wake_after</code> loop has an
end condition. A wake on a resting window runs <code>poll</code> first and draws only if it returns true.
</p>
</SectionHead>
<Pair before={loopBefore} after={loopAfter} />
<div className="prose prose-after">
<p>
Debug builds warn when <code>poll</code> returns true for 30 frames in a row while nothing on screen
changes, and when a window draws 120 frames within 2 s with no input, motion or visible change; the warning
names what woke it, such as a <code>wake_after</code> loop.
</p>
<p>
Check it with <code>procwatch</code>: an app with its window shown and untouched should sit near zero CPU.
</p>
</div>
</section>
<section className="doc-section">
<SectionHead id="poll" title="poll is cheap, and honest">
<p>
<code>poll</code> runs on every frame the window is awake. On a frame where nothing happened it should cost
microseconds and allocate nothing: drain a channel, compare a generation counter or an mtime. Never reload,
parse or scan in it.
</p>
</SectionHead>
<Pair before={pollBefore} after={pollAfter} />
</section>
<section className="doc-section">
<SectionHead id="reads" title="Read the size, not the rect">
<p>
A view that calls <code>Cx::window_layout</code> re-runs when the rect moves past half a point, and inside a
scroll view it moves every frame. <code>Cx::layout</code> reads the rect unscrolled, so only a commit moves it.
If you use only the size, read <code>Cx::layout_size</code>; for anything else, <code>Cx::layout_with</code>{' '}
and <code>Cx::window_layout_with</code> re-run the view only when your answer changes.
</p>
</SectionHead>
<Pair before={rectBefore} after={rectAfter} />
</section>
<section className="doc-section">
<SectionHead id="live-only" title="Scroll and zoom handlers skip the view">
<p>
A handler that only moves a <code>Live</code> value, such as a scroll position, a zoom or a transform, calls{" "}
<code>Tx::live_only()</code>, so the frame doesn't commit state and re-run the view. Debug builds check for
a handler that said <code>live_only</code> but changed what the view reads.
</p>
</SectionHead>
<Pair before={liveBefore} after={liveAfter} />
</section>
<section className="doc-section">
<SectionHead id="scrolling" title="Smooth scrolling">
<p>
A scroll costs Rune no commit: it moves the content, mounts <code>virtual_rows</code> and paints{" "}
<code>El::hover</code> styles without running <code>view</code>. A frame that commits while a viewport
scrolls is the app's, and on a long page one commit can take more than the 8 ms a 120 Hz frame has.
</p>
</SectionHead>
<div className="prose">
<ul>
<li>
<code>poll</code> returns true only when visible state changed. To act on where a scroll stops, wait
until it has been still a moment with <code>Tx::wake_after</code>; follow it frame by frame with{" "}
<code>El::on_scroll_offset</code> and live values.
</li>
<li>
Hover is a style, not state: <code>El::hover</code>, <code>hover_group</code> and <code>group_*</code>{" "}
styles. A scroll moves rows under a still pointer, so state set from <code>on_hover_change</code> commits
for each one.
</li>
<li>
<code>on_layout</code> and <code>on_drawn_layout</code> report every frame of a scroll for an element
inside it. Use their <code>_tx</code> forms and say <code>Tx::live_only</code> when the handler only
moves live values or bookkeeping.
</li>
<li>
Read <code>Cx::layout_size</code> or <code>Cx::layout</code>, not <code>Cx::window_layout</code>, as
above.
</li>
<li>
Glide with <code>Tx::scroll_to_with</code> rather than an instant scroll stepped every frame.
</li>
</ul>
</div>
<Pair before={hoverBefore} after={hoverAfter} />
<Pair before={glideBefore} after={glideAfter} />
<div className="prose prose-after">
<p>
Debug builds name the source when one keeps committing through a scroll: <code>poll</code>, a handler with
its element and where it was set, or the layout read that moved. Each warns once, when it commits on 6 or
more frames and a quarter of a scroll's frames. They also warn when an app steps a viewport with an
instant scroll on 8 committing frames in a row, and when one hover handler commits for 8 different elements.
</p>
<p>
<code>RUNE_COMMIT_BUDGET_MS=8</code> prints a line for each commit over 8 ms, in any build, release
included, with where its time went (view, layout, text, apply) and what made the frame commit, at most
once a second.
</p>
<p>
<code>El::scroll_anchor()</code> keeps the reading position when content above it changes: rows load
above, an image grows, a new width reflows the text. On a scroll viewport it holds the row at the top of
the view across each commit, like CSS <code>overflow-anchor</code>, while the viewport is still, off its
top and not following its bottom. <code>virtual_rows</code> lists already do this;{" "}
<code>Tx::keep_on_screen</code> holds a chosen element for one commit.
</p>
</div>
<Pair before={anchorBefore} after={anchorAfter} />
</section>
<section className="doc-section">
<SectionHead id="caches" title="Every cache has a bound">
<p>
A cache bounds its entries and its bytes, counting decoded pixels rather than encoded size, so a long
session can't grow it without end. A <code>static</code> map that only ever inserts is a leak with a
lookup. Evict by count, by age or by byte budget, and test the bound.
</p>
</SectionHead>
<Pair before={cacheBefore} after={cacheAfter} />
</section>
<section className="doc-section">
<SectionHead id="audit" title="Audit a repo in seconds">
<p>
<code>scripts/app-audit &lt;repo&gt;</code> greps an app's Rust files for the patterns above and prints one
line per finding with <code>file:line</code>.
</p>
</SectionHead>
<div className="prose">
<ul>
<li>
<code>.virtualize(</code> next to a built <code>.children(</code>, <code>.child(</code> or push loop.
</li>
<li>
<code>Command::new</code>, <code>UnixStream</code>, <code>TcpStream</code>,{" "}
<code>reqwest::blocking</code>, <code>rusqlite</code> and <code>read_to_string</code> in a file that
defines <code>view</code>, <code>poll</code>, <code>init</code> or a handler.
</li>
<li>
A <code>wake_after</code> of 33 ms or less with no <code>if</code>, <code>match</code> or{" "}
<code>return</code> just before it.
</li>
<li>
<code>layout(..)</code> read only for <code>[2]</code> or <code>[3]</code>.
</li>
<li>
A <code>static</code> map in a file with no <code>retain</code>, <code>remove</code> or{" "}
<code>clear</code>.
</li>
<li>
<code>window_layout(</code>; <code>on_layout</code>, <code>on_drawn_layout</code>,{" "}
<code>on_hover</code> or <code>on_hover_change</code> with no <code>live_only</code> just after; and{" "}
<code>scroll_to_instant</code> near a <code>wake_after</code>.
</li>
</ul>
<p>
It is crude: a finding is a place to look, not a verdict. <code>--strict</code> exits 1 when there are
findings. The warnings above catch more, while the app runs; the audit also covers code a run didn't reach.
</p>
</div>
</section>
<Pager prev={["/launch-fast", "Launch fast"]} next={["/architecture", "Architecture"]} />
</>
)
}
+20
View File
@@ -0,0 +1,20 @@
// The site lives under /team/rune on anoma.ly (production) and dev.anoma.ly (dev).
// Pages and files keep root-relative paths internally ("/principles"); these helpers add and
// remove the prefix at the edges.
export const BASE_PATH = "/team/rune"
// The build mode (`--mode dev`) picks the environment; every other mode builds production.
export function hostForMode(mode: string | undefined): string {
return mode === "dev" ? "dev.anoma.ly" : "anoma.ly"
}
export function withBase(path: string): string {
return `${BASE_PATH}${path}`
}
// Returns the site path for a request path, or undefined when it is outside the base.
export function stripBase(pathname: string): string | undefined {
if (pathname === BASE_PATH) return "/"
if (!pathname.startsWith(`${BASE_PATH}/`)) return undefined
return pathname.slice(BASE_PATH.length)
}
+41
View File
@@ -0,0 +1,41 @@
import { useEffect, useRef, type CSSProperties } from "react"
import { attachTriggers, fadeSwap, glint } from "./motion"
import { WORDMARK, carveOrder, runs } from "./pixels"
const { glyphs, width, height } = WORDMARK
const rune = glyphs[0]!
const carve = carveOrder(rune.rows)
/** ᚱUNE in pixel letters. Hover runs a light down the ᚱ's strokes (a fade under reduced motion); `periodic`, the home
* masthead, also plays it every 5–9 s while it's on screen. */
export function Wordmark({ periodic = false }: { periodic?: boolean }) {
const ref = useRef<HTMLSpanElement>(null)
useEffect(() => {
const box = ref.current
if (!box) return
const print = box.querySelector<SVGGElement>(".wordmark-rune")!
const light = glint([...box.querySelectorAll<SVGRectElement>(".wordmark-glint rect")].map(el => ({ el, order: Number(el.dataset.order) })))
return attachTriggers(box, reduced => (reduced ? fadeSwap(print, lit => print.classList.toggle("is-lit", lit)) : light()), { periodic })
}, [periodic])
return (
<span ref={ref} className="wordmark" style={{ "--cells": width, aspectRatio: `${width} / ${height}` } as CSSProperties}>
<svg viewBox={`0 0 ${width} ${height}`} shapeRendering="crispEdges" aria-hidden="true" focusable="false">
<g className="wordmark-rune">
{runs(rune.rows, rune.x).map(([x, y, w, h], i) => <rect key={i} x={x} y={y} width={w} height={h} />)}
<g className="wordmark-glint">
{carve.map(([x, y, order]) => (
<rect key={`${x},${y}`} x={rune.x + x} y={y} width={1} height={1} fillOpacity={0} data-order={order.toFixed(4)} />
))}
</g>
</g>
{glyphs.slice(1).map(g => (
<g key={g.char}>
{runs(g.rows, g.x).map(([x, y, w, h], i) => <rect key={i} x={x} y={y} width={w} height={h} />)}
</g>
))}
</svg>
</span>
)
}
+124
View File
@@ -0,0 +1,124 @@
// The wordmark's motion: one shared frame loop that only runs while something moves, the carve glint, the reduced
// motion fade, and the hover and idle triggers. Nothing plays on first paint.
type Tick = (dt: number) => boolean | void
const ticks = new Set<Tick>()
let raf = 0
let last = 0
/** Run `tick` every frame until it returns false. */
export function animate(tick: Tick) {
ticks.add(tick)
if (!raf) {
last = performance.now()
raf = requestAnimationFrame(frame)
}
return () => ticks.delete(tick)
}
function frame(now: number) {
const dt = Math.min(.05, (now - last) / 1000)
last = now
for (const tick of [...ticks]) if (tick(dt) === false) ticks.delete(tick)
raf = ticks.size ? requestAnimationFrame(frame) : 0
}
export const reducedMotion = () => matchMedia("(prefers-reduced-motion: reduce)").matches
const easeInOut = (p: number) => (p < .5 ? 2 * p * p : 1 - (-2 * p + 2) ** 2 / 2)
function invert(y: number, ease: (p: number) => number) {
let lo = 0, hi = 1
for (let i = 0; i < 20; i++) {
const m = (lo + hi) / 2
if (ease(m) < y) lo = m
else hi = m
}
return (lo + hi) / 2
}
/** A light runs along `cells` in carve order over `travel` s; each cell warms in 40 ms and cools with a 180 ms time
* constant, so nothing cuts out. A replay mid-run restarts the head. */
export function glint(cells: { el: SVGElement; order: number }[], { travel = .7, rise = .04, tau = .18 } = {}) {
const at = cells.map(c => invert(c.order, easeInOut) * travel)
let t = -1
const tick = (dt: number) => {
t += dt
let alive = false
cells.forEach((c, i) => {
const since = t - at[i]!
let h = since < 0 ? 0 : since < rise ? since / rise : Math.exp(-(since - rise) / tau)
if (since < 0 || h > .004) alive = true
else h = 0
c.el.setAttribute("fill-opacity", h.toFixed(3))
})
if (!alive) t = -1
return alive
}
return () => {
const idle = t < 0
t = 0
if (idle) animate(tick)
}
}
/** Reduced motion: no travel. Fade `el` out, show the lit pose, fade in, hold, and back; 90 ms fades. */
export function fadeSwap(el: SVGElement | HTMLElement, pose: (lit: boolean) => void, hold = .5) {
const FADE = .09
const plan: [number, number, number, (() => void)?][] = [
[FADE, 1, 0, () => pose(true)],
[FADE, 0, 1],
[hold, 1, 1],
[FADE, 1, 0, () => pose(false)],
[FADE, 0, 1],
]
let i = 0, t = 0
animate(dt => {
t += dt
while (i < plan.length && t >= plan[i]![0]) {
t -= plan[i]![0]
plan[i]![3]?.()
i++
}
if (i >= plan.length) {
el.style.opacity = ""
return false
}
const [d, a, b] = plan[i]!, p = t / d
el.style.opacity = String(a + (b - a) * (b > a ? 1 - (1 - p) ** 2 : p * p))
})
}
let lastScroll = -Infinity
if (typeof window !== "undefined") addEventListener("scroll", () => { lastScroll = performance.now() }, { passive: true, capture: true })
/** Play on hover; `periodic` adds an idle play every 5–9 s while `host` is on screen, the tab is visible, the page
* isn't scrolling and motion isn't reduced. The first one fires 5–9 s after load. Returns a cleanup. */
export function attachTriggers(host: HTMLElement, play: (reduced: boolean) => void, { periodic = false } = {}) {
const enter = () => play(reducedMotion())
host.addEventListener("pointerenter", enter)
if (!periodic) return () => host.removeEventListener("pointerenter", enter)
let visible = false, timer = 0
const schedule = () => {
clearTimeout(timer)
if (!visible || document.hidden) return
timer = window.setTimeout(() => {
if (!reducedMotion() && performance.now() - lastScroll > 500) play(false)
schedule()
}, (5 + Math.random() * 4) * 1000)
}
const observer = new IntersectionObserver(([entry]) => {
visible = entry!.isIntersecting
schedule()
})
observer.observe(host)
document.addEventListener("visibilitychange", schedule)
return () => {
host.removeEventListener("pointerenter", enter)
observer.disconnect()
document.removeEventListener("visibilitychange", schedule)
clearTimeout(timer)
}
}
+159
View File
@@ -0,0 +1,159 @@
// ᚱUNE on Anomaly's pixel grid: letters 11 pixels tall, 2-pixel stems, notched corners, fitted one clear pixel apart.
// The R is the rune ᚱ (raidō), so the name is spelled with a real rune and still reads as RUNE. Plain data and string
// builders, so the site and the icon script draw the same pixels.
export type Grid = readonly string[]
const grid = (s: string): Grid => s.trim().split("\n").map(row => row.trim())
const GLYPHS: Record<string, Grid> = {
// The stave, a pointed bowl and a straight leg, all on 45° steps two pixels thick.
ᚱ: grid(`
###....
####...
##.##..
##..##.
##..##.
##.##..
####...
##.##..
##..##.
##...##
##...##`),
U: grid(`
##...##
##...##
##...##
##...##
##...##
##...##
##...##
##...##
##...##
#######
.#####.`),
N: grid(`
###...##
####..##
####..##
####..##
##.##.##
##.##.##
##.##.##
##..####
##..####
##..####
##...###`),
E: grid(`
######
######
##....
##....
#####.
#####.
##....
##....
##....
######
######`),
}
export const CAP = 11
/** The ᚱ redrawn for 16 and 32 px favicons: 3-pixel stems, one or two device pixels per cell. */
export const ICON16: Grid = grid(`
................
...####.........
...#####........
...######.......
...###.###......
...###..###.....
...###..###.....
...###.###......
...######.......
...#####........
...######.......
...###.###......
...###..###.....
...###...###....
...###....###...
................`)
/** A pixel rectangle: x, y, width, height. */
export type Rect = readonly [number, number, number, number]
export interface Glyph { char: string; x: number; rows: Grid }
const ink = (rows: Grid) => rows.flatMap((row, y) => [...row].flatMap((c, x) => (c === "#" ? [[x, y] as const] : [])))
/** Where `next` starts after `prev` (placed at `at`): as far left as keeps one clear pixel between their ink in every
* direction, diagonals included. */
function fit(prev: Grid, at: number, next: Grid) {
const a = ink(prev).map(([x, y]) => [x + at, y] as const), b = ink(next)
let x = at + 1
while (a.some(([ax, ay]) => b.some(([bx, by]) => Math.abs(bx + x - ax) <= 1 && Math.abs(by - ay) <= 1))) x++
return x
}
export const WORDMARK = (() => {
const glyphs: Glyph[] = []
for (const char of "ᚱUNE") {
const rows = GLYPHS[char]!
const last = glyphs[glyphs.length - 1]
glyphs.push({ char, x: last ? fit(last.rows, last.x, rows) : 0, rows })
}
const last = glyphs[glyphs.length - 1]!
return { glyphs, width: last.x + last.rows[0]!.length, height: CAP }
})()
/** Rows to rectangles, merging each row's runs so no seams show between pixels. */
export function runs(rows: Grid, dx = 0, dy = 0): Rect[] {
const out: Rect[] = []
rows.forEach((row, y) => {
for (let x = 0; x < row.length; x++) {
if (row[x] !== "#") continue
let end = x
while (row[end] === "#") end++
out.push([dx + x, dy + y, end - x, 1])
x = end
}
})
return out
}
/** ᚱ's carve order: the stave top to bottom, then the bowl out and back, then the leg. Each cell gets the arc length
* (0–1) of its nearest point on that path. */
export function carveOrder(rows: Grid): [number, number, number][] {
const path = [[[1, .5], [1, 10.5]], [[1.5, .5], [5, 3.5]], [[5, 3.5], [1.5, 6.5]], [[2.5, 6.5], [6, 10.5]]] as const
const lens = path.map(([a, b]) => Math.hypot(b[0] - a[0], b[1] - a[1]))
const total = lens.reduce((s, l) => s + l, 0)
return ink(rows).map(([x, y]) => {
const c = [x + .5, y + .5] as const
let best = Infinity, arc = 0, acc = 0
path.forEach(([a, b], i) => {
const dx = b[0] - a[0], dy = b[1] - a[1]
const p = Math.max(0, Math.min(1, ((c[0] - a[0]) * dx + (c[1] - a[1]) * dy) / (dx * dx + dy * dy)))
const d = Math.hypot(a[0] + dx * p - c[0], a[1] + dy * p - c[1])
if (d < best - 1e-6) { best = d; arc = acc + p * lens[i]! }
acc += lens[i]!
})
return [x, y, arc / total]
})
}
/** OKLCH to gamma-encoded sRGB, 0–1 per channel. */
export function oklch(l: number, c: number, hDeg: number): [number, number, number] {
const h = (hDeg * Math.PI) / 180, a = c * Math.cos(h), b = c * Math.sin(h)
const l_ = (l + .3963377774 * a + .2158037573 * b) ** 3
const m_ = (l - .1055613458 * a - .0638541728 * b) ** 3
const s_ = (l - .0894841775 * a - 1.291485548 * b) ** 3
const lin = [
4.0767416621 * l_ - 3.3077115913 * m_ + .2309699292 * s_,
-1.2684380046 * l_ + 2.6097574011 * m_ - .3413193965 * s_,
-.0041960863 * l_ - .7034186147 * m_ + 1.707614701 * s_,
]
const gamma = (x: number) => { x = Math.min(1, Math.max(0, x)); return x <= .0031308 ? 12.92 * x : 1.055 * x ** (1 / 2.4) - .055 }
return [gamma(lin[0]!), gamma(lin[1]!), gamma(lin[2]!)]
}
/** Rune's ink, `--ink` in site.css, and the light the carve runs. */
export const INK: [number, number, number] = [.74, .14, 245]
export const HOT: [number, number, number] = [.97, .035, 245]
+584
View File
@@ -0,0 +1,584 @@
import type { ReactNode } from "react"
export type Spec = { label: string; values: ReactNode[]; mono?: boolean }
/** A file or folder in this repo that implements an idea. The prerender fails if the path doesn't exist. */
export type CodeRef = { path: string; note?: string }
export type Entry = { slug: string; title: string; body: ReactNode; spec?: Spec[]; code?: CodeRef[] }
const at = (path: string, note?: string): CodeRef => ({ path, note })
export const principles: Entry[] = [
{
slug: "feel-first",
title: "Feel is the product",
body: (
<>
<p>
Rune is judged first on how it feels in the hand: 120&nbsp;Hz, springs that can be interrupted at any point, and
nothing that pops, jumps or is cut off by a hard edge. The bar is SwiftUI on a ProMotion iPhone.
</p>
</>
),
spec: [
{ label: "Frame", values: ["8.33 ms at 120 Hz"], mono: true },
{ label: "Target", values: ["event → frame p50 ≤ 8.3 ms"], mono: true },
],
code: [
at("crates/rune-motion/src/spring.rs", "closed-form springs"),
at("examples/settings/src/main.rs", "the smoke test"),
],
},
{
slug: "motion-defaults",
title: "Motion rules are runtime defaults",
body: (
<>
<p>
Kit's motion rules are what the framework does when the app says nothing. Nothing animates on first mount,
drags apply 1:1, removed elements play their exit before they unmount, stationary edges never move, and
reduced motion swaps travel for a short fade.
</p>
<p>
Animated properties change only through spring tracks, so a one-frame jump can't be written. In tests, the
motion-lint rules (pops, jumps, reversals, jitter, hard clips) are failures.
</p>
</>
),
spec: [
{ label: "Spring", values: [<code>Spring::new(duration, bounce)</code>], mono: true },
{ label: "Default", values: ["bounce 0"], mono: true },
],
code: [
at("crates/rune-motion/src/tokens.rs", "the motion palette"),
at("crates/rune-motion/src/transition.rs", "exits before unmount"),
],
},
{
slug: "animation-off-app",
title: "Animation never runs through app code",
body: (
<p>
Views state targets and the render thread animates toward them. While a value animates, the app side does no
work: no view re-run, no layout, no diff. A slow handler can delay the next change but can't stall one that's
already moving.
</p>
),
spec: [{ label: "Target", values: ["app work per animated frame: 0"], mono: true }],
code: [
at("crates/rune-motion/src/scene.rs", "spring tracks"),
at("crates/rune/tests/integration/live.rs", "no view, layout or shaping"),
],
},
{
slug: "native-behaviour",
title: "Native behaviour, one look",
body: (
<>
<p>
Text input, accessibility, scroll momentum, clipboard and window management behave the way each platform
expects. Controls, type, motion and materials come from the app's theme and look the same everywhere, Mac
included.
</p>
<p>The core ships no brand of its own. OpenCode's theme is the first theme built on it and the main example.</p>
</>
),
spec: [
{ label: "Native", values: ["IME, accessibility, scrolling, clipboard, windows"] },
{ label: "Themed", values: ["controls, type, motion, materials"] },
],
code: [
at("crates/rune-edit/src/lib.rs", "text input and IME"),
at("crates/rune/src/a11y/tree.rs", "the accessibility tree (AccessKit)"),
at("crates/rune-core/src/theme.rs", "themes as data"),
at("themes/opencode", "OpenCode's theme"),
],
},
{
slug: "agents",
title: "Written and checked by agents",
body: (
<>
<p>
Agents write most of Rune and most Rune apps, so they need to see and test their own work without a person.
Every component has named scenes, every scene renders headless and deterministically, and an inspector
answers queries about nodes, rects, springs and timings.
</p>
<p>
The code is optimised for performance, correctness and speed of change rather than for a human reading it.
Comments state invariants for the next agent.
</p>
</>
),
spec: [{ label: "Render", values: [<code>--snap out.png --at 0.25</code>], mono: true }],
code: [
at("crates/rune/src/tooling.rs", "--snap, --scene, --script, --trace"),
],
},
{
slug: "one-way",
title: "One way to do things",
body: (
<p>
Views are plain Rust functions that return a keyed tree. There is no view macro language, no second way to
hold state and no notify call to forget. Errors should name the fix, such as{" "}
<code>Text has no key inside a dynamic list; add .key(id)</code>.
</p>
),
code: [at("crates/rune/src/el.rs", "the whole view API")],
},
{
slug: "fast-and-reference",
title: "A fast path and a reference path",
body: (
<p>
Layout, text, the renderer and springs each have a slow, obviously correct reference implementation and a fast
one. Every change tests the fast path against the reference on generated inputs, so the fast path can be
specialised, duplicated or unsafe where a measurement justifies it.
</p>
),
spec: [{ label: "Reference", values: ["CPU renderer, no GPU tricks"] }],
code: [
at("crates/rune-ref/src/shader.rs", "the CPU renderer"),
at("crates/rune-ref/tests/differential.rs", "GPU against CPU"),
],
},
{
slug: "observable",
title: "Everything is observable",
body: (
<p>
Every frame, node, layout rect, spring and timing can be queried, traced and replayed. A pixel traces back to
the node and the <code>file:line</code> that drew it, and a recorded session replays to the same pixels. The
agent's view of the app is the accessibility tree, so every agent test exercises accessibility too.
</p>
),
code: [
at("crates/rune-motion/src/trace.rs", "motion traces"),
at("crates/rune/src/tooling.rs", "--tree, --trace"),
],
},
{
slug: "hot-reload",
title: "Edits reach the screen with state intact",
body: (
<>
<p>
Tokens and literal edits apply live with no rebuild. Structural Rust edits hot-patch on the Mac in
about a second today, keeping app state, and the goal is 300&nbsp;ms.
</p>
<p>
A phone can't load new code, so in development the render thread runs on the iPhone and the app side runs on
the Mac, connected by the same channel the two threads use in production.
</p>
</>
),
spec: [
{
label: "Targets",
values: ["tokens ≤ 50 ms", "literals ≤ 100 ms", "Rust ≈ 1 s, goal 300 ms"],
mono: true,
},
],
code: [at("spikes/hot-patch", "989 ms median")],
},
{
slug: "budgets",
title: "Performance budgets are gates",
body: (
<p>
Each scene's cost is counted exactly: instructions, instances, glyphs, layout nodes and allocations. Counts are
bisectable, so CI can fail the change that pushed a scene over its frame budget. Once settled, an app does no
work at all.
</p>
),
spec: [
{ label: "At rest", values: ["0 ticks, 0 GPU submissions"], mono: true },
{ label: "Per frame", values: ["0 allocations"], mono: true },
],
code: [at("crates/rune/tests/alloc.rs", "0 allocations a frame"), at("crates/rune-motion/tests/alloc.rs")],
},
{
slug: "owned",
title: "Owned, not wrapped",
body: (
<p>
Rune depends on foundational crates and never on another UI framework. It borrows the best parts of Zed's GPUI
(the rope, the line layout cache, the macOS and iOS text input code) under GPUI's Apache-2.0 licence instead of
forking it.
</p>
),
spec: [{ label: "Uses", values: ["wgpu, Taffy, Parley, AccessKit"] }],
code: [at("crates/rune/Cargo.toml", "dependencies")],
},
]
export const layers: Entry[] = [
{
slug: "tree",
title: "Core tree and state",
body: (
<>
<p>
A view is a plain Rust function that returns an <code>El</code> tree with explicit keys. App state lives in
typed models outside any view. Handlers are queued and run between frames with <code>&mut</code> access to
the state, then the view re-runs and the new tree is diffed against the old one by key.
</p>
<p>
The toggle below, from the settings example, states where the knob should be and animates nothing itself.
The <code>.motion(motion::SNAPPY)</code> token tells the render thread how to get there.
</p>
</>
),
spec: [
{ label: "Uses", values: ["keyed retained tree, typed models"] },
{ label: "Not", values: ["signals, GPUI entities, immediate mode"] },
],
code: [at("crates/rune/src/el.rs", "El, keys, handlers"), at("crates/rune/src/runtime.rs", "queue, view, diff")],
},
{
slug: "layout",
title: "Layout",
body: (
<p>
Taffy computes flexbox, grid and block layout over Rune's own node arena, so there is one tree. Layout runs once,
at the target state; moving between layouts is the render thread's job. Long lists build only the visible rows
plus overscan and keep the rest as estimated heights.
</p>
),
spec: [
{ label: "Uses", values: ["Taffy"] },
{ label: "Not", values: ["own engine, SwiftUI-style proposals"] },
],
code: [
at("crates/rune/src/runtime.rs", "Taffy on the node arena"),
at("crates/rune/src/el/virtual_list.rs", "visible rows only"),
],
},
{
slug: "text",
title: "Text",
body: (
<p>
Parley handles shaping, bidi and line breaking, with shaped runs cached apart from wrap points so resizing never
re-shapes. Glyphs rasterise into a greyscale atlas with four horizontal subpixel positions, and coverage is
adjusted by luminance so dark text isn't thin. Text that overflows fades out rather than ending in an ellipsis.
</p>
),
spec: [
{ label: "Uses", values: ["Parley, swash, skrifa"] },
{ label: "Not", values: ["CoreText only, cosmic-text"] },
],
code: [
at("crates/rune-text/src/lib.rs", "Parley, swash, the atlas"),
at("research/23-text-quality.md", "against CoreText"),
],
},
{
slug: "render-thread",
title: "Render thread and spring tracks",
body: (
<>
<p>
The render thread owns the presented tree, which is what's on screen this frame. Every animated property is a
track of analytic spring segments, so position and velocity are exact at any time and a retarget starts the
new spring from where the value really is.
</p>
<p>
Layout animates per edge, so an edge that isn't moving gets no track. Removed nodes leave the flow, play their
exit and unmount at opacity 0. Drags and scrolling are applied here, 1:1, and one clock with time scale and
stepping is shared by tests, traces and the inspector.
</p>
</>
),
spec: [
{ label: "Spring", values: ["ω = 2π / duration", "ζ = 1 − bounce"], mono: true },
{ label: "Snap", values: ["both edges to 1/64 px"], mono: true },
],
code: [
at("crates/rune-motion/src/spring.rs"),
at("crates/rune-motion/src/scene.rs", "today on the main thread"),
at("crates/rune-motion/src/transition.rs", "presence"),
],
},
{
slug: "renderer",
title: "Renderer",
body: (
<>
<p>
One instanced pipeline draws rounded rects, borders, analytic shadows, glyphs and vector strokes and fills, so
a typical frame is one draw call. Every instance carries a clip with soft gradient edges, which makes "no
hard edges" free. Blending is in linear light.
</p>
<p>
Big or scaling text and icons will draw from curves with Slug, complex vectors with Vello's sparse strips, and
in-app blur with a backdrop pass.
</p>
</>
),
spec: [
{ label: "Uses", values: ["wgpu on every platform"] },
{ label: "Not", values: ["Skia, compute Vello, raw Metal first"] },
],
code: [
at("crates/rune/src/render.rs"),
at("crates/rune/src/shaders/shader.wgsl", "one uber-quad pipeline"),
at("crates/rune-core/src/shape.rs", "strokes and fills"),
],
},
{
slug: "shells",
title: "Platform shells",
body: (
<p>
A shell owns windows and panels, menus, clipboard, drag and drop, the text input protocol, the accessibility
adapter and the app lifecycle. Rune runs on winit today. Once text input lands it moves to thin shells per
platform, implementing each one's text protocol directly (<code>NSTextInputClient</code>, TSF,{" "}
<code>text-input-v3</code>, <code>UITextInput</code>) and borrowing from Zed's shells.
</p>
),
spec: [
{ label: "Uses", values: ["winit, then own shells; AccessKit"] },
{ label: "Not", values: ["winit's IME, SDL3"] },
],
code: [
at("crates/rune/src/window.rs", "winit today"),
at("crates/rune/src/platform/macos.rs"),
at("crates/rune/src/platform/win32.rs", "overlays"),
at("crates/rune/src/platform/layer_shell.rs", "Wayland overlays"),
at("crates/rune/src/a11y/mod.rs", "UI Automation, NSAccessibility and AT-SPI adapters"),
],
},
{
slug: "native-layers",
title: "Native layers on Apple",
body: (
<p>
Liquid Glass samples what's behind the window, so only the window server can draw it. For Mac surfaces that want
it, the Apple shell places system glass views behind transparent regions of Rune's layer and the render thread
updates their masks in the same transaction as the frame. This is optional; every platform gets Rune's own
blur and materials.
</p>
),
spec: [{ label: "Uses", values: ["NSGlassEffectView, CATransaction"] }],
},
{
slug: "tooling",
title: "Agent tooling",
body: (
<p>
Scenes are named states with fixture data. They render in the app, offscreen in tests and in a gallery, with
pinned fonts and a fixed clock. The inspector speaks versioned JSON over a socket: query nodes by role, key or
text, read rects, springs and source locations, and inject input with exact timestamps. Motion traces come
straight from the render thread.
</p>
),
code: [
at("crates/rune/src/tooling.rs", "scenes and flags"),
at("crates/rune-motion/src/trace.rs", "motion traces"),
],
},
{
slug: "playground",
title: "Playground",
body: (
<p>
A storybook built into the window, on ⌘⇧D. The app's scenes and its own stories, in a tree of groups nested by
their paths, show one at a time on a plain stage, live and interactive, with their triggers and controls beside
them. The keyboard is in one column at a time, the list, the stage or the controls, so a story's own keys work on
its stage. Each story has its own state, so the real one is never touched. R replays a story from the start, its
timed steps running on the logical clock, the same every time.
</p>
),
code: [at("crates/rune/src/playground.rs", "stories, triggers and replay")],
},
]
export type Decision = { area: string; chose: string; rejected: string; why: string }
export const decisions: Decision[] = [
{
area: "Language",
chose: "Rust",
rejected: "Zig, C++, Swift",
why: "The only option with production text, layout and accessibility crates, no garbage collector, wasm, and a working hot-patcher.",
},
{
area: "GPU",
chose: "wgpu everywhere",
rejected: "Raw Metal first, hand-written Vulkan and D3D12",
why: "One backend ships Mac, Windows, Linux and the web. Raw Metal comes later, only where a measurement asks for it.",
},
{
area: "Renderer",
chose: "One instanced pass, glyph atlas",
rejected: "Skia, compute Vello",
why: "A typical frame is one draw call, and soft clip edges cost nothing extra.",
},
{
area: "Look",
chose: "Token-driven themes",
rejected: "Per-OS look, a built-in brand",
why: "Apps carry their own design language on every platform. OpenCode's is one theme, kept outside the core.",
},
{
area: "Text",
chose: "Parley, swash, skrifa",
rejected: "CoreText only, cosmic-text",
why: "The same text on every platform, and resizing never re-shapes.",
},
{
area: "Layout",
chose: "Taffy on Rune's arena",
rejected: "An own engine, SwiftUI-style proposals",
why: "Agents already know flexbox, and there is one tree instead of two.",
},
{
area: "State",
chose: "Keyed tree from plain functions",
rejected: "Signals, GPUI entities, immediate mode",
why: "Models outside views survive hot patches, and handlers never run inside render, so borrows can't collide.",
},
{
area: "Animation",
chose: "Spring tracks on the render thread",
rejected: "Re-rendering views each frame",
why: "Animations keep running when the app is busy, and retargets keep velocity.",
},
{
area: "Accessibility",
chose: "AccessKit",
rejected: "Own bridges",
why: "The same tree serves the inspector, so agent tests exercise it.",
},
{
area: "Hot reload",
chose: "Live values, subsecond patches, split process on iPhone",
rejected: "A view language interpreter, loading code on the device",
why: "Views stay plain Rust, and iOS won't load new code on a device.",
},
]
export type Milestone = { id: string; title: string; status: "done" | "now" | "started" | "next" | "later"; body: ReactNode }
export const milestones: Milestone[] = [
{
id: "m0",
title: "Spikes",
status: "now",
body: (
<p>
Short experiments that each answer one question with a number: hot-patch speed, glass underlay sync, frame
pacing, the iPhone split mode, and text quality against CoreText. Hot patching is done, at 989&nbsp;ms median from
save to new output.
</p>
),
},
{
id: "m0-5",
title: "Rendering smoke test",
status: "now",
body: (
<p>
A small settings window that proves the basics: rounded rects, borders, shadows, soft edges, crisp text, Retina
scale, springs and clicks, checked by headless renders and then on a real window.
</p>
),
},
{
id: "m1",
title: "Theming, gallery and this site",
status: "now",
body: (
<p>
The token schema and theme system, with OpenCode's theme generated from <code>@opencode/ui</code> as its first
consumer. A gallery of components with the same names as the web kit, each diffed against its web story.
</p>
),
},
{
id: "m2",
title: "Hex Settings",
status: "next",
body: (
<p>
The first real screen, on Mac, Windows and Linux: forms, toggles, a keycap recorder, lists and a text field. Own
shells start here, along with AccessKit and goldens on all three platforms.
</p>
),
},
{
id: "m3",
title: "OpenCode Desktop",
status: "started",
body: (
<p>
The main screens: sidebar and sessions, the streaming transcript, composer, diff view, command palette and
menus, against real data. Done when it looks like OpenCode Desktop side by side and feels clearly better on all
three desktops.
</p>
),
},
{
id: "m4",
title: "Kit's Mac surfaces",
status: "later",
body: <p>An app's pill, tray and launcher, and their settings windows, with optional Liquid Glass.</p>,
},
{
id: "m5",
title: "Web",
status: "started",
body: (
<p>
The same apps in the browser over WebGPU, starting with live demos on this site. An experimental target builds
and runs today (<code>WEB.md</code>, <code>examples/web-hello</code>).
</p>
),
},
{
id: "m6",
title: "iOS, then Android",
status: "later",
body: (
<p>
An iOS shell with <code>UITextInput</code>, a view for embedding Rune in SwiftUI, and the split-process dev mode.
The first surface ships inside OpenCode iOS. Android follows.
</p>
),
},
]
export const risks: Entry[] = [
{
slug: "risk-text",
title: "Text input and text quality",
body: (
<p>
Input methods on three desktops, then iOS selection, autocorrect and dictation, are where custom-rendered
frameworks most visibly fail. Rune implements each platform's protocol directly and gates text rendering on a
pixel diff against CoreText.
</p>
),
},
{
slug: "risk-look",
title: "Matching OpenCode Desktop",
body: (
<p>
The bar is a Chromium-rendered app. Each component is diffed against its <code>@opencode/ui</code> story,
rendered by headless Chromium beside Rune's headless renderer.
</p>
),
},
{
slug: "risk-scope",
title: "Scope",
body: (
<p>
A renderer, text, input methods, accessibility, six shells and tooling is years of work for a human team. Agents
write it inside a verification harness that was built first, and Rune ships one real surface at a time.
</p>
),
},
]
+13
View File
@@ -0,0 +1,13 @@
import { StrictMode } from "react"
import { renderToString } from "react-dom/server"
import { App } from "./App"
export { routes } from "./routes"
export function render(pathname: string): string {
return renderToString(
<StrictMode>
<App pathname={pathname} />
</StrictMode>,
)
}
+14
View File
@@ -0,0 +1,14 @@
<svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="163.057" height="64.1453" viewBox="0 0 163.057 64.1453" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="Vector">
<path d="M73.5238 4.95025L72.6833 6.74631C72.5771 6.97635 72.3603 7.2639 72.1745 7.45413L70.2811 11.3825C70.144 10.7631 70.6262 10.3296 70.8429 9.82528C71.1438 9.13075 71.4402 8.48929 71.595 7.79476L70.1617 10.9136C70.0201 11.2232 69.9582 11.4798 69.7281 11.7541L69.9361 10.8737L69.8918 10.803L69.3477 11.9974C69.1044 12.2141 68.9407 12.4044 68.8832 12.7406C68.8257 13.0856 68.5779 13.2891 68.4452 13.5988L67.6932 15.3506L67.8878 15.3595C67.9409 15.3595 67.9276 15.5364 67.9188 15.5895C67.9055 15.6382 67.7817 15.6028 67.6224 15.5586L67.1712 16.6247L67.0296 16.8238C67.0031 16.8636 66.9279 16.7397 66.8659 16.6468L66.3616 17.6422L66.6094 17.7395L65.6317 20.062C65.5211 20.323 64.9549 21.0972 64.7337 21.0972L65.322 19.5311L65.6538 19.3896L65.499 18.841L60.8363 29.9138C60.7168 28.5424 60.8097 27.2507 60.8363 25.897L60.9203 21.5218C60.6859 21.3847 60.6151 21.2166 60.6195 20.8317L60.4647 20.8406C60.3364 21.6059 60.6416 22.212 60.2346 22.8932L60.3275 18.987L60.8053 18.0359C61.0442 17.5625 60.7301 17.1511 60.3231 16.9476L60.3762 16.4699C60.3895 16.3548 60.1373 16.2487 59.9161 16.1779L59.7303 15.0542C59.664 14.9481 59.2703 14.8419 59.1287 14.8773C58.7792 15.125 58.4165 15.302 58.0316 15.4568L57.6733 15.6028C57.598 15.6338 57.514 15.5187 57.3415 15.3506L56.439 16.6026L57.0008 16.3946L55.8551 17.9607L56.2753 16.9388L54.7491 18.872L54.2227 19.5179V19.832L51.9931 23.6409L49.967 27.2241L47.5604 27.609L45.1804 27.9408L45.698 26.5031C45.7776 26.2819 45.9059 25.9368 45.9369 25.7377L46.0652 24.9636C46.0961 24.7645 46.4146 24.5876 46.5872 24.5256C47.0915 24.3531 46.6049 23.9019 46.5783 23.6763C46.4854 22.8888 46.742 22.0969 46.8924 21.4024L46.9499 21.3316L48.7195 15.647L49.1264 14.8021L50.7013 9.47581L51.6878 5.75981L51.7453 4.7556C51.763 4.43708 51.1393 3.80891 51.0773 2.6189C50.9535 2.59678 50.8473 2.59235 50.834 2.53042L50.7765 2.20306L50.1882 2.37559C49.7767 1.88454 48.8212 1.89782 48.3832 1.11922L48.3921 0.836107C48.3921 0.787445 48.255 0.756471 48.2328 0.800709L48.0913 1.07498L47.6577 0.694542L46.6845 0.787438L46.1935 1.15019L46.3969 0.345057L45.9236 0.822836L45.9457 0.243318L45.1185 1.22098L43.172 3.41518L39.7966 7.3745L39.9072 7.46297L41.6546 5.47668L42.9685 4.04337L43.1012 4.19378C42.6633 4.72021 42.0174 5.28203 41.6989 5.90136C41.5485 6.19776 41.4865 6.42781 41.2698 6.65785C40.761 7.20198 40.2877 7.7461 39.9293 8.33005C40.7743 7.68859 41.1149 6.75959 42.0085 6.23758L39.9161 8.79011C39.6374 9.12632 39.3808 9.34309 39.0578 9.62179C38.5624 10.0465 38.1554 10.6658 37.7395 11.2011L34.6694 15.1737L34.3111 14.979C34.3111 14.979 34.2846 14.9879 34.258 14.9525L34.665 14.7977L34.4925 14.5765L35.7975 12.8158L36.6336 11.7673L38.0536 9.91819L38.2394 10.1084C38.2394 10.1084 38.3545 9.96243 38.3589 9.97571C38.3589 9.98898 38.2571 9.82972 38.2041 9.75009L39.2835 8.1177C38.7438 8.63529 38.3102 9.17499 37.8634 9.76336L34.7933 13.8377L31.5728 18.0978C32.254 17.7483 32.5548 17.0803 32.9928 16.5185L34.143 15.041L34.2403 15.125C34.3996 15.7222 33.7537 16.5672 33.2007 16.7441L31.3737 19.3675L30.1748 21.0927L30.9888 20.4248L29.843 21.9864L29.1529 22.7871L29.0821 22.7207C29.0821 22.7207 29.0644 22.5438 29.0556 22.5084C29.0512 22.473 29.0202 22.473 28.9937 22.4951C28.9627 22.5172 28.8256 22.6322 28.799 22.6676L27.264 24.7026L27.379 24.8176L28.9671 22.7384L29.0998 22.8578L27.0959 25.6006L24.9813 28.5248L22.6367 31.8426C22.7296 31.0906 23.2737 30.6438 23.6586 30.1173L24.3089 29.0733C24.5743 28.6442 24.9105 28.3168 25.0476 27.7904L24.0257 29.1308L22.7119 30.949L21.1768 33.2051L20.9777 32.9839C20.9468 32.9486 20.8494 33.2671 20.8008 33.2803L18.6066 33.8333C18.3146 33.9041 18.2615 33.8997 18.0359 33.9793C16.9078 34.3686 15.7488 34.6031 14.5897 34.9216L13.267 35.2843L4.55653 37.8015L4.49902 37.8236L2.65429 38.3677C2.84894 38.642 2.91529 38.7349 2.82239 38.6066L2.42425 38.7305C2.38443 38.7438 2.48176 38.8455 2.51273 38.872L2.6764 39.018C3.75139 38.7349 4.81311 38.3854 5.8704 38.0315L4.99006 38.2881C4.29995 38.4872 3.64964 38.5889 2.9728 38.5049C3.52135 38.2262 4.0124 38.1244 4.56538 37.9829L4.64943 37.9254L6.60033 37.4653L10.6702 36.4743L10.7631 36.6071L8.29465 37.3237C8.56893 37.4255 8.63086 37.8944 8.27253 38.0006C6.11371 38.642 4.01682 39.4914 1.80491 39.9515C1.78722 40.0576 1.76952 40.1373 1.73413 40.1461L1.34041 40.2611C1.21212 40.2965 0.955542 40.4292 0.862642 40.5044C0.769742 40.5796 0.80071 40.8628 0.82283 40.9778L0 41.4157C0.398143 41.659 0.641452 41.7298 0.929 41.6502L2.32692 41.2476L2.34462 41.4511L0.597214 42.0218L0.552977 42.1943L2.43752 41.6767L2.44637 41.8714L0.716656 42.4775L0.663572 42.5792L1.33157 42.4376L1.91993 43.0791L0.871488 43.5923L3.22496 42.8977L4.98121 42.3359C5.14047 42.4465 5.33069 42.5173 5.43244 42.4951L6.04735 42.3492L5.89252 42.6102C5.8704 42.6456 5.92349 42.6677 6.06505 42.7606L5.56958 43.1145C5.98984 43.0127 6.22873 42.9641 6.56494 42.9641C7.14446 42.7208 7.79476 42.5084 8.42294 42.3801L9.53332 42.1545C9.60852 41.7962 9.87395 41.6281 10.2632 41.544L10.6216 41.4644C10.6879 41.4511 10.6879 41.6192 10.7056 41.7077L12.0903 Line truncated
<path d="M115.616 12.6698C115.475 12.5238 115.24 12.3867 115.019 12.2628L115.236 11.2498C114.701 11.3648 114.002 11.3427 113.652 10.8737C113.219 10.2986 112.648 10.3561 111.94 10.6968C111.949 10.6614 112.02 10.4225 111.962 10.4225L111.608 10.4004L108.782 13.3953L106.508 16.1867C107.583 15.3152 108.264 14.1606 109.374 13.4395L106.154 17.0538L105.667 17.5935C105.632 17.6289 105.534 17.536 105.459 17.4564L103.026 20.6371L104.765 14.9967L105.375 13.4307L105.07 13.0414L105.486 11.3603L104.26 14.9392L103.579 16.9565L102.916 18.7614L102.739 18.6066C102.712 18.5844 102.774 18.4561 102.792 18.4163L103.345 16.9432L104.331 13.8952L104.721 12.6211L104.889 11.9178L105.127 10.9047L105.579 9.34309C105.738 8.79454 105.849 8.25483 105.995 7.72397C106.039 7.51163 106.105 7.31257 106.185 7.1135C106.269 6.88788 106.362 6.66226 106.481 6.44107C106.654 6.0562 106.813 5.6669 106.844 5.23779C106.879 4.71136 106.8 3.8266 107.22 3.39307C107.136 3.05244 107.158 2.68526 107.211 2.31809C107.083 2.06593 107.021 1.78722 107.083 1.51736C107.065 1.50852 107.043 1.49968 107.025 1.48641C106.968 1.44217 106.928 1.38908 106.893 1.32714C106.875 1.3183 106.857 1.30503 106.84 1.29176L106.565 1.2829L105.822 0.681271C105.738 0.614914 105.676 0.327362 105.574 0.331786L105.207 0.349485C104.698 0.110599 104.092 0.172529 103.747 0.650301L103.849 0.0619399L103.451 0.42911L103.42 0L102.54 1.34041L102.394 1.60585C102.376 1.63681 102.486 1.58816 102.522 1.58373H102.778L100.929 4.22032C100.85 3.63638 101.575 3.52578 101.429 2.95953L99.4252 5.95445L99.1067 6.12256C99.0447 6.15795 99.1067 6.34375 99.1332 6.4455L98.3237 7.64878L97.9786 8.2106L94.4882 14.2049L94.6342 14.3022L95.3243 13.1255L96.97 10.4402H97.315C97.6645 9.91819 97.9653 9.39619 98.3989 8.90957L96.5453 12.1434L94.5634 15.5895C93.8999 15.9257 93.776 16.7486 93.077 16.8636L91.396 19.9647L90.9094 20.9379L89.7238 23.3489L86.5475 30.02C84.2958 34.7446 82.2829 39.4693 80.4338 44.3885L80.8319 44.1585L79.8366 46.773L80.6461 46.1758L80.0799 47.6445C80.0843 47.7285 80.1153 48.0116 80.0799 48.1001L79.3499 49.9979L78.9695 50.7234L78.6819 51.6701L79.2526 51.7276C79.3544 51.7365 79.4694 51.5374 79.58 51.4136L79.4738 52.5903L80.2214 51.1924C80.332 50.9137 80.4426 50.3961 80.7169 50.3341L81.0487 49.3344L81.3583 49.4848C81.1637 49.8741 80.9204 50.2943 80.9602 50.8208L82.6589 46.7066C82.743 46.4987 83.035 46.2775 83.2075 46.1581L85.4681 41.2521C85.9149 40.2832 86.3794 39.4471 86.8572 38.5004L87.127 37.9652C87.0651 37.8944 86.9545 37.7926 86.9854 37.7484L87.1447 37.5095C87.2332 37.3724 87.4145 37.2175 87.5959 37.1512L92.0419 28.2505C92.0728 28.047 92.1657 27.9585 92.2542 27.7948L93.7583 25.0255L96.2179 20.5619L96.6603 19.7612C96.9434 19.2524 97.2044 18.7614 97.6468 18.2704C97.4168 19.0799 96.8727 19.7214 96.4745 20.4734L95.5367 22.2518L94.6254 24.1186L94.1033 25.1803L93.5769 26.0961C93.3646 26.4677 93.1832 26.8304 93.0593 27.1489C93.2274 27.0605 93.3292 26.9808 93.3602 27.0162L93.4973 27.1578C95.6119 23.2118 97.6734 19.3763 100.146 15.5497L98.2308 23.8001L97.2089 28.5203L97.6203 29.1441L97.5805 29.4759C97.6645 29.5776 97.7176 29.7015 97.7265 29.8563C97.7309 29.9492 97.7132 30.0421 97.6999 30.135C97.7043 30.1394 97.7132 30.1483 97.7176 30.1527C97.753 30.1881 97.7928 30.2191 97.8282 30.2545L98.6643 30.4845C98.6555 30.5862 98.6555 30.6791 98.6643 30.7588C98.7439 30.8074 98.8147 30.8605 98.8899 30.9092L99.4208 30.4403C99.9339 30.8428 100.646 30.3429 101.168 29.759C101.695 29.5113 102.093 29.1308 102.128 28.4894L105.362 23.7869L107.866 20.469C108.18 20.0532 108.467 19.6373 108.883 19.279L106.609 26.1492L104.535 33.4661C104.495 33.5989 104.375 33.8068 104.424 33.8997L104.61 34.2315L104.371 35.1649C104.371 35.1649 104.411 35.1693 104.424 35.1782L104.778 34.8773L104.65 35.3817C104.694 35.4569 104.729 35.5453 104.729 35.6427C104.729 35.8329 104.667 36.0187 104.597 36.1912C104.508 36.4168 104.406 36.638 104.309 36.8636C104.305 36.8725 104.3 36.8857 104.296 36.8946C104.287 36.9167 104.278 36.9388 104.269 36.961C104.26 36.9787 104.256 37.0008 104.247 37.0185C104.274 37.0317 104.3 37.045 104.327 37.0583C104.406 37.0981 104.389 37.0804 104.309 37.0716C104.539 37.0981 104.712 37.2795 104.65 37.5228C104.623 37.6378 104.597 37.7484 104.566 37.859C104.57 37.859 104.575 37.859 104.579 37.859C104.583 37.859 104.588 37.859 104.601 37.859C104.955 37.8723 105.061 38.3014 104.796 38.5049C104.844 38.5093 104.893 38.5226 104.937 38.5491L105.008 38.6066C105.052 38.6509 105.083 38.7039 105.101 38.7614C105.101 38.7924 105.11 38.8234 105.114 38.8544C105.114 38.8588 105.114 38.8632 105.114 38.8676C105.282 38.8765 105.49 38.6951 105.645 38.4739L105.773 37.9298L105.911 37.9121L105.928 38.872L106.999 35.6913L107.308 34.1563C107.317 34.1164 107.463 33.9572 107.477 33.9926L107.578 34.3376L107.724 32.9795C107.822 32.0594 108.459 31.1923 108.565 30.2456L108.706 29.0291C108.711 28.9804 108.804 28.8079 108.852 28.8035L109.056 28.7813L110.427 24.8618L111.98 20.208C112.068 19.9381 112.113 19.6904 112.378 19.54L111.201 23.1233L109.18 29.206C109.246 29.2857 Line truncated
<path d="M137.771 44.2249L136.767 45.6405C136.718 45.5786 136.607 45.3927 136.563 45.4237L136.302 45.6051L136.072 45.7909C136.032 45.8219 135.997 45.7909 135.802 45.6803L136.621 44.1187L135.979 44.7292L136.116 44.3974C136.152 44.3178 135.975 44.0966 136.001 44.0081L136.315 42.88L136.001 43.0393C135.696 42.4952 135.961 41.8449 136.351 41.3273L136.13 41.3051C136.085 41.3051 136.015 41.2122 136.037 41.1724L136.691 40.0488L136.152 40.3363C138.377 36.4566 140.62 32.6743 143.172 29.0114L145.888 25.1096C145.955 25.0122 146.203 24.7822 146.114 24.7158C145.986 24.6141 145.782 24.5522 145.57 24.5345L144.415 22.4066L143.013 19.5798L142.504 19.686L142.495 18.5933L141.451 15.3993C141.274 14.8552 141.168 14.3332 141.248 13.82C141.434 13.8819 141.69 13.9925 141.704 13.9085L141.757 13.5148L141.766 12.9264C141.766 12.8069 142.084 12.7715 142.177 12.7317L142.323 12.2186C142.354 12.1124 142.708 12.0195 142.779 12.108L143.659 13.183L144.353 14.5986C144.451 14.7269 144.827 14.4039 144.871 14.1739L145.362 14.7932C145.535 15.0144 146.034 15.302 146.11 15.5762C146.061 16.1071 146.441 16.5053 146.614 16.9167L147.123 18.1376L148.6 21.5263L149.879 19.8054L155.086 13.7581L155.055 13.3865C155.041 13.2184 156.466 13.1122 156.187 11.9045L156.722 11.5506C156.882 11.5506 157.187 11.4842 157.302 11.3736L159.421 9.38733C159.624 9.40945 159.819 9.37848 159.912 9.31655L160.682 8.79897L160.527 9.16614C160.5 9.22808 160.496 9.36522 160.483 9.55987L162.239 8.00268C162.509 7.76379 162.721 7.6532 163.057 7.87881L160.85 10.6437L160.899 11.002L159.315 12.8689H159.713L157.846 15.1383L155.612 17.8235C155.302 18.1951 154.997 18.5535 154.873 19.0136L157.09 16.3858L156.669 17.3281L159.324 14.2314C159.178 15.0542 158.443 15.4258 158.111 16.0142C157.625 16.8813 157.041 17.5581 156.435 18.3102L153.878 21.4599L150.272 26.2111L150.48 26.2553L151.427 25.1582L153.36 22.4863C153.475 22.327 153.621 22.2916 153.913 22.3181L154.112 21.5794L155.139 20.2611L155.869 19.4515C156.315 19.2967 156.448 18.9649 156.731 18.5933L157.705 17.2971L157.846 17.3856L156.351 19.801C156.245 19.9735 155.842 20.1593 155.718 20.3097L154.462 21.8094L151.016 26.3261C150.879 26.5031 150.764 26.7773 150.622 26.8968L150.14 27.3126L150.379 26.8172C150.401 26.7729 150.264 26.6668 150.237 26.7021L150.109 26.8835L149.613 27.5957L147.764 30.0156L144.455 34.7491L143.46 36.2001L143.65 36.4345L142.124 38.5757L140.045 41.4157L139.045 42.6721L139.151 42.243C139.169 42.1634 139.04 42.0351 138.939 41.9466L137.656 43.6453C137.275 44.1497 136.935 44.6584 136.629 45.3131L137.638 44.2116L137.775 44.2249H137.771ZM148.052 28.6929L147.826 28.6707L146.716 30.1925L146.844 30.281L148.052 28.6973V28.6929Z" fill="#242424"/>
<path d="M87.2951 23.6364C86.1361 25.5962 84.8355 27.4498 83.1544 29.06L80.8629 31.2542C79.81 32.2629 78.6289 33.0636 77.3681 33.7979C77.2044 34.0324 76.8461 34.5102 76.5851 34.4836L76.0763 34.435C75.9657 34.4261 75.8419 34.665 75.7799 34.7977C75.3862 35.1472 74.7934 35.1737 74.3643 34.842C74.0015 35.1959 73.5857 35.187 73.2495 34.9349C71.8737 34.8464 71.0155 33.9749 70.4094 34.4527C70.2546 33.997 69.8033 33.7758 69.4273 33.9837L68.7947 32.8911C68.3391 32.1036 67.8701 31.1392 67.8569 30.1837C67.7994 26.3527 70.812 21.7696 73.3247 18.9118C73.5415 18.6685 73.7052 18.4738 73.8423 18.1907L74.7403 17.4033C74.7624 17.3856 74.6828 17.1423 74.6518 17.1379C74.6076 17.1379 74.8509 17.1511 74.8819 17.1511L75.2269 16.523C75.3066 16.377 75.2668 16.0275 75.2181 15.8417L75.5764 15.448L76.4877 14.8463L77.0894 14.9348C77.3459 14.6296 77.7176 14.4791 78.1201 14.6296L78.3811 14.342C78.7881 14.4747 79.2349 14.5234 79.7127 14.4482C82.0086 14.081 84.3223 14.3066 86.4546 15.2445C87.2111 15.5762 87.8215 16.1867 88.3657 16.7972C88.7815 17.2661 88.8302 17.9518 89.016 18.5048C89.1443 18.8808 89.1531 19.0313 89.0691 19.4117C88.7461 20.9202 88.1887 22.3358 87.3526 23.5922L87.2951 23.6409V23.6364ZM72.2984 32.2938C73.4884 31.9178 74.4395 31.4622 75.2712 30.6924L76.8416 29.2414L78.0095 28.2903C80.1285 26.3615 82.566 23.4418 83.8313 20.8893C84.5877 19.3675 85.384 17.5006 84.0524 16.523C82.7518 16.5539 81.584 16.8017 80.363 17.0228C80.2037 16.9786 79.9516 16.9034 79.8277 16.9742C79.7215 17.0361 79.5711 17.3768 79.6508 17.4697L80.0533 17.9253L78.766 19.2923L78.1555 19.9426L76.3506 22.1633C75.311 23.4418 74.413 24.7689 73.7229 26.2642L72.7806 28.3036C72.2055 29.5467 71.6348 31.1304 72.2895 32.3027L72.2984 32.2938ZM88.0073 20.9114C88.578 19.9204 88.7107 18.8056 88.348 17.7351C88.2905 18.4562 88.3745 19.2038 88.1976 19.8939C88.1047 20.2566 87.9454 20.5486 88.0073 20.9114ZM86.1892 24.2823L87.1889 22.6986C87.503 22.1987 87.7729 21.6944 87.9498 21.0308L86.5608 23.4108C86.3971 23.694 86.2599 23.9328 86.1892 24.2823ZM87.2907 23.4816L87.1358 23.3754C86.4988 24.1717 85.9326 24.8751 85.5256 25.7112L87.2111 23.5745L87.2907 23.486V23.4816ZM68.6089 30.5332L68.6355 29.3034C68.6443 28.9008 68.7062 28.6088 68.662 28.2549L68.3568 29.8696C68.3081 30.1218 68.4939 30.604 68.5558 30.865C68.7018 31.4843 68.7859 32.0505 69.2725 32.4089C68.6487 31.2366 68.9673 30.5066 68.6089 30.5287V30.5332Z" fill="#242424"/>
<path d="M130.33 18.8941C129.967 18.7791 129.587 18.872 129.202 18.9428L126.41 19.4382L127.286 16.0806L127.477 16.0983L127.052 18.2173L127.207 18.2659L127.384 17.4696C127.397 17.4121 127.468 17.2308 127.521 17.2396L127.773 17.2794C128.291 14.9702 128.658 12.6698 128.941 10.25L128.653 10.4933L128.835 9.76779L128.963 10.2102L129.175 9.51563C129.282 9.17499 128.914 8.82994 128.574 8.75916C128.689 8.56451 128.821 8.24157 128.746 8.10443L128.304 7.29929V7.09137C128.207 7.05598 128.114 7.0029 128.038 6.91885C128.025 6.90115 128.007 6.88788 127.994 6.87018C127.99 6.87018 127.981 6.86577 127.976 6.86577C127.923 6.84365 127.879 6.81709 127.835 6.77286C127.822 6.75516 127.808 6.7419 127.8 6.7242C127.786 6.73305 127.777 6.73748 127.764 6.7419C127.755 6.75075 127.742 6.75959 127.738 6.76401C127.72 6.78171 127.702 6.79497 127.685 6.81267C127.631 6.86133 127.569 6.90557 127.508 6.94096C127.366 7.02059 127.198 7.06484 127.034 7.04272C126.906 7.02502 126.804 6.96751 126.742 6.87461L126.565 6.93212C126.269 7.03387 126.158 7.18427 125.787 7.05156L125.212 7.46297C125.105 7.432 124.902 7.35239 124.898 7.43201C124.844 8.10886 124.097 8.91399 123.495 9.54217L123.017 9.96685C122.672 10.2721 122.5 10.6216 122.279 11.0286L122.097 11.3603C122.066 11.4134 122.199 11.4931 122.323 11.5373C123.19 10.1792 124.075 8.94052 125.331 7.91862C125.349 8.21944 125.136 8.34332 124.959 8.56451L122.717 11.3515L121.115 13.3909L121.367 12.4663C118.903 16.0009 116.616 19.5134 114.44 23.2516L113.201 23.6586C113.037 23.7116 113.192 24.1629 113.236 24.3221L113.449 25.0565L110.746 30.1616L111.082 30.0952L110.157 31.7895L110.648 31.9267L110.909 31.4931L110.998 31.6037L110.75 32.2054L111.272 31.909L109.733 35.3197C109.963 35.4657 110.131 35.3241 110.241 35.1516L110.441 34.842C110.48 34.78 110.675 34.842 110.768 34.8597L111.285 34.1209L111.268 34.7314L112.21 34.028L112.838 33.0769L113.241 33.298C113.316 32.9663 113.281 32.7849 113.17 32.5858L114.121 30.865C115.108 31.2012 114.227 30.1173 114.922 29.9625C115.24 29.8917 115.121 29.4714 115.209 29.3122L116.886 26.2686L122.765 23.8665L122.075 28.653C122.031 28.9539 122.473 29.3343 122.699 29.4139C122.69 29.582 122.663 29.7634 122.752 29.7988L123.11 29.9492C123.172 29.9758 123.314 30.1925 123.362 30.1439L123.557 29.9448L123.708 30.5199C123.743 30.6526 124.048 30.6836 124.163 30.6968L124.353 31.0154C124.389 31.0773 124.632 30.8694 124.645 30.7897L125.066 28.7282C125.088 28.6176 125.163 28.5159 125.136 28.4628L125.017 28.193C125.309 27.7948 125.406 27.2374 125.163 26.742L125.796 25.9855L125.964 25.4767L126.335 24.154L126.636 22.4509L127.941 21.951H127.087L128.392 21.3626C128.481 21.3228 128.698 21.2741 128.751 21.3493L129.021 21.7121L129.481 21.0131C129.804 20.5221 130.272 20.1151 130.733 19.6594L130.321 18.9074L130.33 18.8941ZM122.748 23.7116L120.819 24.3973L120.721 24.2248L122.717 23.4639C122.809 23.4285 122.805 23.6939 122.748 23.7116ZM123.367 20.3628L119.952 21.3847L122.703 17.2706L124.619 14.6517L123.367 20.3628Z" fill="#242424"/>
<path d="M142.208 25.9722L142.973 25.8174L143.646 26.3792L142.292 27.003L136.408 30.1748C136.373 30.2589 136.302 30.4889 136.231 30.4845L135.908 30.458L132.321 32.692C132.069 32.8512 131.865 32.9441 131.591 33.1034L130.211 33.9174L129.228 34.4173L128.459 34.4084L128.198 33.8156C128.158 33.7227 127.923 33.4927 127.831 33.5325L127.401 33.7183C127.092 33.5015 126.932 33.2759 126.902 32.9574L126.764 31.5329L126.335 31.5418L127.424 28.914L129.666 23.4551L129.958 22.734L130.856 20.9246L131.821 18.8764C131.914 18.6818 132.002 18.5933 132.122 18.3721L132.807 17.1246L132.595 16.8813C132.546 16.8238 132.834 16.7574 132.905 16.7043C133.329 16.3814 133.453 15.7355 133.741 15.3152L134.369 14.3995L135.232 12.8954L139.085 6.69323L139.823 5.75538C140.164 5.32185 140.536 4.96352 140.983 4.62289L140.921 5.52535L140.328 6.76844L140.469 6.75959L142.916 2.81355L143.04 2.95069L141.925 5.06084L140.434 8.20618L140.722 8.14424C141.062 8.07346 139.576 9.87838 139.43 10.7631C139.89 10.2411 140.239 9.58198 140.584 8.97149L141.571 7.22409L141.681 7.31256L140.522 9.52447L140.576 9.58198C140.766 9.27674 140.947 8.98477 141.226 8.6751L140.142 10.7587C139.859 11.3073 139.567 11.7895 139.416 12.4088L140.058 11.3205L140.284 11.5771C140.337 11.6346 140.155 11.7895 140.111 11.8735L138.355 15.3639L135.307 21.4865C135.059 21.9819 134.829 22.5659 134.763 23.079C134.754 23.1542 134.802 23.4329 134.727 23.4197L134.36 23.3622L132.095 28.193L133.489 27.5073L136.156 26.2376C136.461 26.0916 136.669 25.6979 137.112 25.8882L137.824 25.49C137.846 25.4679 137.886 25.2379 137.912 25.2644L138.107 25.4944L141.801 24.3487L141.991 24.5876C140.558 24.968 139.293 25.4237 137.939 26.0164C137.713 26.1138 137.457 26.1049 137.412 26.3969L140.717 25.198C141.301 24.9857 141.854 24.8132 142.464 24.8486L142.787 25.5077L142.203 25.9766L142.208 25.9722ZM137.881 13.966C138.39 13.329 138.748 12.7052 138.877 11.9133C138.642 12.1434 138.549 12.4221 138.421 12.7406C138.253 13.1609 137.908 13.4838 137.881 13.966ZM127.3 30.0996C127.773 29.3653 128.038 28.684 128.246 27.9054C127.738 28.5734 127.41 29.321 127.3 30.0996Z" fill="#242424"/>
<path d="M70.9889 8.0071L70.5598 8.82108L70.4935 8.27695L70.7633 7.62223L71.4888 6.02523C71.7366 6.29951 71.7498 6.53397 71.6525 6.7994L71.0066 8.59989L70.9845 8.00268L70.9889 8.0071Z" fill="#242424"/>
<path d="M89.8786 33.9041L91.8605 29.9492L92.5064 28.7371L92.5771 28.914L90.8297 32.3912C90.5687 32.9132 90.321 33.4352 89.8786 33.9041Z" fill="#242424"/>
<path d="M89.1177 35.7179L88.2816 37.3503L88.1445 37.2662L89.1575 35.2711C89.1885 35.2357 89.1752 35.6073 89.1177 35.7179Z" fill="#242424"/>
<path d="M30.1041 20.2036C30.4403 19.5842 30.8428 19.0534 31.3471 18.5225C31.0596 19.1728 30.6924 19.7302 30.1041 20.2036Z" fill="#242424"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 30 KiB

+15
View File
@@ -0,0 +1,15 @@
import { StrictMode } from "react"
import { createRoot, hydrateRoot } from "react-dom/client"
import { App } from "./App"
import "./system/tokens.css"
import "./site.css"
const root = document.getElementById("root")!
const page = (
<StrictMode>
<App />
</StrictMode>
)
if (root.firstElementChild) hydrateRoot(root, page)
else createRoot(root).render(page)
+1092
View File
File diff suppressed because it is too large. Load diff
+57
View File
@@ -0,0 +1,57 @@
export type Route = { path: string; label: string; title: string; description: string }
export const REPO = "https://github.com/anomalyco/rune"
export const routes: Route[] = [
{
path: "/",
label: "Overview",
title: "Rune · Rust UI framework",
description:
"Rune is a Rust UI framework with its own GPU renderer, text, layout, spring animation and thin per-platform shells, written and checked by agents.",
},
{
path: "/how-it-works",
label: "How it works",
title: "How it works · Rune",
description:
"How a Rune frame runs, from input and state through Taffy layout and springs to wgpu, with real code, the thread model, headless tests and the crate map.",
},
{
path: "/launch-fast",
label: "Launch fast",
title: "Launch fast · Rune",
description:
"How to get a Rune app's first window on screen in about 300 ms: prewarm_gpu, precompiled Metal shaders, a first frame at creation, deferred setup, a still first second, an idle window that draws nothing, a reused hidden window, and how to measure it.",
},
{
path: "/fast-apps",
label: "Fast apps",
title: "Fast apps · Rune",
description:
"How to keep a Rune app fast: a free main thread, long lists that build only what is on screen, memo keyed small, an idle window that draws nothing, cheap poll, bounded caches, and a script that audits a repo.",
},
{
path: "/principles",
label: "Principles",
title: "Principles · Rune",
description: "What Rune optimises for and the rules it holds itself to.",
},
{
path: "/architecture",
label: "Architecture",
title: "Architecture · Rune",
description: "How Rune is built: the app side, the command channel, the render thread, the renderer and the platform shells.",
},
{
path: "/roadmap",
label: "Roadmap",
title: "Roadmap · Rune",
description: "Rune's milestones, from the first spikes to OpenCode Desktop, the web and iOS.",
},
]
export function normalizePath(path: string): string {
const trimmed = path.replace(/\/index\.html$/, "").replace(/\/+$/, "")
return trimmed === "" ? "/" : trimmed
}
+833
View File
@@ -0,0 +1,833 @@
/* Rune on the Anomaly docs system (system/tokens.css, system/primitives.css): the accent, the wordmark, the home
page, the diagrams and the page parts the system doesn't have yet. */
:root {
/* Rune's accent replaces the system's red ink; everything else is the shared system as is. */
--ink: oklch(0.74 0.14 245);
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
/* Wordmark, ᚱUNE (src/brand): pixel letters, drawn at whole pixels a cell, 2 in the sidebar and 12 on the home page. */
.wordmark {
position: relative;
display: block;
width: calc(var(--cells) * 2px);
color: var(--ink);
}
.wordmark svg {
display: block;
width: 100%;
height: 100%;
fill: currentColor;
}
.wordmark-glint { fill: oklch(0.97 0.035 245); }
.wordmark-rune.is-lit { fill: oklch(0.97 0.035 245); }
/* The lockup row stands as tall as the system's, whose search button sets it, so the nav starts on the same line. */
.brand {
display: flex;
align-items: center;
min-height: 28px;
text-decoration: none;
}
/* Home */
.home-hero {
max-width: 40rem;
margin-bottom: var(--space-9);
container-type: inline-size;
}
.masthead { margin: 0; font: inherit; }
/* 12 px a cell, or the most whole pixels a cell that fit a narrow column. */
.masthead .wordmark {
width: min(calc(var(--cells) * 12px), 100%);
width: min(calc(var(--cells) * 12px), round(down, 100cqw / var(--cells), 1px) * var(--cells));
}
.home-lede {
margin: var(--space-7) 0 0;
font: var(--text-20);
font-weight: 400;
letter-spacing: var(--track-20);
color: var(--fg-2);
text-wrap: pretty;
}
.home-lede strong { color: var(--fg); font-weight: 400; }
.home-more {
margin: var(--space-4) 0 0;
font: var(--text-16);
color: var(--fg-2);
text-wrap: pretty;
}
@media (max-width: 900px) {
.home-hero { margin-bottom: var(--space-8); }
}
/* Home: an app's code beside its headless render, and the how-do-I examples. */
.app-demo {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
gap: var(--space-5);
align-items: start;
margin-top: var(--space-5);
}
.app-demo .code-block { max-width: none; margin: 0; }
.app-shot { width: var(--shot-w); max-width: 100%; }
.app-shot figcaption code { font: inherit; white-space: nowrap; }
.howto-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-8); }
.howto h3 {
margin: 0 0 var(--space-2);
font: var(--text-16);
font-weight: 500;
scroll-margin-top: var(--space-6);
}
.howto > p {
max-width: var(--measure);
margin: 0;
color: var(--fg-2);
text-wrap: pretty;
}
.howto > p code, .home-section .section-intro code { font: var(--mono-12); color: var(--fg); }
.howto-list + .home-more { margin-top: var(--space-7); }
.build-meta {
display: flex;
flex-direction: column;
align-items: flex-end;
gap: var(--space-1);
}
.build-meta a { color: var(--fg-3); text-decoration: none; }
@media (hover: hover) and (pointer: fine) {
.build-meta a:hover { color: var(--fg); }
}
.home-section .index-list + .shots { margin-top: var(--space-7); }
@media (max-width: 1100px) {
.app-demo { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
.howto h3 { scroll-margin-top: calc(var(--topbar) + var(--space-4)); }
.build-meta { flex-direction: row; align-items: baseline; gap: var(--space-3); }
}
@media (max-width: 760px) {
/* The status and where to see it go under the text, so the title keeps the row. */
.index-row:has(.build-meta) { grid-template-columns: minmax(0, 1fr); }
.build-meta { grid-row: 3; justify-content: flex-start; }
}
/* Page sections */
.home-section + .home-section,
.doc-section + .doc-section,
.doc-section + #choices,
#choices .doc-section + .doc-section { margin-top: var(--space-9); }
.home-section .index-list { margin-bottom: var(--space-7); }
/* Headless renders, two up; the columns follow each image's aspect so both stand the same height. */
.shots {
display: grid;
grid-template-columns: 1.19fr 1.56fr;
gap: var(--space-5);
align-items: start;
}
.shot { margin: 0; }
.shot img {
display: block;
width: 100%;
height: auto;
border-radius: var(--radius-2);
outline: 1px solid var(--line);
outline-offset: -1px;
}
.shot figcaption {
margin-top: var(--space-2);
font: var(--mono-12);
color: var(--fg-3);
}
/* Code, cut from Rune's source and highlighted at build time (scripts/snippets.ts); the token colours are the
system's. */
.code-block {
max-width: 52rem;
margin: var(--space-5) 0 0;
border-radius: var(--radius-2);
background: var(--surface-1);
box-shadow: inset 0 0 0 1px var(--line);
overflow: hidden;
}
.code-stack {
display: grid;
gap: var(--space-4);
margin-top: var(--space-5);
}
.code-stack .code-block { margin: 0; }
.code-head {
display: flex;
justify-content: space-between;
gap: var(--space-4);
padding: var(--space-2) var(--space-4);
box-shadow: inset 0 -1px var(--line);
font: var(--mono-12);
color: var(--fg-3);
}
.code-head a {
min-width: 0;
overflow-wrap: anywhere;
color: var(--fg-2);
text-decoration: none;
}
.code-lines { color: var(--fg-3); }
.code-lang { flex: none; }
@media (hover: hover) and (pointer: fine) {
.code-head a:hover { color: var(--fg); }
}
.code {
margin: 0;
padding: var(--space-4);
overflow-x: auto;
font: var(--mono-12);
line-height: 20px;
color: var(--fg);
tab-size: 4;
}
.code code { font: inherit; }
.prose-after { margin-top: var(--space-6); }
/* How-it-works diagrams: boxes on the surface, ink arrows, mono kickers; everything stacks on a phone. */
.dg { max-width: 52rem; margin: 0; }
.dg figcaption {
max-width: var(--measure);
margin-top: var(--space-4);
font: var(--text-13);
color: var(--fg-3);
text-wrap: pretty;
}
.dg code, .dg figcaption code { font: var(--mono-12); color: var(--fg); white-space: nowrap; }
.dg-kicker {
margin: 0 0 6px;
font: var(--mono-12);
color: var(--fg-3);
}
.dg-box {
padding: var(--space-3) var(--space-4) var(--space-4);
border-radius: var(--radius-2);
background: var(--surface-1);
box-shadow: inset 0 0 0 1px var(--line);
}
.dg-box h3 {
margin: 0 0 var(--space-2);
font: var(--text-14);
font-weight: 500;
}
.dg-box h3 code { font: var(--mono-13); }
.dg-box ul {
display: grid;
gap: var(--space-1);
margin: 0;
padding: 0;
list-style: none;
font: var(--text-13);
color: var(--fg-2);
}
.dg-box li { position: relative; padding-left: var(--space-4); }
.dg-box li::before {
content: "";
position: absolute;
top: 10px;
left: 0;
width: 6px;
height: 1px;
background: var(--fg-3);
}
.dg-small { padding: var(--space-3) var(--space-4); }
.dg-small h3 { margin-bottom: 2px; font: var(--text-13); font-weight: 500; }
.dg-small p { margin: 0; font: var(--text-13); color: var(--fg-2); text-wrap: pretty; }
/* A vertical arrow in the gap above an element, centred, head pointing down. */
.dg-flow > li + li::before,
.dg-layers > li + li::before {
content: "";
position: absolute;
top: -20px;
left: 50%;
width: 1px;
height: 20px;
background: var(--ink-dim);
}
.dg-flow > li + li::after,
.dg-layers > li + li::after {
content: "";
position: absolute;
top: -7px;
left: calc(50% - 2.5px);
width: 6px;
height: 6px;
border-right: 1px solid var(--ink);
border-bottom: 1px solid var(--ink);
transform: rotate(45deg);
}
/* Chain: boxes left to right with arrows between, and a line back for a loop; top to bottom on a phone. */
.dg-chain {
display: grid;
grid-template-columns: repeat(var(--links), minmax(0, 1fr));
gap: 20px;
margin: 0;
padding: 0;
list-style: none;
}
.dg-chain > li { position: relative; }
.dg-chain > li + li::before {
content: "";
position: absolute;
top: 50%;
left: -20px;
width: 20px;
height: 1px;
background: var(--ink-dim);
}
.dg-chain > li + li::after {
content: "";
position: absolute;
top: calc(50% - 2.5px);
left: -8px;
width: 6px;
height: 6px;
border-top: 1px solid var(--ink);
border-right: 1px solid var(--ink);
transform: rotate(45deg);
}
.dg-chain h3 code { font: var(--mono-13); }
.dg-back {
position: relative;
margin: 0;
padding: var(--space-5) 0 0;
font: var(--mono-12);
color: var(--fg-3);
text-align: center;
}
/* From under the last box, along the bottom and up into the first; the head points up. */
.dg-back-line {
position: absolute;
top: 0;
left: 10%;
right: 10%;
height: 12px;
border: 1px solid var(--ink-dim);
border-top: 0;
border-radius: 0 0 var(--radius-1) var(--radius-1);
}
.dg-back-line::after {
content: "";
position: absolute;
top: -1px;
left: -3.5px;
width: 6px;
height: 6px;
border-top: 1px solid var(--ink);
border-left: 1px solid var(--ink);
transform: rotate(45deg);
}
.dg-back-label { position: relative; }
/* Frame */
.dg-flow {
display: grid;
gap: 20px;
max-width: 52rem;
margin: 0;
padding: 0;
list-style: none;
}
.dg-flow > li { position: relative; }
.dg-step {
display: grid;
grid-template-columns: 2.5ch 5.5rem minmax(0, 1fr) auto;
align-items: baseline;
gap: 0 var(--space-4);
padding: var(--space-3) var(--space-4);
border-radius: var(--radius-2);
background: var(--surface-1);
box-shadow: inset 0 0 0 1px var(--line);
}
.dg-num { font: var(--mono-12); color: var(--fg-3); font-variant-numeric: tabular-nums; }
.dg-name { font: var(--text-14); font-weight: 500; }
.dg-does { font: var(--text-13); color: var(--fg-2); text-wrap: pretty; }
.dg .dg-at { font: var(--mono-12); color: var(--fg-3); text-align: right; }
.dg-group {
padding: 36px var(--space-3) var(--space-3);
border-radius: calc(var(--radius-2) + 4px);
box-shadow: inset 0 0 0 1px var(--ink-dim);
background: color-mix(in srgb, var(--ink) 4%, transparent);
}
.dg-group-label {
position: absolute;
top: 10px;
left: var(--space-4);
margin: 0;
font: var(--mono-12);
color: var(--ink);
}
/* Threads */
.dg-pair {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: var(--space-5);
}
.dg-panel { display: flex; flex-direction: column; }
.dg-panel[data-planned] .dg-box { box-shadow: inset 0 0 0 1px var(--line-2); background: none; }
.dg-panel[data-planned] .dg-kicker { color: var(--ink); }
.dg-feeds {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: var(--space-3);
margin-top: 20px;
}
.dg-feeds > .dg-box { position: relative; }
/* Up into the main thread: these threads hand it data. */
.dg-feeds > .dg-box::before {
content: "";
position: absolute;
top: -20px;
left: 50%;
width: 1px;
height: 20px;
background: var(--ink-dim);
}
.dg-feeds > .dg-box::after {
content: "";
position: absolute;
top: -19px;
left: calc(50% - 2.5px);
width: 6px;
height: 6px;
border-top: 1px solid var(--ink);
border-left: 1px solid var(--ink);
transform: rotate(45deg);
}
.dg-link {
display: flex;
align-items: center;
gap: var(--space-3);
margin: 0;
padding: 0 var(--space-4);
font: var(--mono-12);
color: var(--fg-3);
text-wrap: balance;
}
.dg-link .dg-arrow { flex: none; height: 56px; }
.dg-arrow {
position: relative;
display: block;
width: 1px;
background: var(--ink-dim);
}
/* Heads at both ends: the channel carries traffic both ways. */
.dg-link .dg-arrow::before,
.dg-link .dg-arrow::after {
content: "";
position: absolute;
left: -2.5px;
width: 6px;
height: 6px;
transform: rotate(45deg);
}
.dg-link .dg-arrow::before { top: 1px; border-top: 1px solid var(--ink); border-left: 1px solid var(--ink); }
.dg-link .dg-arrow::after { bottom: 1px; border-right: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
/* Crates */
.dg-crates {
display: grid;
grid-template-columns: minmax(0, 1fr) 13rem;
gap: var(--space-5);
align-items: start;
}
.dg-layers {
display: grid;
gap: 20px;
margin: 0;
padding: 0;
list-style: none;
}
.dg-layer { position: relative; }
.dg-layers > li + li::before { top: -20px; }
.dg-layer-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.dg-layer-row > .dg-box { flex: 1 1 14rem; }
.dg-side {
display: grid;
gap: var(--space-2);
padding: var(--space-3);
border-radius: calc(var(--radius-2) + 4px);
box-shadow: inset 0 0 0 1px var(--line);
}
.dg-side .dg-kicker { margin-bottom: 0; }
/* Tests */
.dg-test {
display: grid;
grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr) 40px minmax(0, 1.25fr);
align-items: center;
}
.dg-test > .dg-arrow { width: auto; height: 1px; }
.dg-test > .dg-arrow::after {
content: "";
position: absolute;
top: -2.5px;
right: 1px;
width: 6px;
height: 6px;
border-top: 1px solid var(--ink);
border-right: 1px solid var(--ink);
transform: rotate(45deg);
}
.dg-outs {
display: grid;
gap: var(--space-2);
margin: 0;
padding: 0;
list-style: none;
}
/* Architecture diagram: app side and render thread with the channel between, the shell under both. */
.arch { margin: 0; }
.arch-grid {
--channel: 176px;
display: grid;
grid-template-columns: minmax(0, 1fr) var(--channel) minmax(0, 1fr);
grid-template-areas:
"app channel render"
"shell shell shell";
gap: var(--space-5) 0;
}
[data-area="app"] { grid-area: app; }
[data-area="channel"] { grid-area: channel; }
[data-area="render"] { grid-area: render; }
[data-area="shell"] { grid-area: shell; }
.arch-box {
position: relative;
padding: var(--space-4) var(--space-5) var(--space-5);
border-radius: var(--radius-2);
background: var(--surface-1);
box-shadow: inset 0 0 0 1px var(--line);
}
.arch-box h3 {
margin: 0 0 var(--space-3);
font: var(--text-14);
font-weight: 500;
}
.arch-kicker {
margin: 0 0 2px;
font: var(--mono-12);
color: var(--fg-3);
}
.arch-box ul {
display: grid;
gap: var(--space-1);
margin: 0;
padding: 0;
list-style: none;
font: var(--text-13);
color: var(--fg-2);
}
.arch-box li {
position: relative;
padding-left: var(--space-4);
}
.arch-box li::before {
content: "";
position: absolute;
top: 10px;
left: 0;
width: 6px;
height: 1px;
background: var(--fg-3);
}
.arch-line {
margin: 0;
font: var(--text-13);
color: var(--fg-2);
text-wrap: pretty;
}
.arch-inner {
margin-top: var(--space-4);
padding: var(--space-3) var(--space-4);
border-radius: var(--radius-1);
background: var(--surface-1);
box-shadow: inset 0 0 0 1px var(--line);
}
.arch-inner-title {
margin: 0 0 var(--space-2);
font: var(--text-13);
font-weight: 500;
}
.arch-channel {
display: flex;
flex-direction: column;
justify-content: center;
gap: var(--space-5);
padding: 0 var(--space-3);
text-align: center;
}
.arch-channel-label {
margin: 0;
font: var(--mono-12);
color: var(--ink);
}
.arch-flow {
display: grid;
gap: var(--space-2);
}
.arch-flow-text {
font: var(--mono-12);
color: var(--fg-3);
text-wrap: balance;
}
/* The line runs edge to edge between the boxes; the head is a chevron drawn from two borders. */
.arch-arrow {
position: relative;
display: block;
height: 1px;
margin-inline: calc(-1 * var(--space-3));
background: var(--ink-dim);
}
.arch-arrow::after {
content: "";
position: absolute;
top: -2.5px;
right: 2px;
width: 6px;
height: 6px;
border-top: 1px solid var(--ink);
border-right: 1px solid var(--ink);
transform: rotate(45deg);
}
.arch-flow[data-dir="back"] .arch-arrow::after {
right: auto;
left: 2px;
transform: rotate(-135deg);
}
/* The shell lines its two parts up under the boxes above, with a connector from each. */
.arch-shell {
display: grid;
grid-template-columns: minmax(0, 1fr) var(--channel) minmax(0, 1fr);
padding: 0;
}
.arch-shell > div { padding: var(--space-4) var(--space-5) var(--space-5); }
.arch-shell > div + div { grid-column: 3; }
.arch-shell::before,
.arch-shell::after {
content: "";
position: absolute;
top: calc(-1 * var(--space-5));
width: 1px;
height: var(--space-5);
background: var(--line-2);
}
.arch-shell::before { left: calc((100% - var(--channel)) / 4); }
.arch-shell::after { right: calc((100% - var(--channel)) / 4); }
.arch figcaption {
max-width: var(--measure);
margin-top: var(--space-4);
font: var(--text-13);
color: var(--fg-3);
text-wrap: pretty;
}
/* Decisions */
.decisions {
width: 100%;
border-collapse: collapse;
font: var(--text-13);
text-align: left;
}
.decisions th,
.decisions td {
padding: var(--space-3) var(--space-5) var(--space-3) 0;
box-shadow: inset 0 -1px var(--line);
vertical-align: top;
text-wrap: pretty;
}
.decisions th:last-child,
.decisions td:last-child { padding-right: 0; }
.decisions thead th {
padding-top: 0;
padding-bottom: var(--space-2);
font: var(--text-12);
color: var(--fg-3);
white-space: nowrap;
}
.decisions tbody th {
width: 8.5rem;
font-weight: 500;
color: var(--fg);
}
.decisions td { color: var(--fg-2); }
.decisions td:nth-child(2) { width: 22%; color: var(--fg); }
.decisions td.rejected { width: 22%; color: var(--fg-3); }
/* Roadmap */
.milestones .index-title {
display: flex;
align-items: baseline;
gap: var(--space-3);
}
.milestone-id {
flex: none;
width: 4ch;
font: var(--mono-13);
color: var(--fg-3);
font-variant-numeric: tabular-nums;
}
.index-text p { margin: 0; }
.index-text code,
.prose li code { font: var(--mono-12); color: var(--fg); }
.milestones .index-row { scroll-margin-top: var(--space-6); }
.rule-text code { font: var(--mono-12); }
.status {
display: inline-flex;
align-items: center;
gap: 6px;
}
.status::before {
content: "";
width: 6px;
height: 6px;
border-radius: 50%;
box-shadow: inset 0 0 0 1px var(--fg-3);
}
.status[data-status="done"]::before { background: var(--fg); box-shadow: none; }
.status[data-status="now"] { color: var(--fg); }
.status[data-status="now"]::before { background: var(--ink); box-shadow: none; }
.status[data-status="started"]::before { background: linear-gradient(90deg, var(--fg-2) 50%, transparent 50%); }
/* Pager and footer */
.doc-pager {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: var(--space-4);
margin-top: var(--space-9);
padding-top: var(--space-4);
box-shadow: inset 0 1px var(--line);
font: var(--text-13);
}
.doc-pager a { color: var(--fg-2); text-decoration: none; }
@media (hover: hover) and (pointer: fine) {
.doc-pager a:hover { color: var(--fg); }
}
.site-footer {
width: 100%;
max-width: calc(var(--content) + 2 * var(--space-7));
margin-inline: auto;
padding: 0 var(--space-7) var(--space-7);
}
.copyright {
position: relative;
display: inline-block;
font: var(--text-12);
color: var(--fg-3);
}
.copyright img {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
opacity: .7;
pointer-events: none;
}
.copyright p { position: relative; margin: 0; }
.copyright a { color: inherit; }
@media (max-width: 900px) {
.site-footer { padding: 0 var(--space-4) var(--space-6); }
.home-section + .home-section,
.doc-section + .doc-section,
.doc-section + #choices,
#choices .doc-section + .doc-section { margin-top: var(--space-8); }
.milestones .index-row { scroll-margin-top: calc(var(--topbar) + var(--space-4)); }
}
/* Narrow: the diagram stacks, the channel turns vertical, the table becomes a list. */
@media (max-width: 760px) {
.arch-grid {
grid-template-columns: minmax(0, 1fr);
grid-template-areas: "app" "channel" "render" "shell";
row-gap: 0;
}
.arch-channel {
display: grid;
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
align-items: center;
gap: 0 var(--space-3);
padding: 0;
}
.arch-channel-label { grid-column: 2; grid-row: 1; }
.arch-flow {
display: flex;
align-items: center;
gap: var(--space-3);
grid-row: 1;
}
.arch-flow[data-dir="fwd"] { grid-column: 1; flex-direction: row-reverse; text-align: right; }
.arch-flow[data-dir="back"] { grid-column: 3; text-align: left; }
.arch-arrow {
flex: none;
width: 1px;
height: 88px;
margin: 0;
}
.arch-arrow::after { top: auto; right: auto; bottom: 2px; left: -2.5px; transform: rotate(135deg); }
.arch-flow[data-dir="back"] .arch-arrow::after { top: 2px; bottom: auto; left: -2.5px; transform: rotate(-45deg); }
.arch-shell {
margin-top: var(--space-5);
grid-template-columns: minmax(0, 1fr);
}
.arch-shell > div + div { grid-column: 1; box-shadow: inset 0 1px var(--line); }
.arch-shell::before { left: 50%; }
.arch-shell::after { display: none; }
.shots { grid-template-columns: minmax(0, 1fr); }
.dg-chain { grid-template-columns: minmax(0, 1fr); }
.dg-chain > li + li::before { top: -20px; left: 50%; width: 1px; height: 20px; }
.dg-chain > li + li::after { top: -7px; left: calc(50% - 2.5px); transform: rotate(135deg); }
.dg-back { padding: var(--space-3) 0 0; text-align: left; }
.dg-back-line { display: none; }
.dg-pair, .dg-crates { grid-template-columns: minmax(0, 1fr); }
.dg-pair { gap: var(--space-6); }
.dg-test { grid-template-columns: minmax(0, 1fr); }
.dg-test > .dg-arrow { justify-self: center; width: 1px; height: 24px; }
.dg-test > .dg-arrow::after { top: auto; right: auto; bottom: 1px; left: -2.5px; transform: rotate(135deg); }
}
@media (max-width: 640px) {
.dg-step { grid-template-columns: 2.5ch minmax(0, 1fr); row-gap: 2px; }
.dg-does, .dg .dg-at { grid-column: 2; text-align: left; }
}
@media (max-width: 640px) {
.decisions thead { display: none; }
.decisions, .decisions tbody, .decisions tr, .decisions th, .decisions td { display: block; width: auto !important; }
.decisions tr { padding: var(--space-3) 0; box-shadow: inset 0 -1px var(--line); }
.decisions th, .decisions td { padding: 0; box-shadow: none; }
.decisions tbody th { margin-bottom: var(--space-1); }
.decisions td + td { margin-top: var(--space-1); }
.decisions td[data-label]::before {
content: attr(data-label) " ";
color: var(--fg-3);
}
}
/* The system's frame lets its two rows share spare height under 900 px, which drops a short page to the middle of the
screen; the top bar keeps its own height and the page takes the rest. */
@media (max-width: 900px) {
.frame { grid-template-rows: auto minmax(0, 1fr); }
}
+5
View File
@@ -0,0 +1,5 @@
declare module "virtual:snippets" {
import type { Snippet } from "../scripts/snippets"
const snippets: Record<string, Snippet>
export default snippets
}
+355
View File
@@ -0,0 +1,355 @@
import { useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore, type ReactNode } from "react"
import { useScrollSpy } from "./useScrollSpy"
import "./primitives.css"
export type NavItem = {
href: string
label: string
/** Mono counter shown before the label, e.g. a rule number. */
num?: string
/** Element id on this page that marks the item current while it is in view. */
spy?: string
/** The page this item opens is the one being shown. */
current?: boolean
children?: NavItem[]
/** A quiet label above a run of children, e.g. a guide's section. */
heading?: boolean
}
export type NavGroup = { label: string; items: NavItem[] }
function spyIds(items: NavItem[]): string[] {
return items.flatMap(item => [...(item.spy ? [item.spy] : []), ...spyIds(item.children ?? [])])
}
/** Top-level items follow the one active section; children (a guide's rules) light up for everything in view. */
function NavLinks({ items, active, inView, depth }: { items: NavItem[]; active: string | null; inView: string[]; depth: number }) {
const here = depth === 0 ? active : (inView[0] ?? null)
return (
<ul className="nav-list" data-depth={depth}>
{items.map(item =>
item.heading ? (
<li key={item.href} className="nav-heading">
<a href={item.href}>{item.label}</a>
</li>
) : (
<li key={item.href}>
<a
href={item.href}
className="nav-link"
data-parent={(item.children && item.children.length > 0) || undefined}
data-active={(item.spy ? (depth === 0 ? item.spy === active : inView.includes(item.spy)) : item.current) || undefined}
aria-current={item.current && !item.children ? "page" : item.spy && item.spy === here ? "location" : undefined}
>
{item.num && <span className="nav-num">{item.num}</span>}
<span className="nav-label">{item.label}</span>
</a>
{item.children && item.children.length > 0 && (
<NavLinks items={item.children} active={active} inView={inView} depth={depth + 1} />
)}
</li>
),
)}
</ul>
)
}
/** One edge of the rail mark on a critically damped spring: position, velocity, and where it's headed. */
type Edge = { x: number; v: number; target: number }
type RailMotion = { top: Edge; bottom: Edge; x: number; shown: boolean; frame: number; last: number }
const still = (): Edge => ({ x: 0, v: 0, target: 0 })
/** .35 s, bounce 0. */
const RAIL_OMEGA = (2 * Math.PI) / 0.35
const RAIL_INSET = 2
const grid = (v: number) => Math.round(v * 64) / 64
/** Advance an edge by dt seconds with the exact critically damped solution, so retargets keep their velocity.
* Returns whether it's still moving. */
function step(s: Edge, dt: number): boolean {
const d = s.x - s.target
const c = s.v + RAIL_OMEGA * d
const e = Math.exp(-RAIL_OMEGA * dt)
s.x = s.target + (d + c * dt) * e
s.v = (s.v - RAIL_OMEGA * c * dt) * e
if (Math.abs(s.x - s.target) < 0.05 && Math.abs(s.v) < 1) {
s.x = s.target
s.v = 0
return false
}
return true
}
const noSubscribe = () => () => {}
/** "⌘" on Apple platforms, "Ctrl " elsewhere; "⌘" on the server and during hydration. */
function useModKey(): string {
return useSyncExternalStore(
noSubscribe,
() => (/Mac|iPhone|iPad/.test(navigator.platform) ? "⌘" : "Ctrl "),
() => "⌘",
)
}
/** The persistent sidebar: brand, then groups of links. A current top-level item sits on a pill; a current child
* (a rule in view, a problem being read) lights its stretch of the guide line, and that mark travels as you scroll.
* The list fades at whichever edge has links scrolled under it. Under 900 px it folds into a top bar. */
function Sidebar({
brand,
groups,
revealBrandAfter,
onSearch,
}: {
brand: ReactNode
groups: NavGroup[]
revealBrandAfter?: string
onSearch?: () => void
}) {
const mod = useModKey()
const ids = groups.flatMap(g => spyIds(g.items))
const { active, inView } = useScrollSpy(ids)
const [open, setOpen] = useState(false)
const [brandShown, setBrandShown] = useState(!revealBrandAfter)
useEffect(() => {
const hero = revealBrandAfter && document.getElementById(revealBrandAfter)
if (!hero) return setBrandShown(true)
const observer = new IntersectionObserver(([entry]) => setBrandShown(!entry!.isIntersecting))
observer.observe(hero)
return () => observer.disconnect()
}, [revealBrandAfter])
const scroller = useRef<HTMLDivElement>(null)
const pill = useRef<HTMLSpanElement>(null)
const rail = useRef<HTMLSpanElement>(null)
const fade = () => {
const el = scroller.current
if (!el) return
const below = el.scrollHeight - el.clientHeight - el.scrollTop
el.style.setProperty("--fade-top", String(Math.min(1, el.scrollTop / 15)))
el.style.setProperty("--fade-bottom", String(Math.min(1, Math.max(0, below) / 15)))
}
const railMotion = useRef<RailMotion>({ top: still(), bottom: still(), x: 0, shown: false, frame: 0, last: 0 })
useEffect(() => () => cancelAnimationFrame(railMotion.current.frame), [])
useLayoutEffect(() => {
const el = scroller.current
const pillEl = pill.current
const railEl = rail.current
if (!el || !pillEl || !railEl) return
const m = railMotion.current
const paint = () => {
const top = grid(m.top.x)
railEl.style.transform = `translate(${m.x}px, ${top}px)`
railEl.style.height = `${Math.max(0, grid(m.bottom.x) - top)}px`
}
const tick = (now: number) => {
const dt = m.last ? Math.min((now - m.last) / 1000, 1 / 20) : 1 / 60
m.last = now
const moving = [m.top, m.bottom].map(s => step(s, dt)).some(Boolean)
paint()
m.frame = moving ? requestAnimationFrame(tick) : 0
}
const showRail = (x: number, top: number, bottom: number) => {
m.x = x
m.top.target = top
m.bottom.target = bottom
// First paint and reduced motion place the mark directly; otherwise the spring carries it, velocity and all.
if (!m.shown || matchMedia("(prefers-reduced-motion: reduce)").matches) {
cancelAnimationFrame(m.frame)
m.frame = 0
m.top = { x: top, v: 0, target: top }
m.bottom = { x: bottom, v: 0, target: bottom }
paint()
} else if (!m.frame) {
m.last = 0
m.frame = requestAnimationFrame(tick)
}
m.shown = true
// Fade back in after hiding, but not on the page's first paint.
if (!railEl.dataset.placed) {
railEl.style.transition = "none"
railEl.style.opacity = "1"
void railEl.offsetHeight
railEl.style.transition = ""
railEl.dataset.placed = ""
}
railEl.style.opacity = "1"
}
const hideRail = () => {
m.shown = false
railEl.style.opacity = "0"
}
const showPill = (link: HTMLElement, top: number) => {
const first = !pillEl.dataset.placed
if (first) pillEl.style.transition = "none"
pillEl.style.transform = `translateY(${top}px)`
pillEl.style.height = `${link.offsetHeight}px`
if (first) {
void pillEl.offsetHeight
pillEl.style.transition = ""
pillEl.dataset.placed = ""
}
pillEl.style.opacity = "1"
}
const hidePill = () => {
pillEl.style.opacity = "0"
delete pillEl.dataset.placed
}
const place = () => {
const box = el.getBoundingClientRect()
const offset = el.scrollTop - box.top
const leaves = [...el.querySelectorAll<HTMLElement>(".nav-link[data-active]:not([data-parent])")]
// The deepest current leaves win: the rules in view, not the guide that holds them.
const nested = leaves.filter(link => link.closest(".nav-list")?.getAttribute("data-depth") !== "0")
let span: [number, number] | null = null
if (nested.length > 0) {
hidePill()
const list = nested[0]!.closest<HTMLElement>(".nav-list")!
const top = nested[0]!.getBoundingClientRect().top + offset
const bottom = nested.at(-1)!.getBoundingClientRect().bottom + offset
// A 2 px bar centred on the 1 px guide line, running alongside the labels' text.
showRail(list.getBoundingClientRect().left - box.left - 0.5, top + RAIL_INSET, bottom - RAIL_INSET)
span = [top, bottom]
} else if (leaves.length > 0) {
hideRail()
const link = leaves.at(-1)!
const top = link.getBoundingClientRect().top + offset
showPill(link, top)
span = [top, top + link.offsetHeight]
} else {
hideRail()
hidePill()
}
// Keep the current items inside the list's viewport, without animating the list; the first wins if they don't fit.
if (span) {
const [top, bottom] = span
if (top - el.scrollTop < 24 || bottom - top > el.clientHeight - 48) el.scrollTop = top - 24
else if (bottom - el.scrollTop > el.clientHeight - 24) el.scrollTop = bottom - el.clientHeight + 24
}
fade()
}
place()
const observer = new ResizeObserver(place)
observer.observe(el)
return () => observer.disconnect()
}, [active, inView])
useEffect(() => {
if (!open) return
const onKey = (e: KeyboardEvent) => e.key === "Escape" && setOpen(false)
document.addEventListener("keydown", onKey)
return () => document.removeEventListener("keydown", onKey)
}, [open])
return (
<aside className="sidebar" data-open={open || undefined}>
<div className="sidebar-scrim" aria-hidden="true" onClick={() => setOpen(false)} />
<div className="sidebar-brand" data-brand-hidden={!brandShown || undefined}>
<div className="sidebar-lockup" inert={!brandShown}>
{brand}
</div>
<div className="sidebar-actions">
{onSearch && (
<button
type="button"
className="sidebar-search"
aria-label="Search"
aria-keyshortcuts="Meta+K Control+K /"
title={`Search (${mod}K)`}
onClick={() => {
setOpen(false)
onSearch()
}}
>
<svg className="sidebar-search-icon" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true">
<circle cx="7" cy="7" r="4.75" fill="none" stroke="currentColor" strokeWidth="1.5" />
<path d="M10.5 10.5 14 14" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
</svg>
<span className="sidebar-search-label">Search</span>
</button>
)}
<button
type="button"
className="sidebar-toggle"
aria-expanded={open}
aria-controls="sidebar-nav"
onClick={() => setOpen(o => !o)}
>
{open ? "Close" : "Menu"}
</button>
</div>
</div>
<div
ref={scroller}
id="sidebar-nav"
className="sidebar-scroll"
onScroll={fade}
onClick={e => (e.target as HTMLElement).closest("a") && setOpen(false)}
>
<span ref={pill} className="nav-pill" aria-hidden="true" />
<span ref={rail} className="nav-rail" aria-hidden="true" />
{groups.map(group => (
<nav key={group.label} className="nav-group" aria-label={group.label}>
<p className="nav-group-label">{group.label}</p>
<NavLinks items={group.items} active={active} inView={inView} depth={0} />
</nav>
))}
</div>
</aside>
)
}
/** Page frame: sidebar on the left, a wide main column on the right, footer at the end of main. */
export function Frame({
brand,
groups,
revealBrandAfter,
onSearch,
footer,
children,
}: {
brand: ReactNode
groups: NavGroup[]
/** Shows a search button in the sidebar's top row. */
onSearch?: () => void
/** Id of a hero that already shows the brand: the sidebar's lockup fades in once it scrolls away. */
revealBrandAfter?: string
footer?: ReactNode
children: ReactNode
}) {
return (
<div className="frame">
<Sidebar brand={brand} groups={groups} revealBrandAfter={revealBrandAfter} onSearch={onSearch} />
<div className="frame-main">
<main className="frame-content">{children}</main>
{footer}
</div>
</div>
)
}
/** Eyebrow, title and lede at the top of a page. */
export function PageHead({ eyebrow, title, children }: { eyebrow?: ReactNode; title: ReactNode; children?: ReactNode }) {
return (
<header className="page-head">
{eyebrow && <p className="eyebrow">{eyebrow}</p>}
<h1 className="page-title">{title}</h1>
{children && <div className="page-lede">{children}</div>}
</header>
)
}
/** A section's heading on a hairline, with an optional count or note on the right. */
export function SectionHead({ id, title, aside, children }: { id?: string; title: ReactNode; aside?: ReactNode; children?: ReactNode }) {
return (
<header className="section-head">
<div className="section-head-row">
<h2 id={id}>{title}</h2>
{aside && <span className="section-aside">{aside}</span>}
</div>
{children && <div className="section-intro">{children}</div>}
</header>
)
}
+753
View File
@@ -0,0 +1,753 @@
/* Anomaly docs primitives: frame, sidebar nav, page head, section head, rule row, bench (specimen), prose, button.
Built only from tokens.css. */
/* Base */
* { box-sizing: border-box; }
html {
background: var(--bg);
color-scheme: dark;
-webkit-font-smoothing: antialiased;
-webkit-text-size-adjust: 100%;
text-size-adjust: 100%;
}
body {
margin: 0;
background: var(--bg);
color: var(--fg);
font: var(--text-14);
font-feature-settings: "ss01" 0;
}
code, pre, kbd { font-family: var(--font-mono); }
::selection { background: var(--fg); color: var(--bg); }
a {
color: inherit;
text-decoration: underline var(--line-2);
text-decoration-thickness: 1px;
text-underline-offset: 3px;
}
@media (hover: hover) and (pointer: fine) {
a:hover { text-decoration-color: var(--fg); }
}
:focus-visible { outline: 1px solid var(--fg); outline-offset: 2px; }
/* Frame: a fixed-width sidebar and a main column that takes the rest. */
.frame {
display: grid;
grid-template-columns: var(--sidebar) minmax(0, 1fr);
min-height: 100vh;
}
.frame-main {
display: flex;
flex-direction: column;
min-width: 0;
}
/* The column centres in the space right of the sidebar once the window is wider than it. */
.frame-content {
flex: 1;
width: 100%;
max-width: calc(var(--content) + 2 * var(--space-7));
margin-inline: auto;
padding: var(--space-8) var(--space-7) var(--space-9);
}
/* Sidebar */
.sidebar {
position: sticky;
top: 0;
display: grid;
grid-template-rows: auto minmax(0, 1fr);
height: 100vh;
box-shadow: inset -1px 0 var(--line);
}
.sidebar-brand {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--space-3);
/* The lockup's left edge sits on the nav text, past the pill's bleed. */
padding: var(--space-5) var(--space-5) var(--space-4) calc(var(--space-3) + var(--space-2));
}
.sidebar-lockup { transition: opacity .2s var(--ease-out); }
.sidebar-brand[data-brand-hidden] .sidebar-lockup { opacity: 0; transition-timing-function: var(--ease-in); }
.sidebar-toggle,
.sidebar-scrim,
.sidebar-search-label {
display: none;
}
.sidebar-actions {
display: flex;
align-items: center;
}
/* Search: an icon beside the lockup whose hover box ends on the nav pill's right edge. */
.sidebar-search {
display: grid;
place-items: center;
width: 28px;
height: 28px;
margin-right: calc(var(--space-3) - var(--space-5));
padding: 0;
border: 0;
border-radius: var(--radius-1);
background: none;
color: var(--fg-3);
cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
.sidebar-search:hover { background: var(--surface-2); color: var(--fg); }
}
.sidebar-scroll {
position: relative;
min-height: 0;
padding: var(--space-2) var(--space-3) var(--space-7);
overflow-y: auto;
overscroll-behavior: contain;
scrollbar-width: none;
--edge: linear-gradient(to bottom, rgb(0 0 0 / calc(1 - var(--fade-top, 0))), #000 32px, #000 calc(100% - 32px), rgb(0 0 0 / calc(1 - var(--fade-bottom, 0))));
-webkit-mask-image: var(--edge);
mask-image: var(--edge);
}
.sidebar-scroll::-webkit-scrollbar { display: none; }
/* Nav: groups of links; the current one sits on a pill that travels. Text sits on the brand's edge, the pill bleeds. */
.nav-group + .nav-group { margin-top: var(--space-5); }
.nav-group-label {
margin: 0 0 var(--space-1);
padding: 0 var(--space-2);
font: var(--text-12);
font-weight: 500;
color: var(--fg-3);
}
.nav-list {
margin: 0;
padding: 0;
list-style: none;
}
.nav-link {
position: relative;
z-index: 1;
display: flex;
gap: var(--space-2);
padding: 4px var(--space-2);
border-radius: var(--radius-1);
font: var(--text-13);
color: var(--fg-2);
text-decoration: none;
text-wrap: pretty;
}
.nav-link[data-active] { color: var(--fg); }
.nav-link[data-parent][data-active] { font-weight: 500; }
@media (hover: hover) and (pointer: fine) {
.nav-link:hover { color: var(--fg); }
}
.nav-link:focus-visible { outline-offset: -1px; }
.nav-num {
flex: none;
width: 2ch;
font: var(--mono-12);
line-height: inherit;
color: var(--fg-3);
font-variant-numeric: tabular-nums;
}
.nav-link[data-active] .nav-num { color: var(--ink); }
/* Children hang off a thin guide line under their parent's text: one line each, smaller, with quiet group headers.
A label too long for the column fades out at its end rather than wrapping. */
.nav-list[data-depth="1"] {
margin: 2px 0 var(--space-3) var(--space-2);
box-shadow: inset 1px 0 var(--line);
}
.nav-list[data-depth="1"] .nav-link {
padding: 2px var(--space-2) 2px var(--space-3);
border-radius: 0;
font: var(--text-12);
line-height: 16px;
white-space: nowrap;
}
.nav-list[data-depth="1"] .nav-label {
flex: 1;
min-width: 0;
overflow: hidden;
-webkit-mask-image: linear-gradient(to right, #000 calc(100% - 1.5em), transparent);
mask-image: linear-gradient(to right, #000 calc(100% - 1.5em), transparent);
}
.nav-heading {
margin: var(--space-3) 0 2px;
padding: 0 var(--space-2) 0 var(--space-3);
line-height: 16px;
}
.nav-heading:first-child { margin-top: var(--space-1); }
.nav-heading a {
font: var(--text-11);
letter-spacing: .02em;
color: var(--fg-3);
text-decoration: none;
}
@media (hover: hover) and (pointer: fine) {
.nav-heading a:hover { color: var(--fg-2); }
}
.nav-pill,
.nav-rail {
position: absolute;
top: 0;
left: 0;
opacity: 0;
pointer-events: none;
}
.nav-pill {
left: var(--space-3);
right: var(--space-3);
border-radius: var(--radius-1);
background: var(--surface-2);
transition: transform .25s var(--ease-out), height .25s var(--ease-out), opacity .15s;
}
/* The stretch of guide line beside every rule in view. A spring in Frame.tsx moves it; CSS only fades it. */
.nav-rail {
z-index: 2;
width: 2px;
border-radius: 1px;
background: var(--fg-3);
transition: opacity .15s;
}
.nav-list[data-depth="1"] :is(.nav-link, .nav-num) { transition: color .2s; }
.nav-list[data-depth="1"] .nav-link[data-active] .nav-num { color: var(--fg-2); }
@media (hover: hover) and (pointer: fine) {
.nav-list[data-depth="1"] .nav-link:hover { transition-duration: 0s; }
}
@media (prefers-reduced-motion: reduce) {
.nav-pill { transition: opacity .15s; }
}
/* Page head */
.page-head {
max-width: var(--measure);
margin-bottom: var(--space-8);
}
.eyebrow {
display: flex;
flex-wrap: wrap;
gap: var(--space-1) var(--space-3);
margin: 0 0 var(--space-3);
font: var(--mono-12);
color: var(--fg-3);
}
.page-title {
margin: 0;
font: var(--text-28);
letter-spacing: var(--track-28);
text-wrap: balance;
}
.page-lede {
margin-top: var(--space-4);
font: var(--text-16);
color: var(--fg-2);
text-wrap: pretty;
}
.page-lede p { margin: 0 0 var(--space-3); }
.page-lede p:last-child { margin-bottom: 0; }
/* Section head: a hairline, the heading, an aside on the same line. */
.section-head {
padding-top: var(--space-5);
box-shadow: inset 0 1px var(--line);
margin-bottom: var(--space-7);
}
.section-head-row {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: var(--space-4);
}
.section-head h2 {
margin: 0;
font: var(--text-20);
letter-spacing: var(--track-20);
scroll-margin-top: var(--space-7);
}
.section-aside {
font: var(--mono-12);
color: var(--fg-3);
}
.section-intro {
max-width: var(--measure);
margin-top: var(--space-2);
font: var(--text-14);
color: var(--fg-2);
}
.section-intro p { margin: 0; }
.section-intro code { font: var(--mono-12); color: var(--fg); }
/* Rule row: number and title, then text beside a spec list, then the bench across the full width. */
.rule { scroll-margin-top: var(--space-6); }
.rule + .rule { margin-top: var(--space-8); }
.rule-head {
display: flex;
align-items: baseline;
gap: var(--space-3);
margin: 0 0 var(--space-2);
}
.rule-num {
flex: none;
font: var(--mono-13);
color: var(--ink);
text-decoration: none;
font-variant-numeric: tabular-nums;
}
.rule-title {
margin: 0;
font: var(--text-16);
font-weight: 500;
text-wrap: balance;
}
.rule-title code { font-family: var(--font-mono); font-size: .875em; }
/* Quiet marker for a rule nobody has approved yet. */
.rule-tag {
flex: none;
padding: 0 5px;
border: 1px solid var(--line);
border-radius: var(--radius-1);
font: var(--mono-12);
line-height: 18px;
color: var(--fg-3);
}
.rule-body {
display: grid;
grid-template-columns: minmax(0, var(--measure)) minmax(240px, 1fr);
gap: var(--space-3) var(--space-7);
align-items: start;
}
.rule-text {
color: var(--fg-2);
text-wrap: pretty;
}
.rule-text p { margin: 0 0 var(--space-2); }
.rule-text code { font: var(--mono-13); color: var(--fg); }
.rule-text :not(pre) > code { white-space: nowrap; }
.rule-text p:last-child { margin-bottom: 0; }
.rule-text pre {
margin: var(--space-3) 0;
padding: var(--space-3) var(--space-4);
border-radius: var(--radius-2);
background: var(--surface-1);
box-shadow: inset 0 0 0 1px var(--line);
overflow-x: auto;
}
.rule-text pre code { font: var(--mono-12); line-height: 20px; }
.rule-spec {
display: grid;
gap: var(--space-2);
margin: 0;
padding-top: 3px;
}
.rule-spec > div {
display: grid;
grid-template-columns: 56px minmax(0, 1fr);
gap: var(--space-3);
}
.rule-spec dt {
font: var(--text-12);
line-height: 18px;
color: var(--fg-3);
}
.rule-spec dd {
margin: 0;
font: var(--text-13);
color: var(--fg-2);
}
.rule-spec dd.mono {
font: var(--mono-12);
line-height: 18px;
color: var(--fg);
}
.rule-spec dd.mono code { font: inherit; }
.rule-spec dd.mono > span { display: block; }
/* References: a file in one of our repos (crate, then file, then a note), a principle, or plain text.
Crates sit in one column so the files line up. */
.refs {
display: grid;
grid-template-columns: max-content minmax(0, 1fr);
gap: 2px var(--space-3);
margin: 0;
padding: 0;
list-style: none;
font: var(--mono-12);
line-height: 18px;
}
.refs > li,
.ref-link {
display: grid;
grid-column: 1 / -1;
grid-template-columns: subgrid;
}
.ref-link { color: inherit; text-decoration: none; }
.ref-label { color: var(--fg-2); }
.ref-name { color: var(--fg); overflow-wrap: anywhere; }
.ref-name + .ref-note { margin-left: var(--space-2); }
.ref-note { color: var(--fg-3); }
.ref-note code { font: inherit; }
.ref-principle { font: var(--text-13); line-height: 18px; }
.refs > .ref-text {
display: block;
font: var(--text-13);
line-height: 18px;
color: var(--fg-2);
}
.ref-text code { font: var(--mono-12); color: var(--fg); }
a.ref-link .ref-name {
text-decoration: underline;
text-decoration-color: transparent;
text-underline-offset: 3px;
transition: text-decoration-color .15s;
}
@media (hover: hover) and (pointer: fine) {
a.ref-link:hover .ref-name { text-decoration-color: var(--line-2); }
}
/* Code, highlighted at build time: keywords in soft red, strings sand, macros and attributes steel, the rest
neutral with dim punctuation. */
.tk-k { color: var(--code-keyword); }
.tk-s, .tk-n { color: var(--code-string); }
.tk-f, .tk-a { color: var(--code-call); }
.tk-c { color: var(--fg-3); }
.tk-p { color: var(--fg-2); }
.rule-benches {
display: grid;
gap: var(--space-4);
margin-top: var(--space-5);
}
/* Bench: bad and good side by side, each live, controls for both along the bottom. */
.bench {
margin: 0;
border-radius: var(--radius-2);
background: var(--surface-1);
box-shadow: inset 0 0 0 1px var(--line);
font: var(--text-13);
}
.bench-sides {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.bench-side {
display: grid;
grid-row: span 3;
grid-template-rows: subgrid;
min-width: 0;
padding: var(--space-4) var(--space-5) var(--space-4);
}
.bench-side + .bench-side { box-shadow: inset 1px 0 var(--line); }
.bench-label {
display: flex;
align-items: center;
gap: var(--space-2);
margin: 0 0 var(--space-4);
font: var(--text-12);
font-weight: 500;
color: var(--fg);
}
.bench-label::before {
content: "";
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--fg);
}
.bench-side[data-kind="bad"] .bench-label { color: var(--ink); }
.bench-side[data-kind="bad"] .bench-label::before { background: var(--ink); }
.bench-note {
margin: var(--space-4) 0 0;
font: var(--text-12);
color: var(--fg-3);
text-wrap: pretty;
}
.bench-note::first-letter { text-transform: uppercase; }
.bench-controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--space-2);
padding: var(--space-3) var(--space-5);
box-shadow: inset 0 1px var(--line);
}
/* Button: the one control shape. */
.button {
height: 28px;
padding: 0 var(--space-3);
border: 0;
border-radius: var(--radius-1);
background: var(--surface-2);
box-shadow: inset 0 0 0 1px var(--line);
color: var(--fg);
font: var(--text-13);
font-weight: 500;
cursor: pointer;
transition: background-color 100ms ease-out;
}
.button::first-letter { text-transform: uppercase; }
@media (hover: hover) and (pointer: fine) {
.button:hover:not(:disabled) { background: var(--surface-3); transition-duration: 0ms; }
}
.button:disabled { opacity: .4; cursor: default; }
/* Prose */
.prose { max-width: var(--measure); color: var(--fg-2); text-wrap: pretty; }
.prose > :first-child { margin-top: 0; }
.prose h2 { margin: var(--space-7) 0 var(--space-3); font: var(--text-20); letter-spacing: var(--track-20); color: var(--fg); }
.prose h3 { margin: var(--space-6) 0 var(--space-2); font: var(--text-16); font-weight: 500; color: var(--fg); }
.prose p, .prose ul, .prose ol, .prose pre, .prose .table-wrap { margin: 0 0 var(--space-4); }
.prose ul, .prose ol { padding-left: var(--space-5); }
.prose li + li { margin-top: var(--space-1); }
.prose strong { color: var(--fg); font-weight: 500; }
.prose code { padding: 1px 4px; border-radius: 3px; background: var(--surface-2); font: var(--mono-12); color: var(--fg); }
.prose pre { padding: var(--space-4); border-radius: var(--radius-2); background: var(--surface-1); box-shadow: inset 0 0 0 1px var(--line); overflow-x: auto; }
.prose pre code { padding: 0; background: none; }
.prose table { width: 100%; border-collapse: collapse; font: var(--text-13); text-align: left; }
.prose th, .prose td { padding: var(--space-2) var(--space-4) var(--space-2) 0; box-shadow: inset 0 -1px var(--line); vertical-align: top; }
.prose th { font-weight: 500; color: var(--fg-3); white-space: nowrap; }
.table-wrap { width: 100%; overflow-x: auto; }
/* Under 1100 px of window the rule's spec drops under its text. */
@media (max-width: 1100px) {
.rule-body { grid-template-columns: minmax(0, var(--measure)); }
}
/* Under 900 px the sidebar folds into a top bar with a menu. */
@media (max-width: 900px) {
.frame { grid-template-columns: minmax(0, 1fr); }
.sidebar {
z-index: 10;
height: auto;
grid-template-rows: auto;
box-shadow: none;
}
/* The blur sits on the bar, not the sidebar, so the scrim stays fixed to the viewport. */
.sidebar-brand {
position: relative;
height: var(--topbar);
padding: 0 var(--space-2) 0 var(--space-4);
background: rgb(0 0 0 / .86);
-webkit-backdrop-filter: blur(16px) saturate(1.4);
backdrop-filter: blur(16px) saturate(1.4);
box-shadow: inset 0 -1px var(--line);
}
.sidebar-scrim {
position: fixed;
inset: var(--topbar) 0 0;
display: block;
background: var(--bg);
opacity: 0;
visibility: hidden;
transition: opacity .11s var(--ease-in), visibility 0s .11s;
}
.sidebar[data-open] .sidebar-scrim {
opacity: 1;
visibility: visible;
transition: opacity .15s var(--ease-out), visibility 0s;
}
.sidebar-search-icon { display: none; }
.sidebar-search-label { display: inline; }
.sidebar-toggle,
.sidebar-search {
display: block;
width: auto;
margin: 0;
height: 36px;
padding: 0 var(--space-3);
border: 0;
border-radius: var(--radius-1);
background: none;
color: var(--fg-2);
font: var(--text-13);
font-weight: 500;
cursor: pointer;
}
.sidebar-scroll {
position: absolute;
top: var(--topbar);
left: 0;
right: 0;
height: calc(100dvh - var(--topbar));
padding: var(--space-3) var(--space-2) var(--space-6);
opacity: 0;
visibility: hidden;
translate: 0 -4px;
transition: opacity .11s var(--ease-in), translate .11s var(--ease-in), visibility 0s .11s;
}
.sidebar[data-open] .sidebar-scroll {
opacity: 1;
visibility: visible;
translate: 0 0;
transition: opacity .15s var(--ease-out), translate .15s var(--ease-out), visibility 0s;
}
.nav-pill { left: var(--space-2); right: var(--space-2); }
.frame-content { padding: var(--space-7) var(--space-4) var(--space-8); }
.rule, .section-head h2 { scroll-margin-top: calc(var(--topbar) + var(--space-4)); }
}
@media (max-width: 900px) and (prefers-reduced-motion: reduce) {
.sidebar-scroll, .sidebar[data-open] .sidebar-scroll { translate: none; }
}
@media (max-width: 640px) {
.bench-sides { grid-template-columns: minmax(0, 1fr); }
.bench-side { padding: var(--space-4); }
.bench-side + .bench-side { box-shadow: inset 0 1px var(--line); }
.bench-controls { padding: var(--space-3) var(--space-4); }
.rule + .rule { margin-top: var(--space-7); }
}
/* Index row: title, text and meta on one line at width; the list behind every collection page. */
.index-list {
display: grid;
margin: 0;
padding: 0;
list-style: none;
}
.index-row {
display: grid;
grid-template-columns: minmax(160px, 15rem) minmax(0, 1fr) auto;
gap: var(--space-1) var(--space-6);
align-items: baseline;
padding: var(--space-3) 0;
box-shadow: inset 0 -1px var(--line);
}
.index-row:first-child { padding-top: 0; }
.index-title {
font: var(--text-14);
font-weight: 500;
color: var(--fg);
text-decoration: none;
}
@media (hover: hover) and (pointer: fine) {
a.index-title:hover { text-decoration: underline var(--line-2); text-underline-offset: 3px; }
}
.index-text {
margin: 0;
max-width: var(--measure);
font: var(--text-14);
color: var(--fg-2);
text-wrap: pretty;
}
.index-meta {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: var(--space-1) var(--space-3);
font: var(--mono-12);
color: var(--fg-3);
white-space: nowrap;
font-variant-numeric: tabular-nums;
}
.index-meta a { color: inherit; }
@media (max-width: 760px) {
.index-row { grid-template-columns: minmax(0, 1fr) auto; }
.index-text { grid-column: 1 / -1; grid-row: 2; }
}
/* Command menu: a search field over a list of one fixed height, centred near the top. Opens on the next frame; the
close fade is the component's. The selected row moves with no transition. */
.cmdk {
position: fixed;
inset: 0;
z-index: 50;
}
.cmdk[inert] { pointer-events: none; }
.cmdk-scrim {
position: absolute;
inset: 0;
background: rgb(0 0 0 / .6);
}
.cmdk-panel {
position: relative;
width: min(560px, calc(100% - 2 * var(--space-2)));
margin: max(var(--space-4), 12vh) auto 0;
overflow: hidden;
border-radius: var(--radius-2);
background: color-mix(in srgb, var(--fg) 4%, var(--bg));
box-shadow: inset 0 0 0 1px var(--line-2), 0 1px 2px rgb(0 0 0 / .5), 0 24px 64px rgb(0 0 0 / .6);
}
/* On a phone the keyboard takes the bottom half, so the panel sits at the top. */
@media (max-width: 900px) {
.cmdk-panel { margin-top: var(--space-2); }
}
.cmdk-input {
display: block;
width: 100%;
height: 48px;
padding: 0 var(--space-4);
border: 0;
border-radius: 0;
background: none;
box-shadow: inset 0 -1px var(--line);
color: var(--fg);
font: var(--text-16);
outline: none;
}
.cmdk-input::placeholder { color: var(--fg-3); }
.cmdk-list {
position: relative;
height: min(344px, 52dvh);
padding: var(--space-1);
overflow-y: auto;
overscroll-behavior: contain;
scroll-padding-block: var(--space-5);
scrollbar-width: none;
--edge: linear-gradient(to bottom, rgb(0 0 0 / calc(1 - var(--fade-top, 0))), #000 24px, #000 calc(100% - 24px), rgb(0 0 0 / calc(1 - var(--fade-bottom, 0))));
-webkit-mask-image: var(--edge);
mask-image: var(--edge);
}
.cmdk-list::-webkit-scrollbar { display: none; }
.cmdk-option {
display: flex;
align-items: center;
gap: var(--space-3);
height: 36px;
padding: 0 var(--space-3);
border-radius: var(--radius-1);
color: var(--fg-2);
font: var(--text-14);
cursor: pointer;
user-select: none;
}
.cmdk-option[aria-selected="true"] { background: var(--surface-2); }
.cmdk-title {
flex: 1;
min-width: 0;
overflow: hidden;
white-space: nowrap;
-webkit-mask-image: linear-gradient(to left, transparent, #000 24px);
mask-image: linear-gradient(to left, transparent, #000 24px);
}
.cmdk-title mark {
background: none;
color: var(--fg);
}
.cmdk-context {
margin-left: var(--space-2);
font: var(--text-13);
color: var(--fg-3);
}
.cmdk-tag {
margin-left: var(--space-2);
font: var(--mono-12);
color: var(--fg-3);
}
.cmdk-kind {
flex: none;
font: var(--mono-12);
color: var(--fg-3);
}
.cmdk-empty {
margin: 0;
padding: var(--space-2) var(--space-3);
font: var(--text-14);
color: var(--fg-3);
}
.cmdk-status {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
+64
View File
@@ -0,0 +1,64 @@
/* Anomaly docs tokens. Dark only. One sans for interface and prose, one mono for values, code and numbers.
Copied from @anomalyco/site. */
@font-face { font-family: "Geist"; src: url("/fonts/geist.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/fonts/geist-mono.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
:root {
--font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
--font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
/* Type: seven sizes (11 only for sidebar section labels), line heights on the 4 px grid. Mono only at 12 and 13, one step under the sans beside it. */
--text-11: 500 11px/16px var(--font-sans);
--text-12: 400 12px/16px var(--font-sans);
--text-13: 400 13px/20px var(--font-sans);
--text-14: 400 14px/22px var(--font-sans);
--text-16: 400 16px/26px var(--font-sans);
--text-20: 500 20px/28px var(--font-sans);
--text-28: 500 28px/36px var(--font-sans);
--mono-12: 400 12px/16px var(--font-mono);
--mono-13: 400 13px/20px var(--font-mono);
--track-20: -.01em;
--track-28: -.02em;
/* Space: a 4 px base. Tight inside a group, loose between groups. */
--space-1: 4px;
--space-2: 8px;
--space-3: 12px;
--space-4: 16px;
--space-5: 24px;
--space-6: 32px;
--space-7: 48px;
--space-8: 64px;
--space-9: 96px;
/* Colour: black, one neutral at four strengths, hairlines as translucent white, red ink as the only accent. */
--bg: #000;
--fg: #ededed;
--fg-2: rgb(255 255 255 / .62);
--fg-3: rgb(255 255 255 / .4);
--surface-1: rgb(255 255 255 / .03);
--surface-2: rgb(255 255 255 / .06);
--surface-3: rgb(255 255 255 / .1);
--line: rgb(255 255 255 / .09);
--line-2: rgb(255 255 255 / .16);
--ink: #ff2a2a;
--ink-dim: color-mix(in srgb, var(--ink) 55%, transparent);
/* Code: three quiet hues at one lightness, red only for keywords. */
--code-keyword: oklch(.74 .12 25);
--code-string: oklch(.84 .06 80);
--code-call: oklch(.84 .045 235);
/* Radius: one family; a control nests inside a bench with 4 px to spare. */
--radius-1: 4px;
--radius-2: 8px;
/* Frame */
--sidebar: 264px;
--content: 1120px;
--measure: 36rem;
--topbar: 52px;
/* Motion (Kit's palette as CSS): enter, exit. */
--ease-out: cubic-bezier(.2, .8, .2, 1);
--ease-in: cubic-bezier(.4, 0, 1, 1);
}
+55
View File
@@ -0,0 +1,55 @@
import { useEffect, useMemo, useState } from "react"
/** How much of an element has to be on screen to count as in view: enough to read its heading, or all of it. */
const IN_VIEW_PX = 48
/** Scroll position against a list of element ids, measured once per frame. `active` is the last element whose top has
* passed a line a third of the way down the viewport. `inView` is every element showing at least a heading's worth
* on screen, in order, falling back to `active` when none is. Both are empty on the server and during hydration, so
* the first client render matches the prerendered HTML. */
export function useScrollSpy(ids: string[]): { active: string | null; inView: string[] } {
const [active, setActive] = useState<string | null>(null)
const [visible, setVisible] = useState("")
const key = ids.join(" ")
useEffect(() => {
if (ids.length === 0) return
let frame = 0
const measure = () => {
frame = 0
const height = window.innerHeight
const line = Math.min(height * 0.33, 280)
const atEnd = height + window.scrollY >= document.documentElement.scrollHeight - 2
let current: string | null = null
let lastOnScreen: string | null = null
const shown: string[] = []
for (const id of ids) {
const el = document.getElementById(id)
if (!el) continue
const rect = el.getBoundingClientRect()
if (rect.top <= line) current = id
if (rect.top < height) lastOnScreen = id
const overlap = Math.min(rect.bottom, height) - Math.max(rect.top, 0)
if (overlap >= Math.min(IN_VIEW_PX, rect.height)) shown.push(id)
}
// At the very end of the page the last item wins, even if it never reaches the line.
if (atEnd && lastOnScreen) current = lastOnScreen
setActive(current)
setVisible(shown.join(" "))
}
const schedule = () => {
if (!frame) frame = requestAnimationFrame(measure)
}
measure()
window.addEventListener("scroll", schedule, { passive: true })
window.addEventListener("resize", schedule)
return () => {
cancelAnimationFrame(frame)
window.removeEventListener("scroll", schedule)
window.removeEventListener("resize", schedule)
}
}, [key])
const inView = useMemo(() => (visible ? visible.split(" ") : active ? [active] : []), [visible, active])
return { active, inView }
}