Hotreload the contents of for loops, if chains, component bodies, props, attributes, and any literals discovered in rsx! Add a TUI renderer to the CLI. Improve the CLI build system to be async and parallel. Refactor RSX to allow partial expansion of expressions. Merge autofmt implementations for consistency. Merge the representation of elements and components under the hood. Add a diagnostics system for rsx for improved error messages. Drop interprocess and move to websockets for communication between the CLI and the server. Assign IDs to nodes and attributes in a stable way to be used in non compiler contexts. Add hotreloading to any body of component/for loop/if chain/etc. --------- Co-authored-by: Evan Almloff <evanalmloff@gmail.com> Co-authored-by: Liam Mitchell <liamkarlmitchell@gmail.com>
75 lines
2.1 KiB
Rust
75 lines
2.1 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
use tao::window::WindowId;
|
|
|
|
#[non_exhaustive]
|
|
#[derive(Debug, Clone)]
|
|
pub enum UserWindowEvent {
|
|
/// A global hotkey event
|
|
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]
|
|
GlobalHotKeyEvent(global_hotkey::GlobalHotKeyEvent),
|
|
|
|
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]
|
|
MudaMenuEvent(muda::MenuEvent),
|
|
|
|
/// Poll the virtualdom
|
|
Poll(WindowId),
|
|
|
|
/// Handle an ipc message eminating from the window.postMessage of a given webview
|
|
Ipc { id: WindowId, msg: IpcMessage },
|
|
|
|
/// Handle a hotreload event, basically telling us to update our templates
|
|
#[cfg(all(
|
|
feature = "hot-reload",
|
|
debug_assertions,
|
|
not(target_os = "android"),
|
|
not(target_os = "ios")
|
|
))]
|
|
HotReloadEvent(dioxus_hot_reload::DevserverMsg),
|
|
|
|
/// Create a new window
|
|
NewWindow,
|
|
|
|
/// Close a given window (could be any window!)
|
|
CloseWindow(WindowId),
|
|
|
|
/// Gracefully shutdown the entire app
|
|
Shutdown,
|
|
}
|
|
|
|
/// A message struct that manages the communication between the webview and the eventloop code
|
|
///
|
|
/// This needs to be serializable across the JS boundary, so the method names and structs are sensitive.
|
|
#[derive(Deserialize, Serialize, Debug, Clone)]
|
|
pub struct IpcMessage {
|
|
method: String,
|
|
params: serde_json::Value,
|
|
}
|
|
|
|
/// A set of known messages that we need to respond to
|
|
#[derive(Deserialize, Serialize, Debug, Clone)]
|
|
pub enum IpcMethod<'a> {
|
|
FileDialog,
|
|
UserEvent,
|
|
Query,
|
|
BrowserOpen,
|
|
Initialize,
|
|
Other(&'a str),
|
|
}
|
|
|
|
impl IpcMessage {
|
|
pub(crate) fn method(&self) -> IpcMethod {
|
|
match self.method.as_str() {
|
|
"file_dialog" => IpcMethod::FileDialog,
|
|
"user_event" => IpcMethod::UserEvent,
|
|
"query" => IpcMethod::Query,
|
|
"browser_open" => IpcMethod::BrowserOpen,
|
|
"initialize" => IpcMethod::Initialize,
|
|
_ => IpcMethod::Other(&self.method),
|
|
}
|
|
}
|
|
|
|
pub(crate) fn params(self) -> serde_json::Value {
|
|
self.params
|
|
}
|
|
}
|