fix CI
This commit is contained in:
1 parent
577f99e68c
commit
a9307e57e6
23 files changed
+160
-164
No files matched your search
@@ -21,7 +21,7 @@ fn formatting_compiles() {
|
||||
// function calls in formatings work
|
||||
assert_eq!(
|
||||
format_args_f!("{x.borrow():?}").to_string(),
|
||||
format!("{:?}", x.borrow())
|
||||
format!("{:?}", x)
|
||||
);
|
||||
|
||||
// allows duplicate format args
|
||||
|
||||
@@ -18,7 +18,7 @@ static REGISTERED_SERVER_FUNCTIONS: once_cell::sync::Lazy<
|
||||
/// The registry of all Dioxus server functions.
|
||||
pub struct DioxusServerFnRegistry;
|
||||
|
||||
#[cfg(any(feature = "ssr"))]
|
||||
#[cfg(feature = "ssr")]
|
||||
impl server_fn::ServerFunctionRegistry<DioxusServerContext> for DioxusServerFnRegistry {
|
||||
type Error = ServerRegistrationFnError;
|
||||
|
||||
|
||||
@@ -21,10 +21,9 @@ use std::{
|
||||
};
|
||||
use std::{rc::Rc, sync::RwLock};
|
||||
use style_attributes::StyleModifier;
|
||||
use taffy::Taffy;
|
||||
pub use taffy::{geometry::Point, prelude::*};
|
||||
use tokio::select;
|
||||
use tui::{backend::CrosstermBackend, layout::Rect, Terminal};
|
||||
use tui::{backend::CrosstermBackend, Terminal};
|
||||
|
||||
mod config;
|
||||
mod focus;
|
||||
@@ -160,8 +159,8 @@ pub fn render<R: Driver>(
|
||||
|
||||
if !to_rerender.is_empty() || updated {
|
||||
updated = false;
|
||||
fn resize(dims: Rect, taffy: &mut Taffy, rdom: &RealDom) {
|
||||
let width = screen_to_layout_space(dims.width);
|
||||
fn resize(dims: tui::layout::Rect, taffy: &mut Taffy, rdom: &RealDom) {
|
||||
let width: f32 = screen_to_layout_space(dims.width);
|
||||
let height = screen_to_layout_space(dims.height);
|
||||
let root_node = rdom
|
||||
.get(rdom.root_id())
|
||||
@@ -202,7 +201,7 @@ pub fn render<R: Driver>(
|
||||
} else {
|
||||
let rdom = rdom.read().unwrap();
|
||||
resize(
|
||||
Rect {
|
||||
tui::layout::Rect {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 1000,
|
||||
|
||||
@@ -30,11 +30,10 @@ expressiveness.
|
||||
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_router::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::str::FromStr;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Routable)]
|
||||
#[derive(Clone, Debug, PartialEq, Routable)]
|
||||
enum Route {
|
||||
#[nest("/blog")]
|
||||
#[layout(Blog)]
|
||||
|
||||
@@ -24,8 +24,7 @@ pub struct GenericHistoryButtonProps<'a> {
|
||||
/// ```rust
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use serde::{Deserialize, Serialize};
|
||||
/// #[derive(Clone, Serialize, Deserialize, Routable)]
|
||||
/// #[derive(Clone, Routable)]
|
||||
/// enum Route {
|
||||
/// #[route("/")]
|
||||
/// Index {},
|
||||
@@ -98,8 +97,7 @@ pub fn GenericGoBackButton<'a, R: Routable>(
|
||||
/// ```rust
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use serde::{Deserialize, Serialize};
|
||||
/// #[derive(Clone, Serialize, Deserialize, Routable)]
|
||||
/// #[derive(Clone, Routable)]
|
||||
/// enum Route {
|
||||
/// #[route("/")]
|
||||
/// Index {},
|
||||
|
||||
@@ -83,9 +83,8 @@ impl<R: Routable> Debug for GenericLinkProps<'_, R> {
|
||||
/// ```rust
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use serde::{Deserialize, Serialize};
|
||||
///
|
||||
/// #[derive(Clone, Serialize, Deserialize, Routable)]
|
||||
/// #[derive(Clone, Routable)]
|
||||
/// enum Route {
|
||||
/// #[route("/")]
|
||||
/// Index {},
|
||||
|
||||
@@ -15,9 +15,8 @@ use dioxus::prelude::*;
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # use serde::{Deserialize, Serialize};
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// #[derive(Clone, Serialize, Deserialize, Routable)]
|
||||
/// #[derive(Clone, Routable)]
|
||||
/// #[rustfmt::skip]
|
||||
/// enum Route {
|
||||
/// #[nest("/wrap")]
|
||||
@@ -59,10 +58,7 @@ use dioxus::prelude::*;
|
||||
/// # fn App(cx: Scope) -> Element {
|
||||
/// # render! {
|
||||
/// # Router {
|
||||
/// # config: RouterConfiguration {
|
||||
/// # history: Box::new(MemoryHistory::with_initial_path("/wrap").unwrap()),
|
||||
/// # ..Default::default()
|
||||
/// # }
|
||||
/// # config: || RouterConfig::default().history(MemoryHistory::with_initial_path(Route::Child {}))
|
||||
/// # }
|
||||
/// # }
|
||||
/// # }
|
||||
|
||||
@@ -22,17 +22,6 @@ struct MutableRouterState<R>
|
||||
where
|
||||
R: Routable,
|
||||
{
|
||||
/// Whether there is a previous page to navigate back to.
|
||||
///
|
||||
/// Even if this is [`true`], there might not be a previous page. However, it is nonetheless
|
||||
/// safe to tell the router to go back.
|
||||
can_go_back: bool,
|
||||
/// Whether there is a future page to navigate forward to.
|
||||
///
|
||||
/// Even if this is [`true`], there might not be a future page. However, it is nonetheless safe
|
||||
/// to tell the router to go forward.
|
||||
can_go_forward: bool,
|
||||
|
||||
/// The current prefix.
|
||||
prefix: Option<String>,
|
||||
|
||||
@@ -76,8 +65,6 @@ where
|
||||
R: Clone,
|
||||
{
|
||||
let state = Arc::new(RwLock::new(MutableRouterState {
|
||||
can_go_back: false,
|
||||
can_go_forward: false,
|
||||
prefix: Default::default(),
|
||||
history: cfg.history,
|
||||
unresolved_error: None,
|
||||
@@ -112,13 +99,13 @@ where
|
||||
/// Check whether there is a previous page to navigate back to.
|
||||
#[must_use]
|
||||
pub fn can_go_back(&self) -> bool {
|
||||
self.state.read().unwrap().can_go_back
|
||||
self.state.read().unwrap().history.can_go_back()
|
||||
}
|
||||
|
||||
/// Check whether there is a future page to navigate forward to.
|
||||
#[must_use]
|
||||
pub fn can_go_forward(&self) -> bool {
|
||||
self.state.read().unwrap().can_go_forward
|
||||
self.state.read().unwrap().history.can_go_forward()
|
||||
}
|
||||
|
||||
/// Go back to the previous location.
|
||||
|
||||
@@ -19,13 +19,12 @@ where
|
||||
///
|
||||
/// ```rust
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use serde::{Deserialize, Serialize};
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # #[inline_props]
|
||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||
/// # #[inline_props]
|
||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||
/// #[derive(Clone, Serialize, Deserialize, Routable, Debug, PartialEq)]
|
||||
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||
/// enum Route {
|
||||
/// #[route("/")]
|
||||
/// Index {},
|
||||
@@ -33,7 +32,7 @@ where
|
||||
/// OtherPage {},
|
||||
/// }
|
||||
///
|
||||
/// let mut history = MemoryHistory::<Route>::with_initial_path(Route::Index {}).unwrap();
|
||||
/// let mut history = MemoryHistory::<Route>::with_initial_path(Route::Index {});
|
||||
/// assert_eq!(history.current_route(), Route::Index {});
|
||||
/// assert_eq!(history.can_go_back(), false);
|
||||
/// ```
|
||||
|
||||
@@ -47,13 +47,12 @@ pub trait HistoryProvider<R: Routable> {
|
||||
///
|
||||
/// ```rust
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use serde::{Deserialize, Serialize};
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # #[inline_props]
|
||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||
/// # #[inline_props]
|
||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||
/// #[derive(Clone, Serialize, Deserialize, Routable, Debug, PartialEq)]
|
||||
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||
/// enum Route {
|
||||
/// #[route("/")]
|
||||
/// Index {},
|
||||
@@ -86,11 +85,10 @@ pub trait HistoryProvider<R: Routable> {
|
||||
///
|
||||
/// ```rust
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use serde::{Deserialize, Serialize};
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # #[inline_props]
|
||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||
/// #[derive(Clone, Serialize, Deserialize, Routable, Debug, PartialEq)]
|
||||
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||
/// enum Route {
|
||||
/// #[route("/")]
|
||||
/// Index {},
|
||||
@@ -113,13 +111,12 @@ pub trait HistoryProvider<R: Routable> {
|
||||
///
|
||||
/// ```rust
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use serde::{Deserialize, Serialize};
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # #[inline_props]
|
||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||
/// # #[inline_props]
|
||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||
/// #[derive(Clone, Serialize, Deserialize, Routable, Debug, PartialEq)]
|
||||
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||
/// enum Route {
|
||||
/// #[route("/")]
|
||||
/// Index {},
|
||||
@@ -146,13 +143,12 @@ pub trait HistoryProvider<R: Routable> {
|
||||
///
|
||||
/// ```rust
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use serde::{Deserialize, Serialize};
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # #[inline_props]
|
||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||
/// # #[inline_props]
|
||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||
/// #[derive(Clone, Serialize, Deserialize, Routable, Debug, PartialEq)]
|
||||
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||
/// enum Route {
|
||||
/// #[route("/")]
|
||||
/// Index {},
|
||||
@@ -180,13 +176,12 @@ pub trait HistoryProvider<R: Routable> {
|
||||
///
|
||||
/// ```rust
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use serde::{Deserialize, Serialize};
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # #[inline_props]
|
||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||
/// # #[inline_props]
|
||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||
/// #[derive(Clone, Serialize, Deserialize, Routable, Debug, PartialEq)]
|
||||
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||
/// enum Route {
|
||||
/// #[route("/")]
|
||||
/// Index {},
|
||||
@@ -214,13 +209,12 @@ pub trait HistoryProvider<R: Routable> {
|
||||
///
|
||||
/// ```rust
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use serde::{Deserialize, Serialize};
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # #[inline_props]
|
||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||
/// # #[inline_props]
|
||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||
/// #[derive(Clone, Serialize, Deserialize, Routable, Debug, PartialEq)]
|
||||
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||
/// enum Route {
|
||||
/// #[route("/")]
|
||||
/// Index {},
|
||||
@@ -244,13 +238,12 @@ pub trait HistoryProvider<R: Routable> {
|
||||
///
|
||||
/// ```rust
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use serde::{Deserialize, Serialize};
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # #[inline_props]
|
||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||
/// # #[inline_props]
|
||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||
/// #[derive(Clone, Serialize, Deserialize, Routable, Debug, PartialEq)]
|
||||
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||
/// enum Route {
|
||||
/// #[route("/")]
|
||||
/// Index {},
|
||||
|
||||
@@ -12,8 +12,7 @@ use crate::{
|
||||
/// ```rust
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use serde::{Deserialize, Serialize};
|
||||
/// #[derive(Clone, Serialize, Deserialize, Routable)]
|
||||
/// #[derive(Clone, Routable)]
|
||||
/// enum Route {
|
||||
/// #[route("/")]
|
||||
/// Index {},
|
||||
|
||||
@@ -17,10 +17,9 @@ use crate::utils::use_router_internal::use_router_internal;
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # use serde::{Deserialize, Serialize};
|
||||
/// # use dioxus_router::{prelude::*};
|
||||
///
|
||||
/// #[derive(Clone, Serialize, Deserialize, Routable)]
|
||||
/// #[derive(Clone, Routable)]
|
||||
/// enum Route {
|
||||
/// #[route("/")]
|
||||
/// Index {},
|
||||
|
||||
@@ -19,12 +19,11 @@ pub enum NavigationTarget<R: Routable> {
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use dioxus_router::navigation::NavigationTarget;
|
||||
/// # use serde::{Deserialize, Serialize};
|
||||
/// # #[inline_props]
|
||||
/// # fn Index(cx: Scope) -> Element {
|
||||
/// # todo!()
|
||||
/// # }
|
||||
/// #[derive(Clone, Serialize, Deserialize, Routable, PartialEq, Debug)]
|
||||
/// #[derive(Clone, Routable, PartialEq, Debug)]
|
||||
/// enum Route {
|
||||
/// #[route("/")]
|
||||
/// Index {},
|
||||
@@ -40,12 +39,11 @@ pub enum NavigationTarget<R: Routable> {
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use dioxus_router::navigation::NavigationTarget;
|
||||
/// # use serde::{Deserialize, Serialize};
|
||||
/// # #[inline_props]
|
||||
/// # fn Index(cx: Scope) -> Element {
|
||||
/// # todo!()
|
||||
/// # }
|
||||
/// #[derive(Clone, Serialize, Deserialize, Routable, PartialEq, Debug)]
|
||||
/// #[derive(Clone, Routable, PartialEq, Debug)]
|
||||
/// enum Route {
|
||||
/// #[route("/")]
|
||||
/// Index {},
|
||||
|
||||
@@ -12,18 +12,17 @@ use crate::prelude::*;
|
||||
/// This implements [`Default`] and follows the builder pattern, so you can use it like this:
|
||||
/// ```rust,no_run
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use serde::{Deserialize, Serialize};
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # #[inline_props]
|
||||
/// # fn Index(cx: Scope) -> Element {
|
||||
/// # todo!()
|
||||
/// # }
|
||||
/// #[derive(Clone, Serialize, Deserialize, Routable)]
|
||||
/// #[derive(Clone, Routable)]
|
||||
/// enum Route {
|
||||
/// #[route("/")]
|
||||
/// Index {},
|
||||
/// }
|
||||
/// let cfg = RouterConfig::default().history(WebHistory<Route>::default());
|
||||
/// let cfg = RouterConfig::default().history(WebHistory::<Route>::default());
|
||||
/// ```
|
||||
pub struct RouterConfig<R: Routable> {
|
||||
pub(crate) failure_external_navigation: fn(Scope) -> Element,
|
||||
|
||||
@@ -34,7 +34,7 @@ where
|
||||
render! {
|
||||
h1 { "App" }
|
||||
GenericRouter::<R> {
|
||||
config: || RouterConfiguration::default().history(MemoryHistory::default())
|
||||
config: || RouterConfig::default().history(MemoryHistory::default())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ fn prepare(path: impl Into<String>) -> VirtualDom {
|
||||
h1 { "App" }
|
||||
Router {
|
||||
config: {
|
||||
let path = cx.props.path.clone();
|
||||
move || RouterConfiguration::default().history(MemoryHistory::with_initial_path(path).unwrap())
|
||||
let path = cx.props.path.parse().unwrap();
|
||||
move || RouterConfig::default().history(MemoryHistory::with_initial_path(path))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
#![cfg(feature = "wasm_test")]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_router::prelude::*;
|
||||
use gloo::utils::document;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::str::FromStr;
|
||||
use wasm_bindgen_test::*;
|
||||
|
||||
wasm_bindgen_test_configure!(run_in_browser);
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Routable)]
|
||||
#[derive(Clone, Debug, PartialEq, Routable)]
|
||||
enum Route {
|
||||
#[route("/")]
|
||||
Home {},
|
||||
@@ -25,12 +21,7 @@ enum Route {
|
||||
}
|
||||
|
||||
fn App(cx: Scope) -> Element {
|
||||
render!(Router {
|
||||
config: RouterConfiguration {
|
||||
history: Box::<WebHistory<Route>>::default(),
|
||||
..Default::default()
|
||||
}
|
||||
})
|
||||
render!(Router {})
|
||||
}
|
||||
|
||||
#[inline_props]
|
||||
|
||||
Reference in new issue
Block a user