Remove SSR evalulator

This commit is contained in:
Jonathan Kelley 2024-02-14 16:38:05 -08:00
parent cbadea022a
commit 22a5acfcb8
No known key found for this signature in database
GPG key ID: 1FBB50F7EB0A08BE
3 changed files with 1 additions and 48 deletions

View file

@ -3,5 +3,6 @@
"[toml]": {
"editor.formatOnSave": false
},
"rust-analyzer.check.workspace": true,
"rust-analyzer.checkOnSave.allTargets": false,
}

View file

@ -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
}
}

View file

@ -11,7 +11,6 @@ pub mod incremental;
#[cfg(feature = "incremental")]
mod incremental_cfg;
pub mod eval;
pub mod renderer;
pub mod template;
@ -29,7 +28,6 @@ pub fn render_element(element: Element) -> String {
}
let mut dom = VirtualDom::new_with_props(lazy_app, element);
dom.in_runtime(crate::eval::init_eval);
dom.rebuild(&mut NoOpMutations);
Renderer::new().render(&dom)