diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d6577d49e..8966854c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,10 @@ concurrency: # A new push to a pull request replaces its running checks; main's runs all finish (releases follow them). group: checks-${{ github.event.pull_request.number || github.sha }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} +env: + # Test runs never reach the telemetry server: no live-count ping, no uploads (docs/telemetry.md). + HORIZON_TELEMETRY_URL: "off" + jobs: verify: runs-on: ubuntu-latest diff --git a/.github/workflows/launcher.yml b/.github/workflows/launcher.yml index 3346e1986..02c61cdd1 100644 --- a/.github/workflows/launcher.yml +++ b/.github/workflows/launcher.yml @@ -49,6 +49,10 @@ concurrency: group: launcher-${{ github.ref == 'refs/heads/main' && 'release' || github.ref }} cancel-in-progress: false +env: + # Test runs never reach the telemetry server: no live-count ping, no uploads (docs/telemetry.md). + HORIZON_TELEMETRY_URL: "off" + jobs: decide: runs-on: ubuntu-latest diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 689cdae59..51f9e89cd 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -23,6 +23,10 @@ permissions: concurrency: group: nightly-audit cancel-in-progress: false +env: + # Test runs never reach the telemetry server: no live-count ping, no uploads (docs/telemetry.md). + HORIZON_TELEMETRY_URL: "off" + jobs: audit: runs-on: [self-hosted, horizon-game] diff --git a/.github/workflows/parity.yml b/.github/workflows/parity.yml index 7289fe4de..a18fc5019 100644 --- a/.github/workflows/parity.yml +++ b/.github/workflows/parity.yml @@ -15,6 +15,10 @@ on: required: true permissions: contents: read +env: + # Test runs never reach the telemetry server: no live-count ping, no uploads (docs/telemetry.md). + HORIZON_TELEMETRY_URL: "off" + jobs: parity: runs-on: [self-hosted, horizon-game] diff --git a/.github/workflows/run-parity.yml b/.github/workflows/run-parity.yml index fd3cce6f8..a2b8e3291 100644 --- a/.github/workflows/run-parity.yml +++ b/.github/workflows/run-parity.yml @@ -11,6 +11,10 @@ permissions: concurrency: group: run-parity-${{ github.event.pull_request.number }} cancel-in-progress: true +env: + # Test runs never reach the telemetry server: no live-count ping, no uploads (docs/telemetry.md). + HORIZON_TELEMETRY_URL: "off" + jobs: parity: if: github.event.label.name == 'run-parity' diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index dd8c5335a..969543601 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -330,6 +330,10 @@ impl Game<'_> { "held": m.extra.main_hand.as_deref(), "mount": m.extra.mount, "rider": m.extra.rider, + // A player's input this tick, and whether it steers. + "ridden": m.rider.map(|r| r.steer), + "controlled": horizon_client::mobs::equine::controlled(m), + "saddled": m.extra.saddled, "enchants": horizon_client::mobs::gear::gear(m).map(|g| g.slots.iter().map(|s| s.iter().map(|(e, l)| format!("{e}:{l}")).collect::>()).collect::>()), "ints": m.extra.ints, "pois": [m.extra.home, m.extra.bed, m.extra.meeting], diff --git a/crates/horizon-client/src/game/lan.rs b/crates/horizon-client/src/game/lan.rs index 17e1e09a3..8864309cc 100644 --- a/crates/horizon-client/src/game/lan.rs +++ b/crates/horizon-client/src/game/lan.rs @@ -800,6 +800,16 @@ impl Game<'_> { self.send_admin_feedback(&mut host, None); } let state = self.lan_host_state(&host); + // An animal whose rider left the game (or the level) stops taking + // its input. + for m in &mut self.mobs { + if m.rider.is_some() + && self.riding != Some(m.id) + && !host.hub.guests.iter().any(|g| g.vehicle == Some(m.id)) + { + m.rider = None; + } + } // A dedicated server runs the hub without a host player. if state.is_some() || host.hub.config.dedicated { let has_guests = !host.hub.guests.is_empty(); diff --git a/crates/horizon-client/src/game/lan_actions.rs b/crates/horizon-client/src/game/lan_actions.rs index eccbd7f0b..569f4937b 100644 --- a/crates/horizon-client/src/game/lan_actions.rs +++ b/crates/horizon-client/src/game/lan_actions.rs @@ -49,6 +49,8 @@ pub(super) struct GuestPlay { /// Swings the guest's actions started this tick, for the players around /// (`LivingEntity.swing` sends ClientboundSwingAnimationPacket). swings: u32, + /// The guest's riding jump charge (`LocalPlayer.jumpRidingTicks`). + mount: super::mounts::MountState, /// The trading screen the guest has open. pub(super) merchant: Option, /// The inventory menu and the crafting table the guest crafts in. @@ -289,6 +291,7 @@ impl Game<'_> { let attack_ticks = std::mem::replace(&mut self.attack_ticks, play.attack_ticks); let attack_item = std::mem::replace(&mut self.attack_item, play.attack_item.take()); let swing = std::mem::replace(&mut self.swing, play.swing); + std::mem::swap(&mut self.mount, &mut play.mount); let (left, right) = (self.left, self.right); self.left = play.digging.is_some(); self.right = play.using.is_some() || self.using.is_some(); @@ -478,6 +481,7 @@ impl Game<'_> { play.attack_ticks = std::mem::replace(&mut self.attack_ticks, attack_ticks); play.attack_item = std::mem::replace(&mut self.attack_item, attack_item); play.swing = std::mem::replace(&mut self.swing, swing); + std::mem::swap(&mut self.mount, &mut play.mount); self.container = container; self.screen = screen; self.sign_edit = host_sign; diff --git a/crates/horizon-client/src/game/lan_vehicles.rs b/crates/horizon-client/src/game/lan_vehicles.rs index 01195e49e..8198f288e 100644 --- a/crates/horizon-client/src/game/lan_vehicles.rs +++ b/crates/horizon-client/src/game/lan_vehicles.rs @@ -26,6 +26,7 @@ pub(super) fn input_keys(flags: u8) -> Keys { right: flags & 8 != 0, jump: flags & 16 != 0, shift: flags & 32 != 0, + sprint: flags & 64 != 0, ..Keys::default() } } @@ -96,9 +97,10 @@ impl Game<'_> { let (keys, dead) = (input_keys(g.input), g.dead || g.health <= 0.0); let boat = self.boats.iter().position(|b| b.id == vehicle); let cart = self.carts.iter().any(|c| c.id == vehicle); + let mount = self.mobs.iter().any(|m| m.id == vehicle); // The vehicle is gone (broken, in another level) or the rider died: // its client drops it with the entity or the death screen. - if dead || (boat.is_none() && !cart) { + if dead || (boat.is_none() && !cart && !mount) { let g = &mut host.hub.guests[gi]; (g.vehicle, g.vehicle_good) = (None, None); return; @@ -122,8 +124,12 @@ impl Game<'_> { return Some([p.x, p.y + SEAT, p.z]); } // The minecart moves with the rider's input, and lets it out when - // it sneaks or the cart breaks. - game.tick_cart_riding(keys); + // it sneaks or the cart breaks. An animal takes the rider's input + // for its own tick (`travelRidden`), or lets it off. + if !game.tick_cart_riding(keys) && game.tick_mount_riding(keys) { + game.riding?; + game.position_rider(); + } game.riding?; let p = game.player.as_ref()?.position; Some([p.x, p.y, p.z]) @@ -163,12 +169,26 @@ impl Game<'_> { .find(|c| c.id == vehicle) .map(|c| c.position) }); - let g = &mut host.hub.guests[gi]; if let Some(p) = at { + let g = &mut host.hub.guests[gi]; g.vehicle_good = Some([p.x, p.y, p.z]); g.previous_position = g.position; g.position = [p.x, p.y + SEAT, p.z]; g.on_ground = false; + return; + } + // An animal: the rider sits where `positionRider` puts it. + let seat = self.as_guest(host, conn, |game| { + game.position_rider(); + game.player + .as_ref() + .map(|p| [p.position.x, p.position.y, p.position.z]) + }); + if let Some(Some(at)) = seat { + let g = &mut host.hub.guests[gi]; + g.previous_position = g.position; + g.position = at; + g.on_ground = false; } } diff --git a/crates/horizon-client/src/game/mounts.rs b/crates/horizon-client/src/game/mounts.rs index 42eac1e9b..c5c7dc31c 100644 --- a/crates/horizon-client/src/game/mounts.rs +++ b/crates/horizon-client/src/game/mounts.rs @@ -107,6 +107,10 @@ impl Game<'_> { let held = self.inventory[self.selected].clone(); let m = &self.mobs[index]; let species = m.species(); + // A server player rides it already (`isVehicle`: no seat, no feeding). + if self.ridden_by_guest(m.id) { + return false; + } if matches!(species, Species::Pig | Species::Strider) { return self.interact_steerable(index, item); } @@ -246,24 +250,9 @@ impl Game<'_> { self.consume_held(); true } - /// The rider's input for this tick; returns false when not on a mount. - pub(super) fn tick_mount_riding(&mut self, keys: Keys) -> bool { - let Some(i) = self.mount_index() else { - return false; - }; - if keys.shift || !self.mobs[i].alive() { - self.dismount_mount(); - return true; - } - let strafe = f32::from(u8::from(keys.left)) - f32::from(u8::from(keys.right)); - let forward = f32::from(u8::from(keys.forward)) - f32::from(u8::from(keys.backward)); - // LocalPlayer.aiStep: the riding jump charges while space is held. - let held = self.held().map(|s| s.item.clone()); - let steer = match self.mobs[i].species() { - Species::Pig => held.as_deref() == Some("minecraft:carrot_on_a_stick"), - Species::Strider => held.as_deref() == Some("minecraft:warped_fungus_on_a_stick"), - _ => false, - }; + /// `LocalPlayer.aiStep`'s riding jump: the bar charges while jump is + /// held; on release, the jump's strength (0 when there is none). + pub(super) fn charge_mount_jump(&mut self, i: usize, keys: Keys) -> f32 { // PlayerRideableJumping: horses, camels and nautili (the dash). let saddled = self.mobs[i].extra.saddled && (equine::is_equine(self.mobs[i].species()) @@ -299,6 +288,27 @@ impl Game<'_> { } st.was_jumping = keys.jump; } + jump + } + /// The rider's input for this tick; returns false when not on a mount. + pub(super) fn tick_mount_riding(&mut self, keys: Keys) -> bool { + let Some(i) = self.mount_index() else { + return false; + }; + if keys.shift || !self.mobs[i].alive() { + self.dismount_mount(); + return true; + } + let strafe = f32::from(u8::from(keys.left)) - f32::from(u8::from(keys.right)); + let forward = f32::from(u8::from(keys.forward)) - f32::from(u8::from(keys.backward)); + // LocalPlayer.aiStep: the riding jump charges while space is held. + let held = self.held().map(|s| s.item.clone()); + let steer = match self.mobs[i].species() { + Species::Pig => held.as_deref() == Some("minecraft:carrot_on_a_stick"), + Species::Strider => held.as_deref() == Some("minecraft:warped_fungus_on_a_stick"), + _ => false, + }; + let jump = self.charge_mount_jump(i, keys); let m = &mut self.mobs[i]; if jump > 0.0 { // onPlayerJump: rear while jumping (horses). @@ -324,7 +334,7 @@ impl Game<'_> { pitch: self.pitch, jump: if jump > 0.0 { jump } else { pending }, steer, - sprint: self.keys.contains(&winit::keyboard::KeyCode::ControlLeft), + sprint: keys.sprint || self.keys.contains(&winit::keyboard::KeyCode::ControlLeft), jumping: keys.jump, }); true diff --git a/crates/horizon-client/src/game/remote_vehicles.rs b/crates/horizon-client/src/game/remote_vehicles.rs index dc3b2b686..027983145 100644 --- a/crates/horizon-client/src/game/remote_vehicles.rs +++ b/crates/horizon-client/src/game/remote_vehicles.rs @@ -112,6 +112,14 @@ impl Game<'_> { let Some(id) = self.riding else { return false; }; + if let Some(i) = self.mobs.iter().position(|m| m.id == id) { + // An animal moves on the server with the rider's input + // (PlayerInput); here the jump bar charges for the HUD and the + // rider sits where `positionRider` puts it. + self.charge_mount_jump(i, keys); + self.position_rider(); + return true; + } let seat = if let Some(i) = self.boats.iter().position(|b| b.id == id) { // AbstractBoat.tick on the controlling client: steer and move. let mut b = self.boats[i].clone(); diff --git a/crates/horizon-client/src/heartbeat.rs b/crates/horizon-client/src/heartbeat.rs index f73c7131f..9f3f3a5a6 100644 --- a/crates/horizon-client/src/heartbeat.rs +++ b/crates/horizon-client/src/heartbeat.rs @@ -2,8 +2,8 @@ //! launcher's "N playing now". While the game runs, a thread of its own sends a random session //! ID made here and kept only in memory, the version, the platform and whether a LAN or //! play-with-friends world is open, every minute and at once when that last one changes. -//! It sends nothing when there is no server (`HORIZON_TELEMETRY_URL`, none by default) or -//! with `HORIZON_NO_HEARTBEAT=1` (automated runs). +//! It sends nothing when sending is turned off (`HORIZON_TELEMETRY_URL=off`) or with +//! `HORIZON_NO_HEARTBEAT=1` (automated runs). use std::sync::OnceLock; use std::sync::atomic::{AtomicBool, Ordering}; use std::thread::Thread; diff --git a/crates/horizon-client/src/mobs/equine.rs b/crates/horizon-client/src/mobs/equine.rs index e7d73f0fa..5bb5faf53 100644 --- a/crates/horizon-client/src/mobs/equine.rs +++ b/crates/horizon-client/src/mobs/equine.rs @@ -338,15 +338,21 @@ pub fn ridden_step(m: &mut Mob) { // Pig/Strider: always forward along the rider's look, at a fraction // of the movement speed, boosted by the stick. m.head_pitch = r.pitch * 0.5; - m.ai.xxa = 0.0; - m.ai.zza = 1.0; + // Strider.getRiddenSpeed: slower while it shivers out of the warmth. let factor = if m.species() == Species::Pig { 0.225 + } else if super::strider::suffocating(m) { + 0.35 } else { 0.55 }; let boost = boost_factor(m); - m.set_speed((m.attrs.speed * factor) as f32 * boost); + // travelRidden: setSpeed(getRiddenSpeed), then travel(getRiddenInput); + // the input is set after the speed (Mob.setSpeed also sets zza). + // getAttributeValue(MOVEMENT_SPEED): with the cold strider's modifier. + m.set_speed((m.movement_speed() * factor) as f32 * boost); + m.ai.xxa = 0.0; + m.ai.zza = 1.0; return; } if super::camel::is_camel(m.species()) { @@ -366,14 +372,14 @@ pub fn ridden_step(m: &mut Mob) { } else { r.forward }; - m.ai.xxa = r.strafe * 0.5; - m.ai.zza = forward; let bonus = if r.sprint && m.extra.anim_ticks == 0 { 0.1 } else { 0.0 }; - m.set_speed(m.attrs.speed as f32 + bonus); + m.set_speed(m.movement_speed() as f32 + bonus); + m.ai.xxa = r.strafe * 0.5; + m.ai.zza = forward; if r.jump > 0.0 { let mut ev = Vec::new(); super::camel::dash(m, r.jump, &mut ev); @@ -394,10 +400,10 @@ pub fn ridden_step(m: &mut Mob) { } else { r.forward }; + let speed = m.movement_speed() as f32; + m.set_speed(speed); m.ai.xxa = r.strafe * 0.5; m.ai.zza = forward; - let speed = m.attrs.speed as f32; - m.set_speed(speed); if m.on_ground && r.jump > 0.0 { // executeRidersJump let impulse = m.extra.vector[0] as f32 * r.jump; diff --git a/crates/horizon-telemetry-server/README.md b/crates/horizon-telemetry-server/README.md index dc1f51248..ed54024a1 100644 --- a/crates/horizon-telemetry-server/README.md +++ b/crates/horizon-telemetry-server/README.md @@ -5,7 +5,7 @@ This server receives what players choose to send (performance summaries, crash a cargo run --release # in this folder: its own workspace, like the launcher's PORT=8080 HORIZON_TELEMETRY_DB=/data/telemetry.sqlite3 horizon-telemetry-server -The launcher sends to it when `HORIZON_TELEMETRY_URL` is set (and to `DEFAULT_ENDPOINT` in `crates/horizon-telemetry` once there is one). +It runs at **https://telemetry.playhorizon.dev** (`DEFAULT_ENDPOINT` in `crates/horizon-telemetry`). The game and the launcher use it unless `HORIZON_TELEMETRY_URL` names another server, or is `off` (tests and automated runs send nothing). ## Endpoints @@ -14,11 +14,34 @@ The launcher sends to it when `HORIZON_TELEMETRY_URL` is set (and to `DEFAULT_EN | `POST /v1/batch` | A zstd batch (`Content-Encoding: zstd`, at most 256 KiB, 1 MiB inflated, 64 items). Returns 204. Returns 400 for a bad batch, 413 for one too large, 415 if it is not zstd, 429 when over a limit. | | `DELETE /v1/installs/` | Deletes everything that install sent. Its share of the daily totals is rebuilt at once. | | `GET /v1/aggregate?days=30` | The totals the website reads. Cached 10 minutes, with `Access-Control-Allow-Origin` set to the website. | +| `GET /v1/benchmarks/summary` | Players' benchmark uploads grouped by GPU, CPU, render distance and game, for the website's Benchmarks page (below). Cached 10 minutes, same `Access-Control-Allow-Origin`. | | `POST /v1/live` | A game's "I'm playing" ping (JSON, at most 512 bytes). Returns 204. Returns 400 for a bad ping, 413 for one too large, 429 over the address's limit, 503 when it holds `LIVE_MAX_SESSIONS` already. | | `GET /v1/live` | How many play now, rounded: `playing`, `lan`, `versions`, `platforms`. Made again at most every 15 seconds, with the same `Access-Control-Allow-Origin`. | | `GET /healthz` | `ok` | -The totals are grouped per version, OS, GPU vendor and render distance. Each group has its sessions, install-days, hours played, the 14 frame-time buckets summed, and the mean p50 and p99 frame times. Groups with fewer than 5 install-days are left out. The totals also list crash counts per version and the newest 50 benchmark uploads. +The totals are grouped per version, OS, GPU vendor and render distance. Each group has its sessions, install-days, hours played, the 14 frame-time buckets summed, and the mean p50 and p99 frame times. Groups with fewer than 5 install-days are left out. The totals also list crash counts per version. Benchmark uploads are published only through the summary below, never one by one. + +## Benchmarks summary + +`src/summary.rs` makes it with the same rules as `website/scripts/benchmarks.mjs`, which bakes the page's fallback copy; both are tested against the same fixtures (`website/scripts/fixtures/benchmarks/`). + +- Only reports that compare: a version 1 `horizon-benchmark-report` of the standard flight over the four scenes, VSync off, no frame cap, on screen, from Horizon or plain vanilla, naming its GPU and CPU. +- A group (GPU, CPU, render distance, game) is published only with **at least 3 different installs**. Each install counts once: the median of its runs, then the median across installs. +- Out go the names, the counts, the newest three versions and the medians. Never an install ID, a day, an OS version, a driver, a memory size or a screen. + +```json +{ + "format": "horizon-benchmark-summary", "version": 1, "generated": "2026-10-22T20:00:00Z", "min_installs": 3, + "groups": [{ + "gpu": "NVIDIA GeForce RTX 4080", "cpu": "13th Gen Intel Core i7-13700KF", "render_distance": 12, + "game": "horizon", "source": "players", "installs": 3, "reports": 4, "versions": ["v0.2.1", "v0.2.0"], + "medians": { "avg_fps": 515, "low_1pct_fps": 120, "p95_ms": 3.5, "world_ms": 4500, + "chunk_load_ms": 1400, "rss_peak_mb": 1450, "rss_steady_mb": 1250 } + }] +} +``` + +Frame rates are whole numbers, milliseconds have one decimal under 10, megabytes are whole. Groups come most installs first. A deleted install leaves its groups at once. ## Storage @@ -45,7 +68,7 @@ All are environment variables: - `HORIZON_TELEMETRY_MIN_INSTALL_DAYS` (5) - `HORIZON_TELEMETRY_REQUESTS_PER_HOUR` per address (60, bursts of 6) - `HORIZON_TELEMETRY_ITEMS_PER_DAY` per install (100) -- `HORIZON_TELEMETRY_TRUST_PROXY=1` behind a proxy (the client's address is then the first of `X-Forwarded-For`) +- `HORIZON_TELEMETRY_TRUST_PROXY=1` behind a proxy (the client's address is then the proxy's `X-Real-IP`, else the last `X-Forwarded-For` entry; it is used only for the rate limits, in memory, and never stored or logged) - `HORIZON_TELEMETRY_ALLOW_ORIGIN` (`https://playhorizon.dev`) - `HORIZON_TELEMETRY_LIVE_PER_HOUR` per address, pings and reads (600, bursts of 60: ten players behind one address) - `HORIZON_TELEMETRY_LIVE_WINDOW_SECONDS` (120) @@ -55,6 +78,14 @@ All are environment variables: `Dockerfile` builds it from the repository root (`docker build -f crates/horizon-telemetry-server/Dockerfile .`). The database goes on a volume mounted at `/data`. +On Railway it is a service of the same project as the website: + +- Source: this repository, root directory `/` (the Dockerfile needs the shared crate), config file `/crates/horizon-telemetry-server/railway.json` (Dockerfile build, health check `/healthz`, one replica in `europe-west4`, Amsterdam: one SQLite file can't be shared). +- A volume mounted at `/data`. The Dockerfile already sets `HORIZON_TELEMETRY_DB=/data/telemetry.sqlite3` and `HORIZON_TELEMETRY_TRUST_PROXY=1`; Railway sets `PORT`. +- The custom domain `telemetry.playhorizon.dev`: a `CNAME` at Porkbun to the target Railway gives. + +Check it with `curl https://telemetry.playhorizon.dev/healthz`. + At Railway's prices (RAM $10/GB-month, CPU $20/vCPU-month, volumes $0.15/GB-month, egress $0.05/GB), one more service with a 1 GB volume uses about $0.35 a month: - RAM about 15 MB: $0.15 diff --git a/crates/horizon-telemetry-server/railway.json b/crates/horizon-telemetry-server/railway.json new file mode 100644 index 000000000..30eb18c33 --- /dev/null +++ b/crates/horizon-telemetry-server/railway.json @@ -0,0 +1,21 @@ +{ + "$schema": "https://railway.com/railway.schema.json", + "build": { + "builder": "DOCKERFILE", + "dockerfilePath": "crates/horizon-telemetry-server/Dockerfile", + "watchPatterns": [ + "/crates/horizon-telemetry/**", + "/crates/horizon-telemetry-server/**", + "/Cargo.toml" + ] + }, + "deploy": { + "healthcheckPath": "/healthz", + "healthcheckTimeout": 60, + "restartPolicyType": "ON_FAILURE", + "restartPolicyMaxRetries": 5, + "multiRegionConfig": { + "europe-west4-drams3a": { "numReplicas": 1 } + } + } +} diff --git a/crates/horizon-telemetry-server/src/lib.rs b/crates/horizon-telemetry-server/src/lib.rs index 061a9ca37..c00002531 100644 --- a/crates/horizon-telemetry-server/src/lib.rs +++ b/crates/horizon-telemetry-server/src/lib.rs @@ -3,6 +3,8 @@ //! - `POST /v1/batch`: a zstd batch from the launcher, checked by `horizon_telemetry::batch`. //! - `DELETE /v1/installs/`: everything an install sent goes. //! - `GET /v1/aggregate?days=30`: the anonymous totals the website reads, cached. +//! - `GET /v1/benchmarks/summary`: players' benchmark results grouped by GPU and CPU, groups of at +//! least 3 installs only (`summary`), cached; the website's Benchmarks page reads it. //! - `POST /v1/live`: a game's anonymous "I'm playing" ping (`live`, in memory only). //! - `GET /v1/live`: how many play now, rounded, cached briefly. //! - `GET /healthz`. @@ -26,6 +28,7 @@ use horizon_telemetry::batch; pub mod live; pub mod store; +pub mod summary; use horizon_telemetry::live::{MAX_PING_BYTES, Ping}; use live::Live; @@ -40,7 +43,8 @@ pub struct Config { pub requests_per_hour: f64, /// Items one install may send a day. pub items_per_day: u32, - /// Behind a proxy (Railway, Fly…): the client's address is the first of X-Forwarded-For. + /// Behind a proxy (Railway, Fly…): the client's address is the proxy's `X-Real-IP`, else the + /// last `X-Forwarded-For` entry. pub trust_proxy: bool, /// The website allowed to read the totals from a browser. pub allow_origin: String, @@ -117,6 +121,8 @@ pub struct App { live_cache: Mutex>, /// `/v1/aggregate` answers by `days`, with when they were made. cache: Mutex>, + /// `/v1/benchmarks/summary`'s answer and when it was made. + summary_cache: Mutex>, /// Today, in days since 1970 (a test moves it). today: Box u32 + Send + Sync>, } @@ -148,6 +154,7 @@ impl App { live: Mutex::new(live), live_cache: Mutex::default(), cache: Mutex::default(), + summary_cache: Mutex::default(), today, }) } @@ -170,20 +177,26 @@ impl App { self.live.lock().unwrap_or_else(|e| e.into_inner()) } + /// The address requests are counted under, for the rate limits only: kept in memory, never + /// stored or logged. Behind a proxy (Railway) the TCP peer is the proxy, so it is the proxy's + /// `X-Real-IP`, else the last `X-Forwarded-For` entry: the one the proxy added, which a client + /// can't choose (the first one it can). fn client(&self, headers: &HeaderMap, peer: Option) -> IpAddr { + let header = |name: &str| headers.get(name)?.to_str().ok(); let forwarded = self .config .trust_proxy .then(|| { - headers - .get("x-forwarded-for")? - .to_str() - .ok()? - .split(',') - .next()? - .trim() - .parse() - .ok() + header("x-real-ip") + .and_then(|ip| ip.trim().parse().ok()) + .or_else(|| { + header("x-forwarded-for")? + .rsplit(',') + .next()? + .trim() + .parse() + .ok() + }) }) .flatten(); forwarded @@ -196,6 +209,12 @@ impl App { self.store().newest_day(install).ok().flatten() } + /// Drops the cached public answers (after a deletion or expiry). + fn forget_cached(&self) { + self.cache.lock().unwrap_or_else(|e| e.into_inner()).clear(); + *self.summary_cache.lock().unwrap_or_else(|e| e.into_inner()) = None; + } + /// Daily upkeep: totals rebuilt, expired rows removed, idle rate-limit entries and live /// sessions forgotten. pub fn maintain(&self) -> rusqlite::Result { @@ -209,7 +228,7 @@ impl App { } self.live().forget_expired(Instant::now()); if removed > 0 { - self.cache.lock().unwrap_or_else(|e| e.into_inner()).clear(); + self.forget_cached(); } Ok(removed) } @@ -288,7 +307,7 @@ async fn forget(State(app): State>, Path(id): Path, req: Reques }; match app.store().delete_install(&install) { Ok(_) => { - app.cache.lock().unwrap_or_else(|e| e.into_inner()).clear(); + app.forget_cached(); StatusCode::NO_CONTENT.into_response() } Err(e) => { @@ -338,6 +357,60 @@ async fn aggregate(State(app): State>, Query(window): Query) -> json_response(&app, json, CACHE_FOR.as_secs()) } +/// `GET /v1/benchmarks/summary`: players' benchmark groups (`summary`), made again at most every +/// ten minutes. +async fn benchmarks(State(app): State>) -> Response { + let cached = app + .summary_cache + .lock() + .unwrap_or_else(|e| e.into_inner()) + .as_ref() + .filter(|(at, _)| at.elapsed() < CACHE_FOR) + .map(|(_, json)| json.clone()); + let json = match cached { + Some(json) => json, + None => { + let oldest = (app.today)().saturating_sub(app.config.retention_days); + let uploads = match app.store().benchmark_uploads(oldest) { + Ok(uploads) => uploads, + Err(e) => { + eprintln!("horizon-telemetry-server: could not read the benchmarks: {e}"); + return status(StatusCode::SERVICE_UNAVAILABLE, "try again later"); + } + }; + let json = summary::summary(&uploads, summary::MIN_INSTALLS, &utc_now()).to_string(); + *app.summary_cache.lock().unwrap_or_else(|e| e.into_inner()) = + Some((Instant::now(), json.clone())); + json + } + }; + json_response(&app, json, CACHE_FOR.as_secs()) +} + +/// Now as `YYYY-MM-DDTHH:MM:SSZ`. +fn utc_now() -> String { + let secs = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .map_or(0, |d| d.as_secs()); + let (days, rest) = (secs / 86_400, secs % 86_400); + // Days since 1970 to a civil date (Howard Hinnant's algorithm). + let z = days as i64 + 719_468; + let era = z.div_euclid(146_097); + let doe = z - era * 146_097; + let yoe = (doe - doe / 1460 + doe / 36_524 - doe / 146_096) / 365; + let doy = doe - (365 * yoe + yoe / 4 - yoe / 100); + let mp = (5 * doy + 2) / 153; + let day = doy - (153 * mp + 2) / 5 + 1; + let month = if mp < 10 { mp + 3 } else { mp - 9 }; + let year = yoe + era * 400 + i64::from(month <= 2); + format!( + "{year:04}-{month:02}-{day:02}T{:02}:{:02}:{:02}Z", + rest / 3600, + rest / 60 % 60, + rest % 60 + ) +} + /// `POST /v1/live`: one "I'm playing". 204, or 400 for a bad ping, 413 for one too large, 429 /// over the address's limit, 503 when the table is full. async fn ping(State(app): State>, req: Request) -> Response { @@ -407,6 +480,7 @@ pub fn router(app: Arc) -> Router { .route("/v1/live", post(ping).get(playing)) .route("/v1/installs/{id}", delete(forget)) .route("/v1/aggregate", get(aggregate)) + .route("/v1/benchmarks/summary", get(benchmarks)) .route("/healthz", get(|| async { "ok" })) .with_state(app) } diff --git a/crates/horizon-telemetry-server/src/store.rs b/crates/horizon-telemetry-server/src/store.rs index 0bac20e50..5188657ee 100644 --- a/crates/horizon-telemetry-server/src/store.rs +++ b/crates/horizon-telemetry-server/src/store.rs @@ -357,27 +357,33 @@ impl Store { })? .collect::>()? }; - let benchmarks: Vec = { - let mut q = self.db.prepare( - "SELECT day, version, body FROM reports WHERE kind = ?1 AND day BETWEEN ?2 AND ?3 - ORDER BY rowid DESC LIMIT 50", - )?; - q.query_map(params![kind_code(Kind::Benchmark), from, to], |r| { - let body: Vec = r.get(2)?; - Ok(serde_json::json!({ - "day": r.get::<_, u32>(0)?, "version": r.get::<_, String>(1)?, "report": inflate(&body), - })) - })? - .collect::>()? - }; Ok(serde_json::json!({ "from_day": from, "to_day": to, "min_install_days": k, "bucket_edges_ms": BUCKET_EDGES_MS.map(|e| (f64::from(e) * 10.0).round() / 10.0), "totals": { "sessions": sessions, "hours": (hours * 10.0).round() / 10.0 }, - "groups": out, "crashes_by_version": crashes, "benchmarks": benchmarks, + "groups": out, "crashes_by_version": crashes, })) } + /// Every benchmark upload received since `from_day`, with its install (to count installs, never shown) + /// and release, for `summary`. + pub fn benchmark_uploads( + &self, + from_day: u32, + ) -> rusqlite::Result> { + let mut q = self + .db + .prepare("SELECT install, version, body FROM reports WHERE kind = ?1 AND day >= ?2")?; + q.query_map(params![kind_code(Kind::Benchmark), from_day], |r| { + Ok(crate::summary::Upload { + install: r.get(0)?, + version: r.get(1)?, + report: inflate(&r.get::<_, Vec>(2)?), + }) + })? + .collect() + } + /// The day an install's newest row came in, if any (tests, and checking a deletion). pub fn newest_day(&self, install: &[u8]) -> rusqlite::Result> { self.db diff --git a/crates/horizon-telemetry-server/src/summary.rs b/crates/horizon-telemetry-server/src/summary.rs new file mode 100644 index 000000000..6cec9200e --- /dev/null +++ b/crates/horizon-telemetry-server/src/summary.rs @@ -0,0 +1,266 @@ +//! `GET /v1/benchmarks/summary`: players' benchmark uploads, grouped for the website's Benchmarks page. +//! +//! The same rules as `website/scripts/benchmarks.mjs` (which builds the page's baked copy), checked against the +//! same fixtures (`website/scripts/fixtures/benchmarks/`): +//! +//! - Only reports that compare: `horizon-benchmark-report` version 1, kind `game`, Horizon or plain vanilla, the +//! standard flight over the four scenes, VSync off, no frame cap, drawn on a screen, with a GPU and CPU name. +//! - Groups by GPU, CPU, render distance and game. A group is published only with at least `min_installs` +//! different installs, so no one can be picked out. +//! - Each install counts once: the median of its runs first, then the median across installs. +//! - Out go the group's names, its counts, the newest three versions and the medians. Never the install ID, the +//! day, the OS version, the driver, the memory size or the screen. +use std::collections::{BTreeMap, BTreeSet, HashMap}; + +use serde_json::{Value, json}; + +pub const FORMAT: &str = "horizon-benchmark-summary"; +pub const MIN_INSTALLS: usize = 3; +pub const SCENES: [&str; 4] = ["village", "forest", "ocean", "mountain"]; +pub const FIELDS: [&str; 7] = [ + "avg_fps", + "low_1pct_fps", + "p95_ms", + "world_ms", + "chunk_load_ms", + "rss_peak_mb", + "rss_steady_mb", +]; + +/// One stored upload: who sent it (only to count installs), the release, and the report. +pub struct Upload { + pub install: Vec, + pub version: String, + pub report: Value, +} + +/// "Intel(R) Core(TM) i7" -> "Intel Core i7", spaces collapsed. +fn trim(s: &str) -> String { + s.replace("(R)", "") + .replace("(TM)", "") + .replace("(tm)", "") + .split_whitespace() + .collect::>() + .join(" ") +} + +fn game(app: &Value) -> Option<&'static str> { + match app.get("name").and_then(Value::as_str) { + Some("horizon-client") => Some("horizon"), + Some("minecraft") => { + let mods = app.get("mods").and_then(Value::as_array); + let plain = mods.is_none_or(|m| { + m.iter() + .all(|m| m.get("name").and_then(Value::as_str) == Some("fabric-loader")) + }); + plain.then_some("vanilla") + } + _ => None, + } +} + +/// Why a report can't be compared with the others, or `None` when it can. +pub fn rejection(report: &Value) -> Option<&'static str> { + if report.get("format").and_then(Value::as_str) != Some("horizon-benchmark-report") + || report.get("version").and_then(Value::as_u64) != Some(1) + { + return Some("not a version 1 benchmark report"); + } + if report.get("kind").and_then(Value::as_str) != Some("game") { + return Some("not a game run"); + } + game(&report["app"])?; + let c = &report["conditions"]; + let scenario = c.get("scenario").and_then(Value::as_str).unwrap_or(""); + if !(scenario == "standard" || scenario == "flight" || scenario.starts_with("perf_bench:")) { + return Some("not the standard flight"); + } + if c.get("vsync") != Some(&Value::Bool(false)) { + return Some("VSync on or unknown"); + } + if c.get("fps_cap").is_some_and(|v| !v.is_null()) { + return Some("frame rate capped"); + } + if c.get("offscreen") == Some(&Value::Bool(true)) { + return Some("offscreen"); + } + if !c.get("render_distance").is_some_and(Value::is_number) { + return Some("no render distance"); + } + let phases: BTreeSet<&str> = report["frames"] + .as_array() + .map(|f| f.iter().filter_map(|f| f["phase"].as_str()).collect()) + .unwrap_or_default(); + if !SCENES.iter().all(|s| phases.contains(s)) { + return Some("not every scene"); + } + let named = |v: &Value| v.as_str().is_some_and(|s| !trim(s).is_empty()); + if !named(&report["hardware"]["gpu"]["name"]) || !named(&report["hardware"]["cpu"]) { + return Some("no GPU or CPU name"); + } + None +} + +fn mean(xs: &[f64]) -> Option { + (!xs.is_empty()).then(|| xs.iter().sum::() / xs.len() as f64) +} + +pub fn median(xs: &[f64]) -> Option { + let mut v: Vec = xs.iter().copied().filter(|x| x.is_finite()).collect(); + if v.is_empty() { + return None; + } + v.sort_by(f64::total_cmp); + let m = v.len() / 2; + Some(if v.len() % 2 == 1 { + v[m] + } else { + (v[m - 1] + v[m]) / 2.0 + }) +} + +/// fps to integers, milliseconds to a tenth under 10 and to integers above, megabytes to integers. +pub fn round(field: &str, x: f64) -> f64 { + if field.ends_with("_ms") && x < 10.0 { + (x * 10.0).round() / 10.0 + } else { + x.round() + } +} + +/// Whole numbers as integers (`515`, not `515.0`), as JavaScript writes them. +fn number(x: f64) -> Value { + if x.fract() == 0.0 && x.abs() < 9e15 { + json!(x as i64) + } else { + json!(x) + } +} + +/// A report's figures: frame figures averaged over every flight, the rest from its metrics. +pub fn figures(report: &Value) -> [Option; 7] { + let frames = report["frames"] + .as_array() + .map(Vec::as_slice) + .unwrap_or(&[]); + let avg = |key: &str| { + mean( + &frames + .iter() + .filter_map(|f| f[key].as_f64()) + .collect::>(), + ) + }; + let metrics = report["metrics"].as_object(); + let metric = |name: &str| metrics.and_then(|m| m.get(name)?.get("mean")?.as_f64()); + let loads: Vec = metrics + .map(|m| { + m.iter() + .filter(|(k, _)| { + k.strip_prefix("chunks.") + .and_then(|k| k.strip_suffix(".load_ms")) + .is_some_and(|scene| !scene.contains('.')) + }) + .filter_map(|(_, v)| v.get("mean")?.as_f64()) + .collect() + }) + .unwrap_or_default(); + [ + avg("avg_fps"), + avg("low_1pct_fps"), + avg("p95_ms"), + metric("startup.world_ms"), + mean(&loads), + metric("memory.rss_peak_mb"), + metric("memory.rss_steady_mb"), + ] +} + +/// "v0.2.10" after "v0.2.9", dated tags by their numbers: newest first. +fn newest_first(a: &str, b: &str) -> std::cmp::Ordering { + let n = |v: &str| -> Vec { + v.split(|c: char| !c.is_ascii_digit()) + .filter(|p| !p.is_empty()) + .filter_map(|p| p.parse().ok()) + .collect() + }; + n(b).cmp(&n(a)) +} + +#[derive(Default)] +struct Group { + installs: HashMap, Vec<[Option; 7]>>, + reports: usize, + versions: BTreeSet, +} + +/// Players' groups of at least `min_installs` installs, as `website/scripts/benchmarks.mjs` makes them. +pub fn groups(uploads: &[Upload], min_installs: usize) -> Vec { + let mut by: BTreeMap<(String, String, i64, &str), Group> = BTreeMap::new(); + for u in uploads { + if u.install.is_empty() || rejection(&u.report).is_some() { + continue; + } + let r = &u.report; + let key = ( + trim(r["hardware"]["gpu"]["name"].as_str().unwrap_or_default()), + trim(r["hardware"]["cpu"].as_str().unwrap_or_default()), + r["conditions"]["render_distance"] + .as_f64() + .unwrap_or_default() as i64, + game(&r["app"]).unwrap_or_default(), + ); + let g = by.entry(key).or_default(); + g.reports += 1; + if !u.version.is_empty() { + g.versions.insert(u.version.clone()); + } + g.installs + .entry(u.install.clone()) + .or_default() + .push(figures(r)); + } + let mut out: Vec<(usize, Value)> = by + .into_iter() + .filter(|(_, g)| g.installs.len() >= min_installs) + .map(|((gpu, cpu, rd, game), g)| { + let per_install: Vec<[Option; 7]> = g + .installs + .values() + .map(|runs| { + std::array::from_fn(|i| median(&runs.iter().filter_map(|r| r[i]).collect::>())) + }) + .collect(); + let medians: serde_json::Map = FIELDS + .iter() + .enumerate() + .map(|(i, f)| { + let m = median(&per_install.iter().filter_map(|r| r[i]).collect::>()); + (f.to_string(), m.map_or(Value::Null, |m| number(round(f, m)))) + }) + .collect(); + let mut versions: Vec = g.versions.into_iter().collect(); + versions.sort_by(|a, b| newest_first(a, b)); + versions.truncate(3); + let installs = g.installs.len(); + ( + installs, + json!({ + "gpu": gpu, "cpu": cpu, "render_distance": rd, "game": game, "source": "players", + "installs": installs, "reports": g.reports, "versions": versions, "medians": medians, + }), + ) + }) + .collect(); + // Most installs first, then by GPU and render distance (the map's order). + out.sort_by_key(|g| std::cmp::Reverse(g.0)); + out.into_iter().map(|(_, v)| v).collect() +} + +/// The whole answer; `generated` is an RFC 3339 UTC time. +pub fn summary(uploads: &[Upload], min_installs: usize, generated: &str) -> Value { + json!({ + "format": FORMAT, "version": 1, "generated": generated, "min_installs": min_installs, + "groups": groups(uploads, min_installs), + }) +} diff --git a/crates/horizon-telemetry-server/tests/server.rs b/crates/horizon-telemetry-server/tests/server.rs index f8c78f085..5d5b17b6a 100644 --- a/crates/horizon-telemetry-server/tests/server.rs +++ b/crates/horizon-telemetry-server/tests/server.rs @@ -198,14 +198,30 @@ async fn an_address_is_rate_limited() { s.post(&install(9), vec![perf("x", 8)]).await, StatusCode::TOO_MANY_REQUESTS ); + let from = |forwarded: &str, real: Option<&str>| { + let body = batch::encode(&Batch::new(&install(9), vec![perf("x", 8)])); + let mut req = Request::post("/v1/batch") + .header("x-forwarded-for", forwarded) + .header("content-encoding", "zstd"); + if let Some(ip) = real { + req = req.header("x-real-ip", ip); + } + req.body(Body::from(body)).unwrap() + }; + // A client can't pick its address: the proxy adds the real one last, or sets X-Real-IP. + assert_eq!( + s.send(from("198.51.100.7, 203.0.113.9", None)).await.0, + StatusCode::TOO_MANY_REQUESTS + ); + assert_eq!( + s.send(from("198.51.100.7", Some("203.0.113.9"))).await.0, + StatusCode::TOO_MANY_REQUESTS + ); // Another address has its own allowance. - let body = batch::encode(&Batch::new(&install(9), vec![perf("x", 8)])); - let req = Request::post("/v1/batch") - .header("x-forwarded-for", "198.51.100.7, 10.0.0.1") - .header("content-encoding", "zstd") - .body(Body::from(body)) - .unwrap(); - assert_eq!(s.send(req).await.0, StatusCode::NO_CONTENT); + assert_eq!( + s.send(from("203.0.113.9, 198.51.100.7", None)).await.0, + StatusCode::NO_CONTENT + ); } #[tokio::test] diff --git a/crates/horizon-telemetry-server/tests/summary.rs b/crates/horizon-telemetry-server/tests/summary.rs new file mode 100644 index 000000000..5a59aa8a1 --- /dev/null +++ b/crates/horizon-telemetry-server/tests/summary.rs @@ -0,0 +1,180 @@ +//! `GET /v1/benchmarks/summary` against the website's fixtures (website/scripts/fixtures/benchmarks/): the same +//! uploads must give the groups `website/scripts/benchmarks.mjs` gives. +use std::sync::Arc; +use std::sync::atomic::AtomicU32; + +use axum::body::Body; +use axum::http::{Request, StatusCode}; +use horizon_telemetry::Item; +use horizon_telemetry::batch::{self, Batch}; +use horizon_telemetry::payload::{Payload, Source}; +use horizon_telemetry_server::store::Store; +use horizon_telemetry_server::summary::{self, Upload}; +use horizon_telemetry_server::{App, Config, router}; +use http_body_util::BodyExt; +use serde_json::Value; +use tower::ServiceExt; + +const FIXTURES: &str = concat!( + env!("CARGO_MANIFEST_DIR"), + "/../../website/scripts/fixtures/benchmarks" +); + +fn items() -> Vec { + std::fs::read_to_string(format!("{FIXTURES}/items.jsonl")) + .unwrap() + .lines() + .filter(|l| !l.trim().is_empty()) + .map(|l| serde_json::from_str(l).unwrap()) + .collect() +} + +fn expected() -> Value { + serde_json::from_str(&std::fs::read_to_string(format!("{FIXTURES}/expected.json")).unwrap()) + .unwrap() +} + +/// The fixtures' short install names as the 32 hex digits real installs have. +fn install_id(name: &str) -> String { + format!( + "{:032x}", + name.bytes().fold(0u128, |n, b| n * 257 + u128::from(b)) + ) +} + +#[test] +fn the_fixtures_give_the_websites_groups() { + let uploads: Vec = items() + .into_iter() + .map(|i| Upload { + install: i["install_id"] + .as_str() + .unwrap_or_default() + .as_bytes() + .to_vec(), + version: i["version"].as_str().unwrap_or_default().to_owned(), + report: i["data"].clone(), + }) + .collect(); + let s = summary::summary(&uploads, summary::MIN_INSTALLS, "2026-11-03T00:00:00Z"); + let want = expected(); + assert_eq!(s["format"], "horizon-benchmark-summary"); + assert_eq!(s["version"], 1); + assert_eq!(s["min_installs"], want["min_installs"]); + assert_eq!(s["groups"], want["groups"]); +} + +#[test] +fn only_comparable_runs_count() { + let reasons: Vec<&str> = items() + .iter() + .filter_map(|i| summary::rejection(&i["data"])) + .collect(); + assert_eq!( + reasons, + [ + "VSync on or unknown", + "offscreen", + "frame rate capped", + "not every scene", + "not the standard flight", + "not a version 1 benchmark report" + ] + ); +} + +#[test] +fn medians_and_rounding() { + assert_eq!(summary::median(&[3.0, 1.0, 2.0]), Some(2.0)); + assert_eq!(summary::median(&[4.0, 1.0, 2.0, 3.0]), Some(2.5)); + assert_eq!(summary::median(&[f64::NAN]), None); + assert_eq!(summary::round("p95_ms", 3.46), 3.5); + assert_eq!(summary::round("world_ms", 4512.4), 4512.0); + assert_eq!(summary::round("avg_fps", 99.5), 100.0); +} + +async fn get(app: &Arc, uri: &str) -> (StatusCode, String, Option) { + let res = router(app.clone()) + .oneshot(Request::get(uri).body(Body::empty()).unwrap()) + .await + .unwrap(); + let code = res.status(); + let origin = res + .headers() + .get("access-control-allow-origin") + .map(|v| v.to_str().unwrap().to_owned()); + let body = res.into_body().collect().await.unwrap().to_bytes(); + (code, String::from_utf8_lossy(&body).into_owned(), origin) +} + +/// Uploaded through `POST /v1/batch` as the launcher sends them, then read back from the endpoint. +#[tokio::test] +async fn uploads_come_back_grouped_and_anonymous() { + let day = Arc::new(AtomicU32::new(20_396)); + let clock = day.clone(); + let config = Config { + requests_per_hour: 1e6, + ..Config::default() + }; + let app = App::with_clock( + Store::open(":memory:").unwrap(), + config, + Box::new(move || clock.load(std::sync::atomic::Ordering::SeqCst)), + ); + for i in items() { + let Some(name) = i["install_id"].as_str() else { + continue; // an item without an install can't be sent + }; + let item = Item::new( + Source::Game, + i["version"].as_str().unwrap(), + Payload::Benchmark(i["data"].clone()), + ); + let body = batch::encode(&Batch::new(&install_id(name), vec![item])); + let res = router(app.clone()) + .oneshot( + Request::post("/v1/batch") + .header("content-encoding", "zstd") + .body(Body::from(body)) + .unwrap(), + ) + .await + .unwrap(); + assert_eq!(res.status(), StatusCode::NO_CONTENT, "{name}"); + } + + let (code, body, origin) = get(&app, "/v1/benchmarks/summary").await; + assert_eq!(code, StatusCode::OK); + assert_eq!(origin.as_deref(), Some("https://playhorizon.dev")); + let s: Value = serde_json::from_str(&body).unwrap(); + assert_eq!(s["groups"], expected()["groups"]); + let generated = s["generated"].as_str().unwrap(); + assert!( + generated.len() == 20 && generated.ends_with('Z'), + "{generated}" + ); + for secret in [ + install_id("a1").as_str(), + "install_id", + "secret-os-version", + "secret-driver", + "20394", + "ram_mb", + ] { + assert!(!body.contains(secret), "{secret} in {body}"); + } + + // Deleting one of the three installs takes the group below three: it goes at once. + let res = router(app.clone()) + .oneshot( + Request::delete(format!("/v1/installs/{}", install_id("a3"))) + .body(Body::empty()) + .unwrap(), + ) + .await + .unwrap(); + assert_eq!(res.status(), StatusCode::NO_CONTENT); + let (_, body, _) = get(&app, "/v1/benchmarks/summary").await; + let s: Value = serde_json::from_str(&body).unwrap(); + assert_eq!(s["groups"], serde_json::json!([])); +} diff --git a/crates/horizon-telemetry/src/lib.rs b/crates/horizon-telemetry/src/lib.rs index 8d2840a08..018c13df8 100644 --- a/crates/horizon-telemetry/src/lib.rs +++ b/crates/horizon-telemetry/src/lib.rs @@ -33,16 +33,21 @@ pub const SCHEMA: u32 = 1; /// and until the player answers nothing new is kept or sent. pub const CONSENT_VERSION: u32 = 1; -/// The ingest server, or none while there isn't one: then nothing is ever sent (no ping either) -/// and the outbox stays within its caps. `HORIZON_TELEMETRY_URL` overrides it (tests, a local -/// server). -pub const DEFAULT_ENDPOINT: Option<&str> = None; +/// The ingest server (`crates/horizon-telemetry-server`, on Railway). `HORIZON_TELEMETRY_URL` +/// overrides it (a local server); `HORIZON_TELEMETRY_URL=off` sends nothing at all, no ping +/// either (tests and automated runs). What is sent still depends on the player's switches. +pub const DEFAULT_ENDPOINT: &str = "https://telemetry.playhorizon.dev"; /// Where items are sent, if anywhere. pub fn endpoint() -> Option { - match std::env::var("HORIZON_TELEMETRY_URL") { - Ok(url) if !url.trim().is_empty() => Some(url.trim().trim_end_matches('/').to_owned()), - _ => DEFAULT_ENDPOINT.map(str::to_owned), + resolve(std::env::var("HORIZON_TELEMETRY_URL").ok().as_deref()) +} + +fn resolve(var: Option<&str>) -> Option { + match var.map(str::trim) { + Some("off" | "none" | "0") => None, + Some(url) if !url.is_empty() => Some(url.trim_end_matches('/').to_owned()), + _ => Some(DEFAULT_ENDPOINT.to_owned()), } } @@ -100,3 +105,20 @@ pub(crate) mod test_home { dir } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn the_endpoint_defaults_to_the_server_and_can_be_moved_or_turned_off() { + assert_eq!(resolve(None).as_deref(), Some(DEFAULT_ENDPOINT)); + assert_eq!(resolve(Some(" ")).as_deref(), Some(DEFAULT_ENDPOINT)); + assert_eq!( + resolve(Some("http://127.0.0.1:8080/")).as_deref(), + Some("http://127.0.0.1:8080") + ); + assert_eq!(resolve(Some("off")), None); + assert!(DEFAULT_ENDPOINT.starts_with("https://") && !DEFAULT_ENDPOINT.ends_with('/')); + } +} diff --git a/crates/horizon-theme/src/lib.rs b/crates/horizon-theme/src/lib.rs index 14bbc3efd..dac5bf8d2 100644 --- a/crates/horizon-theme/src/lib.rs +++ b/crates/horizon-theme/src/lib.rs @@ -474,6 +474,41 @@ impl Palette { } } +impl Blocks { + /// Every colour by its CSS name. The website reads the Blocks palettes; the first twelve keep + /// the names of [`Palette::named`] (`plate-soft` is `raised`, `plate` is `button`, `surface` + /// is `panel`, `on-accent` is `on_face`), so styles written for those still apply. + pub fn named(&self) -> [(&'static str, u32); 25] { + [ + ("page", self.page), + ("plate-soft", self.raised), + ("plate", self.button), + ("surface", self.panel), + ("rule", self.rule), + ("ink", self.ink), + ("ink-soft", self.ink_soft), + ("muted", self.muted), + ("accent", self.accent), + ("on-accent", self.on_face), + ("danger", self.danger), + ("success", self.success), + ("warn", self.warn), + ("side", self.side), + ("panel", self.panel), + ("raised", self.raised), + ("button", self.button), + ("button-bevel", self.button_bevel), + ("well", self.well), + ("bevel", self.bevel), + ("lip", self.lip), + ("outline", self.outline), + ("face", self.face), + ("face-bevel", self.face_bevel), + ("face-lip", self.face_lip), + ] + } +} + /// The WCAG 2 contrast ratio of two colours. pub fn contrast(a: u32, b: u32) -> f32 { fn luminance(c: u32) -> f32 { @@ -499,10 +534,12 @@ pub fn css() -> String { let t = format!("{v:.3}"); t.trim_end_matches('0').trim_end_matches('.').to_string() }; - let colors = |s: &mut String, p: &Palette| { + // The website wears the launcher's Blocks look; the game's menus keep LIGHT and DARK. + let colors = |s: &mut String, p: &Blocks| { for (name, c) in p.named() { let _ = writeln!(s, " --{name}: #{c:06x};"); } + let _ = writeln!(s, " --on-face: #{:06x};", p.on_face); let _ = writeln!( s, " color-scheme: {};", @@ -513,11 +550,18 @@ pub fn css() -> String { "/* Generated from crates/horizon-theme by `cargo run -p xtask -- tokens`; do not edit.\n \ docs/design-system.md describes the tokens. */\n\n:root {\n", ); - colors(&mut s, &LIGHT); + colors(&mut s, &BLOCKS_LIGHT); let _ = writeln!( s, - " --font: \"{FONT}\", ui-sans-serif, system-ui, sans-serif;\n --mono: \"{MONO}\", ui-monospace, monospace;" + " --font: \"{FONT}\", ui-sans-serif, system-ui, sans-serif;\n --mono: \"{MONO}\", ui-monospace, monospace;\n --pixel: \"{PIXEL}\", \"{FONT}\", ui-sans-serif, sans-serif;" ); + for (name, v) in [ + ("block-outline", BLOCK_OUTLINE), + ("block-bevel", BLOCK_BEVEL), + ("block-lip", BLOCK_LIP), + ] { + let _ = writeln!(s, " --{name}: {}px;", num(v)); + } for step in TYPE { let size = match step.web { Web::Fixed => format!("{}px", num(step.px)), @@ -576,7 +620,7 @@ pub fn css() -> String { "}\n\n@media (prefers-color-scheme: dark) {\n :root:not([data-theme=\"light\"]) {\n", ); let mut dark = String::new(); - colors(&mut dark, &DARK); + colors(&mut dark, &BLOCKS_DARK); for line in dark.lines() { let _ = writeln!(s, " {line}"); } diff --git a/docs/design-system.md b/docs/design-system.md index db61993ba..bd4b635cb 100644 --- a/docs/design-system.md +++ b/docs/design-system.md @@ -140,37 +140,39 @@ Geist (400, 500, 600) and Geist Mono (400), bundled under the SIL Open Font Lice landscape banner with the hero, the version picker and Play; Mods holds the resource pack, shader pack and modpack tabs; Versions and Patch notes are lists of panels; Settings is grouped panels of rows. Dark by default, Light or System in Settings (Appearance). -- **Website** (`website/`): the same page structure as before (what it is, screenshots, - parity, launcher, patch notes, community), each section a `micro` mono label, a `display` - heading and a short paragraph, its content an index list. Screenshots stay as images (radius - 12, no frame). Light and dark follow the system, with a toggle. A giant faint wordmark sits - above the footer. No hero photograph: the first screen is the headline, one paragraph, the - download button and the parity score as an index row. +- **Website** (`website/`): the Blocks look below. The same page structure as before (what it + is, screenshots, parity, launcher, patch notes, community), headings in Pixelify Sans, lists as + stacks of panels, the stone texture behind the page and Horizon's pixel landscape (a dawn or a + sunset) behind the hero. Light and dark follow the system, with a toggle. A giant wordmark in + pixels sits in the footer. - **Game**: vanilla's screens. The on-screen keyboard is a rounded plate of keys in the page colour, the focused key in the accent. -## Blocks (the launcher) +## Blocks -The launcher's look since the gaming redesign: Minecraft's inventory rather than a document. -Its tokens are `horizon_theme::Blocks` (`BLOCKS_DARK`, `BLOCKS_LIGHT`); the palettes above stay -what the game's menus read. +A blocky, Minecraft-like look in Horizon's purple, for the website and the redesigned launcher: +Minecraft's inventory rather than a document. Its colours are `horizon_theme::Blocks` +(`BLOCKS_LIGHT`, `BLOCKS_DARK`), which `tokens.css` carries under the same names as before plus +`--panel`, `--raised`, `--button`, `--well`, `--bevel`, `--lip`, `--outline` and the `--face` +of the main action. The game's menus keep `LIGHT` and `DARK`. -- **Pixel type for what you act on.** Headings, tabs, buttons, badges and the wordmark use Pixelify - Sans (Medium, SemiBold, Bold); paragraphs, details and numbers stay in Geist and Geist Mono so long - text reads easily. -- **Blocks, not rounded cards.** Every surface is a square panel: a 2 px dark outline, a 2 px light - bevel along the top and a darker lip along the bottom. The main action (Play, Install) is the - violet `face` with its own bevel and a 4 px lip; secondary buttons are raised `button` blocks; - fields and tracks are sunk `well`s. +- **Pixel type for what names and what you act on.** Headings, navigation, buttons and the + wordmark use Pixelify Sans (OFL; Medium, SemiBold, Bold); paragraphs and numbers stay in Geist + and Geist Mono so long text reads easily. +- **Blocks, not rounded cards.** Every surface is square: a 2 px dark outline, a 2 px light bevel + along the top and a darker lip along the bottom. The main action is the violet face with its own + bevel and a 4 px lip; it sinks a pixel when pressed. Code and fields are sunk wells. - **Inventory tabs** switch the kinds in Mods: the open tab joins the panel under it. - **Slots** hold pictures: a mod's or pack's own icon and gallery images from its source, downloaded when first shown and kept on disk (`launcher/src/browser/images.rs`); the launcher ships no third-party pictures. The Horizon instance shows a grass block drawn from the player's own prepared Minecraft textures. Sources are named in text ("from Modrinth"): Modrinth's logo is all rights reserved, so it is not shown. -- **Pixel art made in code** (`launcher/src/art.rs`): the stone behind the pages (16 texel tiles in - five shades of the page colour) and the landscape behind Home (a sunset in dark, a dawn in light), - baked at the window's scale so each texel covers whole device pixels. +- **Pixel art drawn in code.** The stone behind the pages is close shades of the page colour + (`TILE_SHADES`), never Minecraft's stone; the landscape is a banded sky, a sun cut in slices like + the mark, hills and square trees (a sunset in dark, a dawn in light). The launcher bakes them in + `launcher/src/art.rs` at the window's scale so each texel covers whole device pixels; the website + draws them in `website/scripts/art.mjs`. - **Icons**: Pixelarticons (MIT), 24 unit pixel SVGs in `crates/horizon-theme/icons/pixel/`, tinted with the text colour. - **Contrast**: every text colour meets WCAG AA (4.5:1) on the panels, the page and the lightest diff --git a/docs/telemetry.md b/docs/telemetry.md index f701044f2..e2cb9b050 100644 --- a/docs/telemetry.md +++ b/docs/telemetry.md @@ -45,7 +45,8 @@ Never sent: account names or UUIDs, world names, server or LAN addresses, chat, - `telemetry/outbox/` holds one JSON file per item, `--.json`. It never holds more than 200 items or 2 MiB, and the oldest go first. `kept.json` counts today's items per kind against the caps above. - The launcher sends the outbox when it starts and when it closes. Items go as one JSON batch (`{"schema":1,"install_id":…,"items":[…]}`, up to 64 items and 1 MiB), compressed with zstd: `POST /v1/batch` with `Content-Encoding: zstd`. A day's perf summaries are under 2 KB on the wire. - After a failure the launcher waits a minute, doubling up to a day, and sends at most 8 batches a day. A batch the server refuses with a 4xx (not 429) is dropped. -- `HORIZON_TELEMETRY_URL` sets the server. There is none by default: until there is, nothing is sent and the outbox stays within its caps. +- The server is `https://telemetry.playhorizon.dev` (`DEFAULT_ENDPOINT`), on Railway in the EU (`europe-west4`, Amsterdam). `HORIZON_TELEMETRY_URL` names another one (a local server); `HORIZON_TELEMETRY_URL=off` sends nothing at all, no ping either. Tests, CI and the benchmark and test harnesses set `off`. +- What is sent still depends on the switches: with every switch off nothing but the ping leaves, and the outbox stays empty. - `SCHEMA` versions the format. New optional fields keep it. A field that changes meaning or goes bumps it, and the server keeps reading the older ones. ## The "I'm playing" ping @@ -68,13 +69,14 @@ The server keeps sessions in memory only, never on disk, and never with the send { "playing": 1240, "lan": 85, "versions": { "v2026.10.22": 1100, "other": 140 }, "platforms": { "linux": 300, "macos": 240, "windows": 700 } } ``` -The launcher reads it when it opens and every minute after, and shows "N playing now" on the Play page. It shows nothing when the server can't be reached. Like the rest, there is no server by default (`HORIZON_TELEMETRY_URL`): until there is one, the game sends no ping and the launcher shows no count. `HORIZON_NO_HEARTBEAT=1` keeps automated runs out of the count. +The launcher reads it when it opens and every minute after, and shows "N playing now" on the Play page. It shows nothing when the server can't be reached. `HORIZON_TELEMETRY_URL=off` turns both off; `HORIZON_NO_HEARTBEAT=1` keeps a single automated run out of the count. ## Server - `POST /v1/batch` - `DELETE /v1/installs/`: deletes everything sent under that ID. - `GET /v1/aggregate`: the anonymous totals the website's results page reads. +- `GET /v1/benchmarks/summary`: players' benchmark uploads grouped by GPU, CPU, render distance and game for playhorizon.dev/benchmarks. A group shows only with at least 3 different installs, and only its medians and counts: no install ID, day, OS version, driver, memory or screen. Uploads are never published one by one. - `POST /v1/live` and `GET /v1/live`: the "I'm playing" ping and the live count. -`crates/horizon-telemetry-server` is the server. Its [README](../crates/horizon-telemetry-server/README.md) covers storage (about 190 bytes per play session), retention (180 days of raw rows, anonymous daily totals kept), rate limits and hosting. +`crates/horizon-telemetry-server` is the server, at `https://telemetry.playhorizon.dev` on Railway (one SQLite file on a volume, region `europe-west4`). Its [README](../crates/horizon-telemetry-server/README.md) covers storage (about 190 bytes per play session), retention (180 days of raw rows, anonymous daily totals kept), rate limits and hosting. diff --git a/launcher/src/cli.rs b/launcher/src/cli.rs index 9c1c37fe2..88934f3a5 100644 --- a/launcher/src/cli.rs +++ b/launcher/src/cli.rs @@ -765,7 +765,7 @@ fn data(action: DataCmd, as_json: bool) -> Result<(), String> { println!("Waiting to be sent: {}", status["waiting"]); match horizon_telemetry::endpoint() { Some(url) => println!("Server: {url}"), - None => println!("Server: none yet, nothing is sent"), + None => println!("Server: turned off (HORIZON_TELEMETRY_URL=off), nothing is sent"), } } DataCmd::Allow { kinds } => { diff --git a/launcher/src/collection.rs b/launcher/src/collection.rs index 67745284e..995bce17c 100644 --- a/launcher/src/collection.rs +++ b/launcher/src/collection.rs @@ -307,7 +307,7 @@ impl Launcher { let server = if horizon_telemetry::endpoint().is_some() { format!("{waiting} waiting to be sent") } else { - "No data server yet: nothing is sent".into() + "Sending is turned off here (HORIZON_TELEMETRY_URL=off)".into() }; let confirm = self.collection.confirm_delete; let actions = div() diff --git a/launcher/src/telemetry.rs b/launcher/src/telemetry.rs index 26e8c0625..5cdd913f8 100644 --- a/launcher/src/telemetry.rs +++ b/launcher/src/telemetry.rs @@ -54,7 +54,7 @@ pub fn playing_now() -> Option { } /// Sends [`playing_now`] to the window as `Msg::Playing` now and every minute, on its own -/// thread. Nothing at all when there is no server. +/// thread. Nothing at all when sending is turned off. pub fn watch_playing(tx: std::sync::mpsc::Sender) { if horizon_telemetry::endpoint().is_none() { return; @@ -151,7 +151,9 @@ pub fn delete_my_data() -> Result { outbox::clear(&home).map_err(|e| e.to_string())?; let remote = match horizon_telemetry::endpoint() { _ if consent.install_id.is_empty() => "Nothing was ever sent from here.", - None => "Nothing was sent: there is no data server yet.", + None => { + "Sending is turned off here (HORIZON_TELEMETRY_URL=off), so the server was not asked." + } Some(url) => { upload::delete_remote(&url, &consent.install_id) .map_err(|e| format!("The server could not be reached ({e}). Try again later."))?; @@ -230,7 +232,7 @@ pub fn submit(item: &Item) -> Result { Ok(match send() { Flush::Sent { .. } => "Sent. Thank you.".into(), Flush::Nothing if horizon_telemetry::endpoint().is_none() => { - "Kept to be sent once the data server is up.".into() + "Kept; sending is turned off here (HORIZON_TELEMETRY_URL=off).".into() } _ => "Kept; it will be sent the next time the launcher starts.".into(), }) diff --git a/tools/agent_control_e2e.py b/tools/agent_control_e2e.py index 6f75b8a14..f4c7acaa9 100644 --- a/tools/agent_control_e2e.py +++ b/tools/agent_control_e2e.py @@ -64,7 +64,7 @@ class Failed(Exception): def game_env(screen): if sys.platform == 'darwin': - return dict(os.environ, HORIZON_NO_AUDIO='1') + return dict(os.environ, HORIZON_NO_AUDIO='1', HORIZON_TELEMETRY_URL='off') env = dict(os.environ, VSCREEN=screen) subprocess.run(['vscreen', 'up'], env=env, check=False, capture_output=True) text = subprocess.run(['vscreen', 'env'], env=env, capture_output=True, text=True, check=True).stdout @@ -72,6 +72,7 @@ def game_env(screen): for match in re.finditer(r'(\w+)=(\S+)', text.split('unset')[0]): env[match.group(1)] = match.group(2) env['HORIZON_NO_AUDIO'] = '1' + env['HORIZON_TELEMETRY_URL'] = 'off' # no live-count ping from test games if LAVAPIPE.exists(): env['VK_ICD_FILENAMES'] = str(LAVAPIPE) return env diff --git a/tools/graphics_bench.py b/tools/graphics_bench.py index 202a5ea3c..0e42e94d5 100644 --- a/tools/graphics_bench.py +++ b/tools/graphics_bench.py @@ -61,6 +61,8 @@ def vscreen_env(): env.pop("DISPLAY", None) # Benchmark games never play sound on the machine's speakers. env["HORIZON_NO_AUDIO"] = "1" + # Nor reach the telemetry server (docs/telemetry.md). + env["HORIZON_TELEMETRY_URL"] = "off" return env diff --git a/tools/lan_e2e.py b/tools/lan_e2e.py index a93115f63..894bb8627 100755 --- a/tools/lan_e2e.py +++ b/tools/lan_e2e.py @@ -123,6 +123,9 @@ address. The script then checks, from both sides, what a guest's game used to ge it (#1222). - frames: the host and the guest each put a diamond in an item frame and turn it, and put a helmet on an armor stand and take it back (#1222). +- riding: the host and the guest each saddle and ride a horse (walk, jump), a pig and a strider + (with their sticks), a camel and a donkey, sit on a llama and fly a happy ghast, and + get off by sneaking; the other side sees the animal move. - lightning: a bolt summoned beside the host, then the guest: both sides get the bolt and flash the sky (on its server thread the host's window is a client of it too). - flight: a player in creative double-taps jump and flies, stays up, and stops flying in survival: @@ -166,7 +169,7 @@ ROOT = Path(__file__).resolve().parents[1] GUEST_NAME = 'Guest' # The host plays single player on its server thread (--server-thread). SERVER_THREAD = False -CHECKS = ['tab', 'self', 'armour', 'nametags', 'walls', 'chest', 'crafting', 'sign', 'damage', 'mobs', 'hazards', 'pvp', 'arrows', 'kills', 'hurt', 'respawn', 'containers', 'feedback', 'titles', 'chat', 'commands', 'recipes', 'machines', 'brewing', 'loom', 'stonecutter', 'grindstone', 'anvil', 'smithing', 'enchanting', 'beacon', 'crafter', 'lectern', 'cartography', 'trials', 'clicks', 'sleep', 'predict', 'push', 'eat', 'eating', 'xp', 'objects', 'projectiles', 'worn', 'blast', 'barter', 'deflect', 'fireball', 'light', 'time', 'swings', 'cracks', 'plates', 'effects', 'portals', 'distance', 'growth', 'flight', 'ladder', 'boats', 'minecarts', 'frames', 'lightning'] +CHECKS = ['tab', 'self', 'armour', 'nametags', 'walls', 'chest', 'crafting', 'sign', 'damage', 'mobs', 'hazards', 'pvp', 'arrows', 'kills', 'hurt', 'respawn', 'containers', 'feedback', 'titles', 'chat', 'commands', 'recipes', 'machines', 'brewing', 'loom', 'stonecutter', 'grindstone', 'anvil', 'smithing', 'enchanting', 'beacon', 'crafter', 'lectern', 'cartography', 'trials', 'clicks', 'sleep', 'predict', 'push', 'eat', 'eating', 'xp', 'objects', 'projectiles', 'worn', 'blast', 'barter', 'deflect', 'fireball', 'light', 'time', 'swings', 'cracks', 'plates', 'effects', 'portals', 'distance', 'growth', 'flight', 'ladder', 'boats', 'minecarts', 'frames', 'lightning', 'riding'] class Game: @@ -2509,6 +2512,132 @@ def check_frames(host, guest, out): return result +# Animals a player rides: (kind, summon NBT, what readies it, what is held to ride, the test +# while riding). `move` walks forward, `jump` charges the horse's jump bar, `rise` holds jump on +# a happy ghast, `sit` only rides (a llama goes where it likes). +RIDES = [ + ('horse', '{Tame:1b}', 'minecraft:saddle', None, 'move jump'), + ('pig', '', 'minecraft:saddle', 'minecraft:carrot_on_a_stick', 'move'), + ('strider', '', 'minecraft:saddle', 'minecraft:warped_fungus_on_a_stick', 'move'), + ('camel', '', 'minecraft:saddle', None, 'move'), + ('donkey', '{Tame:1b}', 'minecraft:saddle', None, 'move'), + ('llama', '{Tame:1b}', None, None, 'sit'), + ('happy_ghast', '', 'minecraft:white_harness', None, 'rise'), +] +HEIGHTS = {'horse': 1.6, 'donkey': 1.5, 'pig': 0.9, 'strider': 1.7, 'camel': 2.375, 'llama': 1.87, + 'happy_ghast': 4.0} + + +def mob_seen(game, mob_id): + found = [m for m in game.raw('mobs', 96).get('near', []) if m['id'] == mob_id] + return found[0] if found else None + + +def hold(game, key, ticks): + game.raw('key', key, 'down') + game.wait(ticks) + game.raw('key', key, 'up') + + +def ride(player, other, label, spot, kind, nbt, ready, stick, test): + """Summon `kind` in front of `player`, ready it (saddle, harness), get on with a right click, + run `test`, and get off by sneaking. The other side sees the animal move.""" + x, y, z = spot + # In reach (3 blocks), clear of the player: a happy ghast is 4 blocks wide. + at = (x + 0.5, z + {'happy_ghast': 3.2, 'camel': 3.0}.get(kind, 2.5)) + # The first item in hand before it appears: a happy ghast drifts out of reach quickly. + player('command', command=f'item replace entity @s weapon.mainhand with {ready or stick or "minecraft:air"}') + player('command', command=f'summon minecraft:{kind} {at[0]} {y} {at[1]} {nbt}') + player.wait(3) + found = [m for m in player.raw('mobs', 16).get('near', []) if m['kind'].endswith(kind) and m['health'] > 0] + assert found, f'the {label} sees no {kind}' + mob = found[0] + def click(item): + player('command', command=f'item replace entity @s weapon.mainhand with {item or "minecraft:air"}') + player.wait(2) + m = mob_seen(player, mob['id']) + assert m, f'the {label} lost its {kind}' + p = m['pos'] + # Back in front of it if it wandered off (a happy ghast drifts away fast). + if abs(p[0] - (x + 0.5)) > 0.5 or abs(p[2] - at[1]) > 0.5: + player('command', command=f'tp @s {p[0]:.2f} {y} {p[2] - (at[1] - z - 0.5):.2f} 0 0') + player.wait(1) + player.raw('look-at', f'{p[0]:.2f}', f'{p[1] + HEIGHTS[kind] / 2:.2f}', f'{p[2]:.2f}') + player.raw('mouse', 'right', 'click') + player.wait(5) + try: + if ready: + click(ready) + click(stick) + riding = player('status').get('riding') + assert riding == mob['id'], f'the {label} right-clicked the {kind} {mob["id"]}: riding {riding}' + result = {'rode': True} + # South, along the cleared floor. + player.raw('look-at', f'{x + 0.5:.2f}', f'{y + 1.6:.2f}', f'{z + 40.5:.2f}') + player.wait(5) + start = mob_seen(player, mob['id'])['pos'] + if 'move' in test: + hold(player, 'w', 60) + player.wait(5) + mine = mob_seen(player, mob['id'])['pos'] + theirs = mob_seen(other, mob['id']) + moved = math.dist(start, mine) + assert moved > 1.0, f"the {label}'s {kind} moved {moved:.2f} blocks in 3 s of forward" + assert theirs and math.dist(theirs['pos'], mine) < 1.5, \ + f"the other side sees the {label}'s {kind} at {theirs and theirs['pos']}, not {mine}" + seated = pos_of(player) + assert math.dist(seated[::2], mine[::2]) < 1.5, f'the {label} sits at {seated}, its {kind} at {mine}' + result['moved'] = round(moved, 2) + if 'jump' in test: + base = mob_seen(player, mob['id'])['pos'][1] + player.raw('key', 'space', 'down') + player.wait(10) + player.raw('key', 'space', 'up') + top = base + for _ in range(10): + player.wait(2) + top = max(top, mob_seen(player, mob['id'])['pos'][1]) + assert top - base > 0.4, f"the {label}'s {kind} jumped {top - base:.2f} blocks" + result['jumped'] = round(top - base, 2) + if 'rise' in test: + base = mob_seen(player, mob['id'])['pos'][1] + hold(player, 'space', 40) + player.wait(5) + rose = mob_seen(player, mob['id'])['pos'][1] - base + assert rose > 0.5, f"the {label}'s {kind} rose {rose:.2f} blocks while it held jump" + result['rose'] = round(rose, 2) + hold(player, 'shift', 10) + player.wait(10) + riding = player('status').get('riding') + assert riding is None, f'sneaking off the {kind}: the {label} still rides {riding}' + return result + finally: + player('command', command=f'kill @e[type=minecraft:{kind},x={x},y={y},z={z},distance=..48]') + player('command', command=f'tp @s {x + 0.5} {y} {z + 0.5} 0 0') + player.wait(5) + + +def check_riding(host, guest, out): + """The host (single player, on its server thread or not) and the guest each saddle and ride a + horse (walk and jump), a pig and a strider (with their sticks), a camel and a donkey, sit on a + llama, and harness and fly a happy ghast; they get off by sneaking.""" + spots = apart(host, guest) + result = {} + for label, player, other in (('host', host, guest), ('guest', guest, host)): + x, y, z = spots[label] + player('command', command='gamemode survival') + player('command', command=f'fill {x - 3} {y - 1} {z - 3} {x + 4} {y - 1} {z + 40} minecraft:stone') + player('command', command=f'fill {x - 3} {y} {z - 3} {x + 4} {y + 12} {z + 40} minecraft:air') + player.wait(10) + result[label] = {} + # LAN_E2E_RIDES=pig,horse picks some of them. + only = [k for k in os.environ.get('LAN_E2E_RIDES', '').split(',') if k] + for kind, nbt, ready, stick, test in (r for r in RIDES if not only or r[0] in only): + result[label][kind] = ride(player, other, label, (x, y, z), kind, nbt, ready, stick, test) + player('command', command='item replace entity @s weapon.mainhand with minecraft:air') + return result + + def check_lightning(host, guest, out): """A bolt summoned beside each player: both sides get the bolt entity and flash the sky (the host's window too on its server thread, FEATURES 4z(f)).""" @@ -2848,7 +2977,7 @@ CHECK_FNS = {'tab': check_tab, 'self': check_self, 'armour': check_armour, 'name 'xp': check_xp, 'objects': check_objects, 'projectiles': check_projectiles, 'blast': check_blast, 'light': check_light, 'plates': check_plates, 'swings': check_swings, 'cracks': check_cracks, - 'time': check_time, 'growth': check_growth, 'flight': check_flight, 'fireball': check_fireball, 'deflect': check_deflect, 'barter': check_barter, 'worn': check_worn, 'kills': check_kills, 'arrows': check_arrows, 'predict': check_predict, 'ladder': check_ladder, 'boats': check_boats, 'minecarts': check_minecarts, 'frames': check_frames, 'lightning': check_lightning} + 'time': check_time, 'growth': check_growth, 'flight': check_flight, 'fireball': check_fireball, 'deflect': check_deflect, 'barter': check_barter, 'worn': check_worn, 'kills': check_kills, 'arrows': check_arrows, 'predict': check_predict, 'ladder': check_ladder, 'boats': check_boats, 'minecarts': check_minecarts, 'frames': check_frames, 'lightning': check_lightning, 'riding': check_riding} def run(ctl, out, resources, checks): diff --git a/tools/launcher_mcp_e2e.py b/tools/launcher_mcp_e2e.py index 8dd3dc1bc..955d141d4 100644 --- a/tools/launcher_mcp_e2e.py +++ b/tools/launcher_mcp_e2e.py @@ -116,7 +116,7 @@ def main(): os.symlink(resources, version / '.local/horizon-client' / lab.VERSION) (version / '.installed').write_text('') env = dict(os.environ, HORIZON_LAUNCHER_HOME=str(work / 'launcher'), HORIZON_HOME=str(work / 'home'), - HORIZON_NO_AUDIO='1') + HORIZON_NO_AUDIO='1', HORIZON_TELEMETRY_URL='off') m = Mcp(Path(args.launcher).resolve(), env) try: summary = scenario(m, out) diff --git a/tools/perf_bench.py b/tools/perf_bench.py index eb6b3fda2..c60533aa8 100644 --- a/tools/perf_bench.py +++ b/tools/perf_bench.py @@ -364,7 +364,8 @@ def run_horizon(args, distance): command.append("--offscreen") for carry in dev_mods(args): command += ["--dev-mod", str(carry)] - env = dict(os.environ, HORIZON_NO_AUDIO="1") + # Benchmark runs stay out of the live count and send nothing (docs/telemetry.md). + env = dict(os.environ, HORIZON_NO_AUDIO="1", HORIZON_TELEMETRY_URL="off") if args.warm: # A first start to the title screen builds what later starts reuse (the content-mod # root, the block behaviour snapshot). It is not measured: players see it once. diff --git a/website/Caddyfile b/website/Caddyfile index 1ae4639f5..1571566ad 100644 --- a/website/Caddyfile +++ b/website/Caddyfile @@ -20,7 +20,7 @@ Referrer-Policy strict-origin-when-cross-origin X-Frame-Options DENY Permissions-Policy "interest-cohort=(), browsing-topics=(), camera=(), microphone=(), geolocation=()" - Content-Security-Policy "default-src 'self'; script-src 'self' {$CSP_SCRIPT}; style-src 'self' {$CSP_STYLE}; img-src 'self' data: https://avatars.githubusercontent.com; font-src 'self'; connect-src 'self' https://api.github.com https://raw.githubusercontent.com; frame-ancestors 'none'; base-uri 'self'; form-action 'self'" + Content-Security-Policy "default-src 'self'; script-src 'self' {$CSP_SCRIPT}; style-src 'self' {$CSP_STYLE}; img-src 'self' data: https://avatars.githubusercontent.com; font-src 'self'; connect-src 'self' https://api.github.com https://raw.githubusercontent.com https://telemetry.playhorizon.dev; frame-ancestors 'none'; base-uri 'self'; form-action 'self'" -Server } @assets path /assets/* @@ -31,9 +31,11 @@ redir /server /docs/hosting permanent redir /server.html /docs/hosting permanent rewrite /privacy /privacy.html + rewrite /releases /releases.html + rewrite /benchmarks /benchmarks.html @doc path_regexp doc ^/docs/([a-z-]+)$ rewrite @doc /docs/{re.doc.1}.html - @pages path / /index.html /404.html /privacy.html /docs /docs/* /sitemap.xml + @pages path / /index.html /404.html /privacy.html /releases /releases.html /benchmarks /benchmarks.html /benchmarks.json /docs /docs/* /sitemap.xml header @pages Cache-Control "no-cache" @legal path /LEGAL.md /fonts/*.txt header @legal Content-Type "text/plain; charset=utf-8" diff --git a/website/LEGAL.md b/website/LEGAL.md index da0a31f28..5a2ea9f15 100644 --- a/website/LEGAL.md +++ b/website/LEGAL.md @@ -21,6 +21,7 @@ cookies. The only requests to other hosts are the browser's calls to `api.github | File | Source | Licence | | --- | --- | --- | | `public/fonts/Geist-Regular.woff2`, `Geist-Medium.woff2`, `Geist-SemiBold.woff2`, `GeistMono-Regular.woff2` | Geist and Geist Mono, from `crates/horizon-theme/fonts` (converted from TTF to WOFF2) | SIL Open Font License 1.1, shipped as `public/fonts/OFL-Geist.txt` | +| `public/fonts/PixelifySans-Medium.woff2`, `PixelifySans-SemiBold.woff2`, `PixelifySans-Bold.woff2` | Pixelify Sans by The Pixelify Sans Project Authors (github.com/eifetx/Pixelify-Sans), from `crates/horizon-theme/fonts` (converted from TTF to WOFF2) | SIL Open Font License 1.1, shipped as `public/fonts/OFL-PixelifySans.txt` | The fonts are self-hosted; nothing is fetched from a font service. @@ -34,11 +35,16 @@ The fonts are self-hosted; nothing is fetched from a font service. No Minecraft logo or wordmark appears anywhere on the site, in images or as text styling. GitHub and Discord appear only as plain text links, without their logos. -## No hero image +## The pixel art -The page opens on type, not a photograph. The launcher's old background -(`launcher/assets/background.jpg`, from backgrounds.supply, licence never confirmed) is gone from -the repository, so the launcher's screenshots no longer show it. +| Files in `public/media/` | Source | Licence | +| --- | --- | --- | +| `stone-light.png`, `stone-dark.png` | The page's stone texture, drawn in code by `scripts/art.mjs` from the page colours of `crates/horizon-theme` | MIT, Horizon's original work | +| `scene-light.png`, `scene-dark.png` | The hero's landscape (a dawn and a sunset with Horizon's sliced sun), drawn in code by `scripts/art.mjs`, the same drawing as the launcher's Home banner (`launcher/src/art.rs`) | MIT, Horizon's original work | + +No Minecraft texture is used: the stone is not Minecraft's stone, only shades of the page colour. +The launcher's old background (`launcher/assets/background.jpg`, from backgrounds.supply, licence +never confirmed) is gone from the repository, so the launcher's screenshots no longer show it. ## Screenshots diff --git a/website/README.md b/website/README.md index b5a3ac51d..8ac6e3910 100644 --- a/website/README.md +++ b/website/README.md @@ -2,12 +2,12 @@ Live at **https://playhorizon.dev**. -A landing page and a documentation section in Horizon's design language (`docs/design-system.md`), with the tokens of +A landing page, a Releases page, a Benchmarks page and a documentation section in Horizon's design language (`docs/design-system.md`), with the tokens of `crates/horizon-theme` (generated into `src/tokens.css` by `cargo run -p xtask -- tokens`): -Geist and Geist Mono, cool neutrals in a light and a dark appearance (the system's, or the -toggle's) and one violet accent, numbered index lists with one-pixel rules, and short, eased -motion. A headline and the download, then a scroll through what it is, the screenshots, the parity grid, the launcher, the patch -notes, the community links and the contributors. Plain HTML, CSS and JavaScript; no framework and +the Blocks look: Pixelify Sans headings over Geist text, Horizon's purple in a light and a dark +appearance (the system's, or the toggle's), square panels with an outline, a bevel and a lip, a +stone texture and a pixel landscape drawn in code (`scripts/art.mjs`), and short, eased motion. A headline and the download, then a scroll through what it is, the screenshots, the parity grid, the launcher, the newest +releases, the community links and the contributors. Plain HTML, CSS and JavaScript; no framework and no runtime dependencies. ## Layout @@ -20,15 +20,26 @@ serve.mjs a tiny static server for local checks src/index.html the page, with {{placeholders}} build.mjs fills src/404.html the not-found page src/privacy.html what the launcher can send when players allow it, retention, deletion (/privacy) +src/releases.html every release, newest first, with what it adds and fixes, its notes and downloads (/releases) +src/benchmarks.html Horizon against vanilla 26.3 on our machines, the hardware picker, players' results (/benchmarks) src/docs.html the template of every documentation page (/docs/...), with its left navigation src/tokens.css the design tokens, generated from crates/horizon-theme (do not edit) src/style.css every style, on top of the tokens -src/main.js download buttons, patch notes, links, contributors, nav and menu, tabs, lightbox, motion +src/main.js the home page: download buttons, recent releases, links, contributors, nav, tabs, lightbox, motion +src/chrome.js the light/dark switch, the phone menu and GitHub fetching, shared by the pages +src/releases-page.js the Releases page: the channel filter and the refresh from GitHub +src/benchmarks-page.js the Benchmarks page: players' results from the telemetry server, the picker +src/bench.js the Benchmarks tables, shared by build and page +src/hardware.js the spec table estimates use (GPU TFLOPS and bandwidth, CPU single-thread score) +src/estimate.js estimates for unmeasured hardware from the nearest measured machine src/markdown.js a small Markdown renderer (escapes everything), shared by build and page -src/releases.js the patch notes' markup, shared by build and page +src/releases.js the home page's "Recently added" and the Releases page's markup, shared by build and page src/contributors.js the contributors' filtering and markup, shared by build and page -public/ fonts, screenshots, icons, og.png, robots.txt: copied as is (sitemap.xml is written by the build) -scripts/assets.mjs rebuilds public/ from the repo (fonts to WOFF2, images to WebP) +public/ fonts, screenshots, icons, og.png, robots.txt, benchmarks.json: copied as is (sitemap.xml is written by the build) +data/benchmarks/ our raw benchmark reports (tools/perf_bench.py) and fleet.json, the list scripts/benchmarks.mjs reads +scripts/benchmarks.mjs benchmark reports -> public/benchmarks.json (ours, and players' groups of 3+ installs) +scripts/assets.mjs rebuilds public/ from the repo (fonts to WOFF2, images to WebP, the pixel art) +scripts/art.mjs draws the stone tile and the hero's landscape (PNG, one pixel per texel) scripts/shots.mjs Playwright screenshots at every width, and og.png Dockerfile, Caddyfile, railway.json the Railway service LEGAL.md every asset, its source and licence @@ -45,8 +56,9 @@ shots/ (gitignored) full-page screenshots at 360–1920 px, a 1250× the checkout; on Railway, which builds only this folder, from `main` on GitHub. The build fails if the README has no parity table, so a broken README never deploys. - **Fetched by the page**: the releases (the download button picks the newest - `launcher-v*` release's asset for the visitor's OS, and the three latest game releases' - notes are rendered), the contributors (avatars come from `avatars.githubusercontent.com`), + `launcher-v*` release's asset for the visitor's OS, the home page lists the newest game releases, and + the Releases page reloads its list when GitHub has a newer release), players' benchmark results + (`GET https://telemetry.playhorizon.dev/v1/benchmarks/summary`, 3-second timeout), the contributors (avatars come from `avatars.githubusercontent.com`), and `links.json` from `main`. Each falls back to what was built in, and the download button to the releases page. @@ -106,3 +118,18 @@ GitHub's anonymous rate limit is hit. - Parity is worded as the README words it: 100% of what the harnesses compare. - No cookies, analytics, trackers or third-party fonts and scripts. - Motion stops under `prefers-reduced-motion`; nothing hijacks the scroll. + +## Benchmarks + +`public/benchmarks.json` is what the Benchmarks page shows: `{ format: "horizon-benchmark-summary", version: 1, +generated, min_installs, groups }`, one group per GPU, CPU, render distance and game (`horizon`, `vanilla`) with +`medians` (`avg_fps`, `low_1pct_fps`, `p95_ms`, `world_ms`, `chunk_load_ms`, `rss_peak_mb`, `rss_steady_mb`). +Groups `"source": "us"` are our runs (with the machine, date, version and the four scenes); groups `"source": +"players"` come from players' `benchmark` uploads (docs/telemetry.md) and need at least `min_installs` (3) +different installs. The telemetry server's `GET /v1/benchmarks/summary` answers in the same shape; the page asks it +for players' groups and keeps the baked ones when it doesn't answer. The rules are in `scripts/benchmarks.mjs`, with +a fixture set (`scripts/fixtures/benchmarks/`) the server's test shares. + +To publish new measurements: run `tools/perf_bench.py` for Horizon and vanilla on a machine (docs/benchmark.md), copy +the reports into `data/benchmarks/`, list them in `data/benchmarks/fleet.json`, then +`node scripts/benchmarks.mjs --ours data/benchmarks/fleet.json`. diff --git a/website/build.mjs b/website/build.mjs index acb121538..698079dc1 100644 --- a/website/build.mjs +++ b/website/build.mjs @@ -11,7 +11,9 @@ import { createHash } from "node:crypto"; import { join, dirname } from "node:path"; import { fileURLToPath } from "node:url"; import { markdown, inline, section, escape } from "./src/markdown.js"; -import { releasesHtml } from "./src/releases.js"; +import { recentHtml, releasesPageHtml } from "./src/releases.js"; +import { machinesHtml, playersHtml } from "./src/bench.js"; +import { CPUS, GPUS, singleThread } from "./src/hardware.js"; import { isGame, isLauncher, launcherVersion, newestFirst } from "./src/versions.js"; import { contributorsFrom, contributorsHtml } from "./src/contributors.js"; @@ -41,11 +43,18 @@ try { // An optional token (a Railway variable, or `gh auth token` locally) lifts the rate limit. const githubHeaders = { Accept: "application/vnd.github+json", ...(process.env.GITHUB_TOKEN ? { Authorization: `Bearer ${process.env.GITHUB_TOKEN}` } : {}) }; +// Every release (the Releases page lists them all), a page of 100 at a time. let releases = []; try { - const res = await fetch(`https://api.github.com/repos/${REPO}/releases?per_page=100`, { headers: githubHeaders, signal: AbortSignal.timeout(15000) }); - if (res.ok) releases = (await res.json()).filter((r) => !r.draft); - else console.warn(`releases: ${res.status} from GitHub; the page will load them itself`); + let res; + for (let page = 1; page <= 5; page++) { + res = await fetch(`https://api.github.com/repos/${REPO}/releases?per_page=100&page=${page}`, { headers: githubHeaders, signal: AbortSignal.timeout(15000) }); + if (!res.ok) break; + const batch = await res.json(); + releases.push(...batch.filter((r) => !r.draft)); + if (batch.length < 100) break; + } + if (!res.ok) console.warn(`releases: ${res.status} from GitHub; the pages will load them themselves`); // A day of betas can push the stable release out of the newest 100: it is GitHub's "latest" (betas never are). if (res.ok && !releases.some((r) => isGame(r.tag_name) && !r.prerelease)) { const latest = await fetch(`https://api.github.com/repos/${REPO}/releases/latest`, { headers: githubHeaders, signal: AbortSignal.timeout(15000) }); @@ -110,14 +119,21 @@ const parityCells = body const matching = body.filter(([, score]) => Number(score) === 1).length; const parityHeadline = matching === body.length ? "Every subsystem matches vanilla." : `${matching} of ${body.length} subsystems match vanilla.`; -// --- The latest notes ------------------------------------------------- +// --- The releases ---------------------------------------------------------------------- -// Stable releases only: betas become stable 6 hours later (docs/release-flow.md, "Channels"). Newest first by -// tag: every 0.2 tag is newer than the dated ones (src/versions.js). +// Newest first by tag: every 0.2 tag is newer than the dated ones (src/versions.js). Alpha builds are GitHub +// pre-releases, Stable the others (docs/release-flow.md, "Channels"). const byTag = (a, b) => newestFirst(a.tag_name, b.tag_name); -const game = releases.filter((r) => isGame(r.tag_name) && !r.prerelease).sort(byTag).slice(0, 3); +const ours = releases.filter((r) => isGame(r.tag_name) || isLauncher(r.tag_name)).sort(byTag); +const game = ours.filter((r) => isGame(r.tag_name)); const launcher = releases.filter((r) => isLauncher(r.tag_name) && !r.prerelease).sort(byTag)[0]; +// --- The benchmarks ---------------------------------------------------------------------- + +// public/benchmarks.json: our measurements (scripts/benchmarks.mjs from data/benchmarks/fleet.json) and, once the +// telemetry server has some, players' groups. The page shows it baked and asks the server for newer player results. +const benchSummary = JSON.parse(await readFile(join(site, "public", "benchmarks.json"), "utf8")); + // --- The page -------------------------------------------------------------------------- const fingerprint = (text) => createHash("sha256").update(text).digest("hex").slice(0, 10); @@ -152,7 +168,9 @@ await writeFile(join(dist, "favicon.ico"), Buffer.concat([ico, png32])); // The page's modules, fingerprinted; each import of a shared module is rewritten to its name. const names = {}; const rewrite = (code) => code.replace(/"\.\/(\w+\.js)"/g, (all, file) => (names[file] ? `"./${names[file]}"` : all)); -for (const file of ["markdown.js", "releases.js", "contributors.js", "versions.js", "main.js"]) { +// Dependencies before what imports them. +const modules = ["markdown.js", "versions.js", "chrome.js", "hardware.js", "estimate.js", "releases.js", "contributors.js", "bench.js", "main.js", "releases-page.js", "benchmarks-page.js"]; +for (const file of modules) { const code = rewrite(await readFile(join(site, "src", file), "utf8")); names[file] = `${file.replace(".js", "")}.${fingerprint(code)}.js`; await writeFile(join(dist, "assets", names[file]), code); @@ -180,9 +198,53 @@ const baked = { })), }; -const notesHtml = - releasesHtml(game) || - `

