diff --git a/Cargo.toml b/Cargo.toml index bc4e879..9235fbe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,5 @@ panic = "abort" [workspace] members = [ "skeleton-app", - "target/caller-utils", ] -resolver = "2" \ No newline at end of file +resolver = "2" diff --git a/skeleton-app/Cargo.toml b/skeleton-app/Cargo.toml index 08f3089..e19d727 100644 --- a/skeleton-app/Cargo.toml +++ b/skeleton-app/Cargo.toml @@ -12,6 +12,7 @@ package = "hyperware:process" [dependencies] # Core dependencies for Hyperware apps anyhow = "1.0" +hyperware_process_lib = { git = "https://github.com/hyperware-ai/process_lib", features = ["hyperapp"], rev = "d67b65e" } process_macros = "0.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" @@ -20,12 +21,7 @@ wit-bindgen = "0.42.1" # IMPORTANT: hyperprocess_macro provides async support and WIT generation [dependencies.hyperprocess_macro] git = "https://github.com/hyperware-ai/hyperprocess-macro" -rev = "f1cd5bb" - -# Common utilities for Hyperware apps -[dependencies.hyperware_app_common] -git = "https://github.com/hyperware-ai/hyperprocess-macro" -rev = "f1cd5bb" +rev = "66884c0" # Optional dependencies you might need: # uuid = { version = "1.4.1", features = ["v4", "serde"] } diff --git a/skeleton-app/src/lib.rs b/skeleton-app/src/lib.rs index ac60142..3fd8dae 100644 --- a/skeleton-app/src/lib.rs +++ b/skeleton-app/src/lib.rs @@ -8,7 +8,7 @@ // - Automatic WIT (WebAssembly Interface Types) generation // - State persistence // - HTTP/WebSocket bindings -use hyperprocess_macro::*; +use hyperprocess_macro::hyperprocess; // HYPERWARE PROCESS LIB IMPORTS // These are provided by the hyperprocess_macro, DO NOT add hyperware_process_lib to Cargo.toml @@ -36,24 +36,24 @@ pub struct AppState { #[hyperprocess( // App name shown in the UI and logs name = "Skeleton App", - + // Enable UI serving at root path ui = Some(HttpBindingConfig::default()), - + // HTTP API endpoints - MUST include /api for frontend communication endpoints = vec![ - Binding::Http { - path: "/api", - config: HttpBindingConfig::new(false, false, false, None) + Binding::Http { + path: "/api", + config: HttpBindingConfig::new(false, false, false, None) } ], - + // State persistence options: // - EveryMessage: Save after each message (safest, slower) // - OnInterval(n): Save every n seconds // - Never: No automatic saves (manual only) save_config = SaveOptions::EveryMessage, - + // WIT world name - must match package naming convention wit_world = "skeleton-app-dot-os-v0" )] @@ -69,16 +69,16 @@ impl AppState { // Add your app to the Hyperware homepage // Parameters: name, icon (emoji), path, widget add_to_homepage("Skeleton App", Some("ðŸĶī"), Some("/"), None); - + // Initialize your app state self.counter = 0; self.messages.push("App initialized!".to_string()); - + // Get our node identity (useful for P2P apps) let our_node = our().node.clone(); println!("Skeleton app initialized on node: {}", our_node); } - + // HTTP ENDPOINT EXAMPLE // CRITICAL: ALL HTTP endpoints MUST accept _request_body parameter // even if they don't use it. This is a framework requirement. @@ -91,7 +91,7 @@ impl AppState { "node": our().node }).to_string() } - + // HTTP ENDPOINT WITH PARAMETERS // Frontend sends parameters as either: // - Single value: { "MethodName": value } @@ -103,20 +103,20 @@ impl AppState { Ok(val) => val, Err(_) => 1, // Default increment }; - + self.counter += amount; self.messages.push(format!("Counter incremented by {}", amount)); - + Ok(self.counter) } - + // HTTP ENDPOINT RETURNING COMPLEX DATA // For complex types, return as JSON string to avoid WIT limitations #[http] async fn get_messages(&self, _request_body: String) -> String { serde_json::to_string(&self.messages).unwrap_or_else(|_| "[]".to_string()) } - + } @@ -125,12 +125,12 @@ impl AppState { // Supported types: // ✅ Primitives: bool, u8-u64, i8-i64, f32, f64, String // ✅ Vec where T is supported -// ✅ Option where T is supported +// ✅ Option where T is supported // ✅ Simple structs with public fields // ❌ HashMap - use Vec<(K,V)> instead // ❌ Fixed arrays [T; N] - use Vec // ❌ Complex enums with data -// +// // Workaround: Return complex data as JSON strings // COMMON PATTERNS: @@ -175,4 +175,4 @@ impl AppState { // * Missing _request_body parameter // * Wrong parameter format (object vs tuple) // * ProcessId parsing errors -// * Missing /our.js in HTML \ No newline at end of file +// * Missing /our.js in HTML