1use std::rc::Rc;
2
3mod document;
4mod elements;
5mod error;
6mod eval;
7
8pub use document::*;
9pub use elements::*;
10pub use error::*;
11pub use eval::*;
12
13pub fn document() -> Rc<dyn Document> {
15 match dioxus_core::prelude::try_consume_context::<Rc<dyn Document>>() {
16 Some(document) => document,
17 None => {
18 tracing::error!(
19 "Unable to find a document in the renderer. Using the default no-op document."
20 );
21 Rc::new(NoOpDocument)
22 }
23 }
24}
25
26#[doc = include_str!("../docs/eval.md")]
28#[doc(alias = "javascript")]
29pub fn eval(script: &str) -> Eval {
30 document().eval(script.to_string())
31}