Merge branch 'master' into cli-config-library
This commit is contained in:
commit
557630c419
6 files changed
+72
-44
No files matched your search
@@ -62,6 +62,7 @@ fn app(cx: Scope) -> Element {
|
|||||||
div { id: "wrapper",
|
div { id: "wrapper",
|
||||||
div { class: "app",
|
div { class: "app",
|
||||||
div { class: "calculator",
|
div { class: "calculator",
|
||||||
|
tabindex: "0",
|
||||||
onkeydown: handle_key_down_event,
|
onkeydown: handle_key_down_event,
|
||||||
div { class: "calculator-display", val.to_string() }
|
div { class: "calculator-display", val.to_string() }
|
||||||
div { class: "calculator-keypad",
|
div { class: "calculator-keypad",
|
||||||
|
|||||||
@@ -460,8 +460,14 @@ pub fn gen_page(config: &DioxusConfig, serve: bool) -> String {
|
|||||||
&style.to_str().unwrap(),
|
&style.to_str().unwrap(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
if config.application.tools.clone().contains_key("tailwindcss") {
|
if config
|
||||||
style_str.push_str("<link rel=\"stylesheet\" href=\"tailwind.css\">\n");
|
.application
|
||||||
|
.tools
|
||||||
|
.clone()
|
||||||
|
.unwrap_or_default()
|
||||||
|
.contains_key("tailwindcss")
|
||||||
|
{
|
||||||
|
style_str.push_str("<link rel=\"stylesheet\" href=\"/{base_path}/tailwind.css\">\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
replace_or_insert_before("{style_include}", &style_str, "</head", &mut html);
|
replace_or_insert_before("{style_include}", &style_str, "</head", &mut html);
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ pub enum Error {
|
|||||||
#[error("Cargo Error: {0}")]
|
#[error("Cargo Error: {0}")]
|
||||||
CargoError(String),
|
CargoError(String),
|
||||||
|
|
||||||
|
#[error("Couldn't retrieve cargo metadata")]
|
||||||
|
CargoMetadata(#[source] cargo_metadata::Error),
|
||||||
|
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
CustomError(String),
|
CustomError(String),
|
||||||
|
|
||||||
|
|||||||
+28
-39
@@ -10,42 +10,31 @@ use dioxus_cli::plugin::PluginManager;
|
|||||||
|
|
||||||
use Commands::*;
|
use Commands::*;
|
||||||
|
|
||||||
fn get_bin(bin: Option<String>) -> Result<Option<PathBuf>> {
|
fn get_bin(bin: Option<String>) -> Result<PathBuf> {
|
||||||
const ERR_MESSAGE: &str = "The `--bin` flag has to be ran in a Cargo workspace.";
|
let metadata = cargo_metadata::MetadataCommand::new()
|
||||||
|
.exec()
|
||||||
|
.map_err(Error::CargoMetadata)?;
|
||||||
|
let package = if let Some(bin) = bin {
|
||||||
|
metadata
|
||||||
|
.workspace_packages()
|
||||||
|
.into_iter()
|
||||||
|
.find(|p| p.name == bin)
|
||||||
|
.ok_or(format!("no such package: {}", bin))
|
||||||
|
.map_err(Error::CargoError)?
|
||||||
|
} else {
|
||||||
|
metadata
|
||||||
|
.root_package()
|
||||||
|
.ok_or("no root package?".into())
|
||||||
|
.map_err(Error::CargoError)?
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(ref bin) = bin {
|
let crate_dir = package
|
||||||
let manifest = cargo_toml::Manifest::from_path("./Cargo.toml")
|
.manifest_path
|
||||||
.map_err(|_| Error::CargoError(ERR_MESSAGE.to_string()))?;
|
.parent()
|
||||||
|
.ok_or("couldn't take parent dir".into())
|
||||||
|
.map_err(Error::CargoError)?;
|
||||||
|
|
||||||
if let Some(workspace) = manifest.workspace {
|
Ok(crate_dir.into())
|
||||||
for item in workspace.members.iter() {
|
|
||||||
let path = PathBuf::from(item);
|
|
||||||
|
|
||||||
if !path.exists() {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if !path.is_dir() {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if path.ends_with(bin.clone()) {
|
|
||||||
return Ok(Some(path));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return Err(Error::CargoError(ERR_MESSAGE.to_string()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the bin exists but we couldn't find it
|
|
||||||
if bin.is_some() {
|
|
||||||
return Err(Error::CargoError(
|
|
||||||
"The specified bin does not exist.".to_string(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(None)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
@@ -56,7 +45,7 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
let bin = get_bin(args.bin)?;
|
let bin = get_bin(args.bin)?;
|
||||||
|
|
||||||
let _dioxus_config = DioxusConfig::load(bin.clone())
|
let _dioxus_config = DioxusConfig::load(Some(bin.clone()))
|
||||||
.map_err(|e| anyhow!("Failed to load Dioxus config because: {e}"))?
|
.map_err(|e| anyhow!("Failed to load Dioxus config because: {e}"))?
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
log::warn!("You appear to be creating a Dioxus project from scratch; we will use the default config");
|
log::warn!("You appear to be creating a Dioxus project from scratch; we will use the default config");
|
||||||
@@ -73,15 +62,15 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
.map_err(|e| anyhow!("🚫 Translation of HTML into RSX failed: {}", e)),
|
.map_err(|e| anyhow!("🚫 Translation of HTML into RSX failed: {}", e)),
|
||||||
|
|
||||||
Build(opts) => opts
|
Build(opts) => opts
|
||||||
.build(bin.clone())
|
.build(Some(bin.clone()))
|
||||||
.map_err(|e| anyhow!("🚫 Building project failed: {}", e)),
|
.map_err(|e| anyhow!("🚫 Building project failed: {}", e)),
|
||||||
|
|
||||||
Clean(opts) => opts
|
Clean(opts) => opts
|
||||||
.clean(bin.clone())
|
.clean(Some(bin.clone()))
|
||||||
.map_err(|e| anyhow!("🚫 Cleaning project failed: {}", e)),
|
.map_err(|e| anyhow!("🚫 Cleaning project failed: {}", e)),
|
||||||
|
|
||||||
Serve(opts) => opts
|
Serve(opts) => opts
|
||||||
.serve(bin.clone())
|
.serve(Some(bin.clone()))
|
||||||
.await
|
.await
|
||||||
.map_err(|e| anyhow!("🚫 Serving project failed: {}", e)),
|
.map_err(|e| anyhow!("🚫 Serving project failed: {}", e)),
|
||||||
|
|
||||||
@@ -94,7 +83,7 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
.map_err(|e| anyhow!("🚫 Configuring new project failed: {}", e)),
|
.map_err(|e| anyhow!("🚫 Configuring new project failed: {}", e)),
|
||||||
|
|
||||||
Bundle(opts) => opts
|
Bundle(opts) => opts
|
||||||
.bundle(bin.clone())
|
.bundle(Some(bin.clone()))
|
||||||
.map_err(|e| anyhow!("🚫 Bundling project failed: {}", e)),
|
.map_err(|e| anyhow!("🚫 Bundling project failed: {}", e)),
|
||||||
|
|
||||||
#[cfg(feature = "plugin")]
|
#[cfg(feature = "plugin")]
|
||||||
|
|||||||
@@ -23,8 +23,37 @@ use crate::{innerlude::VNode, ScopeState};
|
|||||||
///
|
///
|
||||||
///
|
///
|
||||||
/// ```rust, ignore
|
/// ```rust, ignore
|
||||||
/// LazyNodes::new(|f| f.element("div", [], [], [] None))
|
/// LazyNodes::new(|f| {
|
||||||
|
/// static TEMPLATE: dioxus::core::Template = dioxus::core::Template {
|
||||||
|
/// name: "main.rs:5:5:20", // Source location of the template for hot reloading
|
||||||
|
/// roots: &[
|
||||||
|
/// dioxus::core::TemplateNode::Element {
|
||||||
|
/// tag: dioxus_elements::div::TAG_NAME,
|
||||||
|
/// namespace: dioxus_elements::div::NAME_SPACE,
|
||||||
|
/// attrs: &[],
|
||||||
|
/// children: &[],
|
||||||
|
/// },
|
||||||
|
/// ],
|
||||||
|
/// node_paths: &[],
|
||||||
|
/// attr_paths: &[],
|
||||||
|
/// };
|
||||||
|
/// dioxus::core::VNode {
|
||||||
|
/// parent: None,
|
||||||
|
/// key: None,
|
||||||
|
/// template: std::cell::Cell::new(TEMPLATE),
|
||||||
|
/// root_ids: dioxus::core::exports::bumpalo::collections::Vec::with_capacity_in(
|
||||||
|
/// 1usize,
|
||||||
|
/// f.bump(),
|
||||||
|
/// )
|
||||||
|
/// .into(),
|
||||||
|
/// dynamic_nodes: f.bump().alloc([]),
|
||||||
|
/// dynamic_attrs: f.bump().alloc([]),
|
||||||
|
/// })
|
||||||
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
///
|
||||||
|
/// Find more information about how to construct [`VNode`] at <https://dioxuslabs.com/learn/0.4/contributing/walkthrough_readme#the-rsx-macro>
|
||||||
|
|
||||||
pub struct LazyNodes<'a, 'b> {
|
pub struct LazyNodes<'a, 'b> {
|
||||||
#[cfg(not(miri))]
|
#[cfg(not(miri))]
|
||||||
inner: SmallBox<dyn FnMut(&'a ScopeState) -> VNode<'a> + 'b, S16>,
|
inner: SmallBox<dyn FnMut(&'a ScopeState) -> VNode<'a> + 'b, S16>,
|
||||||
@@ -61,7 +90,7 @@ impl<'a, 'b> LazyNodes<'a, 'b> {
|
|||||||
/// Call the closure with the given factory to produce real [`VNode`].
|
/// Call the closure with the given factory to produce real [`VNode`].
|
||||||
///
|
///
|
||||||
/// ```rust, ignore
|
/// ```rust, ignore
|
||||||
/// let f = LazyNodes::new(move |f| f.element("div", [], [], [] None));
|
/// let f = LazyNodes::new(/* Closure for creating VNodes */);
|
||||||
///
|
///
|
||||||
/// let node = f.call(cac);
|
/// let node = f.call(cac);
|
||||||
/// ```
|
/// ```
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ fn default_external_navigation_handler() -> fn(Scope) -> Element {
|
|||||||
dioxus_router::prelude::FailureExternalNavigation
|
dioxus_router::prelude::FailureExternalNavigation
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The configeration for the router
|
/// The configuration for the router
|
||||||
#[derive(Props, serde::Serialize, serde::Deserialize)]
|
#[derive(Props, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct FullstackRouterConfig<R>
|
pub struct FullstackRouterConfig<R>
|
||||||
where
|
where
|
||||||
|
|||||||
Reference in new issue
Block a user