Make the web app work offline and update itself (#239)

This commit is contained in:
Jan Szumiec authored and GitHub committed 2026-10-13 23:40:19 -04:00
1 parent 09b5da3e9f
commit 4bea4c7785
14 files changed
+1246 -6

No files matched your search

+11 -2
View File
@@ -74,13 +74,22 @@ doesn't update automatically.
The same app runs in the browser: [open SolidCraft on the web](../app/) (`?sample` opens the sample
part, `?webgl` forces WebGL2 where WebGPU is missing). Designs are saved in the browser's private
file storage, which needs HTTPS or localhost. To build it yourself:
file storage, which needs HTTPS or localhost.
After the first visit the web app works offline: the browser keeps a copy of it. Online, each
launch gets the latest published build (the browser downloads it once when it changes); offline,
when the network doesn't answer within a few seconds, or when a new build can't be downloaded
whole, the kept copy starts (and the download carries on for the next launch). To build it
yourself:
```sh
rustup target add wasm32-unknown-unknown
cd apps/solidcraft-web && trunk serve --release
cd apps/solidcraft-web && trunk serve --release --no-autoreload
```
Offline use needs `--no-autoreload`: Trunk's live reload changes the page as it serves it, so it
no longer matches the build the browser would keep. Debug builds (`trunk serve`) never keep a copy.
## CLI
`solidcraft-cli` runs the same commands without a window:
+5
View File
@@ -27,6 +27,11 @@ repository under `/solidcraft/`. Do not add a separate owner-site publisher or p
old-name Pages/Flatpak aliases. GitHub repository redirects are separate from Pages hosting;
verify the new project URLs after deployment.
The browser app keeps itself for offline use (`apps/solidcraft-web/sw.js`). Browsers keep that
service worker after the code that registered it is gone, so to switch it off deploy
`apps/solidcraft-web/sw.js` unbuilt (as `trunk serve` builds do): it deletes what it kept and
unregisters. A site without `build.json` is also safe: launches then go to the network.
## Nightly prereleases
`release.yml` also runs at midnight in `America/New_York` (Eastern time, following daylight