diff --git a/Cargo.toml b/Cargo.toml index 8c2523a..1032479 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,9 +20,10 @@ wasm-bindgen-test = "0.3.33" tauri-sys = { path = ".", features = ["all"] } [features] -all = ["app", "clipboard", "event", "mocks", "tauri"] +all = ["app", "clipboard", "event", "mocks", "tauri", "updater"] app = ["dep:semver"] clipboard = [] event = [] mocks = [] -tauri = ["dep:url"] \ No newline at end of file +tauri = ["dep:url"] +updater = [] \ No newline at end of file diff --git a/examples/api/src/main.rs b/examples/api/src/main.rs index c317bcc..c8a2ebc 100644 --- a/examples/api/src/main.rs +++ b/examples/api/src/main.rs @@ -17,6 +17,9 @@ fn Header(cx: Scope) -> View { a(href="/clipboard") { "Clipboard" } + a(href="/updater") { + "Updater" + } a(href="/communication") { "Communication" } diff --git a/examples/api/src/views/updater.rs b/examples/api/src/views/updater.rs new file mode 100644 index 0000000..53c844c --- /dev/null +++ b/examples/api/src/views/updater.rs @@ -0,0 +1,45 @@ +use sycamore::prelude::*; +use tauri_sys::clipboard::{read_text, write_text}; + +#[component] +pub fn Updater(cx: Scope) -> View { + // let text = create_signal(cx, "clipboard message".to_string()); + + // let write = move |_| { + // sycamore::futures::spawn_local_scoped(cx, async move { + // write_text(&text.get()).await + // // .then(() => { + // // onMessage('Wrote to the clipboard') + // // }) + // // .catch(onMessage) + // }); + // }; + + // let read = |_| { + // sycamore::futures::spawn_local(async move { + // let text = read_text().await; + + // log::info!("Read text from clipboard {:?}", text); + // // readText() + // // .then((contents) => { + // // onMessage(`Clipboard contents: ${contents}`) + // // }) + // // .catch(onMessage) + // }); + // }; + + // view! { cx, + // div(class="flex gap-1") { + // input(class="grow input",placeholder="Text to write to the clipboard",bind:value=text) + // button(class="btn",type="button",on:click=write) { + // "Write" + // } + // button(class="btn",type="button",on:click=read) { + // "Read" + // } + // } + // } + view! { cx, + div(class="updater") { } + } +} diff --git a/src/lib.rs b/src/lib.rs index 20d4fbd..ace5379 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,6 +10,8 @@ pub mod event; pub mod mocks; #[cfg(feature = "tauri")] pub mod tauri; +#[cfg(feature = "updater")] +pub mod updater; #[derive(Debug, thiserror::Error)] pub enum Error {