code wiki / _hdl_build / nx_brand_preview.nx

nx_brand_preview.nx source

↩ module page · 65 lines · 3529 B

1// nx_brand_preview.nx -- SAFE local preview (NO production touch): render the REAL andelinwest.site blueprint 2// through the now-brand-wired builder (compose_build -> sg_build_page -> wb_doc_open: tokens + polish) to a 3// Windows-openable file, then VERIFY it is token-driven, polished, and free of off-token colour drift. This is the 4// SHIP dry-run: it proves the whole arc (auto-build + R1 tokens + R1b wiring + R2 contrast + R7 polish) on the real 5// S-class test site, without deploying anything. 100% sovereign. license_tier: ORIGINAL expect_exit: 0 6import "nx_syscalls.nx" 7import "nx_sitegate_emit_lib.nx" 8import "nx_site_compose.nx" 9import "nx_brand_book.nx" 10import "nx_brand_tokens.nx" 11 12 13func g_has(s: *u8, n: i64, lit: *u8) -> i64 { if bt_find(s, n, lit, bt_len(lit)) >= 0 { return 1 } return 0 } 14 15func main() -> i64 { 16 let tot: *i64 = sys_mmap(32) as *i64 17 tot[0]=0; tot[1]=0 18 gw("=== nx_brand_preview -- render the REAL andelinwest.site through the brand-wired builder (local, no deploy) ===\n" as *u8) 19 20 // read the real blueprint 21 let lp: *i64 = sys_mmap(16) as *i64 22 let site: *u8 = sys_read_file("web_assets/_sites/andelinwest.site" as *u8, lp) 23 let sn: i64 = lp[0] 24 if (site as i64) == 0 { gw(" FAIL could not read andelinwest.site\n" as *u8); return 1 } 25 if sn <= 0 { gw(" FAIL empty andelinwest.site\n" as *u8); return 1 } 26 27 // build it through the unified composer (legal -> sg_build_page -> wb_doc_open: tokens + polish) 28 let outpath: *u8 = "web_assets/andelin_branded.html" as *u8 29 let fd: i64 = sys_openat_wr(outpath, 0x1a4) 30 if fd < 0 { gw(" FAIL could not open output\n" as *u8); return 1 } 31 compose_build(site, sn, fd, "web_assets/_game_build/game_page.tpl.html" as *u8) 32 sys_close(fd) 33 34 // read the rendered page back + verify 35 let page: *u8 = sys_read_file(outpath, lp) 36 let pn: i64 = lp[0] 37 gw(" rendered " as *u8); gn(pn); gw(" bytes -> web_assets/andelin_branded.html (open in a browser)\n" as *u8) 38 39 var t1: i64 = 0 40 if pn > 0 { if g_has(page, pn, "<header" as *u8) == 1 { if g_has(page, pn, "<div class=\"hero\"" as *u8) == 1 { t1 = 1 } } } 41 t_row("P1 real andelinwest legal site built (header + hero from its blueprint)" as *u8, t1, tot) 42 43 var t2: i64 = 0 44 if g_has(page, pn, ":root{" as *u8) == 1 { if g_has(page, pn, "--nx-color-primary: #0b2545" as *u8) == 1 { if g_has(page, pn, "var(--nx-color-primary)" as *u8) == 1 { t2 = 1 } } } 45 t_row("P2 token-driven (declares :root{--nx-*} + uses var(--nx-*))" as *u8, t2, tot) 46 47 var t3: i64 = 0 48 if g_has(page, pn, "@media(prefers-reduced-motion:no-preference)" as *u8) == 1 { if g_has(page, pn, ":focus-visible" as *u8) == 1 { t3 = 1 } } 49 t_row("P3 polished (motion + micro-interactions, accessible by construction)" as *u8, t3, tot) 50 51 let off: i64 = ba_audit(page, pn) 52 gw(" off-token colour drift = " as *u8); gn(off); gw("\n" as *u8) 53 var t4: i64 = 0 54 if off == 0 { t4 = 1 } 55 t_row("P4 brand audit: 0 off-token colour drift (fully on the design system)" as *u8, t4, tot) 56 57 var t5: i64 = 0 58 if g_has(page, pn, "<script" as *u8) == 0 { t5 = 1 } 59 t_row("P5 sovereign: 0 third-party <script> in the page" as *u8, t5, tot) 60 61 gw("\nrows pass=" as *u8); gn(tot[0]); gw(" fail=" as *u8); gn(tot[1]); gw("\n" as *u8) 62 if tot[1] == 0 { gw("VERDICT=GREEN -- andelinwest renders fully branded (tokens+polish), 0 drift, sovereign. Ready for SHIP on your go-ahead.\n" as *u8); return 0 } 63 gw("VERDICT=RED\n" as *u8) 64 return 1 65}