Skip to content

Conversation

@rysb-dev
Copy link
Owner

Add interactive web frontend with WASM bindings

Introduce a complete web-based Riichi Mahjong calculator powered by WebAssembly, enabling client-side scoring calculations in the browser.

Project Structure Changes

  • Migrate to Cargo workspace with two crates:
    • agari-core: Core library (moved from src/)
    • agari-wasm: WebAssembly bindings using wasm-bindgen
  • Add build script for WASM compilation (scripts/build-web.sh)
  • Add GitHub Actions workflow for automatic deployment to GitHub Pages

WASM Bindings (crates/agari-wasm)

  • Expose scoring, shanten, ukeire, and yaku detection APIs
  • Serialize/deserialize game context from JavaScript
  • Support full hand notation parsing with aka-dora
  • Provide detailed scoring breakdown (han, fu, payment, yaku list)

Web Frontend (web/)

  • Built with Svelte 5, Vite, TypeScript, and Tailwind CSS 4
  • Interactive tile selection with visual palette
  • Real-time shanten calculation as hand is built
  • Complete scoring display with yaku breakdown and fu details
  • SVG-rendered mahjong tiles with smooth animations
  • Responsive design for desktop and mobile
  • Game context options (riichi, tsumo, dora, winds, etc.)

Components

Component Description
Tile.svelte SVG tile renderer for all tile types
TilePalette.svelte Clickable tile selection grid
HandDisplay.svelte Visual hand representation
ContextOptions.svelte Game situation configuration
ScoreResult.svelte Detailed scoring output

Deployment

Once merged, the site will be automatically deployed to https://ryblogs.github.io/agari/

This commit adds a Svelte-based web frontend that uses the Agari
scoring engine via WebAssembly. The project has been restructured
as a Cargo workspace to support multiple crates.

Changes:
- Restructure as Cargo workspace with crates/agari-core and crates/agari-wasm
- Add serde Serialize/Deserialize to core types for JS interop
- Create agari-wasm crate with wasm-bindgen bindings
- Build Svelte 5 frontend with:
  - Interactive tile palette with SVG tiles
  - Real-time shanten calculation as you build hands
  - Complete game context options (winds, riichi, situational yaku)
  - Full scoring results with yaku, fu breakdown, and payment
  - Responsive design with Tailwind CSS
- Add build script for WASM and web frontend

The CLI remains fully functional and unchanged from a user perspective.
Introduce a complete web-based Riichi Mahjong calculator powered by
WebAssembly, enabling client-side scoring calculations in the browser.

- Migrate to Cargo workspace with two crates:
  - `agari-core`: Core library (moved from src/)
  - `agari-wasm`: WebAssembly bindings using wasm-bindgen
- Add build script for WASM compilation (scripts/build-web.sh)

- Expose scoring, shanten, ukeire, and yaku detection APIs
- Serialize/deserialize game context from JavaScript
- Support full hand notation parsing with aka-dora
- Provide detailed scoring breakdown (han, fu, payment, yaku list)

- Built with Svelte 5, Vite, TypeScript, and Tailwind CSS 4
- Interactive tile selection with visual palette
- Real-time shanten calculation as hand is built
- Complete scoring display with yaku breakdown and fu details
- SVG-rendered mahjong tiles with smooth animations
- Responsive design for desktop and mobile
- Game context options (riichi, tsumo, dora, winds, etc.)

- Tile.svelte: SVG tile renderer for all tile types
- TilePalette.svelte: Clickable tile selection grid
- HandDisplay.svelte: Visual hand representation
- ContextOptions.svelte: Game situation configuration
- ScoreResult.svelte: Detailed scoring output

- Add serde Serialize/Deserialize derives for WASM interop
- Minor refactoring to support workspace structure
@rysb-dev rysb-dev self-assigned this Jan 30, 2026
@rysb-dev rysb-dev merged commit 718e225 into main Jan 30, 2026
7 of 8 checks passed
@rysb-dev rysb-dev deleted the web-frontend branch January 30, 2026 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant