From 98fac2177df21a39a0950d48b248e1b12013f7f0 Mon Sep 17 00:00:00 2001 From: hosted-fornet Date: Wed, 24 Sep 2025 15:23:22 -0700 Subject: [PATCH] add optional ui_path field --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/lib.rs | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fe0f162..ad4364c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1628,7 +1628,7 @@ dependencies = [ [[package]] name = "hyperware_process_lib" version = "2.2.0" -source = "git+https://github.com/hyperware-ai/process_lib?rev=a16d47a#a16d47a2bfae7864e97d70a3914829b4e54a4033" +source = "git+https://github.com/hyperware-ai/process_lib?rev=232fe25#232fe2526f383c88efc2ef3a289deba2e193d68f" dependencies = [ "alloy", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index f8ea4d7..00f63a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,4 +11,4 @@ proc-macro2 = "1.0" quote = "1.0" syn = { version = "2.0", features = ["full", "extra-traits"] } -hyperware_process_lib = { git = "https://github.com/hyperware-ai/process_lib", features = ["hyperapp"], rev = "b9f1ead" } +hyperware_process_lib = { git = "https://github.com/hyperware-ai/process_lib", features = ["hyperapp"], rev = "232fe25" } diff --git a/src/lib.rs b/src/lib.rs index 2970aff..601ff40 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,6 +16,7 @@ mod kw { syn::custom_keyword!(icon); syn::custom_keyword!(widget); syn::custom_keyword!(ui); + syn::custom_keyword!(ui_path); syn::custom_keyword!(endpoints); syn::custom_keyword!(save_config); syn::custom_keyword!(wit_world); @@ -30,6 +31,7 @@ struct HyperProcessArgs { icon: Option, widget: Option, ui: Option, + ui_path: Option, endpoints: Expr, save_config: Expr, wit_world: String, @@ -396,6 +398,7 @@ fn parse_args(attr_args: MetaList) -> syn::Result { let mut icon = None; let mut widget = None; let mut ui = None; + let mut ui_path = None; let mut endpoints = None; let mut save_config = None; let mut wit_world = None; @@ -421,6 +424,9 @@ fn parse_args(attr_args: MetaList) -> syn::Result { "ui" => { ui = parse_ui_expr(&nv.value)?; } + "ui_path" => { + ui_path = Some(parse_string_literal(&nv.value, nv.value.span())?); + } "endpoints" => endpoints = Some(nv.value.clone()), "save_config" => save_config = Some(nv.value.clone()), "wit_world" => { @@ -438,6 +444,7 @@ fn parse_args(attr_args: MetaList) -> syn::Result { icon, widget, ui, + ui_path, endpoints: endpoints.ok_or_else(|| syn::Error::new(span, "Missing 'endpoints'"))?, save_config: save_config.ok_or_else(|| syn::Error::new(span, "Missing 'save_config'"))?, wit_world: wit_world.ok_or_else(|| syn::Error::new(span, "Missing 'wit_world'"))?, @@ -2078,6 +2085,11 @@ fn generate_component_impl( None => quote! { None }, }; + let ui_path = match &args.ui_path { + Some(path_str) => quote! { Some(#path_str.to_string()) }, + None => quote! { None }, + }; + let init_method_ident = &init_method_details.identifier; let init_method_call = &init_method_details.call; let ws_method_call = &ws_method_details.call; @@ -2147,6 +2159,7 @@ fn generate_component_impl( let app_icon = #icon; let app_widget = #widget; let ui_config = #ui; + let ui_path = #ui_path; let endpoints = #endpoints; // Setup UI if needed @@ -2157,7 +2170,7 @@ fn generate_component_impl( #logging_init // Setup server with endpoints - let mut server = hyperware_process_lib::hyperapp::setup_server(ui_config.as_ref(), &endpoints); + let mut server = hyperware_process_lib::hyperapp::setup_server(ui_config.as_ref(), ui_path, &endpoints); hyperware_process_lib::hyperapp::APP_HELPERS.with(|ctx| { ctx.borrow_mut().current_server = Some(&mut server); });