new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Tauri · all subjects

state & architecture

48 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

PredefinedMenuItem replaces MenuItem in Tauri 2

In Tauri 2, tauri::menu::PredefinedMenuItem replaces tauri::MenuItem.

MenuItemBuilder replaces CustomMenuItem in Tauri 2

In Tauri 2, tauri::menu::MenuItemBuilder replaces tauri::CustomMenuItem.

JavaScript window module renamed

In Tauri 2, @tauri-apps/api/window was renamed to @tauri-apps/api/webviewWindow.

SubmenuBuilder replaces Submenu in Tauri 2

In Tauri 2, tauri::menu::SubmenuBuilder replaces tauri::Submenu.

Builder.menu now takes closure in Tauri 2

In Tauri 2, tauri::Builder::menu now takes a closure because the menu needs a Manager instance to be constructed.

Menu event handlers moved in Tauri 2

In Tauri 2, tauri::Builder::on_menu_event was removed. Use tauri::App::on_menu_event or tauri::AppHandle::on_menu_event instead.

TrayIconBuilder replaces SystemTray in Tauri 2

In Tauri 2, tauri::tray::TrayIconBuilder replaces tauri::SystemTray.

Tray icon events split in Tauri 2

In Tauri 2, tauri::SystemTray::on_event was split into tauri::tray::TrayIconBuilder::on_menu_event and tauri::tray::TrayIconBuilder::on_tray_icon_event.

Menu APIs removed in Tauri 2

In Tauri 2, Menu, MenuEvent, CustomMenuItem, Submenu, WindowMenuEvent, MenuItem, and Builder::on_menu_event were removed and refactored using the muda crate.

SystemTray APIs removed in Tauri 2

In Tauri 2, SystemTray, SystemTrayHandle, SystemTrayMenu, SystemTrayMenuItemHandle, SystemTraySubmenu, MenuEntry, and SystemTrayMenuItem were removed. Use tauri::tray module instead.

Multiwebview support in Tauri 2

Tauri 2 introduces multiwebview support behind an unstable feature flag. Window type was renamed to WebviewWindow, WindowBuilder to WebviewWindowBuilder, WindowUrl to WebviewUrl. Manager::get_window renamed to get_webview_window. WebviewWindow type now reexports from @tauri-apps/api/webviewWindow.

MenuBuilder requires Manager instance in Tauri 2

In Tauri 2, tauri::menu::MenuBuilder replaced tauri::Menu and requires a Manager instance (App, AppHandle, or WebviewWindow) as a constructor argument.

Tray icon migration: event handling

'tauri::SystemTray::on_event' split into 'tauri::tray::TrayIconBuilder::on_menu_event' and 'tauri::tray::TrayIconBuilder::on_tray_icon_event'. Menu events handled separately from tray icon click/interaction events.

Tray icon migration: event example

Complete tray migration example: let toggle = MenuItemBuilder::with_id("toggle", "Toggle").build(app)?; let menu = MenuBuilder::new(app).items(&[&toggle]).build()?; let tray = TrayIconBuilder::new().menu(&menu).on_menu_event(move |app, event| { if event.id().as_ref() == "toggle" { println!("toggle clicked"); } }).on_tray_icon_event(|tray, event| { if let TrayIconEvent::Click { button: MouseButton::Left, button_state: MouseButtonState::Up, .. } = event { let app = tray.app_handle(); if let Some(window) = app.get_webview_window("main") { let _ = window.unminimize(); let _ = window.show(); let _ = window.set_focus(); } } }).build(app)?;

Window API rename: Window to WebviewWindow

Rust type 'Window' renamed to 'WebviewWindow'. Type 'WindowBuilder' renamed to 'WebviewWindowBuilder'. Type 'WindowUrl' renamed to 'WebviewUrl'.

Window API rename: Manager methods

Manager function 'get_window' renamed to 'get_webview_window'. Window method 'parent_window' API renamed to 'parent_raw'.

Menu module migration: Builder.menu closure requirement

