Merge pull request #24 from fiddlerwoaroof/wave/j-browser-harness
WU-J: a headless browser harness, and the first execution of OpfsFs (improvise-vvl3, improvise-vhcz, improvise-hmws; improvise-xf1 stays open for Safari). storage_contract had been cited for months as the written-down spec OpfsFs must satisfy in a browser. The first time OpfsFs was handed to it, it failed on its first assertion.
This commit is contained in:
Executable
+72
@@ -0,0 +1,72 @@
|
||||
#!/bin/sh
|
||||
# Assemble the static site from `web/` into `site/`.
|
||||
#
|
||||
# `web/` is the *source* directory: it also holds build.sh, assemble.sh and
|
||||
# .gitignore, which have no business being served. This copies what ships.
|
||||
#
|
||||
# Extracted from the CI workflow so that the Pages job and the browser harness
|
||||
# assemble the same tree — a harness that runs against a different arrangement
|
||||
# of files is testing something nobody deploys (improvise-vvl3). Same reason
|
||||
# `web/build.sh` exists rather than two copies of the wasm-pack invocation.
|
||||
#
|
||||
# Usage: web/assemble.sh [OUT_DIR] [CACHE_BUST_TOKEN]
|
||||
#
|
||||
# The token cache-busts the two generated bundles. Pages serves everything
|
||||
# `max-age=600` and the wasm-pack filenames carry no content hash, so for ten
|
||||
# minutes after a deploy a returning visitor runs the PREVIOUS build — which
|
||||
# during improvise-9x6 debugging made a shipped fix look like it had not
|
||||
# shipped, twice. CI passes the commit SHA; a local run defaults to `dev`.
|
||||
#
|
||||
# Both halves are stamped, because a fresh glue file does NOT pull a fresh
|
||||
# .wasm: the glue locates it with `new URL('..._bg.wasm', import.meta.url)`,
|
||||
# and a URL constructed against a base does not inherit the base's query
|
||||
# string. Stamping only the import specifier would refresh the wrapper and
|
||||
# keep the stale binary — the failure mode this is here to end.
|
||||
set -eu
|
||||
|
||||
root=$(cd "$(dirname "$0")/.." && pwd)
|
||||
out=${1:-"$root/site"}
|
||||
token=${2:-dev}
|
||||
|
||||
test -d "$root/web/pkg" || { echo "web/pkg missing — run web/build.sh first" >&2; exit 1; }
|
||||
test -d "$root/web/worker-pkg" || { echo "web/worker-pkg missing — run web/build.sh first" >&2; exit 1; }
|
||||
|
||||
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 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"
|
||||
|
||||
# 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|'improvise_wasm_client_bg\.wasm'|'improvise_wasm_client_bg.wasm?v=${token}'|" \
|
||||
"$out/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"
|
||||
|
||||
# One `grep` over all four files succeeds when ANY one of them matches, so
|
||||
# three failed substitutions could still produce a "successful" assembly under
|
||||
# `set -e` (found by Copilot on PR #24). These checks are the only guard
|
||||
# against the generated glue changing shape, so each stamped reference is
|
||||
# verified on its own and names itself when it is the one missing.
|
||||
stamped() {
|
||||
grep -q "$2" "$1" || {
|
||||
echo "assemble: $1 is missing the cache-bust stamp: $2" >&2
|
||||
exit 1
|
||||
}
|
||||
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}"
|
||||
Reference in New Issue
Block a user