Live location tracking and playback for the game "manhunt"

Seperate type export binary

bwc9876.dev 95d629f1 729d4947

verified
+51 -11
+14
TODO.md
··· 1 + # TODO 2 + 3 + ## Ben 4 + 5 + - [ ] Transport : Packet splitting 6 + - [ ] State : Event history tracking 7 + - [ ] State : Post game sync 8 + - [ ] API : Handling Profile Syncing 9 + - [ ] ALL : State Update Events 10 + - [ ] ALL : Game Replay Screen 11 + - [ ] Frontend : Scaffolding 12 + - [ ] Meta : CI Setup 13 + - [ ] Meta : README Instructions 14 + - [x] Meta : Recipes for type binding generation
+4
backend/Cargo.toml
··· 9 9 name = "manhunt_app_lib" 10 10 crate-type = ["staticlib", "cdylib", "rlib"] 11 11 12 + [[bin]] 13 + name = "export-types" 14 + path = "src/export_types.rs" 15 + 12 16 [build-dependencies] 13 17 tauri-build = { version = "2", features = [] } 14 18
+20
backend/src/export_types.rs
··· 1 + use std::path::PathBuf; 2 + 3 + use manhunt_app_lib::mk_specta; 4 + use specta_typescript::Typescript; 5 + 6 + pub fn main() { 7 + let args = std::env::args().collect::<Vec<_>>(); 8 + let path = args.get(1).expect("Usage: export-types path"); 9 + let path = PathBuf::from(path) 10 + .canonicalize() 11 + .expect("Failed to canonicalize path"); 12 + let specta = mk_specta(); 13 + specta 14 + .export(Typescript::default(), &path) 15 + .expect("Failed to export types"); 16 + println!( 17 + "Successfully exported type and commands to {}", 18 + path.to_str().unwrap() 19 + ); 20 + }
+9 -11
backend/src/lib.rs
··· 11 11 use location::TauriLocation; 12 12 use profile::PlayerProfile; 13 13 use serde::{Deserialize, Serialize}; 14 - use specta_typescript::Typescript; 15 14 use tauri::{AppHandle, Manager, State}; 16 15 use tauri_specta::collect_commands; 17 16 use tokio::sync::RwLock; ··· 282 281 } 283 282 } 284 283 285 - #[cfg_attr(mobile, tauri::mobile_entry_point)] 286 - pub fn run() { 287 - let state = RwLock::new(AppState::Setup); 288 - 289 - let builder = tauri_specta::Builder::<tauri::Wry>::new().commands(collect_commands![ 284 + pub fn mk_specta() -> tauri_specta::Builder { 285 + tauri_specta::Builder::<tauri::Wry>::new().commands(collect_commands![ 290 286 start_lobby, 291 287 quit_game_or_lobby, 292 288 get_current_screen, ··· 298 294 mark_caught, 299 295 grab_powerup, 300 296 use_powerup, 301 - ]); 297 + ]) 298 + } 302 299 303 - #[cfg(debug_assertions)] 304 - builder 305 - .export(Typescript::default(), "../frontend/src/bindings.ts") 306 - .expect("Failed to export typescript bindings"); 300 + #[cfg_attr(mobile, tauri::mobile_entry_point)] 301 + pub fn run() { 302 + let state = RwLock::new(AppState::Setup); 303 + 304 + let builder = mk_specta(); 307 305 308 306 tauri::Builder::default() 309 307 .manage(state)
+4
justfile
··· 26 26 cargo *CMD: 27 27 nix develop --command cargo {{CMD}} 28 28 29 + # Export types from the backend to TypeScript bindings 30 + [working-directory: 'backend'] 31 + export-types: 32 + nix develop --command cargo run --bin export-types ../frontend/src/bindings.ts 29 33 30 34