Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(core): refactor and fix event system following multiwebview support #8621

Merged
merged 27 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
35625a1
clippy
amrbashir Jan 30, 2024
8492836
Merge branch 'dev' into fix/window-close-requested-from-another-webview
amrbashir Jan 30, 2024
393267f
refactor(core): refactor and fix event system following multiwebview …
amrbashir Jan 30, 2024
171efa5
update documentation
amrbashir Jan 30, 2024
a3f1387
update js docs
amrbashir Jan 30, 2024
bb67d64
lint
amrbashir Jan 31, 2024
1adf5ee
clippy
amrbashir Jan 31, 2024
a4fb4d6
Merge branch 'dev' into fix/window-close-requested-from-another-webview
amrbashir Jan 31, 2024
90a3b64
update multiwindow example [skip ci]
lucasfernog Jan 31, 2024
5d2d9e5
Merge branch 'fix/window-close-requested-from-another-webview' of git…
lucasfernog Jan 31, 2024
75b3149
enhance event tests
lucasfernog Jan 31, 2024
369eda9
fix example
lucasfernog Jan 31, 2024
23ef977
Update .changes/tauri-event-after-multiwebview.md
amrbashir Jan 31, 2024
bbd6a89
fix tests
amrbashir Jan 31, 2024
b04e588
add diagram
amrbashir Jan 31, 2024
83f3de9
Add `App/AppHandle` even target
amrbashir Jan 31, 2024
f71d540
Merge branch 'dev' into fix/window-close-requested-from-another-webview
amrbashir Jan 31, 2024
b5c6ff9
Merge branch 'dev' into fix/window-close-requested-from-another-webview
amrbashir Jan 31, 2024
a38acf4
Discard changes to examples/api/src-tauri/tauri-plugin-sample/permiss…
amrbashir Jan 31, 2024
e4acea6
revert accidental changes
amrbashir Jan 31, 2024
1932c6b
regenerate schemas
amrbashir Jan 31, 2024
fb15841
fix doctests
amrbashir Feb 1, 2024
56bc840
add helper methods
lucasfernog Feb 1, 2024
2489cbe
update docs
lucasfernog Feb 1, 2024
034c68c
update api
lucasfernog Feb 1, 2024
d716754
update docs [skip ci]
lucasfernog Feb 1, 2024
115f7db
update docs [skip ci]
lucasfernog Feb 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/api-emit-to.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tauri-apps/api': 'patch:feat'
---

Added `emitTo` api to `event` module which is equivalent to the rust `emit_to` method. Also added `emitTo` method on `Window`, `Webivew` and `WebviewWindow` classes.
4 changes: 2 additions & 2 deletions .changes/api-event-resource-refactor.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"@tauri-apps/api": patch:breaking
'@tauri-apps/api': patch:breaking
---

Removed event callback's `windowLabel` field and added a `windowSource` object instead.
Removed event callback's `windowLabel`.
5 changes: 5 additions & 0 deletions .changes/tauri-close-requested-another-webview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri': 'patch:bug'
---

Fix can not prevent closing a window from another webview.
12 changes: 12 additions & 0 deletions .changes/tauri-event-after-multiwebview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'tauri': 'patch:breaking'
---

Refactored the event system to better accommodate the new window types:

- Added `EventTarget` enum.
- Added `App/AppHandle::listen`, `App/AppHandle::once` and `App/AppHandle::unlisten` to listen to events targeting `App/AppHandle`
- `App/AppHandle/Window/Webview/WebviewWindow::emit` will now emit to all event listeners.
- `App/AppHandle/Window/Webview/WebviewWindow::emit_to` will emit to event targets that match the given label, see `EventTarget` enum.
- `App/AppHandle/Window/Webview/WebviewWindow::emit_filter` will emit to event targets based on a filter callback which now takes `&EventTarget` instead of `&Window`.
- Renamed `Manager::listen_global` and `Manager::once_global` to `listen_any` and `once_any` respectively to be consistent with `EventTarget::Any`, it will now also listen to any event to any target (aka event sniffer).
5 changes: 5 additions & 0 deletions .changes/tauri-utils-config-error-box.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri-utils': 'patch:breaking'
---

Changed `error` field in `ConfigError::FormatToml` to be boxed `Box<toml::de::Error>` to reduce the enum `ConfigError` size in memory.
2 changes: 1 addition & 1 deletion core/tauri-runtime-wry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2902,7 +2902,7 @@ fn handle_event_loop<T: UserEvent>(
if window.is_window_transparent {
if let Some(surface) = &mut window.surface {
if let Some(window) = &window.inner {
clear_window_surface(&window, surface)
clear_window_surface(window, surface)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/tauri-utils/src/config/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub enum ConfigError {
path: PathBuf,

/// The parsing [`toml::Error`].
error: ::toml::de::Error,
error: Box<::toml::de::Error>,
},

/// Unknown config file name encountered.
Expand Down Expand Up @@ -381,7 +381,7 @@ fn do_parse_json5<D: DeserializeOwned>(raw: &str, path: &Path) -> Result<D, Conf
fn do_parse_toml<D: DeserializeOwned>(raw: &str, path: &Path) -> Result<D, ConfigError> {
::toml::from_str(raw).map_err(|error| ConfigError::FormatToml {
path: path.into(),
error,
error: Box::new(error),
})
}

Expand Down
7 changes: 6 additions & 1 deletion core/tauri/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ const PLUGINS: &[(&str, &[(&str, bool)])] = &[
),
(
"event",
&[("listen", true), ("unlisten", true), ("emit", true)],
&[
("listen", true),
("unlisten", true),
("emit", true),
("emit_to", true),
],
),
(
"window",
Expand Down
Loading