Skip to content

Architecture

GJSify is a Yarn workspaces monorepo that provides Node.js and Web API implementations for GJS using native GNOME libraries.

gjsify/
├── packages/
│ ├── node/ # Node.js API implementations (@gjsify/<name>)
│ ├── web/ # Web API implementations
│ ├── dom/ # DOM & graphics (Canvas2D, WebGL, event bridge)
│ ├── gjs/ # GJS runtime utilities, types, test framework
│ └── infra/ # CLI, Rolldown / Vite plugins, build tools
├── showcases/ # Curated, published example applications
├── examples/ # Private dev/test examples
├── refs/ # Read-only reference submodules (Node.js, Deno, etc.)
└── website/ # This documentation site

GJSify uses Rolldown (Vite 8’s production bundler) with platform-specific plugins to produce different bundles from the same source:

  • GJS build (gjsify build --app gjs): Aliases node:* and Web API imports to @gjsify/*, externalises gi://*, cairo, system and gettext. Target: firefox140.
  • Node build (gjsify build --app node): Aliases @gjsify/processprocess and maps aliased Web packages to their Node equivalents. Target: node24.
  • Browser build (gjsify build --app browser): Standard browser target. Target: esnext.

The alias table lives in packages/infra/resolve-npm/lib/index.mjs; the Rolldown plugins live in packages/infra/rolldown-plugin-gjsify/.

Each @gjsify/* package maps Node.js or Web APIs to native GNOME libraries:

Node.js / Web APIGNOME Library
fsGio.File, Gio.FileIOStream
netGio.SocketClient, Gio.SocketService
httpSoup.Server
cryptoGLib.Checksum, GLib.Hmac
process.envGLib.getenv / GLib.setenv
url.URLGLib.Uri
fetchSoup.Session
WebSocketSoup.WebsocketConnection
Canvas 2DCairo.ImageSurface, PangoCairo
WebGLGtk.GLArea, OpenGL ES via libepoxy (Vala extension)
localStorageGio.File + GLib.KeyFile

GJSify treats the Node.js API, the Web API and the DOM API as three equal pillars:

  • packages/node/ — Node.js builtins (fs, http, crypto, …)
  • packages/web/ — Web platform APIs (fetch, WebSocket, ReadableStream, Web Crypto, …)
  • packages/dom/ — DOM element classes backed by GTK widgets (HTMLCanvasElement, HTMLImageElement, HTMLIFrameElement, …) plus the GTK→DOM event bridge

Each visual DOM element pairs with a GTK widget: HTMLCanvasElement (2D) → Canvas2DBridgeGtk.DrawingArea, HTMLCanvasElement (WebGL) → WebGLBridgeGtk.GLArea, HTMLIFrameElementIFrameBridgeWebKit.WebView.