Skip to content

Commit f77bd42

Browse files
bump wurbo-rs to v0.4.1
syntax changes for minijinja 2.0
1 parent 4840641 commit f77bd42

File tree

16 files changed

+289
-255
lines changed

16 files changed

+289
-255
lines changed

Cargo.lock

Lines changed: 20 additions & 81 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ description = "Tools for working with crypto seeds."
1111
seed-keeper-core = { path = "crates/seed-keeper-core" }
1212
seed-keeper-events = { path = "crates/seed-keeper-events" }
1313
wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] }
14-
wurbo = "0.3.2"
14+
wurbo = "0.4.1"
1515

1616
[package]
1717
name = "seed-keeper"

crates/seed-keeper-events/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ edition = "2021"
77
crate-type = ["lib"]
88

99
[dependencies]
10-
wurbo = "0.2.0"
10+
wurbo = "0.4.1"
1111
serde = { version = "1.0", features = ["derive"] }
1212
serde_with = { version = "3.6.0", features = ["base64"] }

crates/seed-keeper-wit-ui/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ crate-type = ["cdylib"]
88

99
[dependencies]
1010
wit-bindgen-rt = { workspace = true, features = ["bitflags"] }
11-
wurbo = "0.2.0"
11+
wurbo = "0.4.1"
1212
base64ct = { version = "1.6.0", features = ["alloc"] }
1313
seed-keeper-events = { path = "../seed-keeper-events" }
1414

crates/seed-keeper-wit-ui/src/bindings.rs

Lines changed: 94 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -594,32 +594,103 @@ pub mod exports {
594594
_ => _rt::invalid_enum_discriminant(),
595595
});
596596
}
597+
#[doc(hidden)]
598+
#[allow(non_snake_case)]
599+
pub unsafe fn _export_customize_cabi<T: Guest>(
600+
arg0: *mut u8,
601+
arg1: usize,
602+
) -> *mut u8 {
603+
#[cfg(target_arch = "wasm32")]
604+
_rt::run_ctors_once();
605+
let base6 = arg0;
606+
let len6 = arg1;
607+
let mut result6 = _rt::Vec::with_capacity(len6);
608+
for i in 0..len6 {
609+
let base = base6.add(i * 16);
610+
let e6 = {
611+
let l0 = *base.add(0).cast::<*mut u8>();
612+
let l1 = *base.add(4).cast::<usize>();
613+
let len2 = l1;
614+
let bytes2 = _rt::Vec::from_raw_parts(l0.cast(), len2, len2);
615+
let l3 = *base.add(8).cast::<*mut u8>();
616+
let l4 = *base.add(12).cast::<usize>();
617+
let len5 = l4;
618+
let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5);
619+
620+
(_rt::string_lift(bytes2), _rt::string_lift(bytes5))
621+
};
622+
result6.push(e6);
623+
}
624+
_rt::cabi_dealloc(base6, len6 * 16, 4);
625+
let result7 = T::customize(result6);
626+
let ptr8 = _RET_AREA.0.as_mut_ptr().cast::<u8>();
627+
match result7 {
628+
Ok(_) => {
629+
*ptr8.add(0).cast::<u8>() = (0i32) as u8;
630+
}
631+
Err(e) => {
632+
*ptr8.add(0).cast::<u8>() = (1i32) as u8;
633+
let vec9 = (e.into_bytes()).into_boxed_slice();
634+
let ptr9 = vec9.as_ptr().cast::<u8>();
635+
let len9 = vec9.len();
636+
::core::mem::forget(vec9);
637+
*ptr8.add(8).cast::<usize>() = len9;
638+
*ptr8.add(4).cast::<*mut u8>() = ptr9.cast_mut();
639+
}
640+
};
641+
ptr8
642+
}
643+
#[doc(hidden)]
644+
#[allow(non_snake_case)]
645+
pub unsafe fn __post_return_customize<T: Guest>(arg0: *mut u8) {
646+
let l0 = i32::from(*arg0.add(0).cast::<u8>());
647+
match l0 {
648+
0 => (),
649+
_ => {
650+
let l1 = *arg0.add(4).cast::<*mut u8>();
651+
let l2 = *arg0.add(8).cast::<usize>();
652+
_rt::cabi_dealloc(l1, l2, 1);
653+
}
654+
}
655+
}
597656
pub trait Guest {
598657
/// renders the initial Web component with the given data
599658
/// and the target template to use as top level entry point
600659
fn render(ctx: Context) -> Result<_rt::String, _rt::String>;
601660
/// listen on all or given selectors
602661
fn activate(selectors: Option<_rt::Vec<_rt::String>>);
662+
/// Optionally customize the configuration of the templates used to render the component
663+
fn customize(
664+
templates: _rt::Vec<(_rt::String, _rt::String)>,
665+
) -> Result<(), _rt::String>;
603666
}
604667
#[doc(hidden)]
605668

606669
macro_rules! __export_seed_keeper_wit_ui_wurbo_out_0_1_0_cabi{
607-
($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = {
670+
($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = {
608671

609-
#[export_name = "seed-keeper:wit-ui/[email protected]#render"]
610-
unsafe extern "C" fn export_render(arg0: i32,arg1: *mut u8,arg2: *mut u8,arg3: usize,arg4: i32,arg5: *mut u8,arg6: usize,arg7: i32,arg8: *mut u8,arg9: usize,arg10: i32,arg11: *mut u8,arg12: usize,) -> *mut u8 {
611-
$($path_to_types)*::_export_render_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12)
612-
}
613-
#[export_name = "cabi_post_seed-keeper:wit-ui/[email protected]#render"]
614-
unsafe extern "C" fn _post_return_render(arg0: *mut u8,) {
615-
$($path_to_types)*::__post_return_render::<$ty>(arg0)
616-
}
617-
#[export_name = "seed-keeper:wit-ui/[email protected]#activate"]
618-
unsafe extern "C" fn export_activate(arg0: i32,arg1: *mut u8,arg2: usize,) {
619-
$($path_to_types)*::_export_activate_cabi::<$ty>(arg0, arg1, arg2)
620-
}
621-
};);
622-
}
672+
#[export_name = "seed-keeper:wit-ui/[email protected]#render"]
673+
unsafe extern "C" fn export_render(arg0: i32,arg1: *mut u8,arg2: *mut u8,arg3: usize,arg4: i32,arg5: *mut u8,arg6: usize,arg7: i32,arg8: *mut u8,arg9: usize,arg10: i32,arg11: *mut u8,arg12: usize,) -> *mut u8 {
674+
$($path_to_types)*::_export_render_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12)
675+
}
676+
#[export_name = "cabi_post_seed-keeper:wit-ui/[email protected]#render"]
677+
unsafe extern "C" fn _post_return_render(arg0: *mut u8,) {
678+
$($path_to_types)*::__post_return_render::<$ty>(arg0)
679+
}
680+
#[export_name = "seed-keeper:wit-ui/[email protected]#activate"]
681+
unsafe extern "C" fn export_activate(arg0: i32,arg1: *mut u8,arg2: usize,) {
682+
$($path_to_types)*::_export_activate_cabi::<$ty>(arg0, arg1, arg2)
683+
}
684+
#[export_name = "seed-keeper:wit-ui/[email protected]#customize"]
685+
unsafe extern "C" fn export_customize(arg0: *mut u8,arg1: usize,) -> *mut u8 {
686+
$($path_to_types)*::_export_customize_cabi::<$ty>(arg0, arg1)
687+
}
688+
#[export_name = "cabi_post_seed-keeper:wit-ui/[email protected]#customize"]
689+
unsafe extern "C" fn _post_return_customize(arg0: *mut u8,) {
690+
$($path_to_types)*::__post_return_customize::<$ty>(arg0)
691+
}
692+
};);
693+
}
623694
#[doc(hidden)]
624695
pub(crate) use __export_seed_keeper_wit_ui_wurbo_out_0_1_0_cabi;
625696
#[repr(align(4))]
@@ -693,8 +764,8 @@ pub(crate) use __export_seedworld_impl as export;
693764
#[cfg(target_arch = "wasm32")]
694765
#[link_section = "component-type:wit-bindgen:0.25.0:seedworld:encoded world"]
695766
#[doc(hidden)]
696-
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 982] = *b"\
697-
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xd6\x06\x01A\x02\x01\
767+
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1025] = *b"\
768+
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x81\x07\x01A\x02\x01\
698769
A\x0d\x01B\x04\x01p}\x01k\0\x01r\x03\x08username\0\x08password\0\x09encrypted\x01\
699770
\x04\0\x0bcredentials\x03\0\x02\x03\x01\x1eseed-keeper:wallet/[email protected]\x05\0\x02\
700771
\x03\0\0\x0bcredentials\x01B\x0a\x02\x03\x02\x01\x01\x04\0\x0bcredentials\x03\0\0\
@@ -710,12 +781,13 @@ nput\x0a\x04load\x06\x04\0\x07content\x03\0\x0b\x01q\x05\x0ball-content\x01\x0c\
710781
\0\x02\x0elisten-details\x01B\x06\x02\x03\x02\x01\x04\x04\0\x0elisten-details\x03\
711782
\0\0\x01@\x01\x07details\x01\x01\0\x04\0\x10addeventlistener\x01\x02\x01@\x01\x07\
712783
messages\x01\0\x04\0\x04emit\x01\x03\x03\x01!seed-keeper:wit-ui/[email protected]\x05\
713-
\x05\x02\x03\0\x02\x07context\x01B\x09\x02\x03\x02\x01\x06\x04\0\x07context\x03\0\
784+
\x05\x02\x03\0\x02\x07context\x01B\x0e\x02\x03\x02\x01\x06\x04\0\x07context\x03\0\
714785
\0\x01j\x01s\x01s\x01@\x01\x03ctx\x01\0\x02\x04\0\x06render\x01\x03\x01ps\x01k\x04\
715-
\x01@\x01\x09selectors\x05\x01\0\x04\0\x08activate\x01\x06\x04\x01\"seed-keeper:\
716-
wit-ui/[email protected]\x05\x07\x04\x01\"seed-keeper:wit-ui/[email protected]\x04\0\
717-
\x0b\x0f\x01\0\x09seedworld\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dw\
718-
it-component\x070.208.1\x10wit-bindgen-rust\x060.25.0";
786+
\x01@\x01\x09selectors\x05\x01\0\x04\0\x08activate\x01\x06\x01o\x02ss\x01p\x07\x01\
787+
j\0\x01s\x01@\x01\x09templates\x08\0\x09\x04\0\x09customize\x01\x0a\x04\x01\"see\
788+
d-keeper:wit-ui/[email protected]\x05\x07\x04\x01\"seed-keeper:wit-ui/seedworld@0.\
789+
1.0\x04\0\x0b\x0f\x01\0\x09seedworld\x03\0\0\0G\x09producers\x01\x0cprocessed-by\
790+
\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0";
719791

720792
#[inline(never)]
721793
#[doc(hidden)]

crates/seed-keeper-wit-ui/src/input.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ use super::*;
44
#[derive(Debug, Clone, Default)]
55
pub(crate) struct Input(Option<wurbo_types::Input>);
66

7-
impl StructObject for Input {
8-
fn get_field(&self, name: &str) -> Option<Value> {
9-
match name {
7+
impl Object for Input {
8+
fn get_value(self: &std::sync::Arc<Self>, key: &Value) -> Option<Value> {
9+
match key.as_str()? {
1010
"id" => Some(Value::from(rand_id())),
1111
"placeholder" => Some(Value::from(
1212
self.as_ref()
13+
.as_ref()
1314
.map(|c| c.placeholder.clone())
1415
.unwrap_or_default(),
1516
)),
1617
// copy encrypted_seed from Input, if any
17-
"encrypted_seed" => match self.as_ref() {
18+
"encrypted_seed" => match self.as_ref().as_ref() {
1819
Some(val) => match &val.encrypted_seed {
1920
Some(encrypted) => Some(Value::from(encrypted.clone())),
2021
None => None,
@@ -24,10 +25,6 @@ impl StructObject for Input {
2425
_ => None,
2526
}
2627
}
27-
/// So that debug will show the values
28-
fn static_fields(&self) -> Option<&'static [&'static str]> {
29-
Some(&["id", "placeholder"])
30-
}
3128
}
3229

3330
impl From<wurbo_types::Input> for Input {

0 commit comments

Comments
 (0)