Merge remote-tracking branch 'gh/main' into wave/h-shared-frontend

This commit is contained in:
Edward Langley
2026-09-20 11:48:28 -07:00
6 changed files with 273 additions and 35 deletions
+27 -15
View File
@@ -1,5 +1,6 @@
#!/bin/sh
# Assemble the static site from `web/` into `site/`.
# Assemble the static site into `site/`: the landing page from `docs/` at the
# root, and the browser app from `web/` under `app/`.
#
# `web/` is the *source* directory: it also holds build.sh, assemble.sh and
# .gitignore, which have no business being served. This copies what ships.
@@ -33,26 +34,37 @@ test -d "$root/web/worker-pkg" || { echo "web/worker-pkg missing — run web/bui
rm -rf "$out"
mkdir -p "$out"
cp -f "$root/web/index.html" "$root/web/app.js" "$root/web/style.css" "$root/web/worker.js" "$out/"
# The landing page is the front door and the app is what it sends you to
# (user ruling, improvise-kh8). So `docs/` lands at the ROOT and the app moves
# under `app/` whole — every path in app.js and worker.js is relative, so the
# bundles travel with it and the generated glue needs no editing.
cp -f "$root/docs/index.html" "$out/index.html"
cp -rf "$root/docs/casts" "$out/casts"
app="$out/app"
mkdir -p "$app"
cp -f "$root/web/index.html" "$root/web/app.js" "$root/web/style.css" "$root/web/worker.js" "$app/"
# The document the page opens on a browser that has never seen one.
# web/worker.js fetches it by the ?seed= URL and hands the bytes to Rust,
# which writes them through the VFS — so leaving it out is an empty grid, not
# a 404 the page could report.
cp -f "$root/web/demo.improv" "$out/"
cp -rf "$root/web/pkg" "$out/pkg"
cp -rf "$root/web/worker-pkg" "$out/worker-pkg"
rm -f "$out/pkg/.gitignore" "$out/pkg/package.json"
rm -f "$out/worker-pkg/.gitignore" "$out/worker-pkg/package.json"
cp -f "$root/web/demo.improv" "$app/"
cp -rf "$root/web/pkg" "$app/pkg"
cp -rf "$root/web/worker-pkg" "$app/worker-pkg"
rm -f "$app/pkg/.gitignore" "$app/pkg/package.json"
rm -f "$app/worker-pkg/.gitignore" "$app/worker-pkg/package.json"
# BSD sed (macOS) needs an argument to -i; GNU sed must not be given one.
sedi() { sed "$1" "$2" > "$2.tmp" && mv -f "$2.tmp" "$2"; }
sedi "s|\./pkg/improvise_wasm_client\.js|&?v=${token}|" "$out/app.js"
sedi "s|\./worker-pkg/improvise_worker_server\.js|&?v=${token}|" "$out/worker.js"
sedi "s|\./pkg/improvise_wasm_client\.js|&?v=${token}|" "$app/app.js"
sedi "s|\./worker-pkg/improvise_worker_server\.js|&?v=${token}|" "$app/worker.js"
sedi "s|'improvise_wasm_client_bg\.wasm'|'improvise_wasm_client_bg.wasm?v=${token}'|" \
"$out/pkg/improvise_wasm_client.js"
"$app/pkg/improvise_wasm_client.js"
sedi "s|'improvise_worker_server_bg\.wasm'|'improvise_worker_server_bg.wasm?v=${token}'|" \
"$out/worker-pkg/improvise_worker_server.js"
"$app/worker-pkg/improvise_worker_server.js"
# One `grep` over all four files succeeds when ANY one of them matches, so
# three failed substitutions could still produce a "successful" assembly under
@@ -66,7 +78,7 @@ stamped() {
}
grep -n "$2" "$1"
}
stamped "$out/app.js" "pkg/improvise_wasm_client.js?v=${token}"
stamped "$out/worker.js" "worker-pkg/improvise_worker_server.js?v=${token}"
stamped "$out/pkg/improvise_wasm_client.js" "improvise_wasm_client_bg.wasm?v=${token}"
stamped "$out/worker-pkg/improvise_worker_server.js" "improvise_worker_server_bg.wasm?v=${token}"
stamped "$app/app.js" "pkg/improvise_wasm_client.js?v=${token}"
stamped "$app/worker.js" "worker-pkg/improvise_worker_server.js?v=${token}"
stamped "$app/pkg/improvise_wasm_client.js" "improvise_wasm_client_bg.wasm?v=${token}"
stamped "$app/worker-pkg/improvise_worker_server.js" "improvise_worker_server_bg.wasm?v=${token}"