open-standards/wai/quickstart/build-web.sh
Transaction Science 632f8cf394 wai: the developer's path, hello, create, dev and verify, a floor build with no system library, and nine examples
wai-rs gains the feature floor (the mandatory floor of SPEC 5: PNG, FLAC and
zstd, decoded with no system codec library) and quickstart (the floor, and the
receipt checks hello and verify run). The wai command line gains four verbs,
one module each, named in one table (dx::VERBS):

- hello: name, dispatch, rebuild and receipt on a picture made here, the
  receipt laid out as http-delivery 8 lays receipts beside an object;
- create: a new project from one of the examples, whose files the binary
  holds; tests/cli_dx.rs holds them to wai/examples/ byte for byte;
- dev: the relay, the room service and the room page on one loopback origin,
  as a production front serves them; --check checks each piece through it;
- verify: the receipt indexes under a directory, checked offline.

The project file a template writes, wai.json, is read in one place
(dx/project.rs). wai/examples/ holds video-room, watch-together, messaging,
encoder-ingest, package-and-deliver, verify-receipts, apple-app, android-app
and remote-desktop, each with a README and a test that runs it through
wai create and wai dev. wai/quickstart/ builds the room client and the
archive that holds wai, the relay, the room service, the remote host and the
packager.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 22:58:39 -04:00

44 lines
2.5 KiB
Shell
Executable file

#!/usr/bin/env bash
# The room client's files, as `wai dev` serves them, built into one directory:
#
# bash wai/quickstart/build-web.sh <out-dir>
#
# <out-dir>/room/ and <out-dir>/moq/ are joule-moq-web's page code (its tests left out), and
# <out-dir>/pkg/ the three WebAssembly builds the pages load: joule_moq_web (MOQT and
# receipts), joule_moq_web_e2ee (the same, and the member of an end-to-end encrypted room)
# and wai_live_web (the room's records, layout and mixer), each through wasm-bindgen's web
# target. The same files on every platform: an archive for any of them carries this
# directory as share/wai/web/.
#
# Needs the wasm32-unknown-unknown target and the wasm-bindgen CLI at 0.2.127, the version
# both crates pin. Run from anywhere; CARGO_TARGET_DIR is honoured.
set -euo pipefail
[ $# -eq 1 ] || { echo "usage: bash wai/quickstart/build-web.sh <out-dir>" >&2; exit 2; }
ROOT=$(cd "$(dirname "$0")/../.." && pwd)
OUT=$(mkdir -p "$1" && cd "$1" && pwd)
JC="$ROOT/joule-code/joule-code-rs"
WEB="$JC/crates/joule-moq-web/web"
WLW="$ROOT/wai/wai-live-web"
TARGET=${CARGO_TARGET_DIR:-$JC/target}
export CARGO_TARGET_DIR="$TARGET"
command -v wasm-bindgen >/dev/null || { echo "wasm-bindgen CLI 0.2.127 is needed (cargo install --locked wasm-bindgen-cli --version 0.2.127)" >&2; exit 2; }
wasm-bindgen --version | grep -q ' 0\.2\.127$' || { echo "the wasm-bindgen CLI must be 0.2.127, the version both crates pin" >&2; exit 2; }
rm -rf "$OUT/room" "$OUT/moq" "$OUT/pkg"
mkdir -p "$OUT/room" "$OUT/moq" "$OUT/pkg"
(cd "$JC" && cargo build --locked --release -p joule-moq-web --lib --target wasm32-unknown-unknown)
wasm-bindgen --target web --out-dir "$OUT/pkg" --out-name joule_moq_web "$TARGET/wasm32-unknown-unknown/release/joule_moq_web.wasm"
(cd "$JC" && cargo build --locked --profile wasm -p joule-moq-web --lib --target wasm32-unknown-unknown --features e2ee)
wasm-bindgen --target web --remove-name-section --remove-producers-section --out-dir "$OUT/pkg" --out-name joule_moq_web_e2ee "$TARGET/wasm32-unknown-unknown/wasm/joule_moq_web.wasm"
(cd "$WLW" && cargo build --locked --release --lib --target wasm32-unknown-unknown)
wasm-bindgen --target web --out-dir "$OUT/pkg" --out-name wai_live_web "$TARGET/wasm32-unknown-unknown/release/wai_live_web.wasm"
# The pages need the modules and the binaries alone, not the type declarations.
rm -f "$OUT"/pkg/*.d.ts
for d in room moq; do
for f in "$WEB/$d"/*; do
case "$f" in *.test.mjs) continue ;; esac
cp "$f" "$OUT/$d/"
done
done
ls -l "$OUT/pkg"
echo "the room client is in $OUT"