docs / packages

Packages

g2w is not one big framework — it is a set of small packages with one strict rule, enforced by architecture tests: adapters depend on@g2w/core, and core never depends back. You compose only what your game needs.

The full list

PackageResponsibilityStatus
@g2w/coreRenderer-agnostic contracts: Game, SceneManager, InputState, GamepadState, AssetManager, Sprite2D/Transform2D, audio contract.done
@g2w/runtimeEffect-based application runtime: managed lifecycle scope, G2WGame with idempotent shutdown and LIFO finalizers.done
@g2w/renderer-pixiPixiJS 8 renderer adapter: WebGL/Canvas/WebGPU backends, sprite views, texture asset loading.done
@g2w/input-domDOM adapter: keyboard, pointer, and multi-touch through Pointer Events onto InputState.done
@g2w/input-gamepadGamepad API adapter with an injectable polling source; the host drives poll() once per frame.done
@g2w/audio-webWeb Audio backend: decodes sound files, starts playbacks, owns the AudioContext lifecycle.done
@g2w/devtoolsRead-only dev overlay: scene explorer, transforms, FPS, watched input, runtime logs. Dev-only.done
create-g2wZero-dependency CLI that scaffolds a TypeScript + Vite game project from a bundled template.done
@g2w/renderer-threePlanned 3D rendering adapter proving the renderer contract generalizes.planned

@g2w/core — the contract layer

Everything renderer-agnostic lives here, and it has zero runtime dependencies — it never imports a rendering technology and never touches browser globals or DOM events at runtime. Inside you find theGame state machine and frame loop, the renderer contract andSceneManager, the DOM-free InputState /GamepadState, the generic AssetManager, theTransform2D/Sprite2D/Anchor2D model, the GameObject layer, and the AudioManagercontract.

@g2w/runtime — the Effect layer

The primary application path. One managed Effect runtime orchestrates the core Game lifecycle as G2WGame: renderer init as a lifecycle effect, ownership as LIFO finalizers, idempotent disposal, and best-effort cleanup whose failures stay observable. The frame hot path never allocates an Effect runtime, effect, or promise — the per-frame update is a plain synchronous call. Core's Game ships side by side as the reference implementation and stays Effect-free.

Adapters — browser concerns live at the edge

Each adapter implements one core contract and may depend only on@g2w/core (plus its technology, for the renderer):

@g2w/renderer-pixi adapts PixiJS 8 and adds texture loading plus createSpriteView.@g2w/input-dom and @g2w/input-gamepad feed normalized events and sampled state into core.@g2w/audio-web implements the audio backend on Web Audio.@g2w/devtools observes through immutable snapshots and never mutates the runtime.

create-g2w — a developer tool, not a runtime

A zero-dependency Node CLI (Node ≥ 22) that scaffolds a game from its bundled template. It imports nothing from g2w, never prompts, and its only subprocess is a local git init. SeeInstallation.

Publishing status

StatusNo package is published to npm yet (Roadmap R10). The monorepo validates release readiness with packability checks and a release rehearsal that publishes nothing; the release itself is gated behind a manual workflow dispatch. Until then, consume packages from packed tarballs.

Next steps

Read the game lifecycle states, or thearchitecture notes for the boundary rules each test enforces.