#!/usr/bin/env bash # Assemble the deployed single-file pages from source + shared partials + assets/. # # Both index.html and player.html are sources that share code via markers: # /*@BUILD:include:src/@*/ inlines a shared partial (engine, seed lists, base CSS) # @BUILD:favicon@ / @BUILD:logo-*@ / /*@BUILD:samples@*/{} inline base64 assets # This resolves them so each built page in dist/ is one self-contained file # (zero deps, works fully offline). deploy.sh runs this first. dist/ is generated — # don't edit or commit it. set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")" mkdir -p dist python3 - <<'PY' import json, os, pathlib, re A = pathlib.Path("assets") SAMPLES = json.dumps(json.load(open(A / "samples.json"))) def build(name): src = pathlib.Path(name).read_text() # 1) inline shared partials (function-replacement: no backslash/group interpretation) src = re.sub(r"/\*@BUILD:include:([^@]+)@\*/", lambda m: pathlib.Path(m.group(1)).read_text().rstrip("\n"), src) # 2) inline base64 assets src = src.replace("@BUILD:favicon@", (A / "favicon.b64").read_text().strip()) src = src.replace("@BUILD:logo-dark@", (A / "logo-dark.b64").read_text().strip()) src = src.replace("@BUILD:logo-light@", (A / "logo-light.b64").read_text().strip()) src = src.replace("/*@BUILD:samples@*/{}", SAMPLES) assert "@BUILD:" not in src, f"unresolved build marker(s) remain in {name}" out = pathlib.Path("dist") / name out.write_text(src) return out.stat().st_size i = build("index.html"); p = build("player.html"); a = build("stage.html"); u = build("micro.html") print("built index.html (%dKB) + player.html (%dKB) + stage.html (%dKB) + micro.html (%dKB)" % (i // 1024, p // 1024, a // 1024, u // 1024)) PY