Compare commits

...

7 Commits

Author SHA1 Message Date
Amr Bashir 13e6268448 tauri 2.0.0-alpha.12 2023-08-15 03:15:45 +03:00
Amr Bashir 7a605d402b fix fs plugin 2023-08-15 03:12:43 +03:00
Amr Bashir 18635c2200 Merge branch 'v2' into feat/window/dnd-position 2023-08-15 03:11:01 +03:00
Lucas Fernandes Nogueira d0c0084859 fix(example): build on macOS (#557) 2023-08-14 15:54:29 -07:00
Lucas Fernandes Nogueira 265dbc02e3 chore(shell): remove outdated todo (#559) 2023-08-14 15:54:17 -07:00
Lucas Fernandes Nogueira aec17a90fc feat(http): improve performance (#558) 2023-08-14 15:53:55 -07:00
Amr Bashir cdae07afe6 feat(window): add drag and drop position 2023-08-14 06:34:55 +03:00
9 changed files with 44 additions and 24 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"http": patch
---
Improve response performance by using the new IPC streaming data.
+5
View File
@@ -0,0 +1,5 @@
---
"window-js": "minor"
---
Add position information to file drop events.
+1 -1
View File
@@ -5,7 +5,7 @@ resolver = "2"
[workspace.dependencies] [workspace.dependencies]
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
log = "0.4" log = "0.4"
tauri = "2.0.0-alpha.11" tauri = "2.0.0-alpha.12"
tauri-build = "2.0.0-alpha.8" tauri-build = "2.0.0-alpha.8"
serde_json = "1" serde_json = "1"
thiserror = "1" thiserror = "1"
+1 -1
View File
@@ -124,7 +124,7 @@ pub fn run() {
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
{ {
builder = builder.menu(tauri::Menu::os_default("Tauri API Validation")); builder = builder.menu(tauri::menu::Menu::default);
} }
#[allow(unused_mut)] #[allow(unused_mut)]
+1 -1
View File
@@ -83,7 +83,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R, Option<Config>> {
.on_event(|app, event| { .on_event(|app, event| {
if let RunEvent::WindowEvent { if let RunEvent::WindowEvent {
label: _, label: _,
event: WindowEvent::FileDrop(FileDropEvent::Dropped(paths)), event: WindowEvent::FileDrop(FileDropEvent::Dropped { paths, .. }),
.. ..
} = event } = event
{ {
+2 -3
View File
@@ -163,16 +163,15 @@ pub async fn fetch_send<R: Runtime>(
}) })
} }
// TODO: change return value to tauri::ipc::Response on next alpha
#[command] #[command]
pub(crate) async fn fetch_read_body<R: Runtime>( pub(crate) async fn fetch_read_body<R: Runtime>(
app: AppHandle<R>, app: AppHandle<R>,
rid: RequestId, rid: RequestId,
) -> crate::Result<Vec<u8>> { ) -> crate::Result<tauri::ipc::Response> {
let mut response_table = app.http().responses.lock().await; let mut response_table = app.http().responses.lock().await;
let res = response_table let res = response_table
.remove(&rid) .remove(&rid)
.ok_or(Error::InvalidRequestId(rid))?; .ok_or(Error::InvalidRequestId(rid))?;
Ok(res.bytes().await?.to_vec()) Ok(tauri::ipc::Response::new(res.bytes().await?.to_vec()))
} }
-3
View File
@@ -242,8 +242,6 @@ impl Command {
let child_ = child.clone(); let child_ = child.clone();
let guard = Arc::new(RwLock::new(())); let guard = Arc::new(RwLock::new(()));
//TODO commands().lock().unwrap().insert(child.id(), child.clone());
let (tx, rx) = channel(1); let (tx, rx) = channel(1);
spawn_pipe_reader( spawn_pipe_reader(
@@ -263,7 +261,6 @@ impl Command {
let _ = match child_.wait() { let _ = match child_.wait() {
Ok(status) => { Ok(status) => {
let _l = guard.write().unwrap(); let _l = guard.write().unwrap();
//TODO commands().lock().unwrap().remove(&child_.id());
block_on_task(async move { block_on_task(async move {
tx.send(CommandEvent::Terminated(TerminatedPayload { tx.send(CommandEvent::Terminated(TerminatedPayload {
code: status.code(), code: status.code(),
+28 -14
View File
@@ -63,8 +63,8 @@ interface ScaleFactorChanged {
/** The file drop event types. */ /** The file drop event types. */
type FileDropEvent = type FileDropEvent =
| { type: "hover"; paths: string[] } | { type: "hover"; paths: string[]; position: PhysicalPosition }
| { type: "drop"; paths: string[] } | { type: "drop"; paths: string[]; position: PhysicalPosition }
| { type: "cancel" }; | { type: "cancel" };
/** /**
@@ -1901,19 +1901,33 @@ class Window {
async onFileDropEvent( async onFileDropEvent(
handler: EventCallback<FileDropEvent>, handler: EventCallback<FileDropEvent>,
): Promise<UnlistenFn> { ): Promise<UnlistenFn> {
const unlistenFileDrop = await this.listen<string[]>( const unlistenFileDrop = await this.listen<{
TauriEvent.WINDOW_FILE_DROP, paths: string[];
(event) => { position: PhysicalPosition;
handler({ ...event, payload: { type: "drop", paths: event.payload } }); }>(TauriEvent.WINDOW_FILE_DROP, (event) => {
}, handler({
); ...event,
payload: {
type: "drop",
paths: event.payload.paths,
position: mapPhysicalPosition(event.payload.position),
},
});
});
const unlistenFileHover = await this.listen<string[]>( const unlistenFileHover = await this.listen<{
TauriEvent.WINDOW_FILE_DROP_HOVER, paths: string[];
(event) => { position: PhysicalPosition;
handler({ ...event, payload: { type: "hover", paths: event.payload } }); }>(TauriEvent.WINDOW_FILE_DROP_HOVER, (event) => {
}, handler({
); ...event,
payload: {
type: "hover",
paths: event.payload.paths,
position: mapPhysicalPosition(event.payload.position),
},
});
});
const unlistenCancel = await this.listen<null>( const unlistenCancel = await this.listen<null>(
TauriEvent.WINDOW_FILE_DROP_CANCELLED, TauriEvent.WINDOW_FILE_DROP_CANCELLED,
File diff suppressed because one or more lines are too long