@@ -52,52 +52,41 @@ nix develop # one-off shell
5252direnv allow # automatic — uses the bundled .envrc
5353```
5454
55- ### Perfect simulation in the browser ( ` bifunctor-tagless ` only)
55+ ### Perfect simulation in the browser
5656
57- The ` bifunctor-tagless ` variant is cross-built for the JVM and Scala.js. The
58- same ` LadderApi ` /` ProfileApi ` http4s routes that the JVM server exposes are
59- also assembled in the browser into an in-process ` LocalDispatcher ` , which a
60- ` @JSExportTopLevel("LeaderboardSim") ` object surfaces to JavaScript. The JS
61- graph is configured with ` Repo -> Dummy ` , so it uses the same in-memory
62- repositories that the JVM tests use — no network, no postgres, no docker.
57+ [ ![ Live demo] ( https://img.shields.io/badge/live%20demo-7mind.github.io%2Fdistage--example-blue?logo=github )] ( https://7mind.github.io/distage-example/ )
6358
64- A small demo UI in ` bifunctor-tagless/jvm/src/main/resources/webapp/ ` lets you
65- call each endpoint with a radio toggle between ** production** (real HTTP) and
66- ** simulation** (the in-page Scala.js build).
59+ ` distage-example ` cross-builds to Scala.js, so the same
60+ ` LadderApi ` /` ProfileApi ` http4s routes also run entirely in the browser via
61+ an in-process ` LocalDispatcher ` configured with ` Repo -> Dummy ` — no network,
62+ no postgres, no docker. The demo UI in
63+ ` bifunctor-tagless/jvm/src/main/resources/webapp/ ` toggles each call between
64+ ** production** (real HTTP) and ** simulation** (the in-page Scala.js build),
65+ auto-selecting simulation when no production server answers.
6766
68- To use it, run the single convenience script — it builds the Scala.js bundle,
69- copies it next to the UI, and starts the server in dummy mode :
67+ Try the live deployment via the badge above (published to GitHub Pages on
68+ every push to ` develop ` ), or run it locally :
7069
7170``` bash
7271./launch-sim
7372```
7473
75- Then open < http://localhost:8080/ > . You can also open
76- ` bifunctor-tagless/jvm/src/main/resources/webapp/index.html ` directly via
77- ` file:// ` (CORS on the server allows the ` null ` origin used by ` file:// ` ).
74+ Then open < http://localhost:8080/ > . To enable Pages on your fork:
75+ ** Settings → Pages → Build and deployment → Source: GitHub Actions** .
76+
77+ #### Running the server and webpage separately
7878
79- If you prefer the steps separately :
79+ ` ./launch-sim ` is just a wrapper. To run the steps yourself :
8080
8181``` bash
8282sbt copySimJs # build + copy the Scala.js bundle
8383./launcher -u repo:dummy :leaderboard # start the server
8484```
8585
86- The "Production" radio talks to the http4s server (auto-detected from
87- ` location.origin ` , falling back to ` http://localhost:8080 ` when the page is
88- loaded from ` file:// ` ); the "Simulation" radio calls
89- ` LeaderboardSim.call(method, path, body) ` , which runs the exact same request
90- through the in-browser http4s routes. On page load, the UI probes the prod
91- backend with a short timeout — if no server answers (e.g. the page was
92- opened from disk, or hosted as static content), it auto-selects "Simulation"
93- so every button works out of the box. State only persists within each mode —
94- flipping back and forth is itself a useful demonstration that the simulation
95- is a clean process that knows nothing about the real server's state.
96-
97- The simulation half is also published to GitHub Pages on every push to
98- ` develop ` (see ` .github/workflows/pages-deploy.yml ` ) — useful for sharing a
99- live link without anyone having to install sbt. To enable on your fork:
100- ** Settings → Pages → Build and deployment → Source: GitHub Actions** .
86+ The webpage can also be opened directly from disk via ` file:// ` — the UI
87+ auto-detects the backend at ` http://localhost:8080 ` , and with no backend
88+ reachable, falls back to the in-page simulation so the static page works on
89+ its own.
10190
10291#### Note
10392
0 commit comments