feat(ui): implement responsive player browser experience
This commit is contained in:
@@ -78,4 +78,8 @@ cc -std=c11 -Wall -Wextra -Werror -pedantic \
|
||||
-o "$test_directory/test_game_mechanics"
|
||||
|
||||
"$test_directory/test_game_mechanics"
|
||||
node "$project_directory/test/web/test_player_app.js"
|
||||
python3 "$project_directory/scripts/generate_web_assets.py" \
|
||||
--source "$project_directory/web" \
|
||||
--output "$project_directory/data" >/dev/null
|
||||
python3 "$project_directory/scripts/verify_web_assets.py"
|
||||
|
||||
@@ -12,6 +12,7 @@ from generate_web_assets import generate_assets
|
||||
|
||||
|
||||
PROJECT_DIRECTORY = Path(__file__).resolve().parent.parent
|
||||
COMPRESSED_PAYLOAD_LIMIT = 1572864
|
||||
|
||||
|
||||
def tree_digest(directory: Path) -> str:
|
||||
@@ -41,17 +42,25 @@ def main() -> int:
|
||||
if first_digest != checked_in_digest:
|
||||
raise AssertionError("Generated web assets are stale; regenerate the data directory")
|
||||
|
||||
index_source = (source_directory / "index.html").read_bytes()
|
||||
index_compressed = (first / "index.html.gz").read_bytes()
|
||||
if gzip.decompress(index_compressed) != index_source:
|
||||
raise AssertionError("Compressed index does not reproduce its source")
|
||||
for compressed_path in sorted(path for path in first.rglob("*.gz") if path.is_file()):
|
||||
relative_path = compressed_path.relative_to(first)
|
||||
source_relative = Path(str(relative_path)[:-3])
|
||||
if gzip.decompress(compressed_path.read_bytes()) != (
|
||||
source_directory / source_relative
|
||||
).read_bytes():
|
||||
raise AssertionError(f"Compressed asset does not reproduce {source_relative}")
|
||||
|
||||
provision_source = (source_directory / "provision.html").read_bytes()
|
||||
provision_compressed = (first / "provision.html.gz").read_bytes()
|
||||
if gzip.decompress(provision_compressed) != provision_source:
|
||||
raise AssertionError("Compressed provisioning page does not reproduce its source")
|
||||
compressed_size = sum(path.stat().st_size for path in first.rglob("*.gz"))
|
||||
if compressed_size > COMPRESSED_PAYLOAD_LIMIT:
|
||||
raise AssertionError(
|
||||
f"Compressed web payload is {compressed_size} bytes and exceeds "
|
||||
f"the {COMPRESSED_PAYLOAD_LIMIT}-byte limit"
|
||||
)
|
||||
|
||||
print(f"web asset reproducibility: PASS ({first_digest})")
|
||||
print(
|
||||
f"web asset reproducibility: PASS ({first_digest}, "
|
||||
f"{compressed_size}/{COMPRESSED_PAYLOAD_LIMIT} bytes)"
|
||||
)
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user