'tauri::Builder::menu' now takes a closure because Manager instance is required to build menus. See documentation for details.

Removed menu and tray APIs in Tauri 2.0

Removed: 'Menu', 'MenuEvent', 'CustomMenuItem', 'Submenu', 'WindowMenuEvent', 'MenuItem', 'Builder::on_menu_event'; 'SystemTray', 'SystemTrayHandle', 'SystemTrayMenu', 'SystemTrayMenuItemHandle', 'SystemTraySubmenu', 'MenuEntry', 'SystemTrayMenuItem'. Use tauri::menu module and tauri::tray::TrayIcon instead.

Multi-webview support in Tauri 2.0

Tauri 2.0 introduces multi-webview support under the 'unstable' feature flag. Rust's 'Window' type renamed to 'WebviewWindow'. Manager's 'get_window' function renamed to 'get_webview_window'. JavaScript's 'WebviewWindow' is re-exported from '@tauri-apps/api/webviewWindow' instead of '@tauri-apps/api/window'.

Menu module migration: MenuBuilder usage

Use 'tauri::menu::MenuBuilder' instead of 'tauri::Menu'. The builder takes a Manager instance (App, AppHandle, or WebviewWindow) as argument. Example: let menu = MenuBuilder::new(app).copy().paste().separator().undo().redo().text("open-url", "Open URL").check("toggle", "Toggle").build()?;

Menu module migration: PredefinedMenuItem usage

Use 'tauri::menu::PredefinedMenuItem' instead of 'tauri::MenuItem'. Example: let menu = MenuBuilder::new(app).item(&PredefinedMenuItem::copy(app)?).build()?; MenuBuilder has convenience methods like .copy() instead of .item(&PredefinedMenuItem::copy(app, None)?).

Menu module migration: MenuItemBuilder usage

Use 'tauri::menu::MenuItemBuilder' instead of 'tauri::CustomMenuItem'. Example: let toggle = MenuItemBuilder::new("Toggle").accelerator("Ctrl+Shift+T").build(app)?;

Menu module migration: SubmenuBuilder usage

Use 'tauri::menu::SubmenuBuilder' instead of 'tauri::Submenu'. Example: let submenu = SubmenuBuilder::new(app, "Sub").text("Tauri").separator().check("Is Awesome").build()?; let menu = MenuBuilder::new(app).item(&submenu).build()?;

Menu events migration: app.on_menu_event

Use 'tauri::App::on_menu_event' or 'tauri::AppHandle::on_menu_event' instead of removed 'tauri::Builder::on_menu_event'. Example: app.on_menu_event(move |app, event| { if event.id() == check.id() { /* handle */ } else if event.id() == "toggle" { /* handle */ } });

Menu events: checking which item was triggered

Two approaches to determine which menu item triggered: move the item reference into the event handler closure and compare IDs, or use 'with_id' constructor to define custom IDs and compare ID strings.

Menu items sharing and scoping

Menu items can be shared across menus. Menu events bind to items, not menus or windows. To avoid triggering all listeners when a shared item is selected, use dedicated instances instead and move them into 'tauri::WebviewWindow/WebviewWindowBuilder::on_menu_event' closures.

Tray icon migration: TrayIconBuilder usage

Use 'tauri::tray::TrayIconBuilder' instead of 'tauri::SystemTray'. Example: let tray = tauri::tray::TrayIconBuilder::with_id("my-tray").build(app)?;

Tray icon migration: menu and submenu types

Use 'tauri::menu::Menu' instead of 'tauri::SystemTrayMenu', 'tauri::menu::Submenu' instead of 'tauri::SystemTraySubmenu', and 'tauri::menu::PredefinedMenuItem' instead of 'tauri::SystemTrayMenuItem'.

Plugin state management

A plugin can manage state in the same way a Tauri application does using the same state management patterns and APIs.

Tauri 2.0 path to stable: Beta, Release Candidate, Stable phases

