chore: polish
This commit is contained in:
1 parent
25a8411485
commit
8bf57dc21d
5 files changed
+63
-25
No files matched your search
@@ -43,7 +43,7 @@ impl ToTokens for CallBody {
|
|||||||
quote! {#inner}
|
quote! {#inner}
|
||||||
} else {
|
} else {
|
||||||
let childs = &self.roots;
|
let childs = &self.roots;
|
||||||
quote! { __cx.fragment_from_iter([ #(#childs),* ]) }
|
quote! { __cx.fragment_root([ #(#childs),* ]) }
|
||||||
};
|
};
|
||||||
|
|
||||||
match &self.custom_context {
|
match &self.custom_context {
|
||||||
|
|||||||
@@ -643,6 +643,29 @@ impl<'a> NodeFactory<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn fragment_root<'b, 'c>(
|
||||||
|
self,
|
||||||
|
node_iter: impl IntoIterator<Item = impl IntoVNode<'a> + 'c> + 'b,
|
||||||
|
) -> VNode<'a> {
|
||||||
|
let bump = self.bump;
|
||||||
|
let mut nodes = bumpalo::collections::Vec::new_in(bump);
|
||||||
|
|
||||||
|
for node in node_iter {
|
||||||
|
nodes.push(node.into_vnode(self));
|
||||||
|
}
|
||||||
|
|
||||||
|
if nodes.is_empty() {
|
||||||
|
nodes.push(VNode::Anchor(bump.alloc(VAnchor {
|
||||||
|
dom_id: empty_cell(),
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
|
||||||
|
VNode::Fragment(VFragment {
|
||||||
|
children: nodes.into_bump_slice(),
|
||||||
|
key: None,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
pub fn fragment_from_iter<'b, 'c>(
|
pub fn fragment_from_iter<'b, 'c>(
|
||||||
self,
|
self,
|
||||||
node_iter: impl IntoIterator<Item = impl IntoVNode<'a> + 'c> + 'b,
|
node_iter: impl IntoIterator<Item = impl IntoVNode<'a> + 'c> + 'b,
|
||||||
@@ -665,20 +688,17 @@ impl<'a> NodeFactory<'a> {
|
|||||||
// todo: add a backtrace
|
// todo: add a backtrace
|
||||||
if cfg!(debug_assertions) && children.len() > 1 && children.last().unwrap().key().is_none()
|
if cfg!(debug_assertions) && children.len() > 1 && children.last().unwrap().key().is_none()
|
||||||
{
|
{
|
||||||
// todo: rsx! calls get turned into fragments which means they always trip this error
|
use backtrace::Backtrace;
|
||||||
//
|
let bt = Backtrace::new();
|
||||||
//
|
|
||||||
// use backtrace::Backtrace;
|
|
||||||
// let bt = Backtrace::new();
|
|
||||||
|
|
||||||
log::error!(
|
log::error!(
|
||||||
r#"
|
r#"
|
||||||
Warning: Each child in an array or iterator should have a unique "key" prop.
|
Warning: Each child in an array or iterator should have a unique "key" prop.
|
||||||
Not providing a key will lead to poor performance with lists.
|
Not providing a key will lead to poor performance with lists.
|
||||||
See docs.rs/dioxus for more information.
|
See docs.rs/dioxus for more information.
|
||||||
-------------
|
-------------
|
||||||
|
{:?}
|
||||||
"#,
|
"#,
|
||||||
// bt
|
bt
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -347,11 +347,11 @@ impl Scope {
|
|||||||
/// cx.render(lazy_tree)
|
/// cx.render(lazy_tree)
|
||||||
/// }
|
/// }
|
||||||
///```
|
///```
|
||||||
pub fn render<'src>(&'src self, lazy_nodes: Option<LazyNodes<'src, '_>>) -> Option<NodeLink> {
|
pub fn render<'src>(&'src self, rsx: Option<LazyNodes<'src, '_>>) -> Option<NodeLink> {
|
||||||
let frame = self.wip_frame();
|
let frame = self.wip_frame();
|
||||||
let bump = &frame.bump;
|
let bump = &frame.bump;
|
||||||
let factory = NodeFactory { bump };
|
let factory = NodeFactory { bump };
|
||||||
let node = lazy_nodes.map(|f| f.call(factory))?;
|
let node = rsx.map(|f| f.call(factory))?;
|
||||||
let node = bump.alloc(node);
|
let node = bump.alloc(node);
|
||||||
|
|
||||||
let node_ptr = node as *mut _;
|
let node_ptr = node as *mut _;
|
||||||
|
|||||||
@@ -54,11 +54,6 @@ pub fn launch_with_props<P: Properties + 'static + Send + Sync>(
|
|||||||
run(root, props, builder)
|
run(root, props, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
|
||||||
enum RpcEvent<'a> {
|
|
||||||
Initialize { edits: Vec<DomEdit<'a>> },
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct Response<'a> {
|
struct Response<'a> {
|
||||||
pre_rendered: Option<String>,
|
pre_rendered: Option<String>,
|
||||||
@@ -74,7 +69,7 @@ pub fn run<T: 'static + Send + Sync>(
|
|||||||
let mut cfg = DesktopConfig::new();
|
let mut cfg = DesktopConfig::new();
|
||||||
user_builder(&mut cfg);
|
user_builder(&mut cfg);
|
||||||
let DesktopConfig {
|
let DesktopConfig {
|
||||||
window,
|
window: window_cfg,
|
||||||
manual_edits,
|
manual_edits,
|
||||||
pre_rendered,
|
pre_rendered,
|
||||||
..
|
..
|
||||||
@@ -100,7 +95,7 @@ pub fn run<T: 'static + Send + Sync>(
|
|||||||
|
|
||||||
match window_event {
|
match window_event {
|
||||||
Event::NewEvents(StartCause::Init) => {
|
Event::NewEvents(StartCause::Init) => {
|
||||||
let window = create_window(event_loop);
|
let window = create_window(event_loop, &window_cfg);
|
||||||
let window_id = window.id();
|
let window_id = window.id();
|
||||||
let sender =
|
let sender =
|
||||||
launch_vdom_with_tokio(root, props_shared.take().unwrap(), edit_queue.clone());
|
launch_vdom_with_tokio(root, props_shared.take().unwrap(), edit_queue.clone());
|
||||||
@@ -234,13 +229,9 @@ fn build_menu() -> MenuBar {
|
|||||||
menu_bar_menu
|
menu_bar_menu
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_window(event_loop: &EventLoopWindowTarget<()>) -> Window {
|
fn create_window(event_loop: &EventLoopWindowTarget<()>, cfg: &WindowBuilder) -> Window {
|
||||||
WindowBuilder::new()
|
let builder = cfg.clone().with_menu(build_menu());
|
||||||
.with_maximized(true)
|
builder.build(event_loop).unwrap()
|
||||||
.with_menu(build_menu())
|
|
||||||
.with_title("Dioxus App")
|
|
||||||
.build(event_loop)
|
|
||||||
.unwrap()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_webview(
|
fn create_webview(
|
||||||
@@ -264,7 +255,7 @@ fn create_webview(
|
|||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
// always driven through eval
|
||||||
None
|
None
|
||||||
})
|
})
|
||||||
// Any content that that uses the `wry://` scheme will be shuttled through this handler as a "special case"
|
// Any content that that uses the `wry://` scheme will be shuttled through this handler as a "special case"
|
||||||
|
|||||||
@@ -682,8 +682,35 @@ builder_constructors! {
|
|||||||
/// Build a
|
/// Build a
|
||||||
/// [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
|
/// [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
|
||||||
/// element.
|
/// element.
|
||||||
|
///
|
||||||
|
/// The [`script`] HTML element is used to embed executable code or data; this is typically used to embed or refer to
|
||||||
|
/// JavaScript code. The [`script`] element can also be used with other languages, such as WebGL's GLSL shader
|
||||||
|
/// programming language and JSON.
|
||||||
script {
|
script {
|
||||||
|
/// Normal script elements pass minimal information to the window.onerror for scripts which do not pass the
|
||||||
|
/// standard CORS checks. To allow error logging for sites which use a separate domain for static media, use
|
||||||
|
/// this attribute. See CORS settings attributes for a more descriptive explanation of its valid arguments.
|
||||||
crossorigin: CrossOrigin,
|
crossorigin: CrossOrigin,
|
||||||
|
|
||||||
|
/// This Boolean attribute is set to indicate to a browser that the script is meant to be executed after the
|
||||||
|
/// document has been parsed, but before firing DOMContentLoaded.
|
||||||
|
///
|
||||||
|
/// Scripts with the defer attribute will prevent the DOMContentLoaded event from firing until the script has
|
||||||
|
/// loaded and finished evaluating.
|
||||||
|
///
|
||||||
|
/// ----
|
||||||
|
/// ### Warning:
|
||||||
|
///
|
||||||
|
/// This attribute must not be used if the src attribute is absent (i.e. for inline scripts), in this
|
||||||
|
/// case it would have no effect.
|
||||||
|
///
|
||||||
|
/// ----
|
||||||
|
///
|
||||||
|
/// The defer attribute has no effect on module scripts — they defer by default.
|
||||||
|
/// Scripts with the defer attribute will execute in the order in which they appear in the document.
|
||||||
|
///
|
||||||
|
/// This attribute allows the elimination of parser-blocking JavaScript where the browser would have to load and
|
||||||
|
/// evaluate scripts before continuing to parse. async has a similar effect in this case.
|
||||||
defer: Bool,
|
defer: Bool,
|
||||||
integrity: Integrity,
|
integrity: Integrity,
|
||||||
nomodule: Bool,
|
nomodule: Bool,
|
||||||
|
|||||||
Reference in new issue
Block a user