"""Iteration 2: assemble self-contained pages. Each screen = v3 tokens (fonts inlined as base64) + iteration-1 app.css utilities + components.css + page CSS, then data.js + app.js + page script. Run: python3 build.py (writes ../screens/*.html) """ import base64, pathlib, re HERE = pathlib.Path(__file__).resolve().parent ROOT = HERE.parent.parent # ~/Design/extrudex-v3 OUT = HERE.parent / 'screens' OUT.mkdir(exist_ok=True) tokens = (ROOT / 'design-system-v3.css').read_text() tokens = re.sub(r"url\('\./fonts/([^']+)'\)", lambda m: "url('data:font/woff2;base64," + base64.b64encode((ROOT / 'fonts' / m.group(1)).read_bytes()).decode() + "')", tokens) base_css = (ROOT / 'source' / 'app.css').read_text() comp_css = (HERE / 'components.css').read_text() data_js = (HERE / 'data.js').read_text() app_js = (HERE / 'app.js').read_text() THEME = """""" def build(slug, title, desc): src = (HERE / 'pages' / f'{slug}.html').read_text() css = ''.join(re.findall(r'', src, re.S)) js = ''.join(re.findall(r'', src, re.S)) html = f"""