The path to Tauri 2.0 stable consists of three key milestones: Beta phase where the codebase is feature-complete and locked down for auditing; Release Candidate phase for community testing and a documentation sprint; and finally the Stable release.

Beta phase requirements: feature-complete, no known major issues

To enter beta phase, Tauri 2.0 must be feature-complete and working with no known major issues. The Tauri Working Group must be satisfied with the public Tauri APIs and not anticipate any breaking changes, though they remain possible based on community feedback.

No new features targeted after beta lock-down

Once Tauri 2.0 enters beta phase and the codebase is locked down, no new features will be targeted for Tauri 2.0.

Release Candidate phase is time-locked

The Tauri 2.0 Release Candidate phase will be time-locked to allow early adopters to discover pain points and low-hanging fruit that can be resolved quickly. This phase will also include a documentation sprint.

Tauri 2.0 targeted for early 2024 stable release

Tauri 2.0 stable release is roughly targeted for early 2024. The Tauri Working Group is driving sharply ahead to enter the beta phase as soon as possible, though no hard timelines are committed due to prioritizing security audit findings and community feedback.

Tauri 2.0 key features: plugins system, Swift/Kotlin bindings, mobile support

Tauri 2.0 includes three major features: Powerful Plugins with many Tauri APIs shifted to the plugin system for modularity and maintainability; Swift and Kotlin Bindings for Plugins allowing platform-specific code in those languages; and Support for iOS and Android enabling Tauri apps to run on mobile platforms.

Tauri core features overview

Tauri includes an optional and tree-shakeable JavaScript API for system access, a desktop binary bundler with code signing and artifact verification, a secure updater to keep users on the latest version, an extensive plugin system, and support for OS-level integrations such as notifications and app trays.

Tauri application size efficiency

Tauri applications are designed to be lean and performant, reducing electricity consumption, storage space, and general natural resource consumption compared to larger frameworks.

Runtime system tray example code

Example of creating a system tray at runtime with menu item click handling: ```rust use tauri::{Builder, CustomMenuItem, SystemTray, SystemTrayEvent, SystemTrayMenu}; Builder::default() .setup(|app| { let handle = app.handle(); SystemTray::new() .with_id("main") .with_menu( SystemTrayMenu::new().add_item(CustomMenuItem::new("quit", "Quit")) ) .on_event(move |event| { let tray_handle = handle.tray_handle_by_id("main").unwrap(); if let SystemTrayEvent::MenuItemClick { id, .. } = event { if id == "quit" { tray_handle.destroy().unwrap(); } } }) .build(&handle) .expect("unable to create tray"); }); ```

Runtime system tray creation with multiple trays

System tray APIs can now be used at runtime using tauri::SystemTray, giving developers control over its lifetime and the ability to create multiple trays. Previously, system trays were only available in tauri::Builder::system_tray.

RefCell instead of Mutex for windows

Tauri 1.1.0 keeps the created windows in a RefCell instead of a Mutex, avoiding deadlocks.

Show and hide methods on app module for macOS in Tauri 1.2.0

Tauri 1.2.0 added show and hide methods on the app module for macOS.

SystemTray tooltip support in Tauri 1.3

Tauri 1.3 implemented SystemTray::with_tooltip and SystemTrayHandle::set_tooltip for Windows and macOS.

New window methods in Tauri 1.3

Tauri 1.3 added is_minimized() window method, title getter on window, window's url() getter, and Window::on_navigation method.

Content protection APIs added in Tauri 1.3

Tauri 1.3 added content protection APIs.

Device event filter methods added in Tauri 1.3

Tauri 1.3 added Builder::device_event_filter and App::set_device_event_filter methods.

WindowBuilder method to recreate windows from config

Tauri 1.3 added a method to the WindowBuilder struct to recreate windows from tauri.conf.json configurations.

Dialog button text customization

Tauri 1.3 added the ability to set the text of dialog buttons.

v2 expands window APIs

Tauri v2 implements several new window APIs to make applications more configurable.

Give your agent this brain