gsnake-web is an npm workspace monorepo with two packages:
packages/gsnake-web-ui- shared styles, sprites, and baseModal/Overlaycomponentspackages/gsnake-web-app- the playable web game
The game package depends on gsnake-wasm and auto-detects whether it should use local root-repo WASM artifacts or vendored standalone artifacts.
gsnake-web/
├── package.json
├── scripts/
│ ├── detect-local-deps.js
│ ├── build-wasm.js
│ └── validate-sprites.js
└── packages/
├── gsnake-web-ui/
│ ├── assets/sprites.svg
│ ├── styles/app.css
│ ├── components/{Modal,Overlay}.svelte
│ └── dist/{Modal,Overlay}.js
└── gsnake-web-app/
npm installpreinstall runs scripts/detect-local-deps.js, which configures gsnake-wasm for one of these modes:
- Root repository mode:
file:../../../gsnake-core/engine/bindings/wasm/pkg - Standalone mode:
file:../../vendor/gsnake-wasm
npm run dev # watches gsnake-web-ui + starts gsnake-web-app Vite dev server
npm run build # builds gsnake-web-ui then gsnake-web-app
npm run check # svelte-check for gsnake-web-app
npm test # vitest for gsnake-web-app
npm run coverage # coverage for gsnake-web-app
npm run preview # preview gsnake-web-app buildGET http://localhost:3000/health returns plain text:
gsnake-web:ok
gsnake-web-ui build runs scripts/validate-sprites.js first.
Validation is bidirectional:
- every
CellTypeinpackages/gsnake-web-app/types/models.tsmust have a matching<symbol id="...">inpackages/gsnake-web-ui/assets/sprites.svg - no orphan sprite symbols are allowed
If either condition fails, build exits non-zero.
packages/gsnake-web-app/engine/frame-emission.md is the authoritative guide for WasmGameEngine startup/reset frame emission.
When modifying WasmGameEngine load/reset paths, keep the documented sequence intact (levelChanged then explicit getFrame() -> frameChanged) and update related regression tests.
- Edit
packages/gsnake-web-ui/styles/app.css,assets/sprites.svg, orcomponents/*. - Run
npm run devingsnake-webfor watch + app reload. - Validate changes in both the game app and editor (when working in root repo mode).
- Run
npm run buildbefore pushing.
gsnake-web-ui is intentionally consumed as latest main in standalone editor CI. Breaking changes are allowed, but they can break gsnake-editor until editor compatibility updates are merged.
.github/workflows/ci.ymlvalidates standalone mode (FORCE_GIT_DEPS=1).github/workflows/test.ymlvalidates root-repo mode with localgsnake-core