Working on gpuix-svelte
To build an app with the package, start from the README. The renderer's design, and the constraints any change has to respect, are written down in CLAUDE.md.
Setup
You need both runtimes: Node 24 or later (.nvmrc pins 26, and demo:glass-ffi needs 26.1) and
Bun 1.4 or later, on macOS (arm64), Windows (x64 or arm64) or Linux (x64). Bun installs the
dependencies (bun.lock is the lockfile), and every script body runs on Node through npm run,
the bun: twins included. @gpuix/native comes prebuilt from npm, and so does Svelte, a dev
dependency here and a peer dependency of the published packages.
git clone https://github.com/khromov/gpuix-svelte
cd gpuix-svelte
nvm use
bun install
On Linux, install libxcb1, libxkbcommon0 and libxkbcommon-x11-0 first, and
mesa-vulkan-drivers plus xvfb on a machine without a display.
Demos and tests
npm run demo # four demos at once: counter, tic-tac-toe, Hacker News, liquid glass
npm run demo:counter # counter; edit examples/counter/Counter.svelte and save to hot-reload
npm run demo:tictactoe # tic-tac-toe with score tracking
npm run demo:hn # Hacker News reader (live data, scrollable list)
npm run demo:glass # liquid-glass control center (blurred on macOS, transparent elsewhere)
npm run demo:glass-ffi # the same app on real Liquid Glass: NSGlassEffectView via FFI, macOS 26+
# (older macOS gets the window blur, other platforms plain transparency)
npm run demo:styling # styling playground: which CSS text reaches GPUI and which is dropped
npm run demo:desktop # desktop APIs: window controls, file picker and drops, live image
# pixels, selection, focus walking, accessibility props
npm run demo:native-0.11 # what @gpuix/native 0.11 added: focus-visible, focus dim, Tab,
# onlayout/onscrollchange, new styles, register_font, elements_at
npm run demo:web # tic-tac-toe in a browser, on GPUI's WebAssembly/WebGPU build (Bun only)
npm run demo:cross # one component on both renderers: here in a GPUI window, and
npm run demo:dom # here in a browser DOM through Vite (-- --build-only writes dist/dom-cross-target)
npm run demo:ui # the UI toolkit's showcase (packages/ui/showcase) in a GPUI window, and
npm run demo:ui-dom # the same through Vite (-- --build-only writes dist/dom-showcase)
npm run demo:ui-app # Orbit (examples/ui-app), a small app built from the toolkit: the picture atop ui.md
npm run tutorial # interactive onboarding guide: 12 steps with live samples and quizzes
npm run typecheck # tsc, then svelte-check for the GPUI markup and again for the DOM components
npm test # typecheck, then every test suite except automation-live, linux-icon and coverage
npm run lint # ESLint; not part of `npm test`, so run it before pushing
npm run check:svelte # every component through the Svelte MCP server's autofixer (needs network)
npm run parity # @gpuix/native methods nothing here calls; run it after a native bump
New here? npm run tutorial opens a guided walkthrough of the renderer that is itself a
gpuix-svelte app. Each step pairs an explanation and a diagram with the source of a small
component, most of them running live, and ends with a quiz.
Every test script (except the Linux/Bun-only test:linux-icon), and every demo apart from the Bun-only demo:web and the Vite-run demo:dom
and demo:ui-dom, has a Bun twin under a bun: prefix: npm run bun:test, npm run bun:demo, npm run bun:demo:counter, and so on. The
twins run the same entry points on Bun, which takes the .svelte loader as a --preload. CI runs
both runtimes.
A demo that starts cleanly prints
[gpuix-svelte] created native window
[gpuix-svelte] mount complete
and GPUIX_SCREENSHOT=/tmp/x.png npm run demo:counter writes a PNG after every mount and remount
on macOS and Windows (the Linux addon can't take screenshots, so it logs that instead). Use a
single demo for that, since several would all write to the same file.
The demos run on all three platforms. Most tests run only on macOS and Windows, where gpuix builds
the headless renderer, so on Linux npm test fails right after typecheck. The suites that need no
headless renderer (test:bundle, test:compile, test:update, test:launcher, test:migrate, test:wrong-svelte, test:dom, test:ui-dom, test:docs) run anywhere, and so do
test:automation-live (a real window; under Xvfb on CI), consume and bun:consume (which skip
the headless test on Linux). test:linux-icon runs only on Linux, under Bun, with an X11 display:
it builds tic-tac-toe and checks the desktop entry and window icon the executable sets up. CI's
Linux job runs those plus typecheck and lint.
npm run test:coverage mounts Svelte's own custom renderer samples when SVELTE_SAMPLES_DIR
points at packages/svelte/tests/custom-renderers/samples in a svelte checkout, at the tag of the
installed version. Without it, the script skips.
The headless renderer and every window crash under Claude Code's Bash sandbox, so run tests and demos with it disabled.
Developing in a devcontainer
.devcontainer/ is a Linux machine with everything CI's Linux job has: Node 26,
Bun 1.4.4, the X11 libraries the binding links, Xvfb with Mesa's software Vulkan, xwd, Chrome,
the GitHub CLI, Claude Code and Docker-in-Docker. Open the folder in VS Code's Dev Containers or
run devcontainer up --workspace-folder .; it runs bun install when it is created.
Docker-in-Docker makes the container run --privileged, with the host kernel's capabilities and
devices, so remove that feature from devcontainer.json if you don't need Docker inside it.
The container is always linux/amd64, because @gpuix/native has no linux-arm64 prebuild. On
Apple Silicon that means Docker Desktop emulates it (Rosetta when enabled, QEMU otherwise), so the
first build and everything after it are noticeably slower than on the host.
Xvfb runs on :99 (1920×1080) and DISPLAY points at it, so a window opens without extra steps.
To watch it, open port 6080 in a browser: noVNC shows the display live and takes the mouse and
keyboard. VS Code forwards it, and so does code-server's /proxy/6080/. It has no password, so
anyone who can reach the port controls the display. There is no window manager, so windows open
centred on top of each other.
npm run demo:counter # draws on :99
xwd -root -silent | xwdtopnm | pnmtopng > /tmp/x.png # the Linux addon can't take screenshots, so read X11
xdotool mousemove 960 540 click 1 type 'hello' # poke a window by hand
npm run test:automation-live # a real window, driven through gpuix-svelte/automation
npm run test:linux-icon # a built app's desktop entry and _NET_WM_ICON
The browser previews listen on every interface, because the container sets HOST=0.0.0.0:
npm run demo:web (4173), npm run demo:dom and npm run demo:ui-dom (4174) and
npm run docs:serve (4321). It also sets
BROWSER=none, so they don't try to open a browser inside the container. demo:dom only loads on
its own origin (a forwarded or published port), not behind a path prefix such as /proxy/4174/.
Linux has no headless renderer, so npm test fails right after typecheck. Run the suites CI's Linux
job runs instead, on both runtimes: test:bundle, test:update, test:launcher, test:migrate, test:wrong-svelte, test:dom,
test:ui-dom, test:docs, test:compile, plus lint, demo:web -- --build-only,
demo:dom -- --build-only and demo:ui-dom -- --build-only.
Moving Svelte
bun update svelte moves it within the peer range; run npm test, npm run bun:test and
npm run test:coverage against that version's samples afterwards. A new minimum goes into
peerDependencies and devDependencies in package.json (the toolkit's published peer range reads
it from there), starter/package.json and WRONG_SVELTE in src/compile.ts.
The consumer path
npm run consume packs the tarball the way a release would, and the UI toolkit's beside it, and
scaffolds an app with packages/create-gpuix-svelte (whose template is starter/).
It then installs both tarballs into that app, typechecks it, runs its headless test and one over a
toolkit component through the installed bin (on Linux it only typechecks), and builds a page with
Vite that imports both. npm run bun:consume does the same with Bun and also builds the app's
standalone binary. consume:open and bun:consume:open start the app instead of testing it, so
you can look at its window. CI runs both passes.
Releasing
PR titles must be conventional commits (feat:, fix:,
docs:, chore: …), because a squash merge makes the title the commit. release-please keeps a
release PR open on main. Merging it tags the release, runs the tests and the consumer path on
macOS, publishes gpuix-svelte, create-gpuix-svelte and gpuix-svelte-ui to npm through npm
trusted publishing (OIDC, with provenance), builds the tic-tac-toe example on every platform with --archive and
uploads the archives and a signed update.json to the GitHub release (see
Updating). npm run pack -- <dir> builds the same tarball locally.
Docs site
npm run docs renders the README and docs/*.md to static HTML in dist/docs, along with a
markdown copy of each page, an llms.txt index and an llms-full.txt for coding agents. It also
copies the homepage (homepage/) to the root, so the README renders as overview.html. The
docs workflow builds it into an nginx image (Dockerfile,
nginx.conf) and deploys it to CapRover on every push to main that touches any
of them; docker build -t gpuix-svelte-docs . && docker run -p 8080:80 gpuix-svelte-docs serves
the same image at http://localhost:8080. A
new page needs an entry in PAGES in scripts/docs.ts. npm run docs:serve
builds it the same way, then serves it at http://127.0.0.1:4321 (HOST changes the address) and opens it in your browser, and
rebuilds whenever the README, docs/, homepage/, the DOM versions of the components or the script itself changes
(reload the page to see it).
A fenced block whose info string is svelte demo <name> is also a live demo. The block is the
whole source of a component: on GitHub it reads as a code sample, on the site it renders as the
code with the component running above it, in the DOM (details), so the two can't drift. The
build writes each one to dist/docs-demos/<page>-<name>.svelte and bundles them with Vite into
dist/docs/demos.js, the same way demo:dom builds the cross-target example
(scripts/vite-dom.ts holds the plugins): gpuix-svelte and
gpuix-svelte/components/*.svelte resolve to the DOM versions of the components, exactly as in a consumer's Vite app,
and only the pages that have a demo load the bundle. Write a demo in the subset both renderers
draw the same way (Rendering in the DOM) and colour it with
the tokens the page defines for them, --paper, --ink, --panel, --raised and --dim, plus
the components' own --tooltip-*, --popover-* and --scroller-*. Keep set_css_vars and
:root rules for a demo that is about theming: both land on :root, which the whole page reads.
A demo that does not compile fails npm run docs; npm run test:docs builds the site and mounts
every demo from the built bundle under happy-dom, so one that throws at mount fails there, and
CI's Linux job runs it.
The social preview images are screenshots: npm run og retakes homepage/og.png from the
homepage's #og view, and npm run og:docs retakes docs/assets/og-docs.png from the built
overview page. Both need Chrome installed (or CHROME pointing at a Chromium). Rerun them after
changing the hero or the docs template, and keep the og:image:alt text in step.
npm run shots retakes every other screenshot: the example windows in homepage/assets/shots/
(each app launched through gpuix-svelte/automation, driven to the state its image shows and
captured by GPUI at 2×), Orbit's Settings screen as docs/assets/ui-app.png, tic-tac-toe on the
wasm build in headless Chrome, and the README's .github/resources/demos.png (the fresh counter,
tic-tac-toe and Hacker News captures and glass.png, with CSS window chrome on a dark
background), and then runs og and og:docs, since both show what changed. It needs macOS or
Windows for the windows, Bun for the web build and Chrome for the rest; -- --only hn,demos
redoes a subset. glass.png is the one capture it
leaves alone, since the control center needs a desktop behind it, and the hero's wallpapers in
homepage/assets/wall/ are plain images it never touches. Run it after restyling an example; an
<img>'s width/height (and a carousel tile's --a) only change if a window's size did.