mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 06:34:20 +00:00
Fix compile checks on numerous packages using --all --all-features
This commit is contained in:
parent
3506b3ea72
commit
d8af9b7ed1
38 changed files with 147 additions and 186 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -2368,7 +2368,6 @@ dependencies = [
|
|||
"tempfile",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"toml 0.5.11",
|
||||
"toml_edit 0.19.15",
|
||||
"tower",
|
||||
"tower-http 0.2.5",
|
||||
|
@ -2449,14 +2448,13 @@ dependencies = [
|
|||
"async-trait",
|
||||
"core-foundation",
|
||||
"crossbeam-channel",
|
||||
"dioxus",
|
||||
"dioxus-cli-config",
|
||||
"dioxus-core",
|
||||
"dioxus-core-macro",
|
||||
"dioxus-hooks",
|
||||
"dioxus-hot-reload",
|
||||
"dioxus-html",
|
||||
"dioxus-interpreter-js",
|
||||
"dioxus-signals",
|
||||
"dunce",
|
||||
"exitcode",
|
||||
"futures-channel",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use dioxus::{events::*, html::MouseEvent, prelude::*};
|
||||
|
||||
fn main() {
|
||||
launch_desktop(app);
|
||||
launch(app);
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
|
@ -15,7 +15,7 @@ fn main() {
|
|||
.with_inner_size(LogicalSize::new(300.0, 525.0)),
|
||||
);
|
||||
|
||||
LaunchBuilder::desktop().cfg(config).launch(app);
|
||||
LaunchBuilder::desktop().with_cfg(config).launch(app);
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
launch_desktop(app);
|
||||
launch(app);
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
|
|
|
@ -6,13 +6,13 @@ use dioxus_desktop::Config;
|
|||
|
||||
fn main() {
|
||||
LaunchBuilder::new()
|
||||
.cfg(
|
||||
.with_cfg(
|
||||
Config::new().with_custom_head("<style>body { background-color: red; }</style>".into()),
|
||||
)
|
||||
.launch(app);
|
||||
|
||||
LaunchBuilder::new()
|
||||
.cfg(
|
||||
.with_cfg(
|
||||
Config::new().with_custom_index(
|
||||
r#"
|
||||
<!DOCTYPE html>
|
||||
|
|
|
@ -13,7 +13,7 @@ use dioxus_desktop::{Config, WindowBuilder};
|
|||
|
||||
fn main() {
|
||||
LaunchBuilder::new()
|
||||
.cfg(Config::new().with_window(WindowBuilder::new().with_resizable(true)))
|
||||
.with_cfg(Config::new().with_window(WindowBuilder::new().with_resizable(true)))
|
||||
.launch(app)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ use dioxus_desktop::Config;
|
|||
|
||||
fn main() {
|
||||
LaunchBuilder::desktop()
|
||||
.cfg(Config::new().with_file_drop_handler(|_w, e| {
|
||||
.with_cfg(Config::new().with_file_drop_handler(|_w, e| {
|
||||
println!("{e:?}");
|
||||
true
|
||||
}))
|
||||
|
|
|
@ -4,18 +4,14 @@ use dioxus_router::prelude::*;
|
|||
|
||||
fn main() {
|
||||
LaunchBuilder::desktop()
|
||||
.cfg(
|
||||
.with_cfg(
|
||||
Config::new().with_window(
|
||||
WindowBuilder::new()
|
||||
.with_inner_size(LogicalSize::new(600, 1000))
|
||||
.with_resizable(false),
|
||||
),
|
||||
)
|
||||
.launch(|| {
|
||||
rsx! {
|
||||
Router::<Route> {}
|
||||
}
|
||||
})
|
||||
.launch(|| rsx! { Router::<Route> {} })
|
||||
}
|
||||
|
||||
#[derive(Routable, Clone)]
|
||||
|
|
|
@ -14,7 +14,7 @@ use dioxus_desktop::Config;
|
|||
|
||||
fn main() {
|
||||
LaunchBuilder::desktop()
|
||||
.cfg(Config::new().with_prerendered({
|
||||
.with_cfg(Config::new().with_prerendered({
|
||||
// We build the dom a first time, then pre-render it to HTML
|
||||
let pre_rendered_dom = VirtualDom::prebuilt(app);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use dioxus::prelude::*;
|
|||
use dioxus_desktop::{tao::dpi::PhysicalPosition, LogicalSize, WindowBuilder};
|
||||
|
||||
fn main() {
|
||||
LaunchBuilder::new().cfg(make_config());
|
||||
LaunchBuilder::new().with_cfg(make_config());
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
|
|
|
@ -32,7 +32,7 @@ fn main() {
|
|||
.with_inner_size(LogicalSize::new(320.0, 530.0)),
|
||||
);
|
||||
|
||||
LaunchBuilder::new().cfg(cfg).launch(app);
|
||||
LaunchBuilder::new().with_cfg(cfg).launch(app);
|
||||
}
|
||||
|
||||
const STYLE: &str = include_str!("./assets/calculator.css");
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::rc::Rc;
|
|||
use dioxus::{html::geometry::euclid::Rect, prelude::*};
|
||||
|
||||
fn main() {
|
||||
LaunchBuilder::new().cfg(
|
||||
LaunchBuilder::new().with_cfg(
|
||||
dioxus_desktop::Config::default().with_custom_head(
|
||||
r#"
|
||||
<style type="text/css">
|
||||
|
|
|
@ -18,7 +18,7 @@ use dioxus_desktop::{Config, LogicalSize, WindowBuilder};
|
|||
|
||||
fn main() {
|
||||
LaunchBuilder::desktop()
|
||||
.cfg(
|
||||
.with_cfg(
|
||||
Config::new().with_window(
|
||||
WindowBuilder::new()
|
||||
.with_title("Doggo Fetcher")
|
||||
|
|
|
@ -3,7 +3,7 @@ use dioxus_desktop::{window, Config, WindowBuilder};
|
|||
|
||||
fn main() {
|
||||
LaunchBuilder::desktop()
|
||||
.cfg(
|
||||
.with_cfg(
|
||||
Config::new().with_window(
|
||||
WindowBuilder::new()
|
||||
.with_title("Borderless Window")
|
||||
|
|
|
@ -6,7 +6,7 @@ use dioxus_desktop::{Config, WindowCloseBehaviour};
|
|||
|
||||
fn main() {
|
||||
LaunchBuilder::new()
|
||||
.cfg(Config::new().with_close_behaviour(WindowCloseBehaviour::CloseWindow))
|
||||
.with_cfg(Config::new().with_close_behaviour(WindowCloseBehaviour::CloseWindow))
|
||||
.launch(app)
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ serde_json = "1.0.79"
|
|||
toml = { version = "0.5.8", optional = true }
|
||||
cargo_toml = { version = "0.16.0", optional = true }
|
||||
once_cell = "1.18.0"
|
||||
tracing.workspace = true
|
||||
tracing = { workspace = true }
|
||||
|
||||
# bundling
|
||||
tauri-bundler = { version = "=1.4.0", features = ["native-tls-vendored"], optional = true }
|
||||
|
|
|
@ -21,7 +21,6 @@ log = "0.4.14"
|
|||
fern = { version = "0.6.0", features = ["colored"] }
|
||||
serde = { version = "1.0.136", features = ["derive"] }
|
||||
serde_json = "1.0.79"
|
||||
toml = "0.5.8"
|
||||
fs_extra = "1.2.0"
|
||||
cargo_toml = "0.16.0"
|
||||
futures = "0.3.21"
|
||||
|
@ -89,7 +88,7 @@ interprocess-docfix = { version = "1.2.2" }
|
|||
gitignore = "1.0.8"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
default = ["plugin"]
|
||||
plugin = ["mlua"]
|
||||
|
||||
[[bin]]
|
||||
|
|
|
@ -4,14 +4,11 @@ use std::{
|
|||
sync::Mutex,
|
||||
};
|
||||
|
||||
use crate::tools::{app_path, clone_repo};
|
||||
use dioxus_cli_config::CrateConfig;
|
||||
use mlua::{Lua, Table};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::{
|
||||
tools::{app_path, clone_repo},
|
||||
CrateConfig,
|
||||
};
|
||||
|
||||
use self::{
|
||||
interface::{
|
||||
command::PluginCommander, dirs::PluginDirs, fs::PluginFileSystem, log::PluginLogger,
|
||||
|
|
|
@ -21,7 +21,7 @@ use std::{
|
|||
use tokio::sync::broadcast::{self};
|
||||
|
||||
#[cfg(feature = "plugin")]
|
||||
use plugin::PluginManager;
|
||||
use crate::plugin::PluginManager;
|
||||
|
||||
use super::HotReloadState;
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ async fn setup_file_watcher<F: Fn() -> Result<BuildResult> + Send + 'static>(
|
|||
);
|
||||
|
||||
#[cfg(feature = "plugin")]
|
||||
let _ = PluginManager::on_serve_rebuild(
|
||||
let _ = crate::plugin::PluginManager::on_serve_rebuild(
|
||||
chrono::Local::now().timestamp(),
|
||||
e.paths,
|
||||
);
|
||||
|
|
|
@ -39,7 +39,7 @@ use tower_http::{
|
|||
};
|
||||
|
||||
#[cfg(feature = "plugin")]
|
||||
use plugin::PluginManager;
|
||||
use crate::plugin::PluginManager;
|
||||
|
||||
mod proxy;
|
||||
|
||||
|
@ -159,10 +159,10 @@ pub async fn serve(
|
|||
);
|
||||
|
||||
// Router
|
||||
let router = setup_router(config, ws_reload_state, hot_reload_state).await?;
|
||||
let router = setup_router(config.clone(), ws_reload_state, hot_reload_state).await?;
|
||||
|
||||
// Start server
|
||||
start_server(port, router, start_browser, rustls_config).await?;
|
||||
start_server(port, router, start_browser, rustls_config, &config).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -366,10 +366,11 @@ async fn start_server(
|
|||
router: Router,
|
||||
start_browser: bool,
|
||||
rustls: Option<RustlsConfig>,
|
||||
config: &CrateConfig,
|
||||
) -> Result<()> {
|
||||
// If plugins, call on_serve_start event
|
||||
#[cfg(feature = "plugin")]
|
||||
PluginManager::on_serve_start(&config)?;
|
||||
PluginManager::on_serve_start(config)?;
|
||||
|
||||
// Parse address
|
||||
let addr = format!("0.0.0.0:{}", port).parse().unwrap();
|
||||
|
|
|
@ -118,18 +118,3 @@ impl<F: Fn() -> Element + Clone + 'static> ComponentFunction<(), EmptyMarker> fo
|
|||
self()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_works_maybe() {
|
||||
fn test(_: ()) -> Element {
|
||||
todo!()
|
||||
}
|
||||
fn test2() -> Element {
|
||||
todo!()
|
||||
}
|
||||
|
||||
let callable: Rc<dyn ComponentFunction<(), ()>> =
|
||||
Rc::new(test) as Rc<dyn ComponentFunction<_, _>>;
|
||||
let callable2: Rc<dyn ComponentFunction<(), EmptyMarker>> =
|
||||
Rc::new(test2) as Rc<dyn ComponentFunction<_, _>>;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ wry = { version = "0.35.0", default-features = false, features = [
|
|||
"protocol",
|
||||
"file-drop",
|
||||
] }
|
||||
futures-channel.workspace = true
|
||||
futures-channel = { workspace = true }
|
||||
tokio = { workspace = true, features = [
|
||||
"sync",
|
||||
"rt-multi-thread",
|
||||
|
@ -79,9 +79,7 @@ default-features = false
|
|||
features = ["tokio_runtime", "hot-reload"]
|
||||
|
||||
[dev-dependencies]
|
||||
dioxus-core-macro = { workspace = true }
|
||||
dioxus-hooks = { workspace = true }
|
||||
dioxus-signals = { workspace = true }
|
||||
dioxus = { workspace = true, features = ["launch", "desktop"]}
|
||||
exitcode = "1.1.2"
|
||||
|
||||
[build-dependencies]
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
use dioxus::prelude::*;
|
||||
|
||||
fn app() -> Element {
|
||||
let state = use_signal(|| 0);
|
||||
use_future(|| {
|
||||
to_owned![state];
|
||||
async move {
|
||||
loop {
|
||||
state += 1;
|
||||
tokio::time::sleep(std::time::Duration::from_millis(1)).await;
|
||||
}
|
||||
let mut state = use_signal(|| 0);
|
||||
|
||||
use_future(|| async move {
|
||||
loop {
|
||||
state += 1;
|
||||
tokio::time::sleep(std::time::Duration::from_millis(1)).await;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -28,5 +26,5 @@ fn app() -> Element {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
dioxus_desktop::launch(app);
|
||||
launch(app);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use dioxus::html::geometry::euclid::Vector3D;
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_core::prelude::consume_context;
|
||||
use dioxus_desktop::DesktopContext;
|
||||
|
||||
pub(crate) fn check_app_exits(app: Component) {
|
||||
pub(crate) fn check_app_exits(app: fn() -> Element) {
|
||||
use dioxus_desktop::tao::window::WindowBuilder;
|
||||
use dioxus_desktop::Config;
|
||||
// This is a deadman's switch to ensure that the app exits
|
||||
|
@ -15,10 +16,9 @@ pub(crate) fn check_app_exits(app: Component) {
|
|||
}
|
||||
});
|
||||
|
||||
dioxus_desktop::launch_cfg(
|
||||
app,
|
||||
Config::new().with_window(WindowBuilder::new().with_visible(true)),
|
||||
);
|
||||
LaunchBuilder::desktop()
|
||||
.with_cfg(Config::new().with_window(WindowBuilder::new().with_visible(true)))
|
||||
.launch(app);
|
||||
|
||||
// Stop deadman's switch
|
||||
should_panic.store(false, std::sync::atomic::Ordering::SeqCst);
|
||||
|
@ -29,12 +29,12 @@ pub fn main() {
|
|||
}
|
||||
|
||||
fn mock_event(id: &'static str, value: &'static str) {
|
||||
let eval_provider = use_eval(cx).clone();
|
||||
use_effect(move || {
|
||||
spawn(async move {
|
||||
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
|
||||
|
||||
use_effect(move |_| async move {
|
||||
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
|
||||
let js = format!(
|
||||
r#"
|
||||
let js = format!(
|
||||
r#"
|
||||
//console.log("ran");
|
||||
// Dispatch a synthetic event
|
||||
let event = {};
|
||||
|
@ -42,17 +42,18 @@ fn mock_event(id: &'static str, value: &'static str) {
|
|||
console.log(element, event);
|
||||
element.dispatchEvent(event);
|
||||
"#,
|
||||
value, id
|
||||
);
|
||||
value, id
|
||||
);
|
||||
|
||||
eval_provider(&js).unwrap();
|
||||
dioxus::eval(js);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
fn app() -> Element {
|
||||
let desktop_context: DesktopContext = cx.consume_context().unwrap();
|
||||
let received_events = use_signal(|| 0);
|
||||
let desktop_context: DesktopContext = consume_context();
|
||||
let mut received_events = use_signal(|| 0);
|
||||
|
||||
// button
|
||||
mock_event(
|
||||
|
@ -204,7 +205,7 @@ fn app() -> Element {
|
|||
r#"new FocusEvent("focusout",{bubbles: true})"#,
|
||||
);
|
||||
|
||||
if **received_events == 13 {
|
||||
if received_events() == 13 {
|
||||
println!("all events recieved");
|
||||
desktop_context.close();
|
||||
}
|
||||
|
@ -214,15 +215,13 @@ fn app() -> Element {
|
|||
div {
|
||||
width: "100px",
|
||||
height: "100px",
|
||||
onmounted: move |evt| {
|
||||
to_owned![received_events];
|
||||
async move {
|
||||
let rect = evt.get_client_rect().await.unwrap();
|
||||
println!("rect: {:?}", rect);
|
||||
assert_eq!(rect.width(), 100.0);
|
||||
assert_eq!(rect.height(), 100.0);
|
||||
received_events.modify(|x| *x + 1)
|
||||
}
|
||||
onmounted: move |evt| async move {
|
||||
todo!();
|
||||
// let rect = evt.get_client_rect().await.unwrap();
|
||||
// println!("rect: {:?}", rect);
|
||||
// assert_eq!(rect.width(), 100.0);
|
||||
// assert_eq!(rect.height(), 100.0);
|
||||
// received_events.with_mut(|x| *x + 1)
|
||||
}
|
||||
}
|
||||
button {
|
||||
|
@ -235,7 +234,7 @@ fn app() -> Element {
|
|||
event.data.trigger_button(),
|
||||
Some(dioxus_html::input_data::MouseButton::Primary),
|
||||
);
|
||||
received_events.modify(|x| *x + 1)
|
||||
received_events.with_mut(|x| *x + 1);
|
||||
}
|
||||
}
|
||||
div {
|
||||
|
@ -249,7 +248,7 @@ fn app() -> Element {
|
|||
.held_buttons()
|
||||
.contains(dioxus_html::input_data::MouseButton::Secondary),
|
||||
);
|
||||
received_events.modify(|x| *x + 1)
|
||||
received_events.with_mut(|x| *x + 1);
|
||||
}
|
||||
}
|
||||
div {
|
||||
|
@ -267,7 +266,7 @@ fn app() -> Element {
|
|||
event.data.trigger_button(),
|
||||
Some(dioxus_html::input_data::MouseButton::Secondary),
|
||||
);
|
||||
received_events.modify(|x| *x + 1)
|
||||
received_events.with_mut(|x| *x + 1);
|
||||
}
|
||||
}
|
||||
div {
|
||||
|
@ -288,7 +287,7 @@ fn app() -> Element {
|
|||
event.data.trigger_button(),
|
||||
Some(dioxus_html::input_data::MouseButton::Secondary),
|
||||
);
|
||||
received_events.modify(|x| *x + 1)
|
||||
received_events.with_mut(|x| *x + 1);
|
||||
}
|
||||
}
|
||||
div {
|
||||
|
@ -306,7 +305,7 @@ fn app() -> Element {
|
|||
event.data.trigger_button(),
|
||||
Some(dioxus_html::input_data::MouseButton::Secondary),
|
||||
);
|
||||
received_events.modify(|x| *x + 1)
|
||||
received_events.with_mut(|x| *x + 1);
|
||||
}
|
||||
}
|
||||
div {
|
||||
|
@ -319,7 +318,7 @@ fn app() -> Element {
|
|||
event.data.trigger_button(),
|
||||
Some(dioxus_html::input_data::MouseButton::Primary),
|
||||
);
|
||||
received_events.modify(|x| *x + 1)
|
||||
received_events.with_mut(|x| *x + 1);
|
||||
}
|
||||
}
|
||||
div {
|
||||
|
@ -332,7 +331,7 @@ fn app() -> Element {
|
|||
let dioxus_html::geometry::WheelDelta::Pixels(delta) = event.data.delta() else {
|
||||
panic!("Expected delta to be in pixels") };
|
||||
assert_eq!(delta, Vector3D::new(1.0, 2.0, 3.0));
|
||||
received_events.modify(|x| *x + 1)
|
||||
received_events.with_mut(|x| *x + 1);
|
||||
}
|
||||
}
|
||||
input {
|
||||
|
@ -344,7 +343,7 @@ fn app() -> Element {
|
|||
assert_eq!(event.data.code().to_string(), "KeyA");
|
||||
assert_eq!(event.data.location(), Location::Standard);
|
||||
assert!(event.data.is_auto_repeating());
|
||||
received_events.modify(|x| *x + 1)
|
||||
received_events.with_mut(|x| *x + 1);
|
||||
}
|
||||
}
|
||||
input {
|
||||
|
@ -356,7 +355,7 @@ fn app() -> Element {
|
|||
assert_eq!(event.data.code().to_string(), "KeyA");
|
||||
assert_eq!(event.data.location(), Location::Standard);
|
||||
assert!(!event.data.is_auto_repeating());
|
||||
received_events.modify(|x| *x + 1)
|
||||
received_events.with_mut(|x| *x + 1);
|
||||
}
|
||||
}
|
||||
input {
|
||||
|
@ -368,21 +367,21 @@ fn app() -> Element {
|
|||
assert_eq!(event.data.code().to_string(), "KeyA");
|
||||
assert_eq!(event.data.location(), Location::Standard);
|
||||
assert!(!event.data.is_auto_repeating());
|
||||
received_events.modify(|x| *x + 1)
|
||||
received_events.with_mut(|x| *x + 1);
|
||||
}
|
||||
}
|
||||
input {
|
||||
id: "focus_in_div",
|
||||
onfocusin: move |event| {
|
||||
println!("{:?}", event.data);
|
||||
received_events.modify(|x| *x + 1)
|
||||
received_events.with_mut(|x| *x + 1);
|
||||
}
|
||||
}
|
||||
input {
|
||||
id: "focus_out_div",
|
||||
onfocusout: move |event| {
|
||||
println!("{:?}", event.data);
|
||||
received_events.modify(|x| *x + 1)
|
||||
received_events.with_mut(|x| *x + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use dioxus::prelude::*;
|
||||
use dioxus_core::Element;
|
||||
use dioxus_desktop::DesktopContext;
|
||||
use dioxus_desktop::{window, DesktopContext};
|
||||
|
||||
fn main() {
|
||||
check_app_exits(check_html_renders);
|
||||
}
|
||||
|
||||
pub(crate) fn check_app_exits(app: Component) {
|
||||
pub(crate) fn check_app_exits(app: fn() -> Element) {
|
||||
use dioxus_desktop::Config;
|
||||
use tao::window::WindowBuilder;
|
||||
// This is a deadman's switch to ensure that the app exits
|
||||
|
@ -19,30 +19,35 @@ pub(crate) fn check_app_exits(app: Component) {
|
|||
}
|
||||
});
|
||||
|
||||
dioxus_desktop::launch_cfg(
|
||||
app,
|
||||
Config::new().with_window(WindowBuilder::new().with_visible(true)),
|
||||
);
|
||||
LaunchBuilder::desktop()
|
||||
.with_cfg(Config::new().with_window(WindowBuilder::new().with_visible(true)))
|
||||
.launch(app);
|
||||
|
||||
should_panic.store(false, std::sync::atomic::Ordering::SeqCst);
|
||||
}
|
||||
|
||||
fn use_inner_html(d: &'static str) -> Option<String> {
|
||||
let value: Signal<Option<String>> = use_signal(|| None);
|
||||
use_effect(|| async move {
|
||||
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
|
||||
window().eval();
|
||||
let html = eval_provider(&format!(
|
||||
r#"let element = document.getElementById('{}');
|
||||
fn use_inner_html(id: &'static str) -> Option<String> {
|
||||
let mut value = use_signal(|| None as Option<String>);
|
||||
|
||||
use_effect(move || {
|
||||
spawn(async move {
|
||||
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
|
||||
|
||||
let res = dioxus::eval(format!(
|
||||
r#"let element = document.getElementById('{}');
|
||||
return element.innerHTML"#,
|
||||
id
|
||||
))
|
||||
.unwrap();
|
||||
if let Ok(serde_json::Value::String(html)) = html.await {
|
||||
println!("html: {}", html);
|
||||
value.set(Some(html));
|
||||
}
|
||||
id
|
||||
))
|
||||
.await;
|
||||
|
||||
if let Ok(html) = res {
|
||||
// serde_json::Value::String(html)
|
||||
println!("html: {}", html);
|
||||
value.set(Some(html));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
value.read().clone()
|
||||
}
|
||||
|
||||
|
@ -51,7 +56,7 @@ const EXPECTED_HTML: &str = r#"<div id="5" style="width: 100px; height: 100px; c
|
|||
fn check_html_renders() -> Element {
|
||||
let inner_html = use_inner_html("main_div");
|
||||
|
||||
let desktop_context: DesktopContext = cx.consume_context().unwrap();
|
||||
let desktop_context: DesktopContext = consume_context();
|
||||
|
||||
if let Some(raw_html) = inner_html {
|
||||
println!("{}", raw_html);
|
||||
|
|
|
@ -87,7 +87,7 @@ impl LaunchBuilder {
|
|||
impl<Cfg: Default> LaunchBuilder<Cfg> {
|
||||
#[cfg(feature = "fullstack")]
|
||||
/// Inject state into the root component's context that is created on the thread that the app is launched on.
|
||||
pub fn context_provider(
|
||||
pub fn with_context_provider(
|
||||
mut self,
|
||||
state: impl Fn() -> Box<dyn Any> + Send + Sync + 'static,
|
||||
) -> Self {
|
||||
|
@ -98,7 +98,7 @@ impl<Cfg: Default> LaunchBuilder<Cfg> {
|
|||
|
||||
#[cfg(not(feature = "fullstack"))]
|
||||
/// Inject state into the root component's context that is created on the thread that the app is launched on.
|
||||
pub fn context_provider(mut self, state: impl Fn() -> Box<dyn Any> + 'static) -> Self {
|
||||
pub fn with_context_provider(mut self, state: impl Fn() -> Box<dyn Any> + 'static) -> Self {
|
||||
self.contexts
|
||||
.push(Box::new(state) as Box<dyn Fn() -> Box<dyn Any>>);
|
||||
self
|
||||
|
@ -106,7 +106,7 @@ impl<Cfg: Default> LaunchBuilder<Cfg> {
|
|||
|
||||
#[cfg(feature = "fullstack")]
|
||||
/// Inject state into the root component's context.
|
||||
pub fn context(mut self, state: impl Any + Clone + Send + Sync + 'static) -> Self {
|
||||
pub fn with_context(mut self, state: impl Any + Clone + Send + Sync + 'static) -> Self {
|
||||
self.contexts
|
||||
.push(Box::new(move || Box::new(state.clone())));
|
||||
self
|
||||
|
@ -114,14 +114,14 @@ impl<Cfg: Default> LaunchBuilder<Cfg> {
|
|||
|
||||
#[cfg(not(feature = "fullstack"))]
|
||||
/// Inject state into the root component's context.
|
||||
pub fn context(mut self, state: impl Any + Clone + 'static) -> Self {
|
||||
pub fn with_context(mut self, state: impl Any + Clone + 'static) -> Self {
|
||||
self.contexts
|
||||
.push(Box::new(move || Box::new(state.clone())));
|
||||
self
|
||||
}
|
||||
|
||||
/// Provide a platform-specific config to the builder.
|
||||
pub fn cfg(mut self, config: impl Into<Option<Cfg>>) -> Self {
|
||||
pub fn with_cfg(mut self, config: impl Into<Option<Cfg>>) -> Self {
|
||||
if let Some(config) = config.into() {
|
||||
self.platform_config = Some(config);
|
||||
}
|
||||
|
|
|
@ -76,3 +76,13 @@ pub use dioxus_desktop as desktop;
|
|||
|
||||
#[cfg(feature = "tui")]
|
||||
pub use dioxus_tui as tui;
|
||||
|
||||
/// Try to evaluate javascript in the target window
|
||||
///
|
||||
/// For the browser, this is the window object
|
||||
/// For desktop/mobile, this is the webview object
|
||||
///
|
||||
/// For native, it will try and use the platform's JS engine if available
|
||||
pub async fn eval(src: String) -> std::result::Result<String, Box<dyn std::error::Error>> {
|
||||
todo!()
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@ publish = false
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
wasm-bindgen.workspace = true
|
||||
dioxus-autofmt.workspace = true
|
||||
rsx-rosetta.workspace = true
|
||||
html_parser.workspace = true
|
||||
wasm-bindgen = { workspace = true }
|
||||
dioxus-autofmt = { workspace = true }
|
||||
rsx-rosetta = { workspace = true }
|
||||
html_parser = { workspace = true }
|
||||
|
||||
|
||||
[lib]
|
||||
|
|
|
@ -58,17 +58,16 @@ async-trait = "0.1.71"
|
|||
bytes = "1.4.0"
|
||||
tower = { version = "0.4.13", features = ["util"], optional = true }
|
||||
tower-layer = { version = "0.3.2", optional = true }
|
||||
web-sys = { version = "0.3.61", optional = true, features = ["Window", "Document", "Element", "HtmlDocument", "Storage", "console"] }
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
dioxus-hot-reload = { workspace = true }
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
web-sys = { version = "0.3.61", features = ["Window", "Document", "Element", "HtmlDocument", "Storage", "console"] }
|
||||
|
||||
[features]
|
||||
default = ["hot-reload"]
|
||||
hot-reload = ["serde_json", "futures-util"]
|
||||
web = ["dioxus-web"]
|
||||
web = ["dioxus-web", "web-sys"]
|
||||
desktop = ["dioxus-desktop"]
|
||||
warp = ["dep:warp", "ssr"]
|
||||
axum = ["dep:axum", "tower-http", "ssr"]
|
||||
|
|
|
@ -11,7 +11,7 @@ dioxus = { workspace = true, features = ["fullstack"]}
|
|||
serde = "1.0.159"
|
||||
simple_logger = "4.2.0"
|
||||
tracing-wasm = "0.2.1"
|
||||
tracing.workspace = true
|
||||
tracing = { workspace = true }
|
||||
tracing-subscriber = "0.3.17"
|
||||
reqwest = "0.11.18"
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ execute = "0.2.12"
|
|||
reqwest = "0.11.18"
|
||||
simple_logger = "4.2.0"
|
||||
tracing-wasm = "0.2.1"
|
||||
tracing.workspace = true
|
||||
tracing = { workspace = true }
|
||||
tracing-subscriber = "0.3.17"
|
||||
|
||||
[features]
|
||||
|
|
|
@ -10,7 +10,7 @@ publish = false
|
|||
dioxus = { workspace = true, features = ["fullstack"] }
|
||||
serde = "1.0.159"
|
||||
tracing-wasm = "0.2.1"
|
||||
tracing.workspace = true
|
||||
tracing = { workspace = true }
|
||||
tracing-subscriber = "0.3.17"
|
||||
reqwest = "0.11.18"
|
||||
|
||||
|
|
|
@ -7,15 +7,19 @@ use std::sync::Arc;
|
|||
/// Settings for a fullstack app.
|
||||
pub struct Config {
|
||||
#[cfg(feature = "ssr")]
|
||||
server_fn_route: &'static str,
|
||||
pub(crate) server_fn_route: &'static str,
|
||||
|
||||
#[cfg(feature = "ssr")]
|
||||
server_cfg: ServeConfigBuilder,
|
||||
pub(crate) server_cfg: ServeConfigBuilder,
|
||||
|
||||
#[cfg(feature = "ssr")]
|
||||
addr: std::net::SocketAddr,
|
||||
pub(crate) addr: std::net::SocketAddr,
|
||||
|
||||
#[cfg(feature = "web")]
|
||||
web_cfg: dioxus_web::Config,
|
||||
pub(crate) web_cfg: dioxus_web::Config,
|
||||
|
||||
#[cfg(feature = "desktop")]
|
||||
desktop_cfg: dioxus_desktop::Config,
|
||||
pub(crate) desktop_cfg: dioxus_desktop::Config,
|
||||
}
|
||||
|
||||
#[allow(clippy::derivable_impls)]
|
||||
|
@ -88,44 +92,6 @@ impl Config {
|
|||
}
|
||||
}
|
||||
|
||||
/// Launch the app.
|
||||
pub fn launch(self, build_virtual_dom: impl Fn() -> VirtualDom + Send + Sync + 'static) {
|
||||
#[cfg(feature = "ssr")]
|
||||
tokio::runtime::Runtime::new()
|
||||
.unwrap()
|
||||
.block_on(async move {
|
||||
self.launch_server(build_virtual_dom).await;
|
||||
});
|
||||
#[cfg(not(feature = "ssr"))]
|
||||
{
|
||||
#[cfg(feature = "web")]
|
||||
self.launch_web(build_virtual_dom);
|
||||
#[cfg(feature = "desktop")]
|
||||
self.launch_desktop(build_virtual_dom);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "web")]
|
||||
/// Launch the web application
|
||||
pub fn launch_web(self, build_virtual_dom: impl Fn() -> VirtualDom + Send + Sync + 'static) {
|
||||
#[cfg(not(feature = "ssr"))]
|
||||
{
|
||||
let cfg = self.web_cfg.hydrate(true);
|
||||
dioxus_web::launch::launch_virtual_dom(
|
||||
// TODO: this should pull the props from the document
|
||||
build_virtual_dom(),
|
||||
cfg,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "desktop")]
|
||||
/// Launch the web application
|
||||
pub fn launch_desktop<P: AnyProps>(self, build_virtual_dom: impl Fn() -> VirtualDom + 'static) {
|
||||
let cfg = self.desktop_cfg;
|
||||
dioxus_desktop::launch::launch_with_props_blocking(self.component, self.props, cfg);
|
||||
}
|
||||
|
||||
#[cfg(feature = "ssr")]
|
||||
/// Launch a server application
|
||||
pub async fn launch_server(
|
||||
|
|
|
@ -20,17 +20,27 @@ pub fn launch(
|
|||
}
|
||||
vdom
|
||||
};
|
||||
|
||||
#[cfg(feature = "ssr")]
|
||||
tokio::runtime::Runtime::new()
|
||||
.unwrap()
|
||||
.block_on(async move {
|
||||
platform_config.launch_server(virtual_dom_factory).await;
|
||||
});
|
||||
|
||||
#[cfg(not(feature = "ssr"))]
|
||||
{
|
||||
#[cfg(feature = "web")]
|
||||
platform_config.launch_web(virtual_dom_factory);
|
||||
{
|
||||
// TODO: this should pull the props from the document
|
||||
let cfg = platform_config.web_cfg.hydrate(true);
|
||||
dioxus_web::launch::launch_virtual_dom(virtual_dom_factory(), cfg);
|
||||
}
|
||||
|
||||
#[cfg(feature = "desktop")]
|
||||
platform_config.launch_desktop(virtual_dom_factory);
|
||||
{
|
||||
let cfg = platform_config.desktop_cfg;
|
||||
dioxus_desktop::launch::launch_virtual_dom(virtual_dom_factory(), cfg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ keywords = ["dom", "ui", "gui", "react"]
|
|||
dioxus-autofmt = { workspace = true }
|
||||
dioxus-rsx = { workspace = true }
|
||||
dioxus-html = { workspace = true, features = ["html-to-rsx"]}
|
||||
html_parser.workspace = true
|
||||
html_parser = { workspace = true }
|
||||
proc-macro2 = "1.0.49"
|
||||
quote = "1.0.23"
|
||||
syn = { version = "2.0", features = ["full"] }
|
||||
|
|
|
@ -20,7 +20,7 @@ quote = { version = "1.0" }
|
|||
serde = { version = "1.0", features = ["derive"], optional = true }
|
||||
internment = { version = "0.7.0", optional = true }
|
||||
krates = { version = "0.12.6", optional = true }
|
||||
tracing.workspace = true
|
||||
tracing = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["html"]
|
||||
|
|
|
@ -30,7 +30,7 @@ argh = "0.1.4"
|
|||
serde = "1.0.120"
|
||||
serde_json = "1.0.61"
|
||||
fs_extra = "1.2.0"
|
||||
dioxus-signals.workspace = true
|
||||
dioxus-signals = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["incremental"]
|
||||
|
|
Loading…
Reference in a new issue