move to newer wry
This commit is contained in:
1 parent
2ce8ded74d
commit
5506c568c0
6 files changed
+119
-61
No files matched your search
@@ -37,8 +37,10 @@ anyhow = "1.0.56"
|
|||||||
log = "0.4.11"
|
log = "0.4.11"
|
||||||
im-rc = "15.1.0"
|
im-rc = "15.1.0"
|
||||||
dioxus = { path = "../../packages/dioxus" }
|
dioxus = { path = "../../packages/dioxus" }
|
||||||
dioxus-desktop = { path = "../../packages/desktop" }
|
dioxus-desktop = { path = "../../packages/desktop", default-features = false, features = [
|
||||||
wry = { version = "0.27.2" }
|
"tokio_runtime",
|
||||||
|
] }
|
||||||
|
wry = { version = "0.28.0" }
|
||||||
|
|
||||||
[target.'cfg(target_os = "android")'.dependencies]
|
[target.'cfg(target_os = "android")'.dependencies]
|
||||||
android_logger = "0.9.0"
|
android_logger = "0.9.0"
|
||||||
|
|||||||
@@ -1,52 +1,13 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use dioxus::prelude::*;
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
use wry::android_binding;
|
use wry::android_binding;
|
||||||
|
|
||||||
pub fn main() -> Result<()> {
|
|
||||||
init_logging();
|
|
||||||
|
|
||||||
// Right now we're going through dioxus-desktop but we'd like to go through dioxus-mobile
|
|
||||||
// That will seed the index.html with some fixes that prevent the page from scrolling/zooming etc
|
|
||||||
dioxus_desktop::launch_cfg(
|
|
||||||
app,
|
|
||||||
// Note that we have to disable the viewport goofiness of the browser.
|
|
||||||
// Dioxus_mobile should do this for us
|
|
||||||
Config::default().with_custom_index(include_str!("index.html").to_string()),
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn app(cx: Scope) -> Element {
|
|
||||||
let items = use_state(cx, || vec![1, 2, 3]);
|
|
||||||
|
|
||||||
render! {
|
|
||||||
div {
|
|
||||||
h1 { "Hello, Mobile"}
|
|
||||||
div { margin_left: "auto", margin_right: "auto", width: "200px", padding: "10px", border: "1px solid black",
|
|
||||||
button {
|
|
||||||
onclick: move|_| {
|
|
||||||
let mut _items = items.make_mut();
|
|
||||||
let len = _items.len() + 1;
|
|
||||||
_items.push(len);
|
|
||||||
},
|
|
||||||
"Add item"
|
|
||||||
}
|
|
||||||
for item in items.iter() {
|
|
||||||
div { "- {item}" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
fn init_logging() {
|
fn init_logging() {
|
||||||
android_logger::init_once(
|
android_logger::init_once(
|
||||||
android_logger::Config::default()
|
android_logger::Config::default()
|
||||||
.with_min_level(log::Level::Trace)
|
.with_min_level(log::Level::Trace)
|
||||||
.with_tag("rustnl-ios"),
|
.with_tag("android-taurio"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,17 +29,28 @@ fn stop_unwind<F: FnOnce() -> T, T>(f: F) -> T {
|
|||||||
|
|
||||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||||
fn _start_app() {
|
fn _start_app() {
|
||||||
main().unwrap();
|
stop_unwind(|| main().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
use dioxus_desktop::Config;
|
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||||
pub extern "C" fn start_app() {
|
pub extern "C" fn start_app() {
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
android_binding!(com_example, rustnl_ios, _start_app);
|
android_binding!(com_example, android_taurio, _start_app);
|
||||||
#[cfg(target_os = "ios")]
|
#[cfg(target_os = "ios")]
|
||||||
_start_app()
|
_start_app()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn main() -> Result<()> {
|
||||||
|
init_logging();
|
||||||
|
|
||||||
|
use dioxus::prelude::*;
|
||||||
|
fn app(cx: Scope) -> Element {
|
||||||
|
render!("hello dioxus")
|
||||||
|
}
|
||||||
|
|
||||||
|
dioxus_desktop::launch(app);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
use anyhow::Result;
|
||||||
|
use dioxus::prelude::*;
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
use wry::android_binding;
|
||||||
|
|
||||||
|
pub fn main() -> Result<()> {
|
||||||
|
init_logging();
|
||||||
|
|
||||||
|
// Right now we're going through dioxus-desktop but we'd like to go through dioxus-mobile
|
||||||
|
// That will seed the index.html with some fixes that prevent the page from scrolling/zooming etc
|
||||||
|
dioxus_desktop::launch_cfg(
|
||||||
|
app,
|
||||||
|
// Note that we have to disable the viewport goofiness of the browser.
|
||||||
|
// Dioxus_mobile should do this for us
|
||||||
|
Config::default().with_custom_index(include_str!("index.html").to_string()),
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn app(cx: Scope) -> Element {
|
||||||
|
let items = use_state(cx, || vec![1, 2, 3]);
|
||||||
|
|
||||||
|
render! {
|
||||||
|
div {
|
||||||
|
h1 { "Hello, Mobile"}
|
||||||
|
div { margin_left: "auto", margin_right: "auto", width: "200px", padding: "10px", border: "1px solid black",
|
||||||
|
button {
|
||||||
|
onclick: move|_| {
|
||||||
|
let mut _items = items.make_mut();
|
||||||
|
let len = _items.len() + 1;
|
||||||
|
_items.push(len);
|
||||||
|
},
|
||||||
|
"Add item"
|
||||||
|
}
|
||||||
|
for item in items.iter() {
|
||||||
|
div { "- {item}" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
fn init_logging() {
|
||||||
|
android_logger::init_once(
|
||||||
|
android_logger::Config::default()
|
||||||
|
.with_min_level(log::Level::Trace)
|
||||||
|
.with_tag("rustnl-ios"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "android"))]
|
||||||
|
fn init_logging() {
|
||||||
|
env_logger::init();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||||
|
fn stop_unwind<F: FnOnce() -> T, T>(f: F) -> T {
|
||||||
|
match std::panic::catch_unwind(std::panic::AssertUnwindSafe(f)) {
|
||||||
|
Ok(t) => t,
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("attempt to unwind out of `rust` with err: {:?}", err);
|
||||||
|
std::process::abort()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||||
|
fn _start_app() {
|
||||||
|
main().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
use dioxus_desktop::Config;
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
#[inline(never)]
|
||||||
|
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||||
|
pub extern "C" fn start_app() {
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
android_binding!(com_example, rustnl_ios, _start_app);
|
||||||
|
#[cfg(target_os = "ios")]
|
||||||
|
_start_app()
|
||||||
|
}
|
||||||
@@ -15,13 +15,13 @@ keywords = ["dom", "ui", "gui", "react"]
|
|||||||
dioxus-core = { workspace = true, features = ["serialize"] }
|
dioxus-core = { workspace = true, features = ["serialize"] }
|
||||||
dioxus-html = { workspace = true, features = ["serialize", "native-bind"] }
|
dioxus-html = { workspace = true, features = ["serialize", "native-bind"] }
|
||||||
dioxus-interpreter-js = { workspace = true }
|
dioxus-interpreter-js = { workspace = true }
|
||||||
dioxus-hot-reload = { workspace = true, optional = true }
|
# dioxus-hot-reload = { workspace = true, optional = true }
|
||||||
|
|
||||||
serde = "1.0.136"
|
serde = "1.0.136"
|
||||||
serde_json = "1.0.79"
|
serde_json = "1.0.79"
|
||||||
thiserror = "1.0.30"
|
thiserror = "1.0.30"
|
||||||
log = { workspace = true }
|
log = { workspace = true }
|
||||||
wry = { version = "0.27.2" }
|
wry = { version = "0.28.0" }
|
||||||
futures-channel = { workspace = true }
|
futures-channel = { workspace = true }
|
||||||
tokio = { workspace = true, features = [
|
tokio = { workspace = true, features = [
|
||||||
"sync",
|
"sync",
|
||||||
@@ -51,12 +51,12 @@ objc_id = "0.1.1"
|
|||||||
core-foundation = "0.9.3"
|
core-foundation = "0.9.3"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["tokio_runtime", "hot-reload"]
|
default = ["tokio_runtime"]
|
||||||
tokio_runtime = ["tokio"]
|
tokio_runtime = ["tokio"]
|
||||||
fullscreen = ["wry/fullscreen"]
|
fullscreen = ["wry/fullscreen"]
|
||||||
transparent = ["wry/transparent"]
|
transparent = ["wry/transparent"]
|
||||||
tray = ["wry/tray"]
|
tray = ["wry/tray"]
|
||||||
hot-reload = ["dioxus-hot-reload"]
|
# hot-reload = ["dioxus-hot-reload"]
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
dioxus-core-macro = { workspace = true }
|
dioxus-core-macro = { workspace = true }
|
||||||
|
|||||||
+10
-10
@@ -123,16 +123,16 @@ pub fn launch_with_props<P: 'static>(root: Component<P>, props: P, cfg: Config)
|
|||||||
let proxy = event_loop.create_proxy();
|
let proxy = event_loop.create_proxy();
|
||||||
|
|
||||||
// Intialize hot reloading if it is enabled
|
// Intialize hot reloading if it is enabled
|
||||||
#[cfg(all(feature = "hot-reload", debug_assertions))]
|
// #[cfg(all(feature = "hot-reload", debug_assertions))]
|
||||||
dioxus_hot_reload::connect({
|
// dioxus_hot_reload::connect({
|
||||||
let proxy = proxy.clone();
|
// let proxy = proxy.clone();
|
||||||
move |template| {
|
// move |template| {
|
||||||
let _ = proxy.send_event(UserWindowEvent(
|
// let _ = proxy.send_event(UserWindowEvent(
|
||||||
EventData::HotReloadEvent(template),
|
// EventData::HotReloadEvent(template),
|
||||||
unsafe { WindowId::dummy() },
|
// unsafe { WindowId::dummy() },
|
||||||
));
|
// ));
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
// We start the tokio runtime *on this thread*
|
// We start the tokio runtime *on this thread*
|
||||||
// Any future we poll later will use this runtime to spawn tasks and for IO
|
// Any future we poll later will use this runtime to spawn tasks and for IO
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ dioxus-rsx = { workspace = true }
|
|||||||
dioxus-core = { workspace = true, features = ["serialize"] }
|
dioxus-core = { workspace = true, features = ["serialize"] }
|
||||||
dioxus-html = { workspace = true, features = ["hot-reload-context"] }
|
dioxus-html = { workspace = true, features = ["hot-reload-context"] }
|
||||||
|
|
||||||
interprocess-docfix = { version = "1.2.1" }
|
interprocess-docfix = { version = "1.2.2" }
|
||||||
notify = "5.0.0"
|
notify = "5.0.0"
|
||||||
chrono = { version = "0.4.24", default-features = false, features = ["clock"] }
|
chrono = { version = "0.4.24", default-features = false, features = ["clock"] }
|
||||||
serde_json = "1.0.91"
|
serde_json = "1.0.91"
|
||||||
|
|||||||
Reference in new issue
Block a user