fix formatting
This commit is contained in:
1 parent
4c3fb1a33f
commit
7453486448
11 files changed
+85
-41
No files matched your search
@@ -136,12 +136,16 @@ async fn autoformat_project(check: bool) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn collect_rs_files(folder: &Path, files: &mut Vec<PathBuf>) {
|
fn collect_rs_files(folder: &Path, files: &mut Vec<PathBuf>) {
|
||||||
let Ok(folder) = folder.read_dir() else { return };
|
let Ok(folder) = folder.read_dir() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
// load the gitignore
|
// load the gitignore
|
||||||
|
|
||||||
for entry in folder {
|
for entry in folder {
|
||||||
let Ok(entry) = entry else { continue; };
|
let Ok(entry) = entry else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ fn default_plugin() -> toml::Value {
|
|||||||
|
|
||||||
impl DioxusConfig {
|
impl DioxusConfig {
|
||||||
pub fn load() -> crate::error::Result<Option<DioxusConfig>> {
|
pub fn load() -> crate::error::Result<Option<DioxusConfig>> {
|
||||||
let Ok(crate_dir) = crate::cargo::crate_root() else { return Ok(None); };
|
let Ok(crate_dir) = crate::cargo::crate_root() else {
|
||||||
|
return Ok(None);
|
||||||
|
};
|
||||||
let crate_dir = crate_dir.as_path();
|
let crate_dir = crate_dir.as_path();
|
||||||
|
|
||||||
let Some(dioxus_conf_file) = acquire_dioxus_toml(crate_dir) else {
|
let Some(dioxus_conf_file) = acquire_dioxus_toml(crate_dir) else {
|
||||||
|
|||||||
@@ -56,10 +56,9 @@ where
|
|||||||
{
|
{
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
let Ok(file_engine) =
|
let Ok(file_engine) = SerializedFileEngine::deserialize(deserializer) else {
|
||||||
SerializedFileEngine::deserialize(deserializer) else{
|
return Ok(None);
|
||||||
return Ok(None);
|
};
|
||||||
};
|
|
||||||
|
|
||||||
let file_engine = std::sync::Arc::new(file_engine);
|
let file_engine = std::sync::Arc::new(file_engine);
|
||||||
Ok(Some(file_engine))
|
Ok(Some(file_engine))
|
||||||
|
|||||||
@@ -82,7 +82,9 @@ impl Button {
|
|||||||
fn write_value(&self, rdom: &mut RealDom) {
|
fn write_value(&self, rdom: &mut RealDom) {
|
||||||
if let Some(mut text) = rdom.get_mut(self.text_id) {
|
if let Some(mut text) = rdom.get_mut(self.text_id) {
|
||||||
let node_type = text.node_type_mut();
|
let node_type = text.node_type_mut();
|
||||||
let NodeTypeMut::Text(mut text) = node_type else { panic!("input must be an element") };
|
let NodeTypeMut::Text(mut text) = node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
*text.text_mut() = self.value.clone();
|
*text.text_mut() = self.value.clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,7 +113,9 @@ impl CustomElement for Button {
|
|||||||
|
|
||||||
fn create(mut root: dioxus_native_core::real_dom::NodeMut) -> Self {
|
fn create(mut root: dioxus_native_core::real_dom::NodeMut) -> Self {
|
||||||
let node_type = root.node_type();
|
let node_type = root.node_type();
|
||||||
let NodeType::Element(el) = &*node_type else { panic!("input must be an element") };
|
let NodeType::Element(el) = &*node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
|
|
||||||
let value = el
|
let value = el
|
||||||
.attributes
|
.attributes
|
||||||
@@ -146,7 +150,9 @@ impl CustomElement for Button {
|
|||||||
AttributeMask::All => {
|
AttributeMask::All => {
|
||||||
{
|
{
|
||||||
let node_type = root.node_type_mut();
|
let node_type = root.node_type_mut();
|
||||||
let NodeTypeMut::Element(mut el) = node_type else { panic!("input must be an element") };
|
let NodeTypeMut::Element(mut el) = node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
self.update_value_attr(&el);
|
self.update_value_attr(&el);
|
||||||
self.update_size_attr(&mut el);
|
self.update_size_attr(&mut el);
|
||||||
}
|
}
|
||||||
@@ -155,7 +161,9 @@ impl CustomElement for Button {
|
|||||||
AttributeMask::Some(attrs) => {
|
AttributeMask::Some(attrs) => {
|
||||||
{
|
{
|
||||||
let node_type = root.node_type_mut();
|
let node_type = root.node_type_mut();
|
||||||
let NodeTypeMut::Element(mut el) = node_type else { panic!("input must be an element") };
|
let NodeTypeMut::Element(mut el) = node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
if attrs.contains("width") || attrs.contains("height") {
|
if attrs.contains("width") || attrs.contains("height") {
|
||||||
self.update_size_attr(&mut el);
|
self.update_size_attr(&mut el);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,14 +94,18 @@ impl CheckBox {
|
|||||||
fn write_value(&self, mut root: NodeMut) {
|
fn write_value(&self, mut root: NodeMut) {
|
||||||
let single_char = {
|
let single_char = {
|
||||||
let node_type = root.node_type_mut();
|
let node_type = root.node_type_mut();
|
||||||
let NodeTypeMut::Element( el) = node_type else { panic!("input must be an element") };
|
let NodeTypeMut::Element(el) = node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
Self::width(&el) == "1px" || Self::height(&el) == "1px"
|
Self::width(&el) == "1px" || Self::height(&el) == "1px"
|
||||||
};
|
};
|
||||||
let rdom = root.real_dom_mut();
|
let rdom = root.real_dom_mut();
|
||||||
|
|
||||||
if let Some(mut text) = rdom.get_mut(self.text_id) {
|
if let Some(mut text) = rdom.get_mut(self.text_id) {
|
||||||
let node_type = text.node_type_mut();
|
let node_type = text.node_type_mut();
|
||||||
let NodeTypeMut::Text(mut text) = node_type else { panic!("input must be an element") };
|
let NodeTypeMut::Text(mut text) = node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
let value = if single_char {
|
let value = if single_char {
|
||||||
if self.checked {
|
if self.checked {
|
||||||
"☑"
|
"☑"
|
||||||
@@ -156,7 +160,9 @@ impl CustomElement for CheckBox {
|
|||||||
|
|
||||||
fn create(mut root: dioxus_native_core::real_dom::NodeMut) -> Self {
|
fn create(mut root: dioxus_native_core::real_dom::NodeMut) -> Self {
|
||||||
let node_type = root.node_type();
|
let node_type = root.node_type();
|
||||||
let NodeType::Element(el) = &*node_type else { panic!("input must be an element") };
|
let NodeType::Element(el) = &*node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
|
|
||||||
let value = el
|
let value = el
|
||||||
.attributes
|
.attributes
|
||||||
@@ -197,7 +203,9 @@ impl CustomElement for CheckBox {
|
|||||||
AttributeMask::All => {
|
AttributeMask::All => {
|
||||||
{
|
{
|
||||||
let node_type = root.node_type_mut();
|
let node_type = root.node_type_mut();
|
||||||
let NodeTypeMut::Element(mut el) = node_type else { panic!("input must be an element") };
|
let NodeTypeMut::Element(mut el) = node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
self.update_value_attr(&el);
|
self.update_value_attr(&el);
|
||||||
self.update_size_attr(&mut el);
|
self.update_size_attr(&mut el);
|
||||||
self.update_checked_attr(&el);
|
self.update_checked_attr(&el);
|
||||||
@@ -207,7 +215,9 @@ impl CustomElement for CheckBox {
|
|||||||
AttributeMask::Some(attrs) => {
|
AttributeMask::Some(attrs) => {
|
||||||
{
|
{
|
||||||
let node_type = root.node_type_mut();
|
let node_type = root.node_type_mut();
|
||||||
let NodeTypeMut::Element(mut el) = node_type else { panic!("input must be an element") };
|
let NodeTypeMut::Element(mut el) = node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
if attrs.contains("width") || attrs.contains("height") {
|
if attrs.contains("width") || attrs.contains("height") {
|
||||||
self.update_size_attr(&mut el);
|
self.update_size_attr(&mut el);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,9 @@ impl CustomElement for Input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let node_type = root.node_type();
|
let node_type = root.node_type();
|
||||||
let NodeType::Element(el) = &*node_type else { panic!("input must be an element") };
|
let NodeType::Element(el) = &*node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
let input_type = el
|
let input_type = el
|
||||||
.attributes
|
.attributes
|
||||||
.get(&OwnedAttributeDiscription {
|
.get(&OwnedAttributeDiscription {
|
||||||
|
|||||||
@@ -163,7 +163,9 @@ impl Slider {
|
|||||||
|
|
||||||
if let Some(mut div) = rdom.get_mut(self.pre_cursor_div) {
|
if let Some(mut div) = rdom.get_mut(self.pre_cursor_div) {
|
||||||
let node_type = div.node_type_mut();
|
let node_type = div.node_type_mut();
|
||||||
let NodeTypeMut::Element(mut element) = node_type else { panic!("input must be an element") };
|
let NodeTypeMut::Element(mut element) = node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
element.set_attribute(
|
element.set_attribute(
|
||||||
OwnedAttributeDiscription {
|
OwnedAttributeDiscription {
|
||||||
name: "width".to_string(),
|
name: "width".to_string(),
|
||||||
@@ -175,7 +177,9 @@ impl Slider {
|
|||||||
|
|
||||||
if let Some(mut div) = rdom.get_mut(self.post_cursor_div) {
|
if let Some(mut div) = rdom.get_mut(self.post_cursor_div) {
|
||||||
let node_type = div.node_type_mut();
|
let node_type = div.node_type_mut();
|
||||||
let NodeTypeMut::Element(mut element) = node_type else { panic!("input must be an element") };
|
let NodeTypeMut::Element(mut element) = node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
element.set_attribute(
|
element.set_attribute(
|
||||||
OwnedAttributeDiscription {
|
OwnedAttributeDiscription {
|
||||||
name: "width".to_string(),
|
name: "width".to_string(),
|
||||||
@@ -259,7 +263,9 @@ impl CustomElement for Slider {
|
|||||||
|
|
||||||
fn create(mut root: dioxus_native_core::real_dom::NodeMut) -> Self {
|
fn create(mut root: dioxus_native_core::real_dom::NodeMut) -> Self {
|
||||||
let node_type = root.node_type();
|
let node_type = root.node_type();
|
||||||
let NodeType::Element(el) = &*node_type else { panic!("input must be an element") };
|
let NodeType::Element(el) = &*node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
|
|
||||||
let value = el.attributes.get(&OwnedAttributeDiscription {
|
let value = el.attributes.get(&OwnedAttributeDiscription {
|
||||||
name: "value".to_string(),
|
name: "value".to_string(),
|
||||||
@@ -390,7 +396,9 @@ impl CustomElement for Slider {
|
|||||||
AttributeMask::All => {
|
AttributeMask::All => {
|
||||||
{
|
{
|
||||||
let node_type = root.node_type_mut();
|
let node_type = root.node_type_mut();
|
||||||
let NodeTypeMut::Element(mut el) = node_type else { panic!("input must be an element") };
|
let NodeTypeMut::Element(mut el) = node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
self.update_value_attr(&el);
|
self.update_value_attr(&el);
|
||||||
self.update_size_attr(&mut el);
|
self.update_size_attr(&mut el);
|
||||||
self.update_max_attr(&el);
|
self.update_max_attr(&el);
|
||||||
@@ -403,7 +411,9 @@ impl CustomElement for Slider {
|
|||||||
AttributeMask::Some(attrs) => {
|
AttributeMask::Some(attrs) => {
|
||||||
{
|
{
|
||||||
let node_type = root.node_type_mut();
|
let node_type = root.node_type_mut();
|
||||||
let NodeTypeMut::Element(mut el) = node_type else { panic!("input must be an element") };
|
let NodeTypeMut::Element(mut el) = node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
if attrs.contains("width") || attrs.contains("height") {
|
if attrs.contains("width") || attrs.contains("height") {
|
||||||
self.update_size_attr(&mut el);
|
self.update_size_attr(&mut el);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,19 +143,25 @@ impl<C: TextLikeController> TextLike<C> {
|
|||||||
|
|
||||||
if let Some(mut text) = rdom.get_mut(self.pre_cursor_text) {
|
if let Some(mut text) = rdom.get_mut(self.pre_cursor_text) {
|
||||||
let node_type = text.node_type_mut();
|
let node_type = text.node_type_mut();
|
||||||
let NodeTypeMut::Text(mut text) = node_type else { panic!("input must be an element") };
|
let NodeTypeMut::Text(mut text) = node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
*text.text_mut() = self.controller.display_text(text_before_first_cursor);
|
*text.text_mut() = self.controller.display_text(text_before_first_cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(mut text) = rdom.get_mut(self.highlighted_text) {
|
if let Some(mut text) = rdom.get_mut(self.highlighted_text) {
|
||||||
let node_type = text.node_type_mut();
|
let node_type = text.node_type_mut();
|
||||||
let NodeTypeMut::Text(mut text) = node_type else { panic!("input must be an element") };
|
let NodeTypeMut::Text(mut text) = node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
*text.text_mut() = self.controller.display_text(text_highlighted);
|
*text.text_mut() = self.controller.display_text(text_highlighted);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(mut text) = rdom.get_mut(self.post_cursor_text) {
|
if let Some(mut text) = rdom.get_mut(self.post_cursor_text) {
|
||||||
let node_type = text.node_type_mut();
|
let node_type = text.node_type_mut();
|
||||||
let NodeTypeMut::Text(mut text) = node_type else { panic!("input must be an element") };
|
let NodeTypeMut::Text(mut text) = node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
*text.text_mut() = self.controller.display_text(text_after_second_cursor);
|
*text.text_mut() = self.controller.display_text(text_after_second_cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,7 +294,9 @@ impl<C: TextLikeController + Send + Sync + Default + 'static> CustomElement for
|
|||||||
|
|
||||||
fn create(mut root: dioxus_native_core::real_dom::NodeMut) -> Self {
|
fn create(mut root: dioxus_native_core::real_dom::NodeMut) -> Self {
|
||||||
let node_type = root.node_type();
|
let node_type = root.node_type();
|
||||||
let NodeType::Element(el) = &*node_type else { panic!("input must be an element") };
|
let NodeType::Element(el) = &*node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
|
|
||||||
let value = el
|
let value = el
|
||||||
.attributes
|
.attributes
|
||||||
@@ -370,7 +378,9 @@ impl<C: TextLikeController + Send + Sync + Default + 'static> CustomElement for
|
|||||||
AttributeMask::All => {
|
AttributeMask::All => {
|
||||||
{
|
{
|
||||||
let node_type = root.node_type_mut();
|
let node_type = root.node_type_mut();
|
||||||
let NodeTypeMut::Element(mut el) = node_type else { panic!("input must be an element") };
|
let NodeTypeMut::Element(mut el) = node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
self.update_value_attr(&el);
|
self.update_value_attr(&el);
|
||||||
self.update_size_attr(&mut el);
|
self.update_size_attr(&mut el);
|
||||||
self.update_max_width_attr(&el);
|
self.update_max_width_attr(&el);
|
||||||
@@ -381,7 +391,9 @@ impl<C: TextLikeController + Send + Sync + Default + 'static> CustomElement for
|
|||||||
AttributeMask::Some(attrs) => {
|
AttributeMask::Some(attrs) => {
|
||||||
{
|
{
|
||||||
let node_type = root.node_type_mut();
|
let node_type = root.node_type_mut();
|
||||||
let NodeTypeMut::Element(mut el) = node_type else { panic!("input must be an element") };
|
let NodeTypeMut::Element(mut el) = node_type else {
|
||||||
|
panic!("input must be an element")
|
||||||
|
};
|
||||||
if attrs.contains("width") || attrs.contains("height") {
|
if attrs.contains("width") || attrs.contains("height") {
|
||||||
self.update_size_attr(&mut el);
|
self.update_size_attr(&mut el);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -369,13 +369,13 @@ impl RouteEnum {
|
|||||||
let (exclude, layout): (bool, Layout) = attr.parse_args_with(parser)?;
|
let (exclude, layout): (bool, Layout) = attr.parse_args_with(parser)?;
|
||||||
|
|
||||||
if exclude {
|
if exclude {
|
||||||
let Some(layout_index) =
|
let Some(layout_index) = layouts.iter().position(|l| l.comp == layout.comp)
|
||||||
layouts.iter().position(|l| l.comp == layout.comp) else {
|
else {
|
||||||
return Err(syn::Error::new(
|
return Err(syn::Error::new(
|
||||||
Span::call_site(),
|
Span::call_site(),
|
||||||
"Attempted to exclude a layout that does not exist",
|
"Attempted to exclude a layout that does not exist",
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
excluded.push(LayoutId(layout_index));
|
excluded.push(LayoutId(layout_index));
|
||||||
} else {
|
} else {
|
||||||
let layout_index = layouts.len();
|
let layout_index = layouts.len();
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
path::{PathBuf},
|
path::PathBuf,
|
||||||
time::{Duration},
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// Information about the freshness of a rendered response
|
/// Information about the freshness of a rendered response
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct RenderFreshness {
|
pub struct RenderFreshness {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use std::{
|
|||||||
hash::BuildHasherDefault,
|
hash::BuildHasherDefault,
|
||||||
io::Write,
|
io::Write,
|
||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
path::{PathBuf},
|
path::PathBuf,
|
||||||
time::{Duration, SystemTime},
|
time::{Duration, SystemTime},
|
||||||
};
|
};
|
||||||
use tokio::io::{AsyncWrite, AsyncWriteExt, BufReader};
|
use tokio::io::{AsyncWrite, AsyncWriteExt, BufReader};
|
||||||
|
|||||||
Reference in new issue
Block a user