diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index f978ba7a2..8888aa2d6 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -14,6 +14,7 @@ jobs:
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v1
+ - run: sudo apt install libwebkit2gtk-4.0-dev libappindicator3-dev libgtk-3-dev libappindicator3-dev
- uses: actions-rs/cargo@v1
with:
command: check
@@ -29,9 +30,11 @@ jobs:
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v1
+ - run: sudo apt install libwebkit2gtk-4.0-dev libappindicator3-dev libgtk-3-dev libappindicator3-dev
- uses: actions-rs/cargo@v1
with:
command: test
+ args: --features "desktop, ssr, router"
fmt:
name: Rustfmt
@@ -66,3 +69,5 @@ jobs:
# with:
# command: clippy
# args: -- -D warnings
+#
+# sudo apt install libwebkit2gtk-4.0-dev libappindicator3-dev libgtk-3-dev libappindicator3-dev
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
index d7d2715d6..ed96aab2c 100644
--- a/.github/workflows/windows.yml
+++ b/.github/workflows/windows.yml
@@ -19,52 +19,50 @@ jobs:
max-parallel: 2
fail-fast: false
matrix:
- target: [
- i686-pc-windows-gnu,
- i686-pc-windows-msvc,
- x86_64-pc-windows-gnu,
- x86_64-pc-windows-msvc,
- ]
+ target:
+ [
+ i686-pc-windows-gnu,
+ i686-pc-windows-msvc,
+ x86_64-pc-windows-gnu,
+ x86_64-pc-windows-msvc,
+ ]
cfg_release_channel: [nightly, stable]
steps:
- # The Windows runners have autocrlf enabled by default
- # which causes failures for some of rustfmt's line-ending sensitive tests
- - name: disable git eol translation
- run: git config --global core.autocrlf false
- - name: checkout
- uses: actions/checkout@v2
+ # The Windows runners have autocrlf enabled by default
+ # which causes failures for some of rustfmt's line-ending sensitive tests
+ - name: disable git eol translation
+ run: git config --global core.autocrlf false
+ - name: checkout
+ uses: actions/checkout@v2
- # Run build
- - name: Install Rustup using win.rustup.rs
- run: |
- # Disable the download progress bar which can cause perf issues
- $ProgressPreference = "SilentlyContinue"
- Invoke-WebRequest https://win.rustup.rs/ -OutFile rustup-init.exe
- .\rustup-init.exe -y --default-host=x86_64-pc-windows-msvc --default-toolchain=none
- del rustup-init.exe
- rustup target add ${{ matrix.target }}
- shell: powershell
+ # Run build
+ - name: Install Rustup using win.rustup.rs
+ run: |
+ # Disable the download progress bar which can cause perf issues
+ $ProgressPreference = "SilentlyContinue"
+ Invoke-WebRequest https://win.rustup.rs/ -OutFile rustup-init.exe
+ .\rustup-init.exe -y --default-host=x86_64-pc-windows-msvc --default-toolchain=none
+ del rustup-init.exe
+ rustup target add ${{ matrix.target }}
+ shell: powershell
- - name: Add mingw32 to path for i686-gnu
- run: |
- echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH
- if: matrix.target == 'i686-pc-windows-gnu' && matrix.channel == 'nightly'
- shell: bash
+ - name: Add mingw32 to path for i686-gnu
+ run: |
+ echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH
+ if: matrix.target == 'i686-pc-windows-gnu' && matrix.channel == 'nightly'
+ shell: bash
- - name: Add mingw64 to path for x86_64-gnu
- run: echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
- if: matrix.target == 'x86_64-pc-windows-gnu' && matrix.channel == 'nightly'
- shell: bash
+ - name: Add mingw64 to path for x86_64-gnu
+ run: echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
+ if: matrix.target == 'x86_64-pc-windows-gnu' && matrix.channel == 'nightly'
+ shell: bash
- - name: build
- run: |
- rustc -Vv
- cargo -V
- set RUST_BACKTRACE=1
- cargo build
- shell: cmd
-
- - name: test
- run: cargo test
- shell: cmd
+ - name: test
+ run: |
+ rustc -Vv
+ cargo -V
+ set RUST_BACKTRACE=1
+ cargo build --features "desktop, ssr, router"
+ cargo test --features "desktop, ssr, router"
+ shell: cmd
diff --git a/docs/reference/src/web/index.md b/docs/reference/src/web/index.md
index 86581f9f8..062cba177 100644
--- a/docs/reference/src/web/index.md
+++ b/docs/reference/src/web/index.md
@@ -38,9 +38,11 @@ $ cargo add dioxus --features web
Add an `index.html` for Trunk to use. Make sure your "mount point" element has an ID of "main" (this can be configured later):
```html
+
-
+
+
diff --git a/examples/framework_benchmark.rs b/examples/framework_benchmark.rs
index f43ac4205..2f4496d86 100644
--- a/examples/framework_benchmark.rs
+++ b/examples/framework_benchmark.rs
@@ -89,8 +89,8 @@ fn app(cx: Scope) -> Element {
#[derive(Props)]
struct ActionButtonProps<'a> {
- name: &'static str,
- id: &'static str,
+ name: &'a str,
+ id: &'a str,
onclick: &'a dyn Fn(),
}
diff --git a/examples/inputs.rs b/examples/inputs.rs
index ed11b48d9..11334b59a 100644
--- a/examples/inputs.rs
+++ b/examples/inputs.rs
@@ -133,7 +133,7 @@ fn app(cx: Scope) -> Element {
r#type: "{field}",
value: "{value}",
// checked: "false",
- oninput: move |evt: Arc| {
+ oninput: move |evt: FormEvent| {
println!("{:?}", evt);
},
}
diff --git a/examples/manual_edits.rs b/examples/manual_edits.rs
index c98590c82..c6486919a 100644
--- a/examples/manual_edits.rs
+++ b/examples/manual_edits.rs
@@ -35,5 +35,5 @@ fn main() {
let app: Component = |cx| cx.render(rsx!(div { "some app" }));
- dioxus_desktop::launch_core(app, (), |c| c.with_edits(edits));
+ dioxus_desktop::launch_with_props(app, (), |c| c.with_edits(edits));
}
diff --git a/examples/pattern_model.rs b/examples/pattern_model.rs
index fc707437d..550879c21 100644
--- a/examples/pattern_model.rs
+++ b/examples/pattern_model.rs
@@ -116,8 +116,8 @@ fn app(cx: Scope) -> Element {
#[derive(Props)]
struct CalculatorKeyProps<'a> {
- name: &'static str,
- onclick: &'a dyn Fn(Arc),
+ name: &'a str,
+ onclick: &'a dyn Fn(MouseEvent),
children: Element<'a>,
}
@@ -211,7 +211,7 @@ impl Calculator {
self.cur_val = self.display_value.parse::().unwrap();
self.waiting_for_operand = true;
}
- fn handle_keydown(&mut self, evt: Arc) {
+ fn handle_keydown(&mut self, evt: KeyboardEvent) {
match evt.key_code {
KeyCode::Backspace => self.backspace(),
KeyCode::Num0 => self.input_digit(0),
diff --git a/examples/router.rs b/examples/router.rs
index 4f4b7b2c1..bd6d51881 100644
--- a/examples/router.rs
+++ b/examples/router.rs
@@ -1,64 +1,53 @@
+#![allow(non_snake_case)]
+
use dioxus::prelude::*;
-use dioxus_router::{use_router, Link};
+use dioxus::router::{Link, Route, Router};
-#[derive(PartialEq, Debug, Clone)]
-pub enum Route {
- // #[at("/")]
- Home,
-
- // #[at("/:id")]
- AllUsers { page: u32 },
-
- // #[at("/:id")]
- User { id: u32 },
-
- // #[at("/:id")]
- BlogList { page: u32 },
-
- // #[at("/:id")]
- BlogPost { post_id: u32 },
-
- // #[at("/404")]
- // #[not_found]
- NotFound,
+fn main() {
+ dioxus::desktop::launch(app);
}
fn app(cx: Scope) -> Element {
- let route = use_router(&cx, Route::parse);
-
cx.render(rsx! {
- nav {
- Link { to: Route::Home, "Go home!" }
- Link { to: Route::AllUsers { page: 0 }, "List all users" }
- Link { to: Route::BlogList { page: 0 }, "Blog posts" }
+ Router {
+ ul {
+ Link { to: "/", li { "Go home!" } }
+ Link { to: "users", li { "List all users" } }
+ Link { to: "blog", li { "Blog posts" } }
+ }
+ Route { to: "/", "Home" }
+ Route { to: "users",
+ Route { to: "/", "User list" }
+ Route { to: ":name", BlogPost {} }
+ }
+ Route { to: "blog"
+ Route { to: "/", "Blog list" }
+ Route { to: ":post", BlogPost {} }
+ }
+ Route { to: "", "Err 404 Route Not Found" }
}
- match route {
- Route::Home => rsx!("Home"),
- Route::AllUsers { page } => rsx!("All users - page {page}"),
- Route::User { id } => rsx!("User - id: {id}"),
- Route::BlogList { page } => rsx!("Blog posts - page {page}"),
- Route::BlogPost { post_id } => rsx!("Blog post - post {post_id}"),
- Route::NotFound => rsx!("Not found"),
- }
- footer {}
})
}
-impl Route {
- // Generate the appropriate route from the "tail" end of the URL
- fn parse(url: &str) -> Self {
- use Route::*;
- match url {
- "/" => Home,
- "/users" => AllUsers { page: 1 },
- "/users/:page" => AllUsers { page: 1 },
- "/users/:page/:id" => User { id: 1 },
- "/blog" => BlogList { page: 1 },
- "/blog/:page" => BlogList { page: 1 },
- "/blog/:page/:id" => BlogPost { post_id: 1 },
- _ => NotFound,
+fn BlogPost(cx: Scope) -> Element {
+ let post = dioxus::router::use_route(&cx).last_segment()?;
+
+ cx.render(rsx! {
+ div {
+ h1 { "Reading blog post: {post}" }
+ p { "example blog post" }
}
- }
+ })
}
-fn main() {}
+fn User(cx: Scope) -> Element {
+ let post = dioxus::router::use_route(&cx).last_segment()?;
+ let bold = dioxus::router::use_route(&cx).param::("bold");
+
+ cx.render(rsx! {
+ div {
+ h1 { "Reading blog post: {post}" }
+ p { "example blog post" }
+ }
+ })
+}
diff --git a/examples/tailwind.rs b/examples/tailwind.rs
index 385e98776..cbefd248f 100644
--- a/examples/tailwind.rs
+++ b/examples/tailwind.rs
@@ -9,16 +9,7 @@
use dioxus::prelude::*;
fn main() {
- dioxus::desktop::launch_cfg(app, |c| {
- // we can configure our primary window through the Tauri Config
- use dioxus::desktop::tao::platform::macos::*;
- c.with_window(|w| {
- w.with_fullsize_content_view(true)
- .with_titlebar_buttons_hidden(false)
- .with_titlebar_transparent(true)
- .with_movable_by_window_background(true)
- })
- });
+ dioxus::desktop::launch(app);
}
pub fn app(cx: Scope) -> Element {
diff --git a/packages/core-macro/src/rsx/component.rs b/packages/core-macro/src/rsx/component.rs
index 211539bbd..50b731e38 100644
--- a/packages/core-macro/src/rsx/component.rs
+++ b/packages/core-macro/src/rsx/component.rs
@@ -187,8 +187,12 @@ impl Parse for ComponentField {
}
if input.peek(LitStr) && input.peek2(Token![,]) {
- let content = ContentField::Formatted(input.parse()?);
- return Ok(Self { name, content });
+ let t: LitStr = input.fork().parse()?;
+
+ if is_literal_foramtted(&t) {
+ let content = ContentField::Formatted(input.parse()?);
+ return Ok(Self { name, content });
+ }
}
if input.peek(LitStr) && input.peek2(LitStr) {
@@ -209,3 +213,19 @@ impl ToTokens for ComponentField {
})
}
}
+
+fn is_literal_foramtted(lit: &LitStr) -> bool {
+ let s = lit.value();
+ let mut chars = s.chars();
+
+ while let Some(next) = chars.next() {
+ if next == '{' {
+ let nen = chars.next();
+ if nen == Some('{') {
+ return true;
+ }
+ }
+ }
+
+ false
+}
diff --git a/packages/core/src/events.rs b/packages/core/src/events.rs
index c7295c56d..c0dad0a47 100644
--- a/packages/core/src/events.rs
+++ b/packages/core/src/events.rs
@@ -4,7 +4,7 @@
//! This is all kinda WIP, but the bones are there.
use crate::{ElementId, ScopeId};
-use std::{any::Any, cell::Cell, rc::Rc, sync::Arc};
+use std::{any::Any, cell::Cell, fmt::Debug, rc::Rc, sync::Arc};
pub(crate) struct BubbleState {
pub canceled: Cell,
@@ -143,6 +143,12 @@ pub struct UiEvent {
bubble_state: Rc,
}
+impl std::fmt::Debug for UiEvent {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ f.debug_struct("UiEvent").field("data", &self.data).finish()
+ }
+}
+
impl std::ops::Deref for UiEvent {
type Target = T;
diff --git a/packages/core/src/scopes.rs b/packages/core/src/scopes.rs
index 66d6cdff5..1ed715208 100644
--- a/packages/core/src/scopes.rs
+++ b/packages/core/src/scopes.rs
@@ -690,8 +690,6 @@ impl ScopeState {
}
/// Pushes the future onto the poll queue to be polled after the component renders.
- ///
- /// The future is forcibly dropped if the component is not ready by the next render
pub fn push_future(&self, fut: impl Future