app
Adom Fields
Public Made by Adomby adom
Adom Fields: where the current and the heat go on your board.
main
John Lauer
Publish 0.3.1
5ff0748
#!/bin/bash
# The canonical Adom 3D viewer is vendored, not copied into git: this fetches the pinned release
# into vendor/3d-viewer/ and regenerates src/vendor.rs, which embeds every file in the binary.
set -e
VER="${1:-0.7.1}"
HERE="$(cd "$(dirname "$0")/.." && pwd)"
cd "$HERE"
mkdir -p vendor/3d-viewer
TMP="$(mktemp -d)"
( cd "$TMP" && adom-wiki release download adom/adom-3d-viewer "$VER" >/dev/null )
tar -xzf "$TMP"/adom-3d-viewer-babylon9-"$VER".tar.gz -C vendor/3d-viewer
rm -rf "$TMP"
python3 - "$HERE" <<'PY'
import os, sys
here = sys.argv[1]
files = sorted(os.listdir(os.path.join(here, 'vendor/3d-viewer')))
ct = lambda f: ('application/javascript' if f.endswith('.js') else 'text/css' if f.endswith('.css')
else 'application/json' if f.endswith('.json') else 'application/wasm' if f.endswith('.wasm')
else 'application/octet-stream' if f.endswith('.env') else 'text/plain')
lines = ["// generated by tools/fetch-viewer.sh: the canonical Adom 3D viewer (adom/adom-3d-viewer), served under /vendor/3d-viewer/",
"pub fn vendor_file(name: &str) -> Option<(&'static [u8], &'static str)> {", " match name {"]
lines += [f' "{f}" => Some((include_bytes!("../vendor/3d-viewer/{f}"), "{ct(f)}")),' for f in files]
lines += [" _ => None,", " }", "}"]
open(os.path.join(here, 'src/vendor.rs'), 'w').write("\n".join(lines) + "\n")
print(f"OK: {len(files)} viewer files vendored and embedded")
PY