diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30fc1d44..3bcaed40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -100,6 +100,8 @@ jobs: run: cargo xtask licences --check - name: Dependency layers run: cargo xtask layers + - name: Web app offline use and updates (headless Chrome) + run: cargo xtask web-offline-test clippy: name: Native Linux Clippy diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index e67bb549..401b3947 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -50,6 +50,8 @@ jobs: - name: Build the web app working-directory: apps/solidcraft-web run: trunk build --release --public-url /solidcraft/app/ + - name: Test the web app offline and across an update (headless Chrome) + run: cargo xtask web-offline-test --site dist/web - name: Assemble the site run: | mkdir -p site diff --git a/AGENTS.md b/AGENTS.md index 3e2fd37a..bb7f59fe 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -75,7 +75,10 @@ People trust SolidCraft with their designs; a crash loses their work. **This out egui/eframe/winit/wgpu/rfd. **The UI crate is swappable.** Only `crates/kernel` may use `truck`. - **The UI is thin**: panels read engine state and act through `app.run(id, params)` / `app.start(id)`. Colours come from `theme::Tokens`. -- **Rust only.** Units are millimetres and radians internally; Z is up. +- **Rust only.** Units are millimetres and radians internally; Z is up. The one exception is + JavaScript the browser requires: the service worker `apps/solidcraft-web/sw.js` (browsers only + run service workers as JavaScript) and the small inline scripts in `apps/solidcraft-web/index.html`. + Keep them minimal; `cargo xtask web-offline-test` covers the service worker. - **Quality gates** before every commit: `cargo xtask ci` (fmt, clippy -D warnings, tests, assets, layers). Commit after every feature arc that builds. - **Publishing**: `origin` is github.com/bherbruck/solidcraft. Changes land through **pull requests**: diff --git a/CLAUDE.md b/CLAUDE.md index 201b44dc..34609918 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -75,7 +75,10 @@ People trust SolidCraft with their designs; a crash loses their work. **This out egui/eframe/winit/wgpu/rfd. **The UI crate is swappable.** Only `crates/kernel` may use `truck`. - **The UI is thin**: panels read engine state and act through `app.run(id, params)` / `app.start(id)`. Colours come from `theme::Tokens`. -- **Rust only.** Units are millimetres and radians internally; Z is up. +- **Rust only.** Units are millimetres and radians internally; Z is up. The one exception is + JavaScript the browser requires: the service worker `apps/solidcraft-web/sw.js` (browsers only + run service workers as JavaScript) and the small inline scripts in `apps/solidcraft-web/index.html`. + Keep them minimal; `cargo xtask web-offline-test` covers the service worker. - **Quality gates** before every commit: `cargo xtask ci` (fmt, clippy -D warnings, tests, assets, layers). Commit after every feature arc that builds. - **Publishing**: `origin` is github.com/bherbruck/solidcraft. Changes land through **pull requests**: diff --git a/Cargo.lock b/Cargo.lock index 951c0af2..d65bc648 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4865,6 +4865,7 @@ name = "xtask" version = "0.9.0" dependencies = [ "serde_json", + "sha2", ] [[package]] diff --git a/apps/solidcraft-web/Trunk.toml b/apps/solidcraft-web/Trunk.toml index e608607f..226ddf70 100644 --- a/apps/solidcraft-web/Trunk.toml +++ b/apps/solidcraft-web/Trunk.toml @@ -8,3 +8,9 @@ filehash = true [serve] addresses = ["127.0.0.1"] port = 8781 + +# Offline use and updates: release builds get sw.js listing this build's files (xtask/src/web_offline.rs). +[[hooks]] +stage = "post_build" +command = "cargo" +command_arguments = ["xtask", "web-offline"] diff --git a/apps/solidcraft-web/index.html b/apps/solidcraft-web/index.html index b52538c2..4d30fc67 100644 --- a/apps/solidcraft-web/index.html +++ b/apps/solidcraft-web/index.html @@ -32,5 +32,11 @@