First load fetches roughly 18 MB of runtime & assets
'''
def main():
with open(INPUT, 'rb') as f:
src = f.read()
# 1) Drop the virtual-terminal feature from data-os. (Temporarily
# leave it on for diagnostic builds: set KEEP_TERMINAL=1 in env.)
if not os.environ.get('KEEP_TERMINAL'):
src = src.replace(b'data-os="fs,gui"', b'data-os="fs,gui"')
# 1b) Make pygbag's HTML canvas drawing buffer 1200x720 to match the
# pygame surface, so the browser does a 1:1 pixel mapping instead of
# downscaling 1280 -> 1200 (which is the source of the smudge).
# Plan step 1: this attribute change in isolation, no other side
# effects (no setInterval diagnostic, no pygbag CLI flags, no extra
# CSS). If the tab crashes after this, the attributes themselves
# were the culprit and we revert; if no visual change, pythons.js
# isn't honouring the attrs and we try --width/--height next.
src = re.sub(
rb'(