Hot reload, storage & builds
Hot reload
Section titled “Hot reload”vgai hot-reloads GameComponent code while the game runs, preserving live state. Two
paths share the same engine mechanism:
- Server HMR (
npm run dev) — Vite transpiles, then the edit is applied viacomponents.hotSwap()/session.hotReload(). - In-browser transpile (
packages/editor/src/browser-transpile.ts) —esbuild-wasmtranspiles TS/TSX in a Web Worker, and bare imports of the registered runtime modules —three,gsap, and@engine/ecs/game-component— are rewritten to blob-URL shims that re-export the live, already-running singletons (registerRuntimeModulesinplay-mode.ts). So the swapped class shares the sameTHREEand extends the sameGameComponentas the running runtime; an import of an unregistered module throws rather than loading a second copy.
State survives because the prototype is swapped, not the instance.
Storage backends & the browser-first editor
Section titled “Storage backends & the browser-first editor”The editor reads/writes through a StorageBackend (packages/editor/src/storage/): Opfs
(browser OPFS), Fsa (File System Access API — a real on-disk folder), Mem (tests), and
Http (the server-first /__editor/* backend). Selecting OPFS/FSA gives a browser-first,
server-less editor — npm run build:web produces a static editor that needs no Node.
Validation & generation
Section titled “Validation & generation”| Command | Does |
|---|---|
npm run validate-scenes | validate .vscn.json against the component registry |
npm run generate-schema | Zod → JSON Schema (.vscn/.prefab) |
npm run generate-engine-manifest | engine-api.json/.md (phases + GameComponent) |
Building & publishing
Section titled “Building & publishing”- Web (shipped):
npm run build:webproduces a static bundle zipped tovgai-web.zip(itch.io-ready). The in-editor Build panel (/__editor/export) runs this for you.
See also
Section titled “See also”- CLI, SDK & scaffolding · Hot reload concept in the runtime
- Editor: build & export — the in-editor Build panel.