Vercel Labs has released vgpu, a TypeScript library designed to streamline WebGPU development through a lightweight, multi-runtime API. The library introduces a typed WGSL import system that treats .wgsl files as TypeScript modules, utilizing reflection to automatically synchronize binding names, types, and layouts without manual declarations or a separate codegen step. Technically, vgpu enforces a "single Gpu context" architecture where a single handle returned by init() is passed explicitly to all entry points like effect(), surface(), and frame(), eliminating hidden global states. The library is optimized for minimal footprint, with a CI-enforced bundle budget ensuring a complete fullscreen effect remains under 25 KB gzipped. It supports three distinct execution environments: the browser, a Dawn-backed headless Node.js runtime (via vgpu/node), and a deterministic software mock (via vgpu/mock) for testing. Developers can manage shaders via the @vgpu/cli, which provides tools for documentation, shader validation, and example retrieval. Furthermore, the library is "agent-ready," providing structured documentation through llms.txt, an OpenAPI-described examples discovery API, and MCP support to facilitate usage by LLM-based coding agents.
Read original
github-trending/typescript