wip: add html event type
This commit is contained in:
1 parent
fa3d1ef574
commit
e256fe1079
17 files changed
+340
-245
No files matched your search
@@ -1,6 +1,21 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
pub static INTERPRETER: &str = include_str!("interpreter.js");
|
||||
|
||||
pub fn interpreter_glue(url: &str) -> String {
|
||||
format!(
|
||||
r#"
|
||||
<script>
|
||||
var WS_ADDR = "{url}";
|
||||
{INTERPRETER}
|
||||
main();
|
||||
</script>
|
||||
"#
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) mod events;
|
||||
|
||||
pub mod adapters {
|
||||
#[cfg(feature = "warp")]
|
||||
pub mod warp_adapter;
|
||||
@@ -16,41 +31,8 @@ use std::net::SocketAddr;
|
||||
|
||||
use tokio_util::task::LocalPoolHandle;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Liveview {
|
||||
pool: LocalPoolHandle,
|
||||
addr: String,
|
||||
}
|
||||
pub mod pool;
|
||||
pub use pool::*;
|
||||
|
||||
impl Liveview {
|
||||
pub fn body(&self, header: &str) -> String {
|
||||
format!(
|
||||
r#"
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
{header}
|
||||
</head>
|
||||
<body>
|
||||
<div id="main"></div>
|
||||
<script>
|
||||
var WS_ADDR = "ws://{addr}/app";
|
||||
{interpreter}
|
||||
main();
|
||||
</script>
|
||||
</body>
|
||||
</html>"#,
|
||||
addr = self.addr,
|
||||
interpreter = include_str!("../src/interpreter.js")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(addr: impl Into<SocketAddr>) -> Liveview {
|
||||
let addr: SocketAddr = addr.into();
|
||||
|
||||
Liveview {
|
||||
pool: LocalPoolHandle::new(16),
|
||||
addr: addr.to_string(),
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, thiserror::Error)]
|
||||
pub enum LiveViewError {}
|
||||
Reference in new issue
Block a user