Merge branch 'master' into intigrate-collect-assets

This commit is contained in:
Jonathan Kelley authored and GitHub committed 2024-01-05 12:13:31 -08:00
commit 785b61a05e
78 files changed
+4628 -1099

No files matched your search

+25 -8
View File
@@ -29,11 +29,12 @@ pub use desktop_context::{
};
use desktop_context::{EventData, UserWindowEvent, WebviewQueue, WindowEventHandlers};
use dioxus_core::*;
use dioxus_html::{event_bubbles, MountedData};
use dioxus_html::{native_bind::NativeFileEngine, FormData, HtmlEvent};
use dioxus_html::{event_bubbles, FileEngine, HasFormData, MountedData, PlatformEventData};
use dioxus_html::{native_bind::NativeFileEngine, HtmlEvent};
use dioxus_interpreter_js::binary_protocol::Channel;
use element::DesktopElement;
use eval::init_eval;
use events::SerializedHtmlEventConverter;
use futures_util::{pin_mut, FutureExt};
pub use protocol::{use_asset_handler, AssetFuture, AssetHandler, AssetRequest, AssetResponse};
use rustc_hash::FxHashMap;
@@ -148,6 +149,9 @@ pub fn launch_with_props<P: 'static>(root: Component<P>, props: P, cfg: Config)
// Copy over any assets we find
crate::collect_assets::copy_assets();
// Set the event converter
dioxus_html::set_event_converter(Box::new(SerializedHtmlEventConverter));
// We start the tokio runtime *on this thread*
// Any future we poll later will use this runtime to spawn tasks and for IO
@@ -316,7 +320,7 @@ pub fn launch_with_props<P: 'static>(root: Component<P>, props: P, cfg: Config)
let element =
DesktopElement::new(element, view.desktop_context.clone(), query);
Rc::new(MountedData::new(element))
Rc::new(PlatformEventData::new(Box::new(MountedData::new(element))))
} else {
data.into_any()
};
@@ -368,15 +372,28 @@ pub fn launch_with_props<P: 'static>(root: Component<P>, props: P, cfg: Config)
if let Ok(file_diolog) =
serde_json::from_value::<file_upload::FileDialogRequest>(msg.params())
{
struct DesktopFileUploadForm {
files: Arc<NativeFileEngine>,
}
impl HasFormData for DesktopFileUploadForm {
fn files(&self) -> Option<Arc<dyn FileEngine>> {
Some(self.files.clone())
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
}
let id = ElementId(file_diolog.target);
let event_name = &file_diolog.event;
let event_bubbles = file_diolog.bubbles;
let files = file_upload::get_file_event(&file_diolog);
let data = Rc::new(FormData {
value: Default::default(),
values: Default::default(),
files: Some(Arc::new(NativeFileEngine::new(files))),
});
let data =
Rc::new(PlatformEventData::new(Box::new(DesktopFileUploadForm {
files: Arc::new(NativeFileEngine::new(files)),
})));
let view = webviews.get_mut(&event.1).unwrap();