14 files changed
+48
-52
No files matched your search
+20
-20
@@ -15,7 +15,7 @@ jobs:
|
|||||||
override: true
|
override: true
|
||||||
- uses: Swatinem/rust-cache@v1
|
- uses: Swatinem/rust-cache@v1
|
||||||
- run: sudo apt-get update
|
- run: sudo apt-get update
|
||||||
- run: sudo apt install libwebkit2gtk-4.0-dev libappindicator3-dev libgtk-3-dev libappindicator3-dev
|
- run: sudo apt install libwebkit2gtk-4.0-dev libappindicator3-dev libgtk-3-dev
|
||||||
- uses: actions-rs/cargo@v1
|
- uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: check
|
command: check
|
||||||
@@ -32,7 +32,7 @@ jobs:
|
|||||||
override: true
|
override: true
|
||||||
- uses: Swatinem/rust-cache@v1
|
- uses: Swatinem/rust-cache@v1
|
||||||
- run: sudo apt-get update
|
- run: sudo apt-get update
|
||||||
- run: sudo apt install libwebkit2gtk-4.0-dev libappindicator3-dev libgtk-3-dev libappindicator3-dev
|
- run: sudo apt install libwebkit2gtk-4.0-dev libappindicator3-dev libgtk-3-dev
|
||||||
- uses: actions-rs/cargo@v1
|
- uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: test
|
command: test
|
||||||
@@ -55,21 +55,21 @@ jobs:
|
|||||||
command: fmt
|
command: fmt
|
||||||
args: --all -- --check
|
args: --all -- --check
|
||||||
|
|
||||||
# clippy:
|
clippy:
|
||||||
# name: Clippy
|
name: Clippy
|
||||||
# runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# steps:
|
steps:
|
||||||
# - uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
# - uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
# with:
|
with:
|
||||||
# profile: minimal
|
profile: minimal
|
||||||
# toolchain: stable
|
toolchain: stable
|
||||||
# override: true
|
override: true
|
||||||
# - uses: Swatinem/rust-cache@v1
|
- uses: Swatinem/rust-cache@v1
|
||||||
# - run: rustup component add clippy
|
- run: sudo apt-get update
|
||||||
# - uses: actions-rs/cargo@v1
|
- run: sudo apt install libwebkit2gtk-4.0-dev libappindicator3-dev libgtk-3-dev
|
||||||
# with:
|
- run: rustup component add clippy
|
||||||
# command: clippy
|
- uses: actions-rs/cargo@v1
|
||||||
# args: -- -D warnings
|
with:
|
||||||
#
|
command: clippy
|
||||||
# sudo apt install libwebkit2gtk-4.0-dev libappindicator3-dev libgtk-3-dev libappindicator3-dev
|
args: -- -D warnings
|
||||||
@@ -41,7 +41,7 @@ pub fn format_args_f_impl(input: IfmtInput) -> Result<TokenStream> {
|
|||||||
let mut out_format_literal = defer(&mut *out_format_literal, |it| {
|
let mut out_format_literal = defer(&mut *out_format_literal, |it| {
|
||||||
it.push(colon_or_closing_brace)
|
it.push(colon_or_closing_brace)
|
||||||
});
|
});
|
||||||
let out_format_literal: &mut String = &mut *out_format_literal;
|
let out_format_literal: &mut String = *out_format_literal;
|
||||||
let mut arg = s[i + 1..end].trim();
|
let mut arg = s[i + 1..end].trim();
|
||||||
if let Some("=") = arg.get(arg.len().saturating_sub(1)..) {
|
if let Some("=") = arg.get(arg.len().saturating_sub(1)..) {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ mod field_info {
|
|||||||
pub setter: SetterSettings,
|
pub setter: SetterSettings,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Default)]
|
||||||
pub struct SetterSettings {
|
pub struct SetterSettings {
|
||||||
pub doc: Option<syn::Expr>,
|
pub doc: Option<syn::Expr>,
|
||||||
pub skip: bool,
|
pub skip: bool,
|
||||||
@@ -278,17 +278,6 @@ mod field_info {
|
|||||||
pub strip_option: bool,
|
pub strip_option: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for SetterSettings {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
doc: Default::default(),
|
|
||||||
skip: false,
|
|
||||||
auto_into: false,
|
|
||||||
strip_option: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FieldBuilderAttr {
|
impl FieldBuilderAttr {
|
||||||
pub fn with(mut self, attrs: &[syn::Attribute]) -> Result<Self, Error> {
|
pub fn with(mut self, attrs: &[syn::Attribute]) -> Result<Self, Error> {
|
||||||
let mut skip_tokens = None;
|
let mut skip_tokens = None;
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ impl Parse for ComponentField {
|
|||||||
return Ok(Self { name, content });
|
return Ok(Self { name, content });
|
||||||
}
|
}
|
||||||
|
|
||||||
if name.to_string() == "key" {
|
if name == "key" {
|
||||||
let content = ContentField::ManExpr(input.parse()?);
|
let content = ContentField::ManExpr(input.parse()?);
|
||||||
return Ok(Self { name, content });
|
return Ok(Self { name, content });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -745,6 +745,7 @@ impl ScopeState {
|
|||||||
/// use_hook(|| Rc::new(RefCell::new(initial_value())))
|
/// use_hook(|| Rc::new(RefCell::new(initial_value())))
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
#[allow(clippy::mut_from_ref)]
|
||||||
pub fn use_hook<'src, State: 'static>(
|
pub fn use_hook<'src, State: 'static>(
|
||||||
&'src self,
|
&'src self,
|
||||||
initializer: impl FnOnce(usize) -> State,
|
initializer: impl FnOnce(usize) -> State,
|
||||||
|
|||||||
@@ -4,11 +4,13 @@ use wry::{
|
|||||||
webview::WebView,
|
webview::WebView,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub(crate) type DynEventHandlerFn = dyn Fn(&mut EventLoop<()>, &mut WebView);
|
||||||
|
|
||||||
pub struct DesktopConfig<'a> {
|
pub struct DesktopConfig<'a> {
|
||||||
pub window: WindowBuilder,
|
pub window: WindowBuilder,
|
||||||
pub(crate) manual_edits: Option<Vec<DomEdit<'a>>>,
|
pub(crate) manual_edits: Option<Vec<DomEdit<'a>>>,
|
||||||
pub(crate) pre_rendered: Option<String>,
|
pub(crate) pre_rendered: Option<String>,
|
||||||
pub(crate) event_handler: Option<Box<dyn Fn(&mut EventLoop<()>, &mut WebView)>>,
|
pub(crate) event_handler: Option<Box<DynEventHandlerFn>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DesktopConfig<'a> {
|
impl<'a> DesktopConfig<'a> {
|
||||||
@@ -55,3 +57,9 @@ impl<'a> DesktopConfig<'a> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Default for DesktopConfig<'a> {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -171,7 +171,7 @@ where
|
|||||||
///
|
///
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
pub fn use_context_provider<'a, T: 'static>(cx: &'a ScopeState, f: impl FnOnce() -> T) {
|
pub fn use_context_provider<T: 'static>(cx: &ScopeState, f: impl FnOnce() -> T) {
|
||||||
cx.use_hook(|_| {
|
cx.use_hook(|_| {
|
||||||
let state: ProvidedState<T> = RefCell::new(ProvidedStateInner {
|
let state: ProvidedState<T> = RefCell::new(ProvidedStateInner {
|
||||||
value: Rc::new(RefCell::new(f())),
|
value: Rc::new(RefCell::new(f())),
|
||||||
|
|||||||
@@ -15,10 +15,7 @@ let g = use_coroutine(&cx, || {
|
|||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
pub fn use_coroutine<'a, F>(
|
pub fn use_coroutine<F>(cx: &ScopeState, create_future: impl FnOnce() -> F) -> CoroutineHandle<'_>
|
||||||
cx: &'a ScopeState,
|
|
||||||
create_future: impl FnOnce() -> F,
|
|
||||||
) -> CoroutineHandle<'a>
|
|
||||||
where
|
where
|
||||||
F: Future<Output = ()> + 'static,
|
F: Future<Output = ()> + 'static,
|
||||||
{
|
{
|
||||||
@@ -98,6 +95,7 @@ impl Clone for CoroutineHandle<'_> {
|
|||||||
impl Copy for CoroutineHandle<'_> {}
|
impl Copy for CoroutineHandle<'_> {}
|
||||||
|
|
||||||
impl<'a> CoroutineHandle<'a> {
|
impl<'a> CoroutineHandle<'a> {
|
||||||
|
#[allow(clippy::needless_return)]
|
||||||
pub fn start(&self) {
|
pub fn start(&self) {
|
||||||
if self.is_running() {
|
if self.is_running() {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -6,12 +6,10 @@ use std::{
|
|||||||
use dioxus_core::ScopeState;
|
use dioxus_core::ScopeState;
|
||||||
|
|
||||||
pub fn use_ref<'a, T: 'static>(cx: &'a ScopeState, f: impl FnOnce() -> T) -> &'a UseRef<T> {
|
pub fn use_ref<'a, T: 'static>(cx: &'a ScopeState, f: impl FnOnce() -> T) -> &'a UseRef<T> {
|
||||||
let inner = cx.use_hook(|_| UseRef {
|
cx.use_hook(|_| UseRef {
|
||||||
update_callback: cx.schedule_update(),
|
update_callback: cx.schedule_update(),
|
||||||
value: Rc::new(RefCell::new(f())),
|
value: Rc::new(RefCell::new(f())),
|
||||||
});
|
})
|
||||||
|
|
||||||
inner
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct UseRef<T> {
|
pub struct UseRef<T> {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ pub fn use_suspense<R: 'static, F: Future<Output = R> + 'static>(
|
|||||||
});
|
});
|
||||||
|
|
||||||
if let Some(value) = sus.value.as_ref() {
|
if let Some(value) = sus.value.as_ref() {
|
||||||
render(&value)
|
render(value)
|
||||||
} else {
|
} else {
|
||||||
// generate a placeholder node if the future isnt ready
|
// generate a placeholder node if the future isnt ready
|
||||||
None
|
None
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ pub fn Link<'a>(cx: Scope<'a, LinkProps<'a>>) -> Element {
|
|||||||
id: format_args!("{}", cx.props.id.unwrap_or("")),
|
id: format_args!("{}", cx.props.id.unwrap_or("")),
|
||||||
|
|
||||||
prevent_default: "onclick",
|
prevent_default: "onclick",
|
||||||
onclick: move |_| service.push_route(cx.props.to.clone()),
|
onclick: move |_| service.push_route(cx.props.to),
|
||||||
|
|
||||||
&cx.props.children
|
&cx.props.children
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ pub fn Route<'a>(cx: Scope<'a, RouteProps<'a>>) -> Element {
|
|||||||
cx.use_hook(|_| {
|
cx.use_hook(|_| {
|
||||||
// create a bigger, better, longer route if one above us exists
|
// create a bigger, better, longer route if one above us exists
|
||||||
let total_route = match cx.consume_context::<RouteContext>() {
|
let total_route = match cx.consume_context::<RouteContext>() {
|
||||||
Some(ctx) => format!("{}", ctx.total_route.clone()),
|
Some(ctx) => ctx.total_route.to_string(),
|
||||||
None => format!("{}", cx.props.to.clone()),
|
None => cx.props.to.to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// provide our route context
|
// provide our route context
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#![allow(warnings)]
|
||||||
//! Dioxus-Router
|
//! Dioxus-Router
|
||||||
//!
|
//!
|
||||||
//! A simple match-based router and router service for most routing needs.
|
//! A simple match-based router and router service for most routing needs.
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ impl SsrRenderer {
|
|||||||
|
|
||||||
pub fn render_lazy<'a>(&'a mut self, f: LazyNodes<'a, '_>) -> String {
|
pub fn render_lazy<'a>(&'a mut self, f: LazyNodes<'a, '_>) -> String {
|
||||||
let scope = self.vdom.base_scope();
|
let scope = self.vdom.base_scope();
|
||||||
let factory = NodeFactory::new(&scope);
|
let factory = NodeFactory::new(scope);
|
||||||
|
|
||||||
let root = f.into_vnode(factory);
|
let root = f.into_vnode(factory);
|
||||||
format!(
|
format!(
|
||||||
@@ -38,6 +38,7 @@ impl SsrRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::needless_lifetimes)]
|
||||||
pub fn render_lazy<'a>(f: LazyNodes<'a, '_>) -> String {
|
pub fn render_lazy<'a>(f: LazyNodes<'a, '_>) -> String {
|
||||||
let vdom = VirtualDom::new(app);
|
let vdom = VirtualDom::new(app);
|
||||||
let scope: *const ScopeState = vdom.base_scope();
|
let scope: *const ScopeState = vdom.base_scope();
|
||||||
@@ -50,11 +51,11 @@ pub fn render_lazy<'a>(f: LazyNodes<'a, '_>) -> String {
|
|||||||
// When LazyNodes are provided, they are FnOnce, but do not come with a allocator selected to borrow from. The <'a>
|
// When LazyNodes are provided, they are FnOnce, but do not come with a allocator selected to borrow from. The <'a>
|
||||||
// lifetime is therefore longer than the lifetime of the allocator which doesn't exist... yet.
|
// lifetime is therefore longer than the lifetime of the allocator which doesn't exist... yet.
|
||||||
//
|
//
|
||||||
// Therefore, we cast our local bump alloactor into right lifetime. This is okay because our usage of the bump arena
|
// Therefore, we cast our local bump allocator to the right lifetime. This is okay because our usage of the bump
|
||||||
// is *definitely* shorter than the <'a> lifetime, and we return *owned* data - not borrowed data.
|
// arena is *definitely* shorter than the <'a> lifetime, and we return *owned* data - not borrowed data.
|
||||||
let scope = unsafe { &*scope };
|
let scope = unsafe { &*scope };
|
||||||
|
|
||||||
let root = f.into_vnode(NodeFactory::new(&scope));
|
let root = f.into_vnode(NodeFactory::new(scope));
|
||||||
|
|
||||||
format!(
|
format!(
|
||||||
"{:}",
|
"{:}",
|
||||||
|
|||||||
Reference in new issue
Block a user