codify "platform" into resolution logic, server-fn/fullstack overhaul (#4596)
overhaul dioxus fullstack using a new implementation of server_fn This PR is a complete rewrite of dioxus fullstack designed to improve compatibility with axum and to fix a number of compilation errors based on feature flag unification plumbing through macros.
This commit is contained in:
1 parent
8421c3aef0
commit
f2b1c6d97f
424 files changed
+17284
-6624
No files matched your search
@@ -1,11 +1,13 @@
|
||||
use crate::{WebFileData, WebFileEngine};
|
||||
|
||||
use super::{Synthetic, WebEventExt};
|
||||
use dioxus_html::{
|
||||
geometry::{ClientPoint, ElementPoint, PagePoint, ScreenPoint},
|
||||
input_data::{decode_mouse_button_set, MouseButton},
|
||||
HasDragData, HasFileData, HasMouseData, InteractionElementOffset, InteractionLocation,
|
||||
Modifiers, ModifiersInteraction, PointerInteraction,
|
||||
FileData, HasDragData, HasFileData, HasMouseData, InteractionElementOffset,
|
||||
InteractionLocation, Modifiers, ModifiersInteraction, PointerInteraction,
|
||||
};
|
||||
use web_sys::DragEvent;
|
||||
use web_sys::{DragEvent, FileReader};
|
||||
|
||||
impl InteractionLocation for Synthetic<DragEvent> {
|
||||
fn client_coordinates(&self) -> ClientPoint {
|
||||
@@ -71,31 +73,35 @@ impl HasDragData for Synthetic<DragEvent> {
|
||||
}
|
||||
|
||||
impl HasFileData for Synthetic<DragEvent> {
|
||||
fn files(&self) -> Option<std::sync::Arc<dyn dioxus_html::FileEngine>> {
|
||||
#[cfg(feature = "file_engine")]
|
||||
{
|
||||
use wasm_bindgen::JsCast;
|
||||
let files = self
|
||||
.event
|
||||
.dyn_ref::<web_sys::DragEvent>()
|
||||
.and_then(|drag_event| {
|
||||
drag_event.data_transfer().and_then(|dt| {
|
||||
dt.files().and_then(|files| {
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
crate::file_engine::WebFileEngine::new(files).map(|f| {
|
||||
std::sync::Arc::new(f)
|
||||
as std::sync::Arc<dyn dioxus_html::FileEngine>
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
fn files(&self) -> Vec<FileData> {
|
||||
use wasm_bindgen::JsCast;
|
||||
|
||||
files
|
||||
}
|
||||
#[cfg(not(feature = "file_engine"))]
|
||||
{
|
||||
None
|
||||
if let Some(target) = self.event.dyn_ref::<web_sys::DragEvent>() {
|
||||
if let Some(data_transfer) = target.data_transfer() {
|
||||
if let Some(file_list) = data_transfer.files() {
|
||||
return WebFileEngine::new(file_list).to_files();
|
||||
} else {
|
||||
let items = data_transfer.items();
|
||||
let mut files = vec![];
|
||||
for i in 0..items.length() {
|
||||
if let Some(item) = items.get(i) {
|
||||
if item.kind() == "file" {
|
||||
if let Ok(Some(file)) = item.get_as_file() {
|
||||
let web_data =
|
||||
WebFileData::new(file, FileReader::new().unwrap());
|
||||
files.push(FileData::new(web_data));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tracing::warn!("DragEvent target was not a DragEvent");
|
||||
}
|
||||
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user