code wiki / _hdl_build / nx_html_head_fd.nx
nx_html_head_fd.nx
buildroot/runtime/_hdl_build/nx_html_head_fd.nx
about
nx_html_head_fd.nx -- the fd-STREAMING half of the canonical accessible head (seq702/seq703).
WHY A SECOND FILE: emitters come in TWO shapes, discovered while migrating them.
(a) BUFFER-ACCUMULATING -- pd_cat / shf_cat / fb_puts / wc_cat build into (out, offset)
and write once at the end. Those use nx_html_head.nx, which stays deliberately
DEPENDENCY-FREE (no imports at all) so anything can adopt it.
(b) fd-STREAMING -- hw(fd, s) writes each literal straight out via sys_write. The 16
nx_wasm_*_html.nx GAME packagers are all this shape.
Writing to an fd needs sys_write, so the fd half lives here rather than contaminating the
dependency-free core. Every emitter already imports nx_syscalls, so this costs adopters nothing.
USAGE -- mirrors the buffer API exactly:
nxh_fd_head_open(fd, "My Title" as *u8) // doctype+lang+charset+viewport+title
hw(fd, "<style>...</style>" as *u8) // emitter keeps its own CSS, unchanged
nxh_fd_body_open(fd) // </head><body><main>
... page content ...
nxh_fd_close(fd) // </main></body></html>
Guarantees the three checks no stylesheet can supply: lang= on <html>, meta viewport,
and a <main> landmark. For the games the viewport line is the load-bearing one -- they
pair a fixed-px canvas with no viewport, which is why they do not scale on a phone.
dependencies 1 imports · 1 importers
imports: nx_syscalls.nx
imported by: nx_wasm_pong_html.nx
structs
| none |
consts
| none |
functions
| 26 | func nxh_fd_lit(fd: i64, s: *u8) -> i64 |
| 33 | func nxh_fd_head_open(fd: i64, title: *u8) -> i64 |
| 40 | func nxh_fd_body_open(fd: i64) -> i64 |
| 44 | func nxh_fd_close(fd: i64) -> i64 |