From c84bd93482e0cdd1e891f0530e45a94a44ae5700 Mon Sep 17 00:00:00 2001 From: Doug Anderson444 Date: Sun, 23 Jun 2024 09:31:09 -0300 Subject: [PATCH] bump wurbo to v0.4.1 --- crates/delano-wit-ui/Cargo.toml | 2 +- crates/delano-wit-ui/src/api.rs | 35 ++--- crates/delano-wit-ui/src/attributes.rs | 38 ++--- crates/delano-wit-ui/src/bindings.rs | 197 +++++++++++++++++-------- crates/delano-wit-ui/src/credential.rs | 21 +-- crates/delano-wit-ui/src/lib.rs | 19 +-- crates/delano-wit-ui/src/output.rs | 11 +- crates/delano-wit-ui/src/page.rs | 21 +-- crates/delano-wit-ui/wit/world.wit | 3 + 9 files changed, 193 insertions(+), 154 deletions(-) diff --git a/crates/delano-wit-ui/Cargo.toml b/crates/delano-wit-ui/Cargo.toml index 3e61aff..042f2cf 100644 --- a/crates/delano-wit-ui/Cargo.toml +++ b/crates/delano-wit-ui/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -wurbo = { version = "0.1.9" } +wurbo = { version = "0.4.1" } base64ct = { version = "1.6.0", features = ["alloc"] } chrono = "0.4.33" ciborium = "0.2.2" diff --git a/crates/delano-wit-ui/src/api.rs b/crates/delano-wit-ui/src/api.rs index 94fa754..95b2b18 100644 --- a/crates/delano-wit-ui/src/api.rs +++ b/crates/delano-wit-ui/src/api.rs @@ -309,12 +309,12 @@ fn subscribe_to_topic(key: impl ToString) { wurbo_in::emit(&message); } -impl StructObject for State { +impl Object for State { /// Remember to add match arms for any new fields. - fn get_field(&self, name: &str) -> Option { + fn get_value(self: &Arc, key: &Value) -> Option { // TODO: Show issues/errors as error variant? // if offer or proof have messages, show them? - match name { + match key.as_str()? { "id" => Some(Value::from(rand_id())), "loaded" => Some(Value::from(self.loaded.clone())), "credential" => Some(Value::from(self.builder.clone())), @@ -329,14 +329,10 @@ impl StructObject for State { }, None => Some(Value::from("Click to generate a proof.")), }, - "history" => Some(Value::from_serializable(&self.history.clone())), + "history" => Some(Value::from_serialize(&self.history.clone())), _ => None, } } - /// So that debug will show the values - fn static_fields(&self) -> Option<&'static [&'static str]> { - Some(&["id", "loaded", "credential", "offer", "proof"]) - } } impl From for State { @@ -442,12 +438,11 @@ impl Loaded { } } -impl StructObject for Loaded { - /// Remember to add match arms for any new fields. - fn get_field(&self, name: &str) -> Option { - match name { +impl Object for Loaded { + fn get_value(self: &Arc, key: &Value) -> Option { + match key.as_str()? { "id" => Some(Value::from(rand_id())), - "context" => match self { + "context" => match **self { // Offer is the only Loaded context that can be edited Self::Offer { .. } => { // We do this so we get the exact name of the context, any changes @@ -464,13 +459,13 @@ impl StructObject for Loaded { } _ => None, }, - "hints" => match self { - Self::Offer { hints, .. } => Some(Value::from(hints.clone())), + "hints" => match **self { + Self::Offer { ref hints, .. } => Some(Value::from(hints.clone())), _ => None, }, - "preimages" => match self { + "preimages" => match **self { Self::Proof(Provables:: { - selected_preimages: preimages, + selected_preimages: ref preimages, .. }) => { let de_preimages: Vec> = preimages @@ -494,15 +489,11 @@ impl StructObject for Loaded { _ => None, } } - /// So that debug will show the values - fn static_fields(&self) -> Option<&'static [&'static str]> { - Some(&["context", "hints", "preimages", "verified"]) - } } impl From for wurbo::prelude::Value { fn from(loaded: Loaded) -> Self { - Value::from_struct_object(loaded) + Value::from_object(loaded) } } diff --git a/crates/delano-wit-ui/src/attributes.rs b/crates/delano-wit-ui/src/attributes.rs index 58ea201..bf0c154 100644 --- a/crates/delano-wit-ui/src/attributes.rs +++ b/crates/delano-wit-ui/src/attributes.rs @@ -40,17 +40,13 @@ impl Operator { } } -impl StructObject for Operator { - fn get_field(&self, name: &str) -> Option { - match name { +impl Object for Operator { + fn get_value(self: &Arc, key: &Value) -> Option { + match key.as_str()? { "value" => Some(Value::from(self.value())), _ => None, } } - /// So that debug will show the values - fn static_fields(&self) -> Option<&'static [&'static str]> { - Some(&["value"]) - } } impl ToString for Operator { @@ -74,7 +70,7 @@ impl TryFrom for Operator { impl From for wurbo::prelude::Value { fn from(operator: Operator) -> Self { - Self::from_struct_object(operator) + Self::from_object(operator) } } @@ -152,20 +148,16 @@ impl AttributeKOV { } } -impl StructObject for AttributeKOV { - fn get_field(&self, name: &str) -> Option { - match name { +impl Object for AttributeKOV { + fn get_value(self: &Arc, key: &Value) -> Option { + match key.as_str()? { "key" => Some(Value::from(self.key.deref().clone())), - "op" => Some(Value::from(self.op.get_field("value").unwrap())), + "op" => Some(Value::from(self.op.value())), "value" => Some(Value::from(self.value.deref().clone())), "selected" => Some(Value::from(self.selected)), _ => None, } } - /// So that debug will show the values - fn static_fields(&self) -> Option<&'static [&'static str]> { - Some(&["key", "op", "value", "selected"]) - } } impl ToString for AttributeKOV { @@ -189,7 +181,7 @@ impl From for Vec> { impl From for wurbo::prelude::Value { fn from(attribute: AttributeKOV) -> Self { - Self::from_struct_object(attribute) + Self::from_object(attribute) } } @@ -230,18 +222,14 @@ impl Hint { } } -impl StructObject for Hint { - fn get_field(&self, name: &str) -> Option { - match name { +impl Object for Hint { + fn get_value(self: &Arc, key: &Value) -> Option { + match key.as_str()? { "key" => Some(Value::from(self.key.deref().clone())), "op" => Some(Value::from(self.op.clone())), _ => None, } } - /// So that debug will show the values - fn static_fields(&self) -> Option<&'static [&'static str]> { - Some(&["key", "op"]) - } } impl ToString for Hint { @@ -281,6 +269,6 @@ impl From for AttributeKOV { impl From for wurbo::prelude::Value { fn from(hint: Hint) -> Self { - Self::from_struct_object(hint) + Self::from_object(hint) } } diff --git a/crates/delano-wit-ui/src/bindings.rs b/crates/delano-wit-ui/src/bindings.rs index 7e58dfd..91952d9 100644 --- a/crates/delano-wit-ui/src/bindings.rs +++ b/crates/delano-wit-ui/src/bindings.rs @@ -3721,6 +3721,65 @@ pub mod exports { super::super::super::super::delano::wit_ui::context_types::Context; #[doc(hidden)] #[allow(non_snake_case)] + pub unsafe fn _export_customize_cabi( + arg0: *mut u8, + arg1: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let base6 = arg0; + let len6 = arg1; + let mut result6 = _rt::Vec::with_capacity(len6); + for i in 0..len6 { + let base = base6.add(i * 16); + let e6 = { + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + let len2 = l1; + let bytes2 = _rt::Vec::from_raw_parts(l0.cast(), len2, len2); + let l3 = *base.add(8).cast::<*mut u8>(); + let l4 = *base.add(12).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + (_rt::string_lift(bytes2), _rt::string_lift(bytes5)) + }; + result6.push(e6); + } + _rt::cabi_dealloc(base6, len6 * 16, 4); + let result7 = T::customize(result6); + let ptr8 = _RET_AREA.0.as_mut_ptr().cast::(); + match result7 { + Ok(_) => { + *ptr8.add(0).cast::() = (0i32) as u8; + } + Err(e) => { + *ptr8.add(0).cast::() = (1i32) as u8; + let vec9 = (e.into_bytes()).into_boxed_slice(); + let ptr9 = vec9.as_ptr().cast::(); + let len9 = vec9.len(); + ::core::mem::forget(vec9); + *ptr8.add(8).cast::() = len9; + *ptr8.add(4).cast::<*mut u8>() = ptr9.cast_mut(); + } + }; + ptr8 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_customize(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } + } + #[doc(hidden)] + #[allow(non_snake_case)] pub unsafe fn _export_render_cabi( arg0: i32, arg1: *mut u8, @@ -3740,41 +3799,41 @@ pub mod exports { let v9 = match arg0 { 0 => { let e9 = super::super::super::super::delano::wit_ui::context_types::Everything{ - page: match arg1 as i32 { - 0 => None, - 1 => { - let e = { - let len0 = arg3 as usize; - let bytes0 = _rt::Vec::from_raw_parts(arg2.cast(), len0, len0); - let len1 = arg5 as usize; - let bytes1 = _rt::Vec::from_raw_parts(arg4.cast(), len1, len1); - let len2 = arg7; - let bytes2 = _rt::Vec::from_raw_parts(arg6.cast(), len2, len2); + page: match arg1 as i32 { + 0 => None, + 1 => { + let e = { + let len0 = arg3 as usize; + let bytes0 = _rt::Vec::from_raw_parts(arg2.cast(), len0, len0); + let len1 = arg5 as usize; + let bytes1 = _rt::Vec::from_raw_parts(arg4.cast(), len1, len1); + let len2 = arg7; + let bytes2 = _rt::Vec::from_raw_parts(arg6.cast(), len2, len2); - super::super::super::super::delano::wit_ui::context_types::Page{ - name: _rt::string_lift(bytes0), - version: _rt::string_lift(bytes1), - description: _rt::string_lift(bytes2), - } - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - load: match arg8 { - 0 => None, - 1 => { - let e = { - let len3 = arg10; - let bytes3 = _rt::Vec::from_raw_parts(arg9.cast(), len3, len3); + super::super::super::super::delano::wit_ui::context_types::Page{ + name: _rt::string_lift(bytes0), + version: _rt::string_lift(bytes1), + description: _rt::string_lift(bytes2), + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + load: match arg8 { + 0 => None, + 1 => { + let e = { + let len3 = arg10; + let bytes3 = _rt::Vec::from_raw_parts(arg9.cast(), len3, len3); - _rt::string_lift(bytes3) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - }; + _rt::string_lift(bytes3) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + }; V9::AllContent(e9) } 1 => V9::Addattribute, @@ -3805,12 +3864,12 @@ pub mod exports { let bytes5 = _rt::Vec::from_raw_parts(arg4.cast(), len5, len5); super::super::super::super::delano::wit_ui::context_types::Kvctx{ - ctx: super::super::super::super::delano::wit_ui::context_types::Entry{ - idx: arg1 as i32 as u32, - val: v4, - }, - value: _rt::string_lift(bytes5), - } + ctx: super::super::super::super::delano::wit_ui::context_types::Entry{ + idx: arg1 as i32 as u32, + val: v4, + }, + value: _rt::string_lift(bytes5), + } }; V9::Editattribute(e9) } @@ -3919,6 +3978,10 @@ pub mod exports { }); } pub trait Guest { + /// Optionally customize the configuration of the templates used to render the component + fn customize( + templates: _rt::Vec<(_rt::String, _rt::String)>, + ) -> Result<(), _rt::String>; /// renders the initial Web component with the given data /// and the target template to use as top level entry point fn render(ctx: Context) -> Result<_rt::String, _rt::String>; @@ -3928,22 +3991,30 @@ pub mod exports { #[doc(hidden)] macro_rules! __export_delano_wit_ui_wurbo_out_0_1_0_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - #[export_name = "delano:wit-ui/wurbo-out@0.1.0#render"] - unsafe extern "C" fn export_render(arg0: i32,arg1: *mut u8,arg2: *mut u8,arg3: *mut u8,arg4: *mut u8,arg5: *mut u8,arg6: *mut u8,arg7: usize,arg8: i32,arg9: *mut u8,arg10: usize,) -> *mut u8 { - $($path_to_types)*::_export_render_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) - } - #[export_name = "cabi_post_delano:wit-ui/wurbo-out@0.1.0#render"] - unsafe extern "C" fn _post_return_render(arg0: *mut u8,) { - $($path_to_types)*::__post_return_render::<$ty>(arg0) - } - #[export_name = "delano:wit-ui/wurbo-out@0.1.0#activate"] - unsafe extern "C" fn export_activate(arg0: i32,arg1: *mut u8,arg2: usize,) { - $($path_to_types)*::_export_activate_cabi::<$ty>(arg0, arg1, arg2) - } - };); - } + #[export_name = "delano:wit-ui/wurbo-out@0.1.0#customize"] + unsafe extern "C" fn export_customize(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_customize_cabi::<$ty>(arg0, arg1) + } + #[export_name = "cabi_post_delano:wit-ui/wurbo-out@0.1.0#customize"] + unsafe extern "C" fn _post_return_customize(arg0: *mut u8,) { + $($path_to_types)*::__post_return_customize::<$ty>(arg0) + } + #[export_name = "delano:wit-ui/wurbo-out@0.1.0#render"] + unsafe extern "C" fn export_render(arg0: i32,arg1: *mut u8,arg2: *mut u8,arg3: *mut u8,arg4: *mut u8,arg5: *mut u8,arg6: *mut u8,arg7: usize,arg8: i32,arg9: *mut u8,arg10: usize,) -> *mut u8 { + $($path_to_types)*::_export_render_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) + } + #[export_name = "cabi_post_delano:wit-ui/wurbo-out@0.1.0#render"] + unsafe extern "C" fn _post_return_render(arg0: *mut u8,) { + $($path_to_types)*::__post_return_render::<$ty>(arg0) + } + #[export_name = "delano:wit-ui/wurbo-out@0.1.0#activate"] + unsafe extern "C" fn export_activate(arg0: i32,arg1: *mut u8,arg2: usize,) { + $($path_to_types)*::_export_activate_cabi::<$ty>(arg0, arg1, arg2) + } + };); + } #[doc(hidden)] pub(crate) use __export_delano_wit_ui_wurbo_out_0_1_0_cabi; #[repr(align(4))] @@ -4098,8 +4169,8 @@ pub(crate) use __export_delanocreds_wit_ui_impl as export; #[cfg(target_arch = "wasm32")] #[link_section = "component-type:wit-bindgen:0.25.0:delanocreds-wit-ui:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 2794] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xe1\x14\x01A\x02\x01\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 2837] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x8c\x15\x01A\x02\x01\ A\x19\x01B5\x01p}\x04\0\x09attribute\x03\0\0\x01p\x01\x04\0\x05entry\x03\0\x02\x01\ p}\x04\0\x05nonce\x03\0\x04\x01p}\x04\0\x05proof\x03\0\x06\x01p\x03\x04\0\x08sel\ ected\x03\0\x08\x01p\x03\x01p\x01\x01r\x02\x07entries\x0a\x06remove\x0b\x04\0\x0b\ @@ -4155,12 +4226,14 @@ ers\x05topics\x04data\x0e\x04\0\x07message\x03\0\x0f\x01q\x09\x0ball-content\x01 \x05\0\x0caddattribute\0\0\x08newentry\0\0\x0deditattribute\x01\x0d\0\x0eeditmax\ entries\x01}\0\x0dgenerateoffer\0\0\x0dgenerateproof\0\0\x0cpublishproof\0\0\x0c\ networkevent\x01\x10\0\x04\0\x07context\x03\0\x11\x03\x01!delano:wit-ui/context-\ -types@0.1.0\x05\x10\x02\x03\0\x04\x07context\x01B\x09\x02\x03\x02\x01\x11\x04\0\x07\ -context\x03\0\0\x01j\x01s\x01s\x01@\x01\x03ctx\x01\0\x02\x04\0\x06render\x01\x03\ -\x01ps\x01k\x04\x01@\x01\x09selectors\x05\x01\0\x04\0\x08activate\x01\x06\x04\x01\ -\x1ddelano:wit-ui/wurbo-out@0.1.0\x05\x12\x04\x01&delano:wit-ui/delanocreds-wit-\ -ui@0.1.0\x04\0\x0b\x18\x01\0\x12delanocreds-wit-ui\x03\0\0\0G\x09producers\x01\x0c\ -processed-by\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; +types@0.1.0\x05\x10\x02\x03\0\x04\x07context\x01B\x0e\x02\x03\x02\x01\x11\x04\0\x07\ +context\x03\0\0\x01o\x02ss\x01p\x02\x01j\0\x01s\x01@\x01\x09templates\x03\0\x04\x04\ +\0\x09customize\x01\x05\x01j\x01s\x01s\x01@\x01\x03ctx\x01\0\x06\x04\0\x06render\ +\x01\x07\x01ps\x01k\x08\x01@\x01\x09selectors\x09\x01\0\x04\0\x08activate\x01\x0a\ +\x04\x01\x1ddelano:wit-ui/wurbo-out@0.1.0\x05\x12\x04\x01&delano:wit-ui/delanocr\ +eds-wit-ui@0.1.0\x04\0\x0b\x18\x01\0\x12delanocreds-wit-ui\x03\0\0\0G\x09produce\ +rs\x01\x0cprocessed-by\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.\ +25.0"; #[inline(never)] #[doc(hidden)] diff --git a/crates/delano-wit-ui/src/credential.rs b/crates/delano-wit-ui/src/credential.rs index db45f4e..4664616 100644 --- a/crates/delano-wit-ui/src/credential.rs +++ b/crates/delano-wit-ui/src/credential.rs @@ -1,5 +1,5 @@ //! This module handles the temporary state that is created and mutated by the User Interface. -//! From this module's [StructObject], we can either Create a Credential, Offer a Credential, Accept a Credential, Prove a Credential, or Verify a Credential. +//! From this module's [Object], we can either Create a Credential, Offer a Credential, Accept a Credential, Prove a Credential, or Verify a Credential. use self::util::try_from_cbor; @@ -201,9 +201,9 @@ impl CredentialStruct { } } -impl StructObject for CredentialStruct { - fn get_field(&self, name: &str) -> Option { - match name { +impl Object for CredentialStruct { + fn get_value(self: &Arc, key: &Value) -> Option { + match key.as_str()? { // assigns a random id attribute to the button element, upon which we can apply "id" => Some(Value::from(rand_id())), "entries" => Some(Value::from(self.entries.clone())), @@ -223,22 +223,11 @@ impl StructObject for CredentialStruct { _ => None, } } - /// So that debug will show the values - fn static_fields(&self) -> Option<&'static [&'static str]> { - Some(&[ - "id", - "entries", - "max_entries", - "context", - "credential", - "offer", - ]) - } } impl From for wurbo::prelude::Value { fn from(context: CredentialStruct) -> Self { - Self::from_struct_object(context) + Self::from_object(context) } } diff --git a/crates/delano-wit-ui/src/lib.rs b/crates/delano-wit-ui/src/lib.rs index 556d9a0..0b66ae2 100644 --- a/crates/delano-wit-ui/src/lib.rs +++ b/crates/delano-wit-ui/src/lib.rs @@ -22,6 +22,7 @@ use bindings::delano::wit_ui::wurbo_in; use bindings::exports::delano::wit_ui::wurbo_out::Guest as WurboGuest; use std::ops::Deref; +use std::sync::Arc; struct Component; @@ -56,7 +57,7 @@ fn get_templates() -> Templates { // Macro builds the Component struct and implements the Guest trait for us, saving copy-and-paste prelude_bindgen! {WurboGuest, Component, StructContext, Context, LAST_STATE} -/// This is a wrapper around [Context] that implements StructObject on the wrapper. +/// This is a wrapper around [Context] that implements Object on the wrapper. /// Enables the conversion of Context to StructContext so we can render with minijinja. #[derive(Debug, Clone, Default)] struct StructContext { @@ -74,20 +75,16 @@ impl StructContext { } } -impl StructObject for StructContext { +impl Object for StructContext { /// Remember to add match arms for any new fields. - fn get_field(&self, name: &str) -> Option { - match name { - "app" => Some(Value::from_struct_object(self.app.clone())), - "state" => Some(Value::from_struct_object(self.state.clone())), - "output" => Some(Value::from_struct_object(self.output.clone())), + fn get_value(self: &Arc, key: &Value) -> Option { + match key.as_str()? { + "app" => Some(Value::from_object(self.app.clone())), + "state" => Some(Value::from_object(self.state.clone())), + "output" => Some(Value::from_object(self.output.clone())), _ => None, } } - /// So that debug will show the values - fn static_fields(&self) -> Option<&'static [&'static str]> { - Some(&["app", "state", "output"]) - } } impl From<&context_types::Context> for StructContext { diff --git a/crates/delano-wit-ui/src/output.rs b/crates/delano-wit-ui/src/output.rs index 9aa1e3e..219a2cc 100644 --- a/crates/delano-wit-ui/src/output.rs +++ b/crates/delano-wit-ui/src/output.rs @@ -8,17 +8,12 @@ static OUTPUT_ID: OnceLock = OnceLock::new(); #[derive(Debug, Clone, Default)] pub(crate) struct OutputStruct; -impl StructObject for OutputStruct { - fn get_field(&self, name: &str) -> Option { - match name { +impl Object for OutputStruct { + fn get_value(self: &Arc, key: &Value) -> Option { + match key.as_str()? { // use OnceLock as output id should not changes after first set "id" => Some(Value::from(OUTPUT_ID.get_or_init(|| rand_id()).to_owned())), _ => None, } } - - /// So that debug will show the values - fn static_fields(&self) -> Option<&'static [&'static str]> { - Some(&["id"]) - } } diff --git a/crates/delano-wit-ui/src/page.rs b/crates/delano-wit-ui/src/page.rs index 067279f..0005219 100644 --- a/crates/delano-wit-ui/src/page.rs +++ b/crates/delano-wit-ui/src/page.rs @@ -11,18 +11,25 @@ static ATTRIBUTES_HTML_ID: OnceLock = OnceLock::new(); #[derive(Debug, Clone, Default)] pub(crate) struct StructPage(Option); -impl StructObject for StructPage { - fn get_field(&self, name: &str) -> Option { - match name { +impl Object for StructPage { + fn get_value(self: &Arc, key: &Value) -> Option { + match key.as_str()? { "id" => Some(Value::from(rand_id())), "name" => Some(Value::from( - self.as_ref().map(|v| v.name.clone()).unwrap_or_default(), + self.as_ref() + .as_ref() + .map(|v| v.name.clone()) + .unwrap_or_default(), )), "version" => Some(Value::from( - self.as_ref().map(|v| v.version.clone()).unwrap_or_default(), + self.as_ref() + .as_ref() + .map(|v| v.version.clone()) + .unwrap_or_default(), )), "description" => Some(Value::from( self.as_ref() + .as_ref() .map(|v| v.description.clone()) .unwrap_or_default(), )), @@ -35,10 +42,6 @@ impl StructObject for StructPage { _ => None, } } - /// So that debug will show the values - fn static_fields(&self) -> Option<&'static [&'static str]> { - Some(&["id", "name", "version", "description"]) - } } impl From> for StructPage { diff --git a/crates/delano-wit-ui/wit/world.wit b/crates/delano-wit-ui/wit/world.wit index a24a429..c6f2d27 100644 --- a/crates/delano-wit-ui/wit/world.wit +++ b/crates/delano-wit-ui/wit/world.wit @@ -90,6 +90,9 @@ interface wurbo-out { use context-types.{context}; + // Optionally customize the configuration of the templates used to render the component + customize: func(templates: list>) -> result<_, string>; + // renders the initial Web component with the given data // and the target template to use as top level entry point render: func(ctx: context) -> result;