ntk API documentation
ntk is a node.js desktop UI toolkit for X11: thin wrappers around node-x11 exposing familiar, browser-like APIs — DOM-style events, an HTML canvas-like 2d context (backed by the XRender extension, so composition happens server-side) and an OpenGL 1.4-style context over indirect GLX.
These documents describe the public API surface. They must be kept in sync with the code — any change to a public API requires updating the matching file here (see AGENTS.md).
Sections
- Getting started — installation, requirements, first window
- App — connecting to the X server, the
Appfactory object - Window — window creation, properties, methods, events,
keyboard input, frame pacing / event coalescing,
requestAnimationFrame - Pixmap — offscreen drawables
- Clipboard —
app.clipboard.write()/read(): text transfer over the CLIPBOARD/PRIMARY selections (ICCCM), INCR-aware reads - 2d rendering context — canvas-like drawing API over XRender
- Images — PNG/JPEG loading (
loadImage), theImageobject,drawImage - Fonts — font lookup, loading, rasterization pipeline
- Text — shaping (kerning/bidi/fallback), TextLayout, MarkdownView, wire-efficiency design, the vector (trapezoid) path for large/animated sizes
- TeX / math — KaTeX-based formula rendering:
layoutTex,TexView, markdown math fences - HTML widget —
HtmlView: static HTML + CSS subset, yoga-layout flexbox/block layout, links, images, the resource-loading safety model - SVG widget —
SvgView: static SVG rendering through the 2d context (shapes, gradients, transforms,use), plusPath2D/SVG path data - OpenGL rendering context — indirect GLX / OpenGL 1.4 API
- Raw X11 rendering context — core X drawing requests
- Resource management —
using/Symbol.dispose, GC-based cleanup - Headless X server — run ntk against node-x11's pure-JS X server (XRender built in since x11 3.1.0) — no DISPLAY needed