mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-26 22:20:19 +00:00
Remove SSR evalulator
This commit is contained in:
parent
cbadea022a
commit
22a5acfcb8
3 changed files with 1 additions and 48 deletions
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
|
@ -3,5 +3,6 @@
|
||||||
"[toml]": {
|
"[toml]": {
|
||||||
"editor.formatOnSave": false
|
"editor.formatOnSave": false
|
||||||
},
|
},
|
||||||
|
"rust-analyzer.check.workspace": true,
|
||||||
"rust-analyzer.checkOnSave.allTargets": false,
|
"rust-analyzer.checkOnSave.allTargets": false,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
use async_trait::async_trait;
|
|
||||||
use dioxus_core::ScopeId;
|
|
||||||
use dioxus_html::prelude::{EvalError, EvalProvider, Evaluator};
|
|
||||||
use generational_box::{AnyStorage, GenerationalBox, UnsyncStorage};
|
|
||||||
use std::rc::Rc;
|
|
||||||
|
|
||||||
/// Provides the SSREvalProvider through [`cx.provide_context`].
|
|
||||||
pub fn init_eval() {
|
|
||||||
let provider: Rc<dyn EvalProvider> = Rc::new(SSREvalProvider {});
|
|
||||||
ScopeId::ROOT.provide_context(provider);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Reprents the ssr-target's provider of evaluators.
|
|
||||||
pub struct SSREvalProvider;
|
|
||||||
impl EvalProvider for SSREvalProvider {
|
|
||||||
fn new_evaluator(&self, _: String) -> GenerationalBox<Box<dyn Evaluator>> {
|
|
||||||
let owner = UnsyncStorage::owner();
|
|
||||||
owner.insert(Box::new(SSREvaluator) as Box<dyn Evaluator + 'static>)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Represents a ssr-target's JavaScript evaluator.
|
|
||||||
pub struct SSREvaluator;
|
|
||||||
|
|
||||||
// In ssr rendering we never run or resolve evals.
|
|
||||||
#[async_trait(?Send)]
|
|
||||||
impl Evaluator for SSREvaluator {
|
|
||||||
/// Sends a message to the evaluated JavaScript.
|
|
||||||
fn send(&self, _el: serde_json::Value) -> Result<(), EvalError> {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn poll_recv(
|
|
||||||
&mut self,
|
|
||||||
_cx: &mut std::task::Context<'_>,
|
|
||||||
) -> std::task::Poll<Result<serde_json::Value, EvalError>> {
|
|
||||||
std::task::Poll::Pending
|
|
||||||
}
|
|
||||||
|
|
||||||
fn poll_join(
|
|
||||||
&mut self,
|
|
||||||
_cx: &mut std::task::Context<'_>,
|
|
||||||
) -> std::task::Poll<Result<serde_json::Value, EvalError>> {
|
|
||||||
std::task::Poll::Pending
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -11,7 +11,6 @@ pub mod incremental;
|
||||||
#[cfg(feature = "incremental")]
|
#[cfg(feature = "incremental")]
|
||||||
mod incremental_cfg;
|
mod incremental_cfg;
|
||||||
|
|
||||||
pub mod eval;
|
|
||||||
pub mod renderer;
|
pub mod renderer;
|
||||||
pub mod template;
|
pub mod template;
|
||||||
|
|
||||||
|
@ -29,7 +28,6 @@ pub fn render_element(element: Element) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut dom = VirtualDom::new_with_props(lazy_app, element);
|
let mut dom = VirtualDom::new_with_props(lazy_app, element);
|
||||||
dom.in_runtime(crate::eval::init_eval);
|
|
||||||
dom.rebuild(&mut NoOpMutations);
|
dom.rebuild(&mut NoOpMutations);
|
||||||
|
|
||||||
Renderer::new().render(&dom)
|
Renderer::new().render(&dom)
|
||||||
|
|
Loading…
Reference in a new issue