#!/usr/bin/env bash # Assemble the deployed single-file pages from source + shared partials + assets/. # # Every page (the landing index.html, the editor.html app, the device mockups and # the info-*.html pages) is a source that shares 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 for name in ("index.html","editor.html","player.html","stage.html","micro.html","concepts.html","embed.html", "info-editor.html","info-initial.html","info-stage.html","info-micro.html"): print("built %s (%dKB)" % (name, build(name) // 1024)) pathlib.Path("dist/embed.js").write_text(pathlib.Path("embed.js").read_text()) # loader, served as-is print("copied embed.js") PY