wip: start to refactor out hot reloading from packages

Also implement alternative simpler template system
This commit is contained in:
Jonathan Kelley committed 2022-10-20 09:56:09 -07:00
1 parent 3b7b503333
commit 90982e0ccb
44 files changed
+3865 -5133

No files matched your search

+27 -81
View File
@@ -1,5 +1,8 @@
#![allow(non_upper_case_globals)]
use crate::{GlobalAttributes, SvgAttributes};
use dioxus_core::*;
pub type AttributeDiscription = (&'static str, Option<&'static str>, bool);
macro_rules! builder_constructors {
(
@@ -18,23 +21,17 @@ macro_rules! builder_constructors {
$(#[$attr])*
pub struct $name;
impl DioxusElement for $name {
const TAG_NAME: &'static str = stringify!($name);
const NAME_SPACE: Option<&'static str> = None;
impl $name {
pub const TAG_NAME: &'static str = stringify!($name);
pub const NAME_SPACE: Option<&'static str> = None;
$(
pub const $fil: (&'static str, &'static str) = (stringify!($fil), stringify!($vil));
)*
}
impl GlobalAttributes for $name {}
impl $name {
$(
#[allow(non_upper_case_globals)]
pub const $fil: AttributeDiscription = AttributeDiscription{
name: stringify!($fil),
namespace: None,
volatile: false
};
)*
}
)*
};
@@ -49,22 +46,14 @@ macro_rules! builder_constructors {
$(#[$attr])*
pub struct $name;
impl DioxusElement for $name {
const TAG_NAME: &'static str = stringify!($name);
const NAME_SPACE: Option<&'static str> = Some($namespace);
}
impl SvgAttributes for $name {}
impl $name {
$(
pub const TAG_NAME: &'static str = stringify!($name);
pub const NAME_SPACE: Option<&'static str> = Some($namespace);
#[allow(non_upper_case_globals)]
pub const $fil: AttributeDiscription = AttributeDiscription{
name: stringify!($fil),
namespace: Some(stringify!($namespace)),
volatile: false
};
$(
pub const $fil: AttributeDiscription = (stringify!($fil), Some(stringify!($namespace)), false)
)*
}
)*
@@ -1068,19 +1057,10 @@ impl input {
/// - `time`
/// - `url`
/// - `week`
#[allow(non_upper_case_globals)]
pub const r#type: AttributeDiscription = AttributeDiscription {
name: "type",
namespace: None,
volatile: false,
};
#[allow(non_upper_case_globals)]
pub const value: AttributeDiscription = AttributeDiscription {
name: "value",
namespace: None,
volatile: true,
};
pub const r#type: AttributeDiscription = ("type", None, false);
pub const value: AttributeDiscription = ("value", None, true);
}
/*
@@ -1090,63 +1070,29 @@ volatile attributes
impl script {
// r#async: Bool,
// r#type: String, // TODO could be an enum
#[allow(non_upper_case_globals)]
pub const r#type: AttributeDiscription = AttributeDiscription {
name: "type",
namespace: None,
volatile: false,
};
#[allow(non_upper_case_globals)]
pub const r#script: AttributeDiscription = AttributeDiscription {
name: "script",
namespace: None,
volatile: false,
};
pub const r#type: AttributeDiscription = ("type", None, false);
pub const r#script: AttributeDiscription = ("script", None, false);
}
impl button {
#[allow(non_upper_case_globals)]
pub const r#type: AttributeDiscription = AttributeDiscription {
name: "type",
namespace: None,
volatile: false,
};
pub const r#type: AttributeDiscription = ("type", None, false);
}
impl select {
#[allow(non_upper_case_globals)]
pub const value: AttributeDiscription = AttributeDiscription {
name: "value",
namespace: None,
volatile: true,
};
pub const value: AttributeDiscription = ("value", None, true);
}
impl option {
#[allow(non_upper_case_globals)]
pub const selected: AttributeDiscription = AttributeDiscription {
name: "selected",
namespace: None,
volatile: true,
};
pub const selected: AttributeDiscription = ("selected", None, true);
}
impl textarea {
#[allow(non_upper_case_globals)]
pub const value: AttributeDiscription = AttributeDiscription {
name: "value",
namespace: None,
volatile: true,
};
pub const value: AttributeDiscription = ("value", None, true);
}
impl label {
#[allow(non_upper_case_globals)]
pub const r#for: AttributeDiscription = AttributeDiscription {
name: "for",
namespace: None,
volatile: false,
};
pub const r#for: AttributeDiscription = ("for", None, false);
}
builder_constructors! {
+22 -31
View File
@@ -1,4 +1,6 @@
use dioxus_core::*;
#![allow(non_upper_case_globals)]
use crate::AttributeDiscription;
macro_rules! no_namespace_trait_methods {
(
@@ -8,12 +10,11 @@ macro_rules! no_namespace_trait_methods {
)*
) => {
$(
#[allow(non_upper_case_globals)]
const $name: AttributeDiscription = AttributeDiscription{
name: stringify!($name),
namespace: None,
volatile: false
};
const $name: AttributeDiscription = (
stringify!($name),
None,
false
);
)*
};
}
@@ -25,12 +26,11 @@ macro_rules! style_trait_methods {
)*
) => {
$(
#[allow(non_upper_case_globals)]
const $name: AttributeDiscription = AttributeDiscription{
name: $lit,
namespace: Some("style"),
volatile: false
};
const $name: AttributeDiscription = (
$lit,
Some("style"),
false
);
)*
};
}
@@ -42,12 +42,11 @@ macro_rules! aria_trait_methods {
)*
) => {
$(
#[allow(non_upper_case_globals)]
const $name: AttributeDiscription = AttributeDiscription{
name: $lit,
namespace: None,
volatile: false
};
const $name: AttributeDiscription = (
$lit,
None,
false
);
)*
};
}
@@ -57,12 +56,8 @@ pub trait GlobalAttributes {
///
/// For more information, see the MDN docs:
/// <https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault>
#[allow(non_upper_case_globals)]
const prevent_default: AttributeDiscription = AttributeDiscription {
name: "dioxus-prevent-default",
namespace: None,
volatile: false,
};
const prevent_default: AttributeDiscription = ("dioxus-prevent-default", None, false);
no_namespace_trait_methods! {
accesskey;
@@ -604,12 +599,8 @@ pub trait SvgAttributes {
///
/// For more information, see the MDN docs:
/// <https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault>
#[allow(non_upper_case_globals)]
const prevent_default: AttributeDiscription = AttributeDiscription {
name: "dioxus-prevent-default",
namespace: None,
volatile: false,
};
const prevent_default: AttributeDiscription = ("dioxus-prevent-default", None, false);
aria_trait_methods! {
accent_height: "accent-height",
accumulate: "accumulate",