Get compiling

This commit is contained in:
Jonathan Kelley committed 2024-01-04 16:28:15 -08:00
1 parent 9a6d745339
commit 436635386d
4 files changed
+35 -31

No files matched your search

+19 -18
View File
@@ -4,26 +4,26 @@ pub use crate::desktop_context::{
use_window, use_wry_event_handler, window, DesktopService, WryEventHandler, WryEventHandlerId,
};
use crate::desktop_context::{EventData, UserWindowEvent, WebviewQueue, WindowEventHandlers};
use crate::element::DesktopElement;
use crate::eval::init_eval;
use crate::events::{IpcMessage, KnownIpcMethod};
use crate::file_upload;
pub use crate::protocol::{
use_asset_handler, AssetFuture, AssetHandler, AssetRequest, AssetResponse,
};
use crate::query::QueryResult;
use crate::shortcut::GlobalHotKeyEvent;
use crate::shortcut::ShortcutRegistry;
pub use crate::shortcut::{use_global_shortcut, ShortcutHandle, ShortcutId, ShortcutRegistryError};
use dioxus_core::*;
use dioxus_html::{event_bubbles, MountedData};
use dioxus_html::{native_bind::NativeFileEngine, FormData, HtmlEvent};
use dioxus_interpreter_js::binary_protocol::Channel;
use futures_util::{pin_mut, FutureExt};
use global_hotkey::{
hotkey::{Code, HotKey, Modifiers},
GlobalHotKeyManager,
};
// use dioxus_interpreter_js::binary_protocol::Channel;
use crate::element::DesktopElement;
use crate::eval::init_eval;
pub use crate::protocol::{
use_asset_handler, AssetFuture, AssetHandler, AssetRequest, AssetResponse,
};
use crate::shortcut::ShortcutRegistry;
pub use crate::shortcut::{use_global_shortcut, ShortcutHandle, ShortcutId, ShortcutRegistryError};
use futures_util::{pin_mut, FutureExt};
use rustc_hash::FxHashMap;
use std::rc::Rc;
use std::sync::atomic::AtomicU16;
@@ -61,7 +61,7 @@ pub struct App<P> {
pub(crate) is_visible_before_start: bool,
}
impl<P> App<P> {
impl<P: 'static> App<P> {
pub fn new(cfg: Config, props: P, root: Component<P>) -> (EventLoop<UserWindowEvent>, Self) {
let event_loop = EventLoopBuilder::<UserWindowEvent>::with_user_event().build();
@@ -279,9 +279,12 @@ impl<P> App<P> {
dioxus_hot_reload::HotReloadMsg::UpdateTemplate(template) => {
for webview in self.webviews.values_mut() {
webview.dom.replace_template(template);
}
// poll_vdom(webview);
todo!()
let ids = self.webviews.keys().copied().collect::<Vec<_>>();
for id in ids {
self.poll_vdom(id);
}
}
dioxus_hot_reload::HotReloadMsg::Shutdown => {
@@ -290,7 +293,7 @@ impl<P> App<P> {
}
}
pub fn handle_file_dialog_msg(&self, msg: IpcMessage, window: WindowId) {
pub fn handle_file_dialog_msg(&mut self, msg: IpcMessage, window: WindowId) {
if let Ok(file_diolog) =
serde_json::from_value::<file_upload::FileDialogRequest>(msg.params())
{
@@ -385,9 +388,9 @@ pub fn create_new_window(
}
pub struct WebviewHandler {
dom: VirtualDom,
desktop_context: DesktopContext,
waker: Waker,
pub dom: VirtualDom,
pub desktop_context: DesktopContext,
pub waker: Waker,
// Wry assumes the webcontext is alive for the lifetime of the webview.
// We need to keep the webcontext alive, otherwise the webview will crash
@@ -408,8 +411,6 @@ pub fn send_edits(edits: Mutations, desktop_context: &DesktopContext) {
}
}
pub struct Channel {}
pub fn apply_edits(
mutations: Mutations,
channel: &mut Channel,
+2 -1
View File
@@ -98,6 +98,7 @@ pub struct DesktopService {
/// The wry/tao proxy to the current window
pub webview: WebView,
/// The tao window itself
pub window: Window,
/// The proxy to the event loop
@@ -176,7 +177,7 @@ impl DesktopService {
///
/// Be careful to not create a cycle of windows, or you might leak memory.
pub fn new_window(&self, dom: VirtualDom, cfg: Config) -> Weak<DesktopService> {
let window = create_new_window(
let window = crate::app::create_new_window(
cfg,
&self.event_loop,
&self.proxy,
+4 -6
View File
@@ -197,7 +197,7 @@ pub fn use_asset_handler<F: AssetFuture>(
handler: impl AssetHandler<F>,
) -> &AssetHandlerHandle {
cx.use_hook(|| {
let desktop = window();
let desktop = crate::window();
let handler_id = Rc::new(OnceCell::new());
let handler_id_ref = Rc::clone(&handler_id);
let desktop_ref = Rc::clone(&desktop);
@@ -220,7 +220,7 @@ pub(super) async fn desktop_handler(
asset_handlers: &AssetHandlerRegistry,
edit_queue: &EditQueue,
headless: bool,
responder: wry::webview::RequestAsyncResponder,
responder: wry::RequestAsyncResponder,
) {
let request = AssetRequest::from(request);
@@ -259,7 +259,7 @@ pub(super) async fn desktop_handler(
.body(Cow::from(body))
{
Ok(response) => {
return Ok(response);
return responder.respond(response);
}
Err(err) => tracing::error!("error building response: {}", err),
}
@@ -305,9 +305,7 @@ pub(super) async fn desktop_handler(
.header("Content-Type", content_type)
.body(Cow::from(asset))
{
Ok(response) => {
return response;
}
Ok(response) => return responder.respond(response),
Err(err) => tracing::error!("error building response: {}", err),
}
}
+10 -6
View File
@@ -12,17 +12,21 @@ pub(crate) fn build(
event_loop: &EventLoopWindowTarget<UserWindowEvent>,
proxy: EventLoopProxy<UserWindowEvent>,
) -> (WebView, WebContext, AssetHandlerRegistry, EditQueue, Window) {
let builder = cfg.window.clone();
let mut builder = cfg.window.clone();
// TODO: restore the menu bar with muda: https://github.com/tauri-apps/muda/blob/dev/examples/wry.rs
if cfg.enable_default_menu_bar {
// builder = builder.with_menu(build_default_menu_bar());
}
let window = builder.build(event_loop).unwrap();
let window_id = window.id();
let file_handler = cfg.file_drop_handler.take();
let custom_head = cfg.custom_head.clone();
let index_file = cfg.custom_index.clone();
let root_name = cfg.root_name.clone();
// TODO: restore the menu bar with muda: https://github.com/tauri-apps/muda/blob/dev/examples/wry.rs
// if cfg.enable_default_menu_bar {
// builder = builder.with_menu(build_default_menu_bar());
// }
// We assume that if the icon is None in cfg, then the user just didnt set it
if cfg.window.window.window_icon.is_none() {
window.set_window_icon(Some(