The release notes could not be loaded here.

Read them on GitHub`; +const unavailable = `

The release notes could not be loaded here.

Read them on GitHub`; + +// The top bar and the footer of the pages beside the home page (Releases, Benchmarks). +const navLinks = [["/#about", "About"], ["/releases", "Releases"], ["/benchmarks", "Benchmarks"], ["/docs/", "Docs"]]; +const siteNav = (current) => ` + `; +const siteFooter = ` `; + +const fixed = (x, n) => Number(x).toFixed(n); +const specTable = + `` + + GPUS.map((g) => ``).join("") + + `
Graphics cardFP32 TFLOPSBandwidth, GB/s
${escape(g.name)}${fixed(g.tflops, 1)}${g.gbps}
` + + CPUS.map((c) => ``).join("") + + `
ProcessorBoost, GHzGeneration factorSingle-thread score
${escape(c.name)}${fixed(c.ghz, 2)}${fixed(c.ipc, 2)}${fixed(singleThread(c), 2)}
`; +const options = (list, selected) => list.map((x) => `${escape(x.name)}`).join(""); +const playersGroups = benchSummary.groups.filter((g) => g.source === "players"); const values = { CSS: `/assets/${cssName}`, @@ -195,7 +257,21 @@ const values = { PARITY_CELLS: parityCells, PARITY_HEADLINE: parityHeadline, SUBSYSTEMS: String(body.length), - NOTES: notesHtml, + RECENT: recentHtml(game) || unavailable, + SITE_NAV: "", + SITE_FOOTER: siteFooter, + RELEASES_JS: `/assets/${names["releases-page.js"]}`, + RELEASE_LIST: releasesPageHtml(ours) || unavailable, + RELEASE_COUNT: ours.length ? `${ours.length} releases` : "", + NEWEST_TAG: escape(ours[0]?.tag_name || ""), + BENCH_JS: `/assets/${names["benchmarks-page.js"]}`, + MACHINES: machinesHtml(benchSummary), + PLAYERS: playersHtml(benchSummary), + PLAYERS_SOURCE: `${playersGroups.length ? `${playersGroups.length} groups` : "No groups yet"}, as of ${benchSummary.generated.slice(0, 10)}. The page asks the telemetry server for newer ones.`, + GPU_OPTIONS: options(GPUS, "NVIDIA GeForce RTX 4060"), + CPU_OPTIONS: options(CPUS, "AMD Ryzen 5 5600X"), + SPEC_TABLE: specTable, + BENCH_DATA: JSON.stringify(benchSummary).replace(/ { }; }); -const pages = ["index.html", "404.html", "privacy.html"]; +const pages = ["index.html", "404.html", "privacy.html", "releases.html", "benchmarks.html"]; +const currentPath = { "releases.html": "/releases", "benchmarks.html": "/benchmarks" }; for (const page of pages) { let html = await readFile(join(site, "src", page), "utf8"); + const own = { ...values, SITE_NAV: siteNav(currentPath[page]) }; html = html.replace(/\{\{(\w+)\}\}/g, (all, key) => { - if (!(key in values)) throw new Error(`${page}: unknown placeholder ${all}`); - return values[key]; + if (!(key in own)) throw new Error(`${page}: unknown placeholder ${all}`); + return own[key]; }); html = html.replace(/href="\/(favicon\.svg|favicon-32\.png|apple-touch-icon\.png)"/g, (all, icon) => `href="/${icon}?v=${iconVersions[icon]}"`); await writeFile(join(dist, page), html); @@ -306,7 +384,7 @@ const hashes = (re) => [...new Set([...allHtml.matchAll(re)].map((m) => `'sha256 await writeFile(join(dist, ".csp-script"), hashes(/ + + + + +{{SITE_NAV}} +
+
+

BenchmarksHorizon against Java Edition 26.3

+

Same machine, same world, same flight.

+

We run Horizon and vanilla Minecraft: Java Edition 26.3 one after the other on the same computer: a fresh world from the same seed, the same settings, and the same four flights over a village, a forest, the ocean and a mountain. Every figure comes from the same code for both games. Where Java does better, the tables say so.

+ +
+

Measured by us

+

The project's own machines, at render distance 12 (vanilla's default) and 32. VSync off, no frame cap, a 1280x720 window, simulation distance 12, everything else at vanilla's defaults. Each figure is the median over the runs; the frame figures are averaged over the four flights.

+
+{{MACHINES}} +
+
+

Not yet measured against Java: the desktop (RTX 4080, Core i7-13700KF). It is in daily use; the comparison runs on it once it is free. The last figures from it are Horizon alone, from an older build (2026-10-13, offscreen, tools/graphics_bench.py): over the village, 2,409 FPS at render distance 8, 1,041 at 16 and 48 at 32, where that build still stuttered while loading. They are not comparable with the tables above; the picker estimates the RTX 4080 from the measured machines instead.

+
+
+ +
+

Your hardware

+

Pick a graphics card and a processor. If we or at least three players have measured that pair, you see what was measured; otherwise an estimate from the nearest measured machine, as a range.

+
+ + +
Render distance + + +
+
+

The picker needs JavaScript; the tables above and the method below work without it.

+
+ +
+

From players

+

Players who allow benchmark uploads in the launcher's data collection settings share the report of horizon-client --benchmark standard. Results are grouped by graphics card, processor and render distance, and a group shows only once at least 3 different installs are in it, so no one can be picked out. Only medians are published: no install ID, date, driver, memory size or screen.

+

{{PLAYERS_SOURCE}}

+
+{{PLAYERS}} +
+
+ +
+

How the estimates work

+
+

An estimate starts from the measured machine closest to the one you picked, then scales its figures with a small table of specifications we wrote ourselves (no benchmark database):

+
    +
  • GPU factor: the geometric mean of the two graphics cards' ratio of FP32 shader throughput (TFLOPS) and of memory bandwidth (GB/s), as their makers state them.
  • +
  • CPU factor: the ratio of the two processors' single-thread scores: top boost clock times a rough factor per chip generation (Zen 4 = 1).
  • +
  • Frame rate: when the measured run split each frame into CPU and GPU time, the slower side is scaled by its factor; otherwise by the geometric mean of both. Whatever the split, the real figure lies between the measured one scaled by the smaller and by the larger factor; we widen that by 15% for the roughness of the table, and show it as the range.
  • +
  • Load times are CPU work (generating, lighting and meshing chunks), scaled by the CPU factor. Memory is not scaled: it follows the world and the settings, not the speed.
  • +
+

Estimates ignore drivers, the graphics API, thermal limits and the operating system, which can matter as much as the chip. Treat them as a rough idea, and run horizon-client --benchmark standard on your own machine for the real figure.

+
+
+ The specification table +
{{SPEC_TABLE}}
+
+
+ +
+

How we measure

+
+

tools/perf_bench.py starts each game from a fresh world (seed 1234, creative), waits until every chunk around the spawn is loaded and drawn, then for each scene teleports, waits for the chunks, holds for 2 seconds and flies a straight 192-block path in 12 seconds. Every frame is recorded. Vanilla runs as players get it (your own client, the official launcher's Java options, Java 25), driven by a small development-only mod that only calls the game's own code; nothing of Minecraft is shipped. The full method and its caveats are in docs/benchmark.md, and every raw report is in the repository.

+

Measure your own computer with horizon-client --benchmark standard --render-distance 12: it writes a report to the benchmarks folder of the game folder.

+
+
+

Not an official Minecraft product. Not approved by or associated with Mojang or Microsoft.

+
+
+{{SITE_FOOTER}} + + + diff --git a/website/src/chrome.js b/website/src/chrome.js new file mode 100644 index 000000000..e70bfb073 --- /dev/null +++ b/website/src/chrome.js @@ -0,0 +1,90 @@ +// What every page with the site's top bar shares: the light and dark switch and the phone menu. +// Used by main.js (the home page) and page.js (Releases, Benchmarks). +const reducedMotion = matchMedia("(prefers-reduced-motion: reduce)").matches; + +// The page follows the system; the toggle picks the other appearance and remembers it. +export function setUpTheme() { + const root = document.documentElement; + const button = document.querySelector(".theme-toggle"); + if (!button) return; + const label = button.querySelector("[data-theme-label]"); + const system = matchMedia("(prefers-color-scheme: dark)"); + const dark = () => (root.dataset.theme ? root.dataset.theme === "dark" : system.matches); + const show = () => (label.textContent = dark() ? "Light" : "Dark"); + button.addEventListener("click", () => { + root.dataset.theme = dark() ? "light" : "dark"; + try { + localStorage.setItem("theme", root.dataset.theme); + } catch {} + show(); + }); + system.addEventListener("change", show); + show(); +} + +// The phone menu: a full-screen sheet; the page behind it is inert while it is open. +export function setUpMenu() { + const bar = document.querySelector(".nav"); + const button = document.querySelector(".menu-button"); + const menu = document.getElementById("menu"); + const main = document.getElementById("main"); + if (!bar || !button || !menu) return; + const label = button.querySelector(".menu-label"); + const items = [...menu.querySelectorAll("nav a")]; + items.forEach((a, i) => a.style.setProperty("transition-delay", `${60 + i * 35}ms`)); + let closing; + const setOpen = (open) => { + clearTimeout(closing); + button.setAttribute("aria-expanded", String(open)); + label.textContent = open ? "Close" : "Menu"; + bar.classList.toggle("is-menu", open); + main.inert = open; + document.body.style.overflow = open ? "hidden" : ""; + if (open) { + menu.hidden = false; + requestAnimationFrame(() => requestAnimationFrame(() => menu.classList.add("is-open"))); + items[0].focus({ preventScroll: true }); + } else { + menu.classList.remove("is-open"); + closing = setTimeout(() => (menu.hidden = true), reducedMotion ? 0 : 320); + } + }; + button.addEventListener("click", () => setOpen(button.getAttribute("aria-expanded") !== "true")); + items.forEach((a) => a.addEventListener("click", () => setOpen(false))); + addEventListener("keydown", (e) => { + if (e.key === "Escape" && button.getAttribute("aria-expanded") === "true") { + setOpen(false); + button.focus(); + } + }); + matchMedia("(min-width: 1120px)").addEventListener("change", (e) => e.matches && setOpen(false)); +} + +// GitHub answers, cached for ten minutes in the tab. +export async function cached(key, load) { + try { + const hit = JSON.parse(sessionStorage.getItem(key) || "null"); + if (hit && Date.now() - hit.at < 10 * 60 * 1000) return hit.value; + } catch {} + const value = await load(); + try { + sessionStorage.setItem(key, JSON.stringify({ at: Date.now(), value })); + } catch {} + return value; +} + +export async function get(url, as = "json") { + const res = await fetch(url, { headers: as === "json" ? { Accept: "application/vnd.github+json" } : {} }); + if (!res.ok) throw new Error(`${res.status}`); + return as === "json" ? res.json() : res.text(); +} + +export const slim = (r) => ({ + tag_name: r.tag_name, + name: r.name, + published_at: r.published_at, + html_url: r.html_url, + prerelease: r.prerelease, + body: r.body || "", + assets: (r.assets || []).map((a) => ({ name: a.name, browser_download_url: a.browser_download_url, size: a.size })), +}); diff --git a/website/src/docs.html b/website/src/docs.html index 746e84fad..67b282f82 100644 --- a/website/src/docs.html +++ b/website/src/docs.html @@ -5,8 +5,8 @@ {{DOC_TITLE}} · Horizon docs - - + + diff --git a/website/src/estimate.js b/website/src/estimate.js new file mode 100644 index 000000000..245ec4094 --- /dev/null +++ b/website/src/estimate.js @@ -0,0 +1,77 @@ +// Estimates for hardware nobody has measured yet, from the nearest measured machine and the spec table +// (src/hardware.js). The method, which the Benchmarks page explains: +// +// - GPU factor: the geometric mean of the two GPUs' FP32 throughput ratio and memory bandwidth ratio. +// - CPU factor: the ratio of the two CPUs' single-thread scores (boost clock x generation factor). +// - Frames: when the measured run split each frame into CPU and GPU time, the slower of the two is scaled by its +// own factor; otherwise the frame rate is scaled by the geometric mean of both factors. Whatever the split, the +// true figure lies between the measured one scaled by the smaller and by the larger factor, widened by 15% for +// the roughness of the table: that is the range shown. +// - World and chunk load times are CPU work (generation, lighting, meshing): scaled by the CPU factor. +// - Memory is not scaled: it depends on the world and settings, not on speed. +import { findCpu, findGpu, singleThread } from "./hardware.js"; + +const MARGIN = 0.15; + +export function factors(fromGpu, fromCpu, toGpu, toCpu) { + const gpu = Math.sqrt((toGpu.tflops / fromGpu.tflops) * (toGpu.gbps / fromGpu.gbps)); + const cpu = singleThread(toCpu) / singleThread(fromCpu); + return { gpu, cpu }; +} + +const distance = (f) => Math.abs(Math.log(f.gpu)) + Math.abs(Math.log(f.cpu)); + +// The rows (benchmarks.json groups) usable as a base: a known GPU and CPU. +function known(rows) { + return rows.map((row) => ({ row, gpu: findGpu(row.gpu), cpu: findCpu(row.cpu) })).filter((r) => r.gpu && r.cpu); +} + +// The measured row for exactly this GPU and CPU, players' first when there are some (more installs), or null. +export function measured(rows, gpu, cpu, rd, game) { + const hits = known(rows).filter((r) => r.gpu === gpu && r.cpu === cpu && r.row.render_distance === rd && r.row.game === game); + hits.sort((a, b) => (b.row.installs || 0) - (a.row.installs || 0)); + return hits.map((r) => r.row); +} + +// The nearest measured machine for a target GPU and CPU, for one game and render distance. +export function nearest(rows, gpu, cpu, rd, game) { + let best = null; + for (const r of known(rows)) { + if (r.row.render_distance !== rd || r.row.game !== game) continue; + const f = factors(r.gpu, r.cpu, gpu, cpu); + const d = distance(f); + if (!best || d < best.d) best = { ...r, f, d }; + } + return best; +} + +export function estimate(rows, gpu, cpu, rd, game) { + const base = nearest(rows, gpu, cpu, rd, game); + if (!base) return null; + const m = base.row.medians; + const { gpu: g, cpu: c } = base.f; + const lo = Math.min(g, c) * (1 - MARGIN); + const hi = Math.max(g, c) * (1 + MARGIN); + let scale = Math.sqrt(g * c); + if (m.cpu_p50_ms && m.gpu_p50_ms) { + const worst = Math.max(m.cpu_p50_ms, m.gpu_p50_ms); + scale = worst / Math.max(m.cpu_p50_ms / c, m.gpu_p50_ms / g); + } + scale = Math.min(hi, Math.max(lo, scale)); + const fps = (x) => (x == null ? null : { value: x * scale, low: x * lo, high: x * hi }); + // A base held to its display's refresh rate gives only a floor for the average. + const avg = fps(m.avg_fps); + if (avg && base.row.capped_fps && m.avg_fps >= base.row.capped_fps * 0.97) Object.assign(avg, { value: null, high: null, atLeast: true }); + const time = (x, f) => (x == null ? null : { value: x / f, low: x / (f * (1 + MARGIN)), high: x / (f * (1 - MARGIN)) }); + return { + base: base.row, + factors: base.f, + avg_fps: avg, + low_1pct_fps: fps(m.low_1pct_fps), + p95_ms: m.p95_ms == null ? null : { value: m.p95_ms / scale, low: m.p95_ms / hi, high: m.p95_ms / lo }, + world_ms: time(m.world_ms, c), + chunk_load_ms: time(m.chunk_load_ms, c), + rss_steady_mb: m.rss_steady_mb == null ? null : { value: m.rss_steady_mb }, + rss_peak_mb: m.rss_peak_mb == null ? null : { value: m.rss_peak_mb }, + }; +} diff --git a/website/src/estimate.test.mjs b/website/src/estimate.test.mjs new file mode 100644 index 000000000..3666b7fa1 --- /dev/null +++ b/website/src/estimate.test.mjs @@ -0,0 +1,64 @@ +// node --test website/src/ (npm test in website/) +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { estimate, factors, measured, nearest } from "./estimate.js"; +import { CPUS, GPUS, findCpu, findGpu } from "./hardware.js"; + +const row = (gpu, cpu, medians, extra = {}) => ({ gpu, cpu, render_distance: 12, game: "horizon", source: "us", medians, ...extra }); +const mac = row("Apple M4 Pro", "Apple M4 Pro", { avg_fps: 500, low_1pct_fps: 100, p95_ms: 3, world_ms: 4000, chunk_load_ms: 1000, rss_peak_mb: 1500, rss_steady_mb: 1200 }); +const laptop = row("Mesa Intel HD Graphics 620 (KBL GT2)", "Intel Core i7-7500U CPU @ 2.70GHz", { avg_fps: 100, low_1pct_fps: 20, p95_ms: 15, world_ms: 12000, chunk_load_ms: 5000, rss_peak_mb: 1400, rss_steady_mb: 1100, cpu_p50_ms: 4, gpu_p50_ms: 9 }); + +test("every reported name of our machines is in the table", () => { + assert.equal(findGpu("Apple M4 Pro").name, "Apple M4 Pro (20-core GPU)"); + assert.equal(findGpu("Mesa Intel HD Graphics 620 (KBL GT2)").name, "Intel HD Graphics 620"); + assert.equal(findGpu("NVIDIA GeForce RTX 4080").name, "NVIDIA GeForce RTX 4080"); + assert.equal(findGpu("NVIDIA GeForce RTX 4080 SUPER"), null); + assert.equal(findCpu("13th Gen Intel Core i7-13700KF").name, "Intel Core i7-13700K / KF"); + assert.equal(findCpu("Intel Core i7-7500U CPU @ 2.70GHz").name, "Intel Core i7-7500U"); + for (const g of GPUS) assert.equal(findGpu(g.name), g, g.name); + for (const c of CPUS) assert.equal(findCpu(c.name), c, c.name); +}); + +test("an exact match is a measurement, not an estimate", () => { + assert.deepEqual(measured([mac, laptop], findGpu("Apple M4 Pro"), findCpu("Apple M4 Pro"), 12, "horizon"), [mac]); + assert.deepEqual(measured([mac], findGpu("Apple M4 Pro"), findCpu("Apple M4 Pro"), 32, "horizon"), []); +}); + +test("the nearest machine is the base, and the range holds the estimate", () => { + const gpu = findGpu("Intel Iris Xe Graphics (96 EU)"); + const cpu = findCpu("Intel Core i5-1135G7"); + assert.equal(nearest([mac, laptop], gpu, cpu, 12, "horizon").row, laptop); + const e = estimate([mac, laptop], gpu, cpu, 12, "horizon"); + const f = factors(findGpu(laptop.gpu), findCpu(laptop.cpu), gpu, cpu); + assert.ok(f.gpu > 1 && f.cpu > 1); + for (const key of ["avg_fps", "low_1pct_fps", "p95_ms", "world_ms", "chunk_load_ms"]) { + const { value, low, high } = e[key]; + assert.ok(low <= value && value <= high, key); + } + // GPU-bound frames (9 ms GPU, 4 ms CPU) follow the GPU factor. + assert.ok(Math.abs(e.avg_fps.value - 100 * Math.min(f.gpu, 9 / (4 / f.cpu))) < 1e-9); + assert.ok(Math.abs(e.world_ms.value - 12000 / f.cpu) < 1e-9); + assert.equal(e.rss_steady_mb.value, 1100); +}); + +test("no base, no estimate", () => { + assert.equal(estimate([mac], findGpu("Apple M4"), findCpu("Apple M4"), 32, "horizon"), null); + assert.equal(estimate([mac], findGpu("Apple M4"), findCpu("Apple M4"), 12, "vanilla"), null); +}); + +test("a base held to its display's refresh rate gives only a floor for the average", () => { + const held = { ...mac, capped_fps: 144, medians: { ...mac.medians, avg_fps: 144 } }; + const e = estimate([held], findGpu("NVIDIA GeForce RTX 4060"), findCpu("AMD Ryzen 5 5600X"), 12, "horizon"); + assert.equal(e.avg_fps.atLeast, true); + assert.equal(e.avg_fps.high, null); + assert.ok(e.avg_fps.low > 0); + // The lows sit under the cap: still a range. + assert.ok(e.low_1pct_fps.high > e.low_1pct_fps.low); +}); + +test("a release title of issue numbers falls back to its notes", async () => { + const { parts } = await import("./releases.js"); + const r = { tag_name: "v2026.10.22.07", name: "Horizon 2026.10.22.07: #1255, mob pushes, fix, #1222", body: "### Fixed\n- Fix #1222: single player runs in the frame again (#1257, fixes #1222)\n- Mob pushes: one list per mob (#1205)\n" }; + assert.equal(parts(r).line, "Single player runs in the frame again and 1 more"); + assert.equal(parts({ ...r, name: "Horizon 2026.10.22.05: Hoppers, mob tick, server tick" }).line, "Hoppers, mob tick, server tick"); +}); diff --git a/website/src/hardware.js b/website/src/hardware.js new file mode 100644 index 000000000..d65c84ae2 --- /dev/null +++ b/website/src/hardware.js @@ -0,0 +1,73 @@ +// The hardware the Benchmarks page can estimate for, from specifications only (our own table, no benchmark +// database): each GPU's FP32 shader throughput in TFLOPS and its memory bandwidth in GB/s as its maker states them, +// and each CPU's single-thread score = its top boost clock (GHz) x our rough per-generation factor (instructions per +// clock, Zen 4 = 1). The factors are round numbers, so estimates are ranges, and the page says so. +// `match` finds a reported name (the GPU and CPU strings in benchmark reports) in this table. + +export const GPUS = [ + { name: "NVIDIA GeForce RTX 4090", tflops: 82.6, gbps: 1008, match: /RTX 4090/i }, + { name: "NVIDIA GeForce RTX 4080", tflops: 48.7, gbps: 717, match: /RTX 4080(?! SUPER)/i }, + { name: "NVIDIA GeForce RTX 4070 Ti", tflops: 40.1, gbps: 504, match: /RTX 4070 Ti/i }, + { name: "NVIDIA GeForce RTX 4070", tflops: 29.1, gbps: 504, match: /RTX 4070(?! Ti)/i }, + { name: "NVIDIA GeForce RTX 4060 Ti", tflops: 22.1, gbps: 288, match: /RTX 4060 Ti/i }, + { name: "NVIDIA GeForce RTX 4060", tflops: 15.1, gbps: 272, match: /RTX 4060(?! Ti)/i }, + { name: "NVIDIA GeForce RTX 3080", tflops: 29.8, gbps: 760, match: /RTX 3080(?! Ti)/i }, + { name: "NVIDIA GeForce RTX 3070", tflops: 20.3, gbps: 448, match: /RTX 3070(?! Ti)/i }, + { name: "NVIDIA GeForce RTX 3060", tflops: 12.7, gbps: 360, match: /RTX 3060(?! Ti)/i }, + { name: "NVIDIA GeForce RTX 3050", tflops: 9.1, gbps: 224, match: /RTX 3050/i }, + { name: "NVIDIA GeForce RTX 2060", tflops: 6.5, gbps: 336, match: /RTX 2060(?! SUPER)/i }, + { name: "NVIDIA GeForce GTX 1660 SUPER", tflops: 5.0, gbps: 336, match: /GTX 1660 SUPER/i }, + { name: "NVIDIA GeForce GTX 1060 6GB", tflops: 4.4, gbps: 192, match: /GTX 1060/i }, + { name: "NVIDIA GeForce GTX 1050 Ti", tflops: 2.1, gbps: 112, match: /GTX 1050 Ti/i }, + { name: "AMD Radeon RX 7900 XTX", tflops: 61.4, gbps: 960, match: /RX 7900 XTX/i }, + { name: "AMD Radeon RX 7800 XT", tflops: 37.3, gbps: 624, match: /RX 7800 XT/i }, + { name: "AMD Radeon RX 7600", tflops: 21.8, gbps: 288, match: /RX 7600(?! XT)/i }, + { name: "AMD Radeon RX 6700 XT", tflops: 13.2, gbps: 384, match: /RX 6700 XT/i }, + { name: "AMD Radeon RX 6600", tflops: 8.9, gbps: 224, match: /RX 6600(?! XT)/i }, + { name: "AMD Radeon RX 580", tflops: 6.2, gbps: 256, match: /RX 580/i }, + { name: "AMD Radeon 780M (integrated)", tflops: 8.6, gbps: 89, match: /780M/i }, + { name: "Steam Deck (AMD Van Gogh)", tflops: 1.6, gbps: 88, match: /VanGogh|Van Gogh|Custom GPU 0405/i }, + { name: "Intel Arc A770", tflops: 19.7, gbps: 560, match: /Arc.*A770/i }, + { name: "Intel Iris Xe Graphics (96 EU)", tflops: 2.1, gbps: 68, match: /Iris\(?R?\)? Xe/i }, + { name: "Intel HD Graphics 620", tflops: 0.4, gbps: 34, match: /\bU?HD Graphics 620\b/i }, + { name: "Apple M1", tflops: 2.6, gbps: 68, match: /^Apple M1$/i }, + { name: "Apple M2", tflops: 3.6, gbps: 100, match: /^Apple M2$/i }, + { name: "Apple M3", tflops: 4.1, gbps: 100, match: /^Apple M3$/i }, + { name: "Apple M4", tflops: 4.3, gbps: 120, match: /^Apple M4$/i }, + { name: "Apple M1 Pro (16-core GPU)", tflops: 5.2, gbps: 200, match: /^Apple M1 Pro$/i }, + { name: "Apple M4 Pro (20-core GPU)", tflops: 8.5, gbps: 273, match: /^Apple M4 Pro$/i }, + { name: "Apple M4 Max (40-core GPU)", tflops: 17.0, gbps: 546, match: /^Apple M4 Max$/i }, +]; + +// ghz: top single-core boost clock; ipc: our per-generation factor (Zen 4 = 1). +export const CPUS = [ + { name: "Intel Core i7-7500U", ghz: 3.5, ipc: 0.62, match: /i7-7500U/i }, + { name: "Intel Core i5-7200U", ghz: 3.1, ipc: 0.62, match: /i5-7200U/i }, + { name: "Intel Core i5-8250U", ghz: 3.4, ipc: 0.62, match: /i5-8250U/i }, + { name: "Intel Core i5-9400F", ghz: 4.1, ipc: 0.62, match: /i5-9400/i }, + { name: "Intel Core i7-9700K", ghz: 4.9, ipc: 0.62, match: /i7-9700K/i }, + { name: "Intel Core i5-10400", ghz: 4.3, ipc: 0.62, match: /i5-10400/i }, + { name: "Intel Core i5-1135G7", ghz: 4.2, ipc: 0.78, match: /i5-1135G7/i }, + { name: "Intel Core i5-12400", ghz: 4.4, ipc: 0.95, match: /i5-12400/i }, + { name: "Intel Core i5-13600K", ghz: 5.1, ipc: 0.95, match: /i5-13600K/i }, + { name: "Intel Core i7-13700K / KF", ghz: 5.4, ipc: 0.95, match: /i7-13700K/i }, + { name: "Intel Core i9-14900K", ghz: 6.0, ipc: 0.95, match: /i9-14900K/i }, + { name: "AMD Ryzen 5 3600", ghz: 4.2, ipc: 0.72, match: /Ryzen 5 3600/i }, + { name: "AMD Ryzen 5 5600X", ghz: 4.6, ipc: 0.88, match: /Ryzen 5 5600X?\b/i }, + { name: "AMD Ryzen 7 5800X3D", ghz: 4.5, ipc: 0.88, match: /5800X3D/i }, + { name: "AMD Ryzen 5 7600X", ghz: 5.3, ipc: 1.0, match: /Ryzen 5 7600/i }, + { name: "AMD Ryzen 7 7800X3D", ghz: 5.0, ipc: 1.0, match: /7800X3D/i }, + { name: "AMD Ryzen 9 7950X", ghz: 5.7, ipc: 1.0, match: /Ryzen 9 7950X(?!3D)/i }, + { name: "AMD Ryzen 7 9700X", ghz: 5.5, ipc: 1.12, match: /Ryzen 7 9700X/i }, + { name: "AMD Ryzen 7 7840U / HS", ghz: 5.1, ipc: 1.0, match: /7840(U|HS)/i }, + { name: "Steam Deck (AMD Zen 2, 4 cores)", ghz: 3.5, ipc: 0.72, match: /AMD Custom APU 0405|Van ?Gogh/i }, + { name: "Apple M1", ghz: 3.2, ipc: 1.25, match: /^Apple M1$/i }, + { name: "Apple M2", ghz: 3.5, ipc: 1.28, match: /^Apple M2$/i }, + { name: "Apple M3", ghz: 4.05, ipc: 1.38, match: /^Apple M3$/i }, + { name: "Apple M4", ghz: 4.4, ipc: 1.5, match: /^Apple M4$/i }, + { name: "Apple M4 Pro", ghz: 4.5, ipc: 1.5, match: /^Apple M4 Pro$/i }, +]; + +export const singleThread = (cpu) => cpu.ghz * cpu.ipc; +export const findGpu = (name) => GPUS.find((g) => g.name === name || g.match.test(name || "")) || null; +export const findCpu = (name) => CPUS.find((c) => c.name === name || c.match.test(name || "")) || null; diff --git a/website/src/index.html b/website/src/index.html index b9ce72cf5..9c7c3ca3e 100644 --- a/website/src/index.html +++ b/website/src/index.html @@ -5,8 +5,8 @@ Horizon: a Rust rewrite for Minecraft: Java Edition 26.3 - - + + @@ -27,6 +27,7 @@ + @@ -42,9 +43,10 @@ In game Parity Launcher - Notes + New Community - Contributors + Releases + Benchmarks Docs + +
  1. 01Matches vanilla{{PERCENT}}
  2. 02Differential harnesses{{HARNESSES}}
  3. 03Drawn by Horizon5 shots
  4. -
  5. 04What changedNotes
  6. +
  7. 04Recently addedReleases
  8. +

Unofficial. Not an official Minecraft product. Not approved by or associated with Mojang or Microsoft.

-
- +
@@ -190,14 +197,15 @@
-
+
-

05Patch notes

-

What changed

+

05Releases

+

Recently added

+

Alpha builds come out many times a day, as changes land; about once a day the tested ones become Stable, the launcher's default. The newest, and what they added:

-
- {{NOTES}} +
+ {{RECENT}}
@@ -230,7 +238,7 @@ diff --git a/website/src/main.js b/website/src/main.js index e61453730..4298cf1fd 100644 --- a/website/src/main.js +++ b/website/src/main.js @@ -1,10 +1,12 @@ // The page's behaviour: the download buttons for this platform, the latest releases, the -// links and contributors, the navigation, the menus' tabs, the lightbox and the motion. +// links and contributors, how many play now, the navigation, the menus' tabs, the lightbox +// and the motion. // Everything degrades to the baked-in content when GitHub can't be reached. import { escape } from "./markdown.js"; -import { releasesHtml } from "./releases.js"; +import { recentHtml } from "./releases.js"; import { contributorsFrom, contributorsHtml } from "./contributors.js"; import { isGame, isLauncher as isLauncherTag, launcherVersion, newestFirst } from "./versions.js"; +import { cached, get, setUpMenu, setUpTheme, slim } from "./chrome.js"; const REPO = "ludovic111/horizon"; const RELEASES_PAGE = `https://github.com/${REPO}/releases?q=launcher&expanded=true`; @@ -13,33 +15,6 @@ const reducedMotion = matchMedia("(prefers-reduced-motion: reduce)").matches; // --- GitHub -------------------------------------------------------------------------- -async function cached(key, load) { - try { - const hit = JSON.parse(sessionStorage.getItem(key) || "null"); - if (hit && Date.now() - hit.at < 10 * 60 * 1000) return hit.value; - } catch {} - const value = await load(); - try { - sessionStorage.setItem(key, JSON.stringify({ at: Date.now(), value })); - } catch {} - return value; -} - -async function get(url, as = "json") { - const res = await fetch(url, { headers: as === "json" ? { Accept: "application/vnd.github+json" } : {} }); - if (!res.ok) throw new Error(`${res.status}`); - return as === "json" ? res.json() : res.text(); -} - -const slim = (r) => ({ - tag_name: r.tag_name, - name: r.name, - published_at: r.published_at, - html_url: r.html_url, - prerelease: r.prerelease, - body: r.body || "", - assets: r.assets.map((a) => ({ name: a.name, browser_download_url: a.browser_download_url, size: a.size })), -}); const isLauncher = (r) => isLauncherTag(r.tag_name) && !r.prerelease; // The newest 100 releases (GitHub's most per page). Game betas come out several times a day, so the stable game @@ -106,11 +81,12 @@ async function setUpDownload() { document.querySelectorAll("[data-download-meta]").forEach((p) => (p.innerHTML = meta)); } -// --- Patch notes and the links from main --------------------------------- +// --- Recently added and the links from main --------------------------------- -async function setUpNotes() { - const list = (await releases).filter((r) => isGame(r.tag_name) && !r.prerelease).sort((a, b) => newestFirst(a.tag_name, b.tag_name)); - if (list.length) document.getElementById("releases").innerHTML = releasesHtml(list.slice(0, 3)); +// "Recently added": the newest game releases, Alpha and Stable. +async function setUpRecent() { + const html = recentHtml((await releases).filter((r) => isGame(r.tag_name))); + if (html) document.getElementById("recent-releases").innerHTML = html; } async function setUpLinks() { @@ -128,6 +104,34 @@ async function setUpLinks() { }); } +// --- Playing now --------------------------------------------------------------------- + +const TELEMETRY = "https://telemetry.playhorizon.dev"; + +// How many play right now, from the games' anonymous "I'm playing" pings (Privacy explains them). The +// server rounds it and makes it again at most every 15 seconds; the row stays hidden while nobody plays +// or the server doesn't answer. +async function setUpLive() { + const row = document.querySelector("[data-live]"); + if (!row) return; + const update = async () => { + try { + const res = await fetch(`${TELEMETRY}/v1/live`, { signal: AbortSignal.timeout(3000) }); + if (!res.ok) throw new Error(String(res.status)); + const { playing } = await res.json(); + if (!Number.isInteger(playing) || playing < 1) throw new Error("nobody"); + row.querySelector("[data-live-count]").textContent = playing.toLocaleString("en"); + row.hidden = false; + // It shows up after the others came in, so it skips their entrance. + row.classList.add("is-visible"); + } catch { + row.hidden = true; + } + }; + await update(); + setInterval(() => document.visibilityState === "visible" && update(), 60_000); +} + // --- Navigation ---------------------------------------------------------------------- function setUpNav() { @@ -151,40 +155,6 @@ function setUpNav() { }; onScroll(update); update(); - - // The phone menu: a full-screen sheet; the page behind it is inert while it is open. - const button = document.querySelector(".menu-button"); - const menu = document.getElementById("menu"); - const main = document.getElementById("main"); - const label = button.querySelector(".menu-label"); - const items = [...menu.querySelectorAll("nav a")]; - items.forEach((a, i) => a.style.setProperty("transition-delay", `${60 + i * 35}ms`)); - let closing; - const setOpen = (open) => { - clearTimeout(closing); - button.setAttribute("aria-expanded", String(open)); - label.textContent = open ? "Close" : "Menu"; - bar.classList.toggle("is-menu", open); - main.inert = open; - document.body.style.overflow = open ? "hidden" : ""; - if (open) { - menu.hidden = false; - requestAnimationFrame(() => requestAnimationFrame(() => menu.classList.add("is-open"))); - items[0].focus({ preventScroll: true }); - } else { - menu.classList.remove("is-open"); - closing = setTimeout(() => (menu.hidden = true), reducedMotion ? 0 : 320); - } - }; - button.addEventListener("click", () => setOpen(button.getAttribute("aria-expanded") !== "true")); - items.forEach((a) => a.addEventListener("click", () => setOpen(false))); - addEventListener("keydown", (e) => { - if (e.key === "Escape" && button.getAttribute("aria-expanded") === "true") { - setOpen(false); - button.focus(); - } - }); - matchMedia("(min-width: 1120px)").addEventListener("change", (e) => e.matches && setOpen(false)); } // One rAF-throttled scroll listener for everything that follows the scroll. @@ -254,27 +224,6 @@ function setUpLightbox() { }); } -// --- Light and dark ------------------------------------------------------------------ - -// The page follows the system; the toggle picks the other appearance and remembers it. -function setUpTheme() { - const root = document.documentElement; - const button = document.querySelector(".theme-toggle"); - const label = button.querySelector("[data-theme-label]"); - const system = matchMedia("(prefers-color-scheme: dark)"); - const dark = () => (root.dataset.theme ? root.dataset.theme === "dark" : system.matches); - const show = () => (label.textContent = dark() ? "Light" : "Dark"); - button.addEventListener("click", () => { - root.dataset.theme = dark() ? "light" : "dark"; - try { - localStorage.setItem("theme", root.dataset.theme); - } catch {} - show(); - }); - system.addEventListener("change", show); - show(); -} - // --- Motion --------------------------------------------------------------------------- function setUpReveal() { @@ -308,9 +257,11 @@ function setUpReveal() { setUpReveal(); setUpTheme(); setUpNav(); +setUpMenu(); setUpTabs(); setUpLightbox(); setUpDownload(); -setUpNotes(); +setUpRecent(); setUpLinks(); setUpContributors(); +setUpLive(); diff --git a/website/src/privacy.html b/website/src/privacy.html index def61dcc9..6b562a4cf 100644 --- a/website/src/privacy.html +++ b/website/src/privacy.html @@ -5,8 +5,8 @@ Privacy · Horizon - - + + @@ -26,25 +26,25 @@
  • Performance statistics, after each play session of a minute or more. These are the frame-time and tick-time percentiles and a 14-bucket histogram (never a recording of each frame), the peak memory, how long the game took to start and to load the world, and the settings that change performance (render and simulation distance, frame limit, VSync, fullscreen, graphics mode).
  • Crash reports, when the game crashes. They hold the error, where it happened in Horizon's code, your graphics adapter and settings. They hold no log, no world, no server and no resource packs.
  • Bug reports that you write and send yourself. The end of the game's log goes with one only if you add it after reading it, and lines of chat are removed first.
  • -
  • Benchmark uploads of the benchmarks you run. These are shown publicly in the community results.
  • +
  • Benchmark uploads of the benchmarks you run. They are shown publicly on the Benchmarks page, only as medians of groups of at least 3 different installs with the same graphics card, processor and render distance; never one by one, and never with your install ID, the day, your OS version, driver, memory or screen.
  • Each one also carries the Horizon version, the day it was made (not the time), and a description of your machine: the operating system and version, the CPU model and thread count, the memory rounded to the gigabyte, and the GPU, its driver and the graphics backend. It also carries a random install ID. The launcher makes that ID the first time you allow something; it says nothing about you and exists only so that your data can be deleted.

    Never sent: your Microsoft or Minecraft account name or UUID, world names, server or LAN addresses, chat, and your user name or home folder in file paths. Before anything is kept, those are replaced with placeholders, along with e-mail and IP addresses. The server does not store the IP address requests come from.

    The launcher shows exactly what would be sent: Settings → Data collection → View what would be sent, or horizon-launcher data show. Every field is listed in docs/telemetry.md.

    The "I'm playing" ping

    -

    The game has an anonymous "I'm playing" ping, so the launcher can show how many people play Horizon right now. It is off today: no server receives it yet, so the game sends nothing. This is what it would hold, so you know before it is ever switched on. It would be sent once a minute while you play, whatever the switches say.

    -

    It would hold: a random number made when the game starts and forgotten when it closes, the Horizon version, your operating system (Linux, macOS or Windows), and whether you have a world open to LAN or to friends. It would not hold: your account, your install ID, world or server names, your hardware or settings, or anything you do in the game. The random number changes every time you start the game, so two of your sessions can't be linked to each other or to you.

    -

    The server would keep the pings in memory only, never on disk, and not with the address they came from (that is used only to stop abuse, as below). A session would count while it pinged in the last two minutes and is then forgotten. What it would show is the number playing now, per version and with a world open, rounded.

    +

    The game sends an anonymous "I'm playing" ping, so the launcher can show how many people play Horizon right now. It is sent once a minute while you play, whatever the switches say.

    +

    It holds: a random number made when the game starts and forgotten when it closes, the Horizon version, your operating system (Linux, macOS or Windows), and whether you have a world open to LAN or to friends. It does not hold: your account, your install ID, world or server names, your hardware or settings, or anything you do in the game. The random number changes every time you start the game, so two of your sessions can't be linked to each other or to you.

    +

    The server keeps the pings in memory only, never on disk, and not with the address they came from (that is used only to stop abuse, as below). A session counts while it pinged in the last two minutes and is then forgotten. What it shows is the number playing now, per version and with a world open, rounded.

    Why

    -

    To find what is slow or crashes on which machines, and fix it. If it is switched on, the ping shows players, and Horizon, how many people play right now. Benchmark uploads also show other players how Horizon runs on hardware like theirs. Nothing is sold, shared for advertising, or used to identify you.

    +

    To find what is slow or crashes on which machines, and fix it. The ping shows players, and Horizon, how many people play right now. Benchmark uploads also show other players how Horizon runs on hardware like theirs. Nothing is sold, shared for advertising, or used to identify you.

    On what basis

    -

    For the switches: your consent (Article 6(1)(a) of the EU's General Data Protection Regulation). It is given kind by kind, recorded on your computer with the version of the question you answered and when, and withdrawn at any time with the same switches. Withdrawing deletes what was waiting to be sent. When what is collected changes, the launcher asks again, and nothing new is sent until you answer. The ping would hold nothing that identifies you; the address it comes from would be used only to limit how often one address may send, kept in memory for an hour at most and never stored.

    +

    For the switches: your consent (Article 6(1)(a) of the EU's General Data Protection Regulation). It is given kind by kind, recorded on your computer with the version of the question you answered and when, and withdrawn at any time with the same switches. Withdrawing deletes what was waiting to be sent. When what is collected changes, the launcher asks again, and nothing new is sent until you answer. The ping holds nothing that identifies you; the address it comes from is used only to limit how often one address may send, kept in memory for an hour at most and never stored.

    Where and how long

    -

    Items wait on your computer (telemetry/ in the game folder) and are sent compressed when the launcher starts or closes, to Horizon's own server at Railway. The server keeps them for 180 days, then deletes them. What stays after that are anonymous totals per day, Horizon version, operating system, GPU maker and render distance (for example "120 sessions on macOS with Apple GPUs at render distance 12"). They hold no install ID, and groups too small to be anonymous are never shown.

    +

    Items wait on your computer (telemetry/ in the game folder) and are sent compressed when the launcher starts or closes, to Horizon's own server, telemetry.playhorizon.dev, hosted by Railway in the European Union (Amsterdam, the Netherlands). The server keeps them for 180 days, then deletes them. What stays after that are anonymous totals per day, Horizon version, operating system, GPU maker and render distance (for example "120 sessions on macOS with Apple GPUs at render distance 12"). They hold no install ID, and groups too small to be anonymous are never shown.

    Deleting your data

    Settings → Data collection → Delete my data, or horizon-launcher data delete. The server deletes everything sent under your install ID, your share of the totals is recomputed, anything waiting on your computer is removed, and you get a new install ID. You can also turn everything off, or delete the telemetry/ folder.

    diff --git a/website/src/releases-page.js b/website/src/releases-page.js new file mode 100644 index 000000000..ace84f63d --- /dev/null +++ b/website/src/releases-page.js @@ -0,0 +1,78 @@ +// The Releases page: the list baked at build time, refreshed from GitHub when a newer release is out, and the +// channel filter. Without JavaScript the baked list reads as it is. +import { releasesPageHtml } from "./releases.js"; +import { isGame, isLauncher, newestFirst } from "./versions.js"; +import { cached, get, setUpMenu, setUpTheme, slim } from "./chrome.js"; + +const REPO = "ludovic111/horizon"; +const list = document.getElementById("release-list"); +const counter = document.querySelector("[data-release-count]"); +const buttons = [...document.querySelectorAll("[data-filter]")]; +let filter = "all"; + +const ours = (r) => !r.draft && (isGame(r.tag_name) || isLauncher(r.tag_name)); + +// Every release, a page of 100 at a time (GitHub's most), up to 500. +async function loadAll() { + const all = []; + for (let page = 1; page <= 5; page++) { + const batch = await get(`https://api.github.com/repos/${REPO}/releases?per_page=100&page=${page}`); + all.push(...batch.filter(ours).map(slim)); + if (batch.length < 100) break; + } + return all; +} + +function apply() { + const entries = [...list.querySelectorAll(".release-entry")]; + let shown = 0; + for (const el of entries) { + const on = filter === "all" || el.dataset.channel === filter; + el.hidden = !on; + if (on) shown++; + } + counter.textContent = `${shown} release${shown === 1 ? "" : "s"}`; + buttons.forEach((b) => b.setAttribute("aria-pressed", String(b.dataset.filter === filter))); +} + +async function refresh() { + // One small request first: the full list only when GitHub has something newer than the page. + const newest = await cached("horizon:releases-newest", () => get(`https://api.github.com/repos/${REPO}/releases?per_page=5`)).catch(() => null); + if (!newest) return; + const top = newest.filter(ours).map((r) => r.tag_name).sort(newestFirst)[0]; + if (!top || top === list.dataset.newest) return; + const all = await cached("horizon:releases-all", loadAll).catch(() => null); + if (!all || !all.length) return; + const open = new Set([...list.querySelectorAll(".release-entry[open]")].map((el) => el.id)); + list.innerHTML = releasesPageHtml(all); + list.dataset.newest = top; + // Keep what the reader opened open. + open.forEach((id) => document.getElementById(id)?.setAttribute("open", "")); + apply(); +} + +// A link to one release (/releases#release-v0.2.1) opens it. +function openTarget() { + const el = location.hash && document.getElementById(location.hash.slice(1)); + if (el && el.classList.contains("release-entry")) { + if (el.hidden) { + filter = "all"; + apply(); + } + el.open = true; + el.scrollIntoView(); + } +} + +buttons.forEach((b) => + b.addEventListener("click", () => { + filter = b.dataset.filter; + apply(); + }), +); +addEventListener("hashchange", openTarget); +setUpTheme(); +setUpMenu(); +apply(); +openTarget(); +refresh().then(openTarget); diff --git a/website/src/releases.html b/website/src/releases.html new file mode 100644 index 000000000..f0e4b2de4 --- /dev/null +++ b/website/src/releases.html @@ -0,0 +1,50 @@ + + + + + + Releases · Horizon + + + + + + + + + + + + + + + + + + + + + +{{SITE_NAV}} +
    +
    +

    ReleasesEvery version, newest first

    +

    What's new in Horizon

    +

    Each release lists what it adds and fixes, then its full notes and its downloads. Alpha builds come out many times a day as changes land and can break; about once a day the tested ones become Stable, what the launcher installs unless you pick Alpha in its Settings. The launcher has its own releases.

    +
    + + + + +
    +

    {{RELEASE_COUNT}}

    +
    +{{RELEASE_LIST}} +
    +

    The releases on GitHub

    +

    Not an official Minecraft product. Not approved by or associated with Mojang or Microsoft.

    +
    +
    +{{SITE_FOOTER}} + + diff --git a/website/src/releases.js b/website/src/releases.js index 1b7011999..2e6a2e524 100644 --- a/website/src/releases.js +++ b/website/src/releases.js @@ -1,42 +1,152 @@ -// The patch notes: the latest game release in full, the ones before it folded. Shared by -// build.mjs (baked into the page) and main.js (refreshed from GitHub). -import { markdown, escape } from "./markdown.js"; +// The release notes on the site: the home page's "Recently added" block and the Releases page (every release, +// newest first). Shared by build.mjs (baked into the pages) and the pages' scripts (refreshed from GitHub). +// Tags: the game's vX.Y.Z and the launcher's launcher@X.Y.Z from 0.2, vYYYY.MM.DD[.N] and launcher-vX.Y.Z before +// (src/versions.js). Alpha is a game pre-release, Stable a game release (docs/release-flow.md, "Channels"). +import { markdown, inline, escape } from "./markdown.js"; +import { isLauncher, launcherVersion, newestFirst } from "./versions.js"; const REPO = "ludovic111/horizon"; +export const channel = (r) => (isLauncher(r.tag_name) ? "Launcher" : r.prerelease ? "Alpha" : "Stable"); +const anchor = (r) => `release-${r.tag_name.replace(/[^\w.-]/g, "-")}`; + // "Horizon 0.2.3: Cave culling, weather" (before 0.2, "Horizon 2026.10.13: …") reads as the version and its line. -function parts(r) { - const version = r.tag_name.replace(/^v/, ""); - const name = r.name || ""; - const line = name.includes(": ") ? name.slice(name.indexOf(": ") + 2) : name.replace(/^Horizon\s*/, "").replace(version, "").trim(); +export function parts(r) { + const version = launcherVersion(r.tag_name) ?? r.tag_name.replace(/^v/, ""); + const name = (r.name || "").trim(); + let line = name.includes(": ") ? name.slice(name.indexOf(": ") + 2) : name.replace(/^Horizon( launcher)?\s*/i, "").replace(version, "").trim(); + if (junk(line)) line = fromNotes(r.body) || line; return { version, line: line.charAt(0).toUpperCase() + line.slice(1), date: (r.published_at || "").slice(0, 10) }; } -export function releasesHtml(list) { - if (!list.length) return ""; - const [latest, ...older] = list; - const l = parts(latest); - const head = `
    -
    -

    Latest release

    -

    ${escape(l.version)}

    - ${l.line ? `

    ${escape(l.line)}

    ` : ""} - Downloads and full notes -
    -
    ${markdown(latest.body || "")}
    -
    `; - const rest = older +// A title made of issue numbers and "fix" ("#1255, mob pushes, fix, #1222") says nothing. +const junk = (line) => { + const bits = line.split(",").map((b) => b.trim()).filter(Boolean); + return bits.length > 1 && bits.filter((b) => /^(#\d+|fix(es)?|fixed)$/i.test(b)).length * 2 >= bits.length; +}; + +// The first item that isn't a bare "Fix #123:" prefix, as the line: "Mob pushes: one list per mob… and 3 more fixes". +function fromNotes(body) { + const s = sections(body); + const items = [...s.filter((x) => /^new|what's new/i.test(x.title)), ...s.filter((x) => /^fixed/i.test(x.title))].flatMap((x) => x.items).map(plainItem); + const clean = items.map((i) => i.replace(/^(fix|fixes)\s+#\d+:\s*/i, "").replace(/^\w+\([^)]*\):\s*/, "")).filter(Boolean); + if (!clean.length) return ""; + const first = clean[0].replace(/[.]$/, ""); + return clean.length > 1 ? `${first} and ${clean.length - 1} more` : first; +} + +// The notes' "### Heading" sections and their top-level items, in order. +export function sections(body) { + const out = []; + let current = null; + for (const raw of (body || "").replace(/\r\n?/g, "\n").split("\n")) { + const heading = raw.match(/^#{2,3}\s+(.+?)\s*$/); + if (heading) out.push((current = { title: heading[1], items: [] })); + else if (current && /^[-*]\s+/.test(raw)) current.items.push(raw.replace(/^[-*]\s+/, "").trim()); + } + return out; +} + +// An item without its pull request references: "Riptide (#123, fixes #45)" -> "Riptide". +export const plainItem = (item) => item.replace(/\s*\((?:#\d+|fixes #\d+|[^()]*#\d+[^()]*)\)\s*/g, " ").replace(/\s+/g, " ").trim(); + +// The notes' first sentence, for a release with no title line and no sections ("Rebuilt from the latest main."). +const firstLine = (body) => ((body || "").split(/\r?\n/).find((l) => l.trim() && !/^#/.test(l)) || "").trim().replace(/[.:]$/, ""); + +const count = (n, one, many) => `${n} ${n === 1 ? one : many}`; + +// What a release changes, in a line: "12 new, 30 fixed, 2 known issues". +export function overview(r) { + const s = sections(r.body); + const by = (re) => s.filter((x) => re.test(x.title)).reduce((n, x) => n + x.items.length, 0); + const added = by(/^new|what's new/i); + const fixed = by(/^fixed/i); + const known = by(/^known/i); + const bits = []; + if (added) bits.push(count(added, "new feature", "new features")); + if (fixed) bits.push(count(fixed, "fix", "fixes")); + if (known) bits.push(count(known, "known issue", "known issues")); + return { added, fixed, known, text: bits.join(", ") }; +} + +export function highlights(r, n = 3) { + const added = sections(r.body).filter((x) => /^new|what's new/i.test(x.title)).flatMap((x) => x.items); + return added.slice(0, n).map(plainItem); +} + +const byTag = (a, b) => newestFirst(a.tag_name, b.tag_name); +const badge = (r) => `${channel(r)}`; + +// The home page: the newest releases on a line each, and what the newest ones added. +export function recentHtml(list, { rows = 5, picks = 3 } = {}) { + const sorted = [...list].sort(byTag); + const game = sorted.filter((r) => !isLauncher(r.tag_name)); + if (!game.length) return ""; + const lines = game + .slice(0, rows) .map((r) => { - const o = parts(r); - return `
    - ${escape(o.version)}${escape(o.line)} -
    ${markdown(r.body || "")}

    Downloads and full notes on GitHub

    -
    `; + const p = parts(r); + return `
  • ${escape(p.version)}${escape(p.line || overview(r).text || firstLine(r.body) || "Release notes")}${badge(r)}
  • `; }) .join(""); - return `${head} -
    - ${rest ? `

    Earlier releases

    ${rest}` : ""} -

    Every release on GitHub

    -
    `; + // What landed last: the "New" items of the newest releases with the highest pull request numbers (a release's + // notes list everything since the last Stable, oldest first). + const pr = (item) => Math.max(0, ...[...item.matchAll(/#(\d+)/g)].map((m) => Number(m[1]))); + const seen = new Set(); + const picked = game + .slice(0, rows) + .flatMap((r) => sections(r.body).filter((x) => /^new|what's new/i.test(x.title)).flatMap((x) => x.items).map((raw) => ({ raw, item: plainItem(raw), r }))) + .filter(({ item }) => !seen.has(item) && seen.add(item)) + .sort((a, b) => pr(b.raw) - pr(a.raw)) + .slice(0, picks); + const picks_ = picked + .map(({ item, r }) => `
  • ${inline(item)}

    ${escape(parts(r).version)}
  • `) + .join(""); + return `
      ${lines}
    + ${picks_ ? `

    New lately

      ${picks_}
    ` : ""} +

    Every release, with its full notes

    `; } + +const ASSET_LABELS = [ + [/linux-x86_64/, "Linux x86-64"], + [/macos-arm64/, "macOS, Apple Silicon"], + [/macos-x86_64/, "macOS, Intel"], + [/windows-x64/, "Windows x64"], +]; +function assetLabel(name) { + if (/^SHA256SUMS/.test(name)) return name.endsWith(".sig") ? "Checksums signature" : "Checksums"; + const os = ASSET_LABELS.find(([re]) => re.test(name)); + const what = /server/.test(name) ? "Server" : /launcher/.test(name) ? "Launcher" : /smoke-test/.test(name) ? "Smoke test" : "Game"; + return os ? `${what}, ${os[1]}` : name; +} +const size = (bytes) => (bytes >= 1e6 ? `${(bytes / 1e6).toFixed(0)} MB` : bytes >= 1e3 ? `${(bytes / 1e3).toFixed(0)} kB` : `${bytes} B`); + +function releaseHtml(r, open) { + const p = parts(r); + const o = overview(r); + const top = highlights(r, 4); + const downloads = (r.assets || []) + .map((a) => `
  • ${escape(assetLabel(a.name))}${escape(a.name)} · ${size(a.size || 0)}
  • `) + .join(""); + return `
    + ${escape(p.version)}${badge(r)}${escape(p.line)} +
    + ${o.text || top.length ? `
    + ${o.text ? `

    ${escape(o.text)}

    ` : ""} + ${top.length ? `
      ${top.map((t) => `
    • ${inline(t)}
    • `).join("")}
    ` : ""} +
    ` : ""} +
    ${markdown(r.body || "") || "

    No notes for this release.

    "}
    + ${downloads ? `

    Downloads

      ${downloads}
    ` : ""} +

    This release on GitHub

    +
    +
    `; +} + +// The Releases page: every release, newest first; the newest few open. +export function releasesPageHtml(list, { open = 3 } = {}) { + const sorted = [...list].sort(byTag); + if (!sorted.length) return ""; + return sorted.map((r, i) => releaseHtml(r, i < open)).join("\n"); +} + +export const releasesUrl = `https://github.com/${REPO}/releases`; diff --git a/website/src/style.css b/website/src/style.css index 03004464b..9ced17c69 100644 --- a/website/src/style.css +++ b/website/src/style.css @@ -1,8 +1,7 @@ /* Horizon's design language (docs/design-system.md), set as a page. The tokens come from crates/horizon-theme through src/tokens.css, which build.mjs puts before this file: the - same palette, type, spacing and motion as the launcher and the game's menus. Type is the - interface; content is numbered index lists with one-pixel rules; one violet accent for the - main action, links and focus; space instead of borders; quiet motion. */ + launcher's Blocks palettes, type, spacing and motion. The base below lays out the page; the + "Blocks" section at the end gives it the launcher's blocky, Minecraft-like look. */ @font-face { font-family: "Geist"; src: url("/fonts/Geist-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; } @font-face { font-family: "Geist"; src: url("/fonts/Geist-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; } @@ -301,12 +300,7 @@ figcaption span { font-family: var(--mono); font-size: var(--text-micro); letter .screen-caption { margin-top: 12px; font-size: var(--text-caption); color: var(--muted); } /* Patch notes. */ -.release-latest { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 48px; padding-top: 32px; border-top: 1px solid var(--rule); } -.release-head { position: sticky; top: calc(var(--nav) + 24px); align-self: start; display: flex; flex-direction: column; gap: 12px; } .eyebrow { text-transform: uppercase; } -.release-version { font-size: var(--text-display); line-height: var(--text-display-line); letter-spacing: var(--text-display-tracking); font-weight: 500; } -.release-line { color: var(--muted); max-width: 36ch; } -.release-body { font-size: var(--text-ui); } .prose h2, .prose h3, .prose h4 { font-size: var(--text-heading); line-height: var(--text-heading-line); color: var(--ink); margin-top: 28px; } .prose ul, .prose ol { padding-left: 18px; list-style: disc; } .prose li + li { margin-top: 6px; } @@ -314,8 +308,6 @@ figcaption span { font-family: var(--mono); font-size: var(--text-micro); letter .prose strong { color: var(--ink); font-weight: 500; } .prose pre { padding: 16px; border-radius: var(--radius-plate); background: var(--plate-soft); overflow-x: auto; } .prose pre code { background: none; padding: 0; } -.release-older { margin-top: 64px; } -.release-older-title { font: var(--text-micro) / var(--text-micro-line) var(--mono); letter-spacing: var(--text-micro-tracking); color: var(--muted); text-transform: uppercase; margin-bottom: 12px; } .release { border-top: 1px solid var(--rule); } .release:last-of-type { border-bottom: 1px solid var(--rule); } .release summary { @@ -405,9 +397,9 @@ figcaption span { font-family: var(--mono); font-size: var(--text-micro); letter /* --- Narrow screens ------------------------------------------------------------------------ */ @media (max-width: 900px) { - .section-head, .parity-hero, .launcher-grid, .release-latest { grid-template-columns: minmax(0, 1fr); } + .section-head, .parity-hero, .launcher-grid { grid-template-columns: minmax(0, 1fr); } .section-head { gap: 16px; } - .screens, .release-head { position: static; } + .screens { position: static; } .fact { grid-template-columns: var(--index) minmax(0, 1fr); row-gap: 6px; } .fact p { grid-column: 2; } .mosaic { grid-template-columns: minmax(0, 1fr); } @@ -499,3 +491,253 @@ figcaption span { font-family: var(--mono); font-size: var(--text-micro); letter @media (pointer: coarse) { .docs-nav li a, .docs-toc a, .docs-bar-title, .docs-bar-link { display: flex; align-items: center; min-height: 44px; } } + +/* --- Blocks: the launcher's look on the page (docs/design-system.md, "Blocks") ------------- + Pixel type for headings and controls, square panels with a dark outline, a light bevel on top + and a darker lip below, the violet face for the main action, sunk wells, a stone texture + behind the page and Horizon's pixel landscape behind the hero. The art is drawn in code + (scripts/art.mjs, like launcher/src/art.rs); nothing in it comes from Minecraft. */ + +@font-face { font-family: "Pixelify Sans"; src: url("/fonts/PixelifySans-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; } +@font-face { font-family: "Pixelify Sans"; src: url("/fonts/PixelifySans-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; } +@font-face { font-family: "Pixelify Sans"; src: url("/fonts/PixelifySans-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; } + +:root { + --stone: url("/media/stone-light.png"); + --scene: url("/media/scene-light.png"); + --sky: #8d7fd8; + --panel-edges: inset 0 var(--block-bevel) 0 var(--bevel), inset 0 calc(-1 * var(--block-bevel)) 0 var(--lip); + --radius: 0px; --radius-plate: 0px; --radius-pill: 0px; +} +:root[data-theme="dark"] { --stone: url("/media/stone-dark.png"); --scene: url("/media/scene-dark.png"); --sky: #0a0f2c; } +@media (prefers-color-scheme: dark) { + :root:not([data-theme="light"]) { --stone: url("/media/stone-dark.png"); --scene: url("/media/scene-dark.png"); --sky: #0a0f2c; } +} + +/* The stone: 64 texels of the page colour in close shades, each texel 4 px. */ +body { position: relative; isolation: isolate; } +body::before { + content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; + background: var(--stone) 0 0 / 256px 256px repeat; image-rendering: pixelated; +} + +/* Pixel type for what names and what you act on; paragraphs stay in Geist. */ +.display, .title, .statement, .row-name, .card-title, .release-tag, .count, +.fact h3, .features h3, .system h3, .contributors-title, .footer-disclaimer, .footer-word, +.nav-mark, .docs-prose h2, .docs-prose h3, .prose h2, .prose h3, .prose h4, .menu nav a { + font-family: var(--pixel); font-weight: 600; letter-spacing: 0; +} +.display, .count, .footer-word { font-weight: 700; } +.nav-mark { font-size: 18px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; } +code { border-radius: 0; background: var(--well); box-shadow: 0 0 0 1px var(--outline); } + +/* Buttons: blocks with an outline, a bevel and a lip; they sink a pixel when pressed. */ +.button { + border: var(--block-outline) solid var(--outline); border-radius: 0; + font: 500 var(--text-ui) / 1 var(--pixel); + box-shadow: inset 0 var(--block-bevel) 0 var(--button-bevel), inset 0 calc(-1 * var(--block-lip)) 0 var(--lip); + padding-bottom: 2px; +} +.button.large { font-size: 18px; } +.button.primary { background: var(--face); color: var(--on-face); box-shadow: inset 0 var(--block-bevel) 0 var(--face-bevel), inset 0 calc(-1 * var(--block-lip)) 0 var(--face-lip); } +.button.primary:hover { opacity: 1; filter: brightness(1.08); } +.button.secondary { background: var(--button); } +.button.secondary:hover { background: var(--button); filter: brightness(1.06); } +.button.ghost { border-color: transparent; box-shadow: none; } +.button:active { opacity: 1; transform: translateY(1px); box-shadow: inset 0 var(--block-bevel) 0 var(--lip); } +:focus-visible { border-radius: 0; } + +/* The top bar: the sidebar colour with an outline under it, tabs with an accent underline. */ +.nav.is-scrolled, .nav.is-menu { background: var(--side); -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: 0 var(--block-outline) 0 var(--outline); } +.nav-links a, .nav-github, .theme-toggle { border-radius: 0; font-family: var(--pixel); font-weight: 500; font-size: 15px; } +.nav-links a:hover, .nav-github:hover, .theme-toggle:hover { background: var(--raised); } +.nav-links a[aria-current] { background: var(--raised); box-shadow: inset 0 -3px 0 var(--accent); } +.theme-toggle { text-transform: none; letter-spacing: 0; } +.menu { background: var(--side); } +.menu nav a { border-bottom: 0; } + +/* Lists become stacks of panels. */ +.index, .systems, .contributors-list { border-top: 0; display: grid; gap: 8px; } +.row, .system, .release, .release:last-of-type, .contributor { border-bottom: 0; border-top: 0; } +.row > a, .row.card, .fact.row, .features li, .system, .release, .contributor, .docs-pager a { + background: var(--panel); border: var(--block-outline) solid var(--outline); box-shadow: var(--panel-edges); + border-radius: 0; +} +.row > a, .row.card, .fact.row, .features li, .system { padding-left: 20px; padding-right: 20px; } +.row > a::before, .row.card::before { display: none; } +.row > a:hover, .row.card:hover, .contributor:hover, .docs-pager a:hover { background: var(--raised); } +.row > a:hover .row-index { color: var(--accent); } +.row-name { font-size: clamp(20px, 2.2vw, 28px); } +.release { padding: 0 20px; } +.release + .release { margin-top: 8px; } +.release .prose { padding-left: 12rem; } +.contributor { padding: 12px 14px; } +.contributors-list { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; } +.contributor-avatar { border-radius: 0; box-shadow: 0 0 0 2px var(--outline); image-rendering: pixelated; } +.system.is-full .system-state { color: var(--success); } + +/* Screenshots and the launcher's screens: square, outlined. */ +.zoom, .screen, .lightbox, .prose pre, .docs-prose figure img { border-radius: 0; box-shadow: 0 0 0 var(--block-outline) var(--outline); } +.tabs { border-radius: 0; background: var(--well); box-shadow: 0 0 0 var(--block-outline) var(--outline); } +.tabs button { border-radius: 0; font-family: var(--pixel); font-weight: 500; font-size: 15px; } +.tabs button[aria-selected="true"] { color: var(--on-face); } +.tab-pill { border-radius: 0; background: var(--face); box-shadow: inset 0 var(--block-bevel) 0 var(--face-bevel), inset 0 calc(-1 * var(--block-bevel)) 0 var(--face-lip); } + +/* The hero: Horizon's landscape under a veil of the page colour, the words on the left. */ +.hero { + position: relative; isolation: isolate; overflow: hidden; + background: var(--scene) 70% 100% / clamp(1200px, 135vw, 2400px) auto no-repeat, var(--sky); image-rendering: pixelated; + border-bottom: var(--block-outline) solid var(--outline); +} +.hero::before { + content: ""; position: absolute; inset: 0; z-index: -1; + background: + linear-gradient(90deg, color-mix(in srgb, var(--page) 92%, transparent) 0%, color-mix(in srgb, var(--page) 78%, transparent) 45%, color-mix(in srgb, var(--page) 0%, transparent) 78%), + linear-gradient(180deg, color-mix(in srgb, var(--page) 0%, transparent) 55%, color-mix(in srgb, var(--page) 70%, transparent) 100%); +} +.hero .kicker span, .hero .kicker { color: var(--ink-soft); } +.hero .lede { color: var(--ink-soft); } +.hero { padding-bottom: clamp(160px, 18vw, 280px); } +.hero-after { padding-top: 40px; } +.hero-after .hero-index { margin-top: 0; max-width: 860px; } +.hero-after .disclaimer { margin-top: 24px; } +@media (max-width: 900px) { + .hero::before { background: color-mix(in srgb, var(--page) 84%, transparent); } +} + +/* Documentation. */ +.docs-bar { background: var(--side); -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: 0 var(--block-outline) 0 var(--outline); } +.docs-nav li a { border-radius: 0; } +.docs-nav li a[aria-current] { background: var(--raised); box-shadow: inset 4px 0 0 var(--accent); } +.docs-toc a { border-radius: 0; background: var(--button); box-shadow: 0 0 0 var(--block-outline) var(--outline); } +.docs-pager a { box-shadow: var(--panel-edges); } +.docs-prose h2 { border-top: var(--block-outline) solid var(--outline); } +.docs-prose blockquote { border-left: 4px solid var(--accent); background: var(--panel); padding: 10px 16px; box-shadow: 0 0 0 var(--block-outline) var(--outline); } + +/* The footer: the giant wordmark in pixels. */ +.footer { background: var(--side); border-top: var(--block-outline) solid var(--outline); margin-top: 48px; } +.footer-word { color: var(--raised); letter-spacing: 0.02em; } +:root[data-theme="dark"] .footer-word { color: var(--panel); } +@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .footer-word { color: var(--panel); } } + +/* --- Releases and Benchmarks pages, and the home page's "Recently added" ------------------ */ + +/* Pixelify Sans' "fi" ligature draws as "A" ("8 Axes"): no common ligatures anywhere. */ +:root { font-variant-ligatures: no-common-ligatures; } + +.page-main { padding-top: calc(var(--nav) + clamp(40px, 6vw, 80px)); } +.page-title { max-width: 18ch; margin-bottom: 20px; } +.page-main > .container > .lede { font-size: var(--text-body); } +.page-main .disclaimer { margin-top: 48px; } + +/* Channel and source badges: small square tags. */ +.badge { + display: inline-flex; align-items: center; height: 22px; padding: 0 8px; margin-right: 10px; vertical-align: 2px; + font: 500 12px / 1 var(--pixel); letter-spacing: 0.02em; text-transform: uppercase; white-space: nowrap; + border: var(--block-outline) solid var(--outline); background: var(--well); color: var(--ink-soft); +} +.badge-stable { background: color-mix(in srgb, var(--success) 22%, var(--panel)); color: var(--ink); } +.badge-alpha { background: color-mix(in srgb, var(--warn) 24%, var(--panel)); color: var(--ink); } +.badge-launcher { background: color-mix(in srgb, var(--accent) 20%, var(--panel)); color: var(--ink); } +.badge-us { background: color-mix(in srgb, var(--accent) 20%, var(--panel)); color: var(--ink); } +.badge-players { background: color-mix(in srgb, var(--success) 22%, var(--panel)); color: var(--ink); } +.badge-estimate { background: color-mix(in srgb, var(--warn) 24%, var(--panel)); color: var(--ink); } + +/* Home: the newest releases on a line each, then what they added. */ +.recent-list .row > a { grid-template-columns: 8.5rem minmax(0, 13rem) minmax(0, 1fr) auto; align-items: baseline; } +.recent-line { color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.recent-list .row-name { font-size: clamp(18px, 1.8vw, 22px); } +.recent-list .badge { margin-right: 0; } +.recent-picks { margin-top: 32px; } +.recent-picks .eyebrow { margin-bottom: 12px; } +.highlights { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; } +.highlight { + display: flex; flex-direction: column; justify-content: space-between; gap: 16px; padding: 18px 20px; + background: var(--panel); border: var(--block-outline) solid var(--outline); box-shadow: var(--panel-edges); +} +.highlight p { color: var(--ink); } +.highlight-from { font: var(--text-micro) / 1 var(--mono); letter-spacing: var(--text-micro-tracking); color: var(--muted); } +.highlight-from:hover { color: var(--accent); } + +/* Releases: a filter, then every release as a panel that opens. */ +.release-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 32px; } +.release-filter .button[aria-pressed="true"] { background: var(--face); color: var(--on-face); box-shadow: inset 0 var(--block-bevel) 0 var(--face-bevel), inset 0 calc(-1 * var(--block-lip)) 0 var(--face-lip); } +.release-count { margin: 16px 0 12px; } +.release-list { display: grid; gap: 8px; } +.release-list .release + .release { margin-top: 0; } +.release-entry summary { grid-template-columns: minmax(0, 11rem) minmax(0, 1fr) auto; } +.release-entry .release-sub { display: flex; align-items: baseline; flex-wrap: wrap; row-gap: 4px; } +.release-detail { padding: 0 0 24px 11rem; margin-left: 16px; display: grid; gap: 20px; max-width: calc(11rem + 16px + var(--measure) + 120px); } +.release-detail .prose { padding: 0; margin: 0; font-size: var(--text-ui); max-width: none; } +.release-overview { padding: 16px 18px; background: var(--well); box-shadow: 0 0 0 var(--block-outline) var(--outline); } +.release-counts { font-family: var(--pixel); font-weight: 600; color: var(--ink); margin-bottom: 8px; } +.release-overview ul { list-style: square; padding-left: 18px; color: var(--ink-soft); font-size: var(--text-ui); } +.release-overview li + li { margin-top: 4px; } +.release-downloads ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; margin-top: 8px; } +.release-downloads li { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--button); box-shadow: 0 0 0 var(--block-outline) var(--outline); } +.release-downloads li a { font-weight: 500; } +.release-downloads li span { font: var(--text-micro) / 1.4 var(--mono); color: var(--muted); overflow-wrap: anywhere; } +.release-github { font-size: var(--text-caption); } +.release-entry:target { box-shadow: var(--panel-edges), 0 0 0 3px var(--accent); } + +/* Benchmarks. */ +.bench-section { margin-top: clamp(64px, 8vw, 112px); } +.bench-section > .title { margin-bottom: 16px; } +.bench-section > .lede { margin-bottom: 32px; } +.machines { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; } +.machine { min-width: 0; padding: 24px; background: var(--panel); border: var(--block-outline) solid var(--outline); box-shadow: var(--panel-edges); } +.machine-head { display: grid; gap: 10px; margin-bottom: 20px; } +.machine-name { font-family: var(--pixel); font-weight: 600; font-size: var(--text-title); line-height: var(--text-title-line); } +.machine-facts { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 0; } +.machine-facts div { display: flex; gap: 8px; min-width: 0; } +.machine-facts dt { font: var(--text-micro) / 1.6 var(--mono); letter-spacing: var(--text-micro-tracking); text-transform: uppercase; color: var(--muted); } +.machine-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-size: var(--text-caption); color: var(--ink-soft); } +.machine-note { font-size: var(--text-caption); color: var(--muted); max-width: 90ch; } +/* relative: the screen-reader-only labels inside are absolute and would escape the scroll box otherwise. */ +.table-wrap { position: relative; overflow-x: auto; } +.bench-table { width: 100%; border-collapse: collapse; font-size: var(--text-ui); } +.bench-table th, .bench-table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--rule); vertical-align: baseline; } +.bench-table thead th { font: var(--text-micro) / 1.4 var(--mono); letter-spacing: var(--text-micro-tracking); text-transform: uppercase; color: var(--muted); font-weight: 400; } +.bench-table thead tr:first-child th { color: var(--ink); } +.bench-table tbody th { font-weight: 500; color: var(--ink); } +.bench-table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; } +.bench-table td.wins { color: var(--ink); font-weight: 600; } +.bench-table td.vs { font-size: var(--text-caption); white-space: nowrap; } +.vs-horizon { color: var(--success); } +.vs-java { color: var(--danger); } +.vs-tie, .vs-none { color: var(--muted); } +.capped { font: var(--text-micro) / 1 var(--mono); color: var(--warn); cursor: help; } +.metric-hint { display: block; font: var(--text-micro) / 1.4 var(--mono); color: var(--muted); font-weight: 400; } +.java-wins { margin-top: 16px; font-size: var(--text-caption); color: var(--ink-soft); } +.picker { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: end; padding: 20px; background: var(--panel); border: var(--block-outline) solid var(--outline); box-shadow: var(--panel-edges); } +.picker label { display: grid; gap: 6px; } +.picker label > span, .picker legend { font: var(--text-micro) / 1.4 var(--mono); letter-spacing: var(--text-micro-tracking); text-transform: uppercase; color: var(--muted); } +.picker select { + min-width: min(320px, 80vw); height: var(--control); padding: 0 10px; font: inherit; font-size: var(--text-ui); color: var(--ink); + background: var(--well); border: var(--block-outline) solid var(--outline); border-radius: 0; +} +.picker-rd { display: flex; gap: 16px; align-items: center; border: 0; padding: 0; margin: 0; } +.picker-rd legend { margin-bottom: 6px; } +.picker-rd label { display: inline-flex; align-items: center; gap: 6px; font-family: var(--pixel); font-weight: 500; height: var(--control); } +.picker-rd input { accent-color: var(--accent); width: 18px; height: 18px; } +.pick-result { margin-top: 16px; padding: 20px; background: var(--panel); border: var(--block-outline) solid var(--outline); box-shadow: var(--panel-edges); } +.pick-head { margin-bottom: 12px; font-size: var(--text-caption); color: var(--ink-soft); line-height: 1.8; } +.pick-result .meta { margin-top: 12px; } +.empty { color: var(--muted); } +.prose-section .prose { max-width: 80ch; } +.spec-table { margin-top: 24px; } +.spec-table summary { cursor: pointer; font-family: var(--pixel); font-weight: 600; } +.spec-table .bench-table { margin-top: 16px; max-width: 760px; } + +@media (max-width: 900px) { + .recent-list .row > a { grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; } + .recent-list .row-index { grid-column: 1; grid-row: 1; } + .recent-list .row-name { grid-column: 1; grid-row: 2; } + .recent-line { grid-column: 1 / -1; grid-row: 3; white-space: normal; } + .recent-list .row-meta { grid-column: 2; grid-row: 1; } + .highlights { grid-template-columns: minmax(0, 1fr); } + .release-entry summary { grid-template-columns: minmax(0, 1fr) auto; } + .release-detail { padding-left: 0; margin-left: 0; } + .machine { padding: 16px; } +} +.older-runs { margin-top: 16px; max-width: 90ch; padding: 16px 20px; background: var(--well); box-shadow: 0 0 0 var(--block-outline) var(--outline); font-size: var(--text-caption); } diff --git a/website/src/tokens.css b/website/src/tokens.css index d272865cc..816ad5b8e 100644 --- a/website/src/tokens.css +++ b/website/src/tokens.css @@ -2,21 +2,39 @@ docs/design-system.md describes the tokens. */ :root { - --page: #fafafc; - --plate-soft: #f3f3f8; - --plate: #ebecf4; - --surface: #ffffff; - --rule: #e2e3ea; - --ink: #16181f; - --ink-soft: #3b3e49; - --muted: #646875; - --accent: #5b3fd6; + --page: #ece7f7; + --plate-soft: #e9e3f8; + --plate: #ddd4f3; + --surface: #f8f6fd; + --rule: #e4ddf4; + --ink: #1b1530; + --ink-soft: #3b3354; + --muted: #585071; + --accent: #5333c9; --on-accent: #ffffff; - --danger: #b4372a; - --success: #1d7a48; + --danger: #a3301d; + --success: #136336; + --warn: #7a4f00; + --side: #e2dbf2; + --panel: #f8f6fd; + --raised: #e9e3f8; + --button: #ddd4f3; + --button-bevel: #f4f0fe; + --well: #f3f0fb; + --bevel: #ffffff; + --lip: #c3b8e2; + --outline: #2b2244; + --face: #5b3fd6; + --face-bevel: #8069ef; + --face-lip: #3a2694; + --on-face: #ffffff; color-scheme: light; --font: "Geist", ui-sans-serif, system-ui, sans-serif; --mono: "Geist Mono", ui-monospace, monospace; + --pixel: "Pixelify Sans", "Geist", ui-sans-serif, sans-serif; + --block-outline: 2px; + --block-bevel: 2px; + --block-lip: 4px; --text-micro: 11px; --text-micro-line: 1.5; --text-micro-tracking: 0.04em; @@ -88,34 +106,62 @@ @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { - --page: #0d0e13; - --plate-soft: #181a22; - --plate: #20222c; - --surface: #16181f; - --rule: #24262f; + --page: #0f0d17; + --plate-soft: #221e34; + --plate: #2b2641; + --surface: #1a1727; + --rule: #120f1c; --ink: #ecedf3; --ink-soft: #c5c7d1; - --muted: #8b8f9c; + --muted: #a29cb8; --accent: #9a86ff; - --on-accent: #0d0e13; + --on-accent: #ffffff; --danger: #f07a68; --success: #45c27a; + --warn: #f0b84f; + --side: #0b0a11; + --panel: #1a1727; + --raised: #221e34; + --button: #2b2641; + --button-bevel: #3d3560; + --well: #0c0b12; + --bevel: #342d52; + --lip: #07060b; + --outline: #05040a; + --face: #5b3fd6; + --face-bevel: #8a74ff; + --face-lip: #3a2694; + --on-face: #ffffff; color-scheme: dark; } } :root[data-theme="dark"] { - --page: #0d0e13; - --plate-soft: #181a22; - --plate: #20222c; - --surface: #16181f; - --rule: #24262f; + --page: #0f0d17; + --plate-soft: #221e34; + --plate: #2b2641; + --surface: #1a1727; + --rule: #120f1c; --ink: #ecedf3; --ink-soft: #c5c7d1; - --muted: #8b8f9c; + --muted: #a29cb8; --accent: #9a86ff; - --on-accent: #0d0e13; + --on-accent: #ffffff; --danger: #f07a68; --success: #45c27a; + --warn: #f0b84f; + --side: #0b0a11; + --panel: #1a1727; + --raised: #221e34; + --button: #2b2641; + --button-bevel: #3d3560; + --well: #0c0b12; + --bevel: #342d52; + --lip: #07060b; + --outline: #05040a; + --face: #5b3fd6; + --face-bevel: #8a74ff; + --face-lip: #3a2694; + --on-face: #ffffff; color-scheme: dark; }