Add play.html: the whole game in one file you can open from a disk - #4
Merged
Conversation
setuptools writes ./build, but the pattern also matched web/build, which is source. Anchoring it keeps the artefact ignored and the source trackable. Co-authored-by: BruceMoseti <BruceMoseti@users.noreply.github.com>
The page is deliberately unbundled, which is why it needs no toolchain and also why it cannot be opened from a disk: a module graph over file:// is refused, so double-clicking web/index.html gets you a blank page. Until a published copy exists there is no way to play without running a server. play.html is the same markup with the stylesheet, the measured figures and all nine modules inlined. It is a concatenation rather than a bundle, which is legal for reasons the build checks instead of assuming: the imports are named and static, the graph is acyclic, and no two modules declare the same top-level name. Any of those failing stops the build with the offending name rather than shipping a file that loads and then misbehaves. It is generated, so CI rebuilds it, compares it against the committed copy, and then plays a full game and the whole input suite from file:// — a copy of the game that has quietly rotted is worse than no copy. Co-authored-by: BruceMoseti <BruceMoseti@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Right now there are two ways to play, and both need something first: the published page needs GitHub Pages switched on (a repository setting no workflow token can set), and
make playneeds a terminal and a server. There is no way to just open the game.Double-clicking
web/index.htmldoes not work and cannot be made to work: the page is deliberately unbundled plain ES modules, and a browser refuses a module graph overfile://. That property is the reason the page needs no toolchain, so it is worth keeping — but it means the repository should ship the one artefact that does open from a disk.What this is
play.htmlat the repository root: the same markup, with the stylesheet, the measured figures and all nine modules inlined. 123 kB, no network, no server. Download it and double-click.play.html opened straight from the filesystem, rendering the full interface
It is a concatenation, not a bundle — no esbuild, no toolchain, in keeping with the rest of
web/. That is only legal under three conditions, soweb/build/standalone.mjschecks them rather than assuming them: every import is named and static, the graph is acyclic, and no two modules declare the same top-level name. If any stops holding, the build fails naming the offending module and symbol instead of emitting a file that loads and then misbehaves. Renaming imports (canPlaceCue as canPlaceCueAt) become explicit bindings, andimport.metaor a dynamicimport()anywhere in the graph is rejected outright.The figures in the prose used to be fetched from
web/data/facts.json, whichfile://will not read, so the build inlines them intowindow.__measuredFactsandloadFactsprefers that when present. The served page is unchanged: it still fetches, and its facts still get checked bysite_facts.py --check.How it is kept honest
A stale copy of the game is worse than no copy, so CI does not trust it:
standalone.mjs --checkplay.htmldrifting fromweb/— rebuilds and compares byte for bytebrowser.mjs --url file://…/play.htmlinput.mjs --url file://…/play.htmlfile://Verified locally: the offline file plays complete games (7 and 11 shots) with no console errors or failed requests, passes 15/15 interaction checks, and the served page still plays clean after the
facts.jschange. The freshness check was confirmed to fail on a deliberately editedplay.html, not just to pass.make standalonerebuilds it and immediately plays it from a file.Also here
.gitignorehadbuild/, which was meant for setuptools'./buildbut also matchedweb/build/, where this script lives. Anchored to/build/.To show artifacts inline, enable in settings.