Merge branch 'master' into jk/templates-v3
This commit is contained in:
commit
073fea9ed3
5 files changed
+31
-10
No files matched your search
@@ -507,6 +507,23 @@ impl VirtualDom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn mark_dirty_scope(&mut self, scope_id: ScopeId) {
|
||||||
|
let scopes = &self.scopes;
|
||||||
|
if let Some(scope) = scopes.get_scope(scope_id) {
|
||||||
|
let height = scope.height;
|
||||||
|
let id = scope_id.0;
|
||||||
|
if let Err(index) = self.dirty_scopes.binary_search_by(|new| {
|
||||||
|
let scope = scopes.get_scope(*new).unwrap();
|
||||||
|
let new_height = scope.height;
|
||||||
|
let new_id = &scope.scope_id();
|
||||||
|
height.cmp(&new_height).then(new_id.0.cmp(&id))
|
||||||
|
}) {
|
||||||
|
self.dirty_scopes.insert(index, scope_id);
|
||||||
|
log::info!("mark_dirty_scope: {:?}", self.dirty_scopes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for VirtualDom {
|
impl Drop for VirtualDom {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ keywords = ["dom", "ui", "gui", "react", "wasm"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
dioxus-core = { path = "../../packages/core", version = "^0.2.1" }
|
dioxus-core = { path = "../../packages/core", version = "^0.2.1" }
|
||||||
futures-channel = "0.3.21"
|
futures-channel = "0.3.21"
|
||||||
log = { version = "0.4" }
|
log = "0.4"
|
||||||
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ dioxus-interpreter-js = { path = "../interpreter", version = "^0.2.1", features
|
|||||||
js-sys = "0.3.56"
|
js-sys = "0.3.56"
|
||||||
wasm-bindgen = { version = "0.2.79", features = ["enable-interning"] }
|
wasm-bindgen = { version = "0.2.79", features = ["enable-interning"] }
|
||||||
wasm-bindgen-futures = "0.4.29"
|
wasm-bindgen-futures = "0.4.29"
|
||||||
log = { version = "0.4.14" }
|
log = "0.4.14"
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash = "1.1.0"
|
||||||
console_error_panic_hook = { version = "0.1.7", optional = true }
|
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||||
once_cell = "1.9.0"
|
once_cell = "1.9.0"
|
||||||
@@ -28,7 +28,6 @@ anyhow = "1.0.53"
|
|||||||
gloo-timers = { version = "0.2.3", features = ["futures"] }
|
gloo-timers = { version = "0.2.3", features = ["futures"] }
|
||||||
futures-util = "0.3.19"
|
futures-util = "0.3.19"
|
||||||
smallstr = "0.2.0"
|
smallstr = "0.2.0"
|
||||||
serde-wasm-bindgen = "0.4.2"
|
|
||||||
futures-channel = "0.3.21"
|
futures-channel = "0.3.21"
|
||||||
serde_json = { version = "1.0" }
|
serde_json = { version = "1.0" }
|
||||||
|
|
||||||
@@ -78,12 +77,13 @@ features = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["panic_hook"]
|
default = ["panic_hook", "hydrate"]
|
||||||
panic_hook = ["console_error_panic_hook"]
|
panic_hook = ["console_error_panic_hook"]
|
||||||
|
hydrate = []
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
dioxus = { path = "../dioxus" }
|
dioxus = { path = "../dioxus" }
|
||||||
wasm-bindgen-test = "0.3.29"
|
wasm-bindgen-test = "0.3.29"
|
||||||
dioxus-ssr = { path = "../ssr" }
|
dioxus-ssr = { path = "../ssr" }
|
||||||
wasm-logger = "0.2.0"
|
wasm-logger = "0.2.0"
|
||||||
|
dioxus-web = { path = "." }
|
||||||
@@ -12,7 +12,7 @@ use dioxus_html::event_bubbles;
|
|||||||
use dioxus_interpreter_js::Interpreter;
|
use dioxus_interpreter_js::Interpreter;
|
||||||
use js_sys::Function;
|
use js_sys::Function;
|
||||||
use std::{any::Any, rc::Rc, sync::Arc};
|
use std::{any::Any, rc::Rc, sync::Arc};
|
||||||
use wasm_bindgen::{closure::Closure, JsCast};
|
use wasm_bindgen::{closure::Closure, JsCast, JsValue};
|
||||||
use web_sys::{Document, Element, Event, HtmlElement};
|
use web_sys::{Document, Element, Event, HtmlElement};
|
||||||
|
|
||||||
use crate::Config;
|
use crate::Config;
|
||||||
@@ -148,11 +148,11 @@ impl WebsysDom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DomEdit::CreateTextNode { text, root } => {
|
DomEdit::CreateTextNode { text, root } => {
|
||||||
let text = serde_wasm_bindgen::to_value(text).unwrap();
|
let text = JsValue::from_str(text);
|
||||||
self.interpreter.CreateTextNode(text, root)
|
self.interpreter.CreateTextNode(text, root)
|
||||||
}
|
}
|
||||||
DomEdit::SetText { root, text } => {
|
DomEdit::SetText { root, text } => {
|
||||||
let text = serde_wasm_bindgen::to_value(text).unwrap();
|
let text = JsValue::from_str(text);
|
||||||
self.interpreter.SetText(root, text)
|
self.interpreter.SetText(root, text)
|
||||||
}
|
}
|
||||||
DomEdit::SetAttribute {
|
DomEdit::SetAttribute {
|
||||||
@@ -161,7 +161,7 @@ impl WebsysDom {
|
|||||||
value,
|
value,
|
||||||
ns,
|
ns,
|
||||||
} => {
|
} => {
|
||||||
let value = serde_wasm_bindgen::to_value(&value).unwrap();
|
let value = JsValue::from_str(&value.to_string());
|
||||||
self.interpreter.SetAttribute(root, field, value, ns)
|
self.interpreter.SetAttribute(root, field, value, ns)
|
||||||
}
|
}
|
||||||
DomEdit::CloneNode { id, new_id } => self.interpreter.CloneNode(id, new_id),
|
DomEdit::CloneNode { id, new_id } => self.interpreter.CloneNode(id, new_id),
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ mod cfg;
|
|||||||
mod dom;
|
mod dom;
|
||||||
#[cfg(any(feature = "hot-reload", debug_assertions))]
|
#[cfg(any(feature = "hot-reload", debug_assertions))]
|
||||||
mod hot_reload;
|
mod hot_reload;
|
||||||
|
#[cfg(feature = "hydrate")]
|
||||||
mod rehydrate;
|
mod rehydrate;
|
||||||
// mod ric_raf;
|
// mod ric_raf;
|
||||||
mod util;
|
mod util;
|
||||||
@@ -164,7 +165,8 @@ where
|
|||||||
pub async fn run_with_props<T: 'static + Send>(root: Component<T>, root_props: T, cfg: Config) {
|
pub async fn run_with_props<T: 'static + Send>(root: Component<T>, root_props: T, cfg: Config) {
|
||||||
let mut dom = VirtualDom::new_with_props(root, root_props);
|
let mut dom = VirtualDom::new_with_props(root, root_props);
|
||||||
|
|
||||||
if cfg!(feature = "panic_hook") && cfg.default_panic_hook {
|
#[cfg(feature = "panic_hook")]
|
||||||
|
if cfg.default_panic_hook {
|
||||||
console_error_panic_hook::set_once();
|
console_error_panic_hook::set_once();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,6 +196,8 @@ pub async fn run_with_props<T: 'static + Send>(root: Component<T>, root_props: T
|
|||||||
// it's a waste to produce edits just to get the vdom loaded
|
// it's a waste to produce edits just to get the vdom loaded
|
||||||
let _ = dom.rebuild();
|
let _ = dom.rebuild();
|
||||||
|
|
||||||
|
#[cfg(feature = "hydrate")]
|
||||||
|
#[allow(unused_variables)]
|
||||||
if let Err(err) = websys_dom.rehydrate(&dom) {
|
if let Err(err) = websys_dom.rehydrate(&dom) {
|
||||||
log::error!(
|
log::error!(
|
||||||
"Rehydration failed {:?}. Rebuild DOM into element from scratch",
|
"Rehydration failed {:?}. Rebuild DOM into element from scratch",
|
||||||
|
|||||||
Reference in new issue
Block a user