Skip to content

Commit

Permalink
bump to wurbo v0.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
DougAnderson444 committed Jan 17, 2024
1 parent 9918558 commit 4241fa7
Show file tree
Hide file tree
Showing 12 changed files with 323 additions and 139 deletions.
430 changes: 306 additions & 124 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/seed-keeper-wit-ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ crate-type = ["cdylib"]

[dependencies]
cargo-component-bindings = { workspace = true }
wurbo = "0.1.6"
wurbo = "0.1.7"

# optional but default dependencies
serde = { version = "1.0", optional = true, features = ["derive"] }
Expand Down
2 changes: 2 additions & 0 deletions crates/seed-keeper-wit-ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub struct SeedUIContext {
page: Page,
input: Input,
pub(crate) output: Output,
target: Option<String>,
}

impl StructObject for SeedUIContext {
Expand Down Expand Up @@ -102,6 +103,7 @@ impl From<wurbo_types::Content> for SeedUIContext {
// We can use default for Output because the minijinja StructObject impl will
// calculate the values from the above inouts for us
output: Output::default(),
target: None,
}
}
}
2 changes: 1 addition & 1 deletion crates/seed-keeper-wit-ui/wit/out.wit
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface wurbo-out {

// renders the initial Web component with the given data
// and the target template to use as top level entry point
render: func(ctx: context, target: string) -> result<string, string>;
render: func(ctx: context) -> result<string, string>;

// listen on all or given selectors
activate: func(selectors: option<list<string>>);
Expand Down
2 changes: 1 addition & 1 deletion examples/crates/aggregate-wit-ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
cargo-component-bindings = { workspace = true }
wurbo = "0.1.3"
wurbo = "0.1.7"
minijinja = { version = "1.0.10" }

[dev-dependencies]
Expand Down
8 changes: 4 additions & 4 deletions examples/crates/aggregate-wit-ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ impl WurboGuest for Component {
let rendered = tmpl.render(&struct_ctx).map_err(prnt_err)?;
rendered
}
Context::Seed(ctx) => wit_ui::wurbo_out::render(&ctx.into(), "output.html")?,
Context::Edwards(ctx) => edwards_ui::wurbo_out::render(&ctx.into(), "output.html")?,
Context::Seed(ctx) => wit_ui::wurbo_out::render(&ctx.into())?,
Context::Edwards(ctx) => edwards_ui::wurbo_out::render(&ctx.into())?,
};
Ok(html)
}
Expand Down Expand Up @@ -171,7 +171,7 @@ impl StructObject for SeedUI {
/// outputs to .html
fn get_field(&self, name: &str) -> Option<Value> {
println!("SeedUI::get_field({})", name);
let render_result = wit_ui::wurbo_out::render(&self, "page.html");
let render_result = wit_ui::wurbo_out::render(&self);
match (name, render_result) {
("html", Ok(html)) => Some(Value::from(html)),
_ => None,
Expand Down Expand Up @@ -206,7 +206,7 @@ struct Edwards(wurbo_types::EdwardsContext);
/// and return the HTML string as the Value
impl StructObject for Edwards {
fn get_field(&self, name: &str) -> Option<Value> {
let render_result = edwards_ui::wurbo_out::render(&self, "page.html");
let render_result = edwards_ui::wurbo_out::render(&self);
match (name, render_result) {
("html", Ok(html)) => Some(Value::from(html)),
_ => None,
Expand Down
6 changes: 2 additions & 4 deletions examples/crates/aggregate-wit-ui/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@ impl bindgen::example::edwards_ui::wurbo_out::Host for MyCtx {
fn render(
&mut self,
_ctx: bindgen::example::edwards_ui::wurbo_out::Context,
_target: String,
) -> wasmtime::Result<Result<String, String>> {
// return some html as string
Ok(Ok("edwards ui for testing".to_string()))
}

fn activate(&mut self, selectors: Option<Vec<String>>) -> wasmtime::Result<()> {
fn activate(&mut self, _selectors: Option<Vec<String>>) -> wasmtime::Result<()> {
Ok(())
}
}
Expand All @@ -72,13 +71,12 @@ impl bindgen::seed_keeper::wit_ui::wurbo_out::Host for MyCtx {
fn render(
&mut self,
_ctx: bindgen::seed_keeper::wit_ui::wurbo_out::Context,
_target: String,
) -> wasmtime::Result<Result<String, String>> {
// return some html as string
Ok(Ok("seed keeper ui for testing".to_string()))
}

fn activate(&mut self, selectors: Option<Vec<String>>) -> wasmtime::Result<()> {
fn activate(&mut self, _selectors: Option<Vec<String>>) -> wasmtime::Result<()> {
Ok(())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface wurbo-out {

// renders the initial Web component with the given data
// and the target template to use as top level entry point
render: func(ctx: context, target: string) -> result<string, string>;
render: func(ctx: context) -> result<string, string>;

// listen on all or given selectors
activate: func(selectors: option<list<string>>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface wurbo-out {

// renders the initial Web component with the given data
// and the target template to use as top level entry point
render: func(ctx: context, target: string) -> result<string, string>;
render: func(ctx: context) -> result<string, string>;

// listen on all or given selectors
activate: func(selectors: option<list<string>>);
Expand Down
2 changes: 1 addition & 1 deletion examples/crates/edwards-ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
cargo-component-bindings = { workspace = true }
wurbo = "0.1.2"
wurbo = "0.1.7"

[lib]
crate-type = ["cdylib"]
Expand Down
2 changes: 2 additions & 0 deletions examples/crates/edwards-ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub struct PageContext {
page: Page,
input: Input,
pub(crate) output: Output,
target: Option<String>,
}

impl StructObject for PageContext {
Expand Down Expand Up @@ -82,6 +83,7 @@ impl From<wurbo_types::Content> for PageContext {
// We can use default for Output because the minijinja StructObject impl will
// calculate the values from the above inouts for us
output: Output::default(),
target: None,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/crates/edwards-ui/wit/out.wit
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface wurbo-out {

// renders the initial Web component with the given data
// and the target template to use as top level entry point
render: func(ctx: context, target: string) -> result<string, string>;
render: func(ctx: context) -> result<string, string>;

// listen on all or given selectors
activate: func(selectors: option<list<string>>);
Expand Down

0 comments on commit 4241fa7

Please sign in to comment.