diff --git a/crates/snowbound/Cargo.toml b/crates/snowbound/Cargo.toml index 570b3256d76eb3df5eb1a03bd5581ce03c13490f..1555712c1a07eed345c3d4c9a4bf4f917b2eb815 100644 --- a/crates/snowbound/Cargo.toml +++ b/crates/snowbound/Cargo.toml @@ -5,11 +5,11 @@ edition = "2024" publish = false [features] -default = ["wgpu"] +default = ["wgpu", "live"] # Paints through wgpu; without it through OpenGL 2.1, for Mac OS X 10.6. wgpu = ["draw/wgpu", "dep:wgpu"] # Live presence: the others with a notebook open, their pages and carets, met over the -# network (resources/live-share.md). Runs only where SNOWBOUND_LIVE asks. +# network (resources/live-share.md). Built in by default; runs only where SNOWBOUND_LIVE asks. live = ["notebook/live"] [dependencies] diff --git a/crates/snowbound/src/live.rs b/crates/snowbound/src/live.rs index 521a2fb37a14a56d8aca40307d14637642e47ca7..96ff14a75d91bbd24196eaf8b61e2bd8ea0382a9 100644 --- a/crates/snowbound/src/live.rs +++ b/crates/snowbound/src/live.rs @@ -1,5 +1,5 @@ //! Live presence in the window (feature `live`, on where `SNOWBOUND_LIVE` is `network` or -//! `loopback`, or `SNOWBOUND_LIVE_RELAY` names a relay, `wss://live.example.net`): the others +//! `loopback`, through the default relay unless `SNOWBOUND_LIVE_RELAY` names another or `off`): the others //! with the notebook open as avatars beside the search box, a dot on the tab of the page each //! has open, and their carets on the page, each in a colour of their own. They meet through //! the notebook's identity, or through `SNOWBOUND_LIVE_CODE` where it is set; through a relay, @@ -27,6 +27,9 @@ pub(crate) struct Peers { pictures: HashMap<[u8; 16], Option>, } +/// The relay used when `SNOWBOUND_LIVE_RELAY` names none; `off` keeps peers to the LAN. +const DEFAULT_RELAY: &str = "wss://relay.snowbound.paperclover.net"; + fn reach() -> Option { match std::env::var("SNOWBOUND_LIVE").ok()?.as_str() { "network" => Some(Reach::Network), @@ -42,6 +45,11 @@ impl State { if reach.is_none() && relay.is_none() { return; } + let relay = match relay.as_deref() { + Some("off") => None, + Some(_) => relay, + None => Some(DEFAULT_RELAY.to_owned()), + }; let room = match std::env::var("SNOWBOUND_LIVE_CODE") { Ok(code) => Some(Room::Code(code)), Err(_) => self diff --git a/tools/ci.py b/tools/ci.py index e19fcdbe2520313dbd2796631217d74a11e09ac1..3361d6e351882ad812aa96a515b3b01f2b4c3f29 100644 --- a/tools/ci.py +++ b/tools/ci.py @@ -80,7 +80,7 @@ def lanes(): result.append(dict( name='web', minutes=20, packages=['snowbound'], paths=('crates/snowbound/web/', 'tools/release_web.py'), # Clippy builds it; the module itself is linked by release_web.py. - commands=[cargo('clippy', '-p', 'snowbound', '--target', 'wasm32-unknown-unknown', '--', '-D', 'warnings')], + commands=[cargo('clippy', '-p', 'snowbound', '--target', 'wasm32-unknown-unknown', '--no-default-features', '--features', 'wgpu', '--', '-D', 'warnings')], environment={**(wasm or {}), 'CARGO_TARGET_DIR': str(TARGET / 'wasm')}, missing='needs the wasm32-unknown-unknown target' if 'wasm32-unknown-unknown' not in targets.split() else None if wasm else 'needs nix for a clang that builds for wasm32')) diff --git a/tools/release_web.py b/tools/release_web.py index cbfd344d988b1a8713259fb5ba2debfd8a1abe4c..9d2c8ff94ed90f3bfcf453d33776790f32a0d771 100644 --- a/tools/release_web.py +++ b/tools/release_web.py @@ -57,7 +57,7 @@ def environment(): def build(out): """Writes index.html, the module, its JavaScript and the fonts to `out`.""" - run(['cargo', 'build', '--locked', '-p', 'snowbound', '--release', '--target', 'wasm32-unknown-unknown', + run(['cargo', 'build', '--locked', '-p', 'snowbound', '--release', '--target', 'wasm32-unknown-unknown', '--no-default-features', '--features', 'wgpu', *PROFILE], env=environment()) if out.exists(): shutil.rmtree(out)