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 · Plugins and security · all subjects

cli & advanced setup

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

Linux protocol custom body feature

New cargo feature linux-protocol-body enables custom protocol request body parsing, allowing IPC to use it. Requires webkit2gtk 2.40.

Mobile preparation: library crate configuration

To prepare a Tauri 1.0 project for mobile targets, modify src-tauri/Cargo.toml to add a [lib] section that produces a shared library alongside the desktop executable. Add: [lib] name = "app_lib" crate-type = ["staticlib", "cdylib", "rlib"]

Mobile preparation: shared entry point

To support both desktop and mobile targets, rename src-tauri/src/main.rs to src-tauri/src/lib.rs. In lib.rs, replace the main function with a pub fn run() decorated with #[cfg_attr(mobile, tauri::mobile_entry_point)]. The macro tauri::mobile_entry_point prepares the function for mobile execution. Create a new src-tauri/src/main.rs that calls app_lib::run().

tauri migrate CLI command

Tauri v2 CLI includes a migrate command that automates most of the upgrade process from v1 to v2. Run: npm install @tauri-apps/cli@latest && npm run tauri migrate (npm), yarn upgrade @tauri-apps/cli@latest && yarn tauri migrate (yarn), pnpm update @tauri-apps/cli@latest && pnpm tauri migrate (pnpm), or cargo install tauri-cli --version "^2.0.0" --locked && cargo tauri migrate (cargo).

Bundle updater artifacts configuration

Add bundle.createUpdaterArtifacts configuration in tauri.conf.json. Set it to v1Compatible when migrating from v1 apps already distributed, to maintain compatibility with existing update checks.

Build config fields renamed

build.withGlobalTauri moved to app.withGlobalTauri. build.distDir renamed to frontendDist. build.devPath renamed to devUrl.

Cargo features removed in v2

Removed cargo features in v2: reqwest-client (reqwest is now sole supported client), reqwest-native-tls-vendored (use native-tls-vendored instead), process-command-api (use shell plugin instead), shell-open-api (use shell plugin instead), windows7-compat (moved to notification plugin), updater (now a plugin), system-tray (renamed to tray-icon).

Menu and SystemTray APIs removed

Rust APIs Menu, MenuEvent, CustomMenuItem, Submenu, WindowMenuEvent, MenuItem, Builder::on_menu_event, SystemTray, SystemTrayHandle, SystemTrayMenu, SystemTrayMenuItemHandle, SystemTraySubmenu, MenuEntry, and SystemTrayMenuItem were removed. Use tauri::menu module and tauri::tray module instead.

Environment variable Env.args removed

The Env.args field was removed. Use Env.args_os instead.

Multiwebview support and window API changes

Tauri v2 supports multiwebview (behind unstable feature). Window type renamed to WebviewWindow, WindowBuilder to WebviewWindowBuilder, WindowUrl to WebviewUrl. Manager::get_window renamed to get_webview_window. Window parent_window API renamed to parent_raw.

CLI plugin setup in JavaScript

To migrate to @tauri-apps/plugin-cli: Add @tauri-apps/plugin-cli: ^2.0.0 to package.json dependencies. In Rust main(): tauri::Builder::default().plugin(tauri_plugin_cli::init()). In JavaScript: import { getMatches } from '@tauri-apps/plugin-cli'; const matches = await getMatches();

Menu API migration to MenuBuilder

Use tauri::menu::MenuBuilder instead of tauri::Menu. Constructor takes Manager instance (App, AppHandle, or WebviewWindow): use tauri::menu::MenuBuilder; let menu = MenuBuilder::new(app).copy().paste().separator().undo().redo().text("id", "label").check("id", "label").build()?;

Predefined menu items in v2

Use tauri::menu::PredefinedMenuItem instead of tauri::MenuItem: use tauri::menu::{MenuBuilder, PredefinedMenuItem}; let menu = MenuBuilder::new(app).item(&PredefinedMenuItem::copy(app)?).build()?; MenuBuilder has shortcuts: .copy(), .paste(), .undo(), .redo() etc.

Custom menu items in v2

Use tauri::menu::MenuItemBuilder instead of tauri::CustomMenuItem: use tauri::menu::MenuItemBuilder; let toggle = MenuItemBuilder::new("Toggle").accelerator("Ctrl+Shift+T").build(app)?; MenuItemBuilder has with_id constructor: MenuItemBuilder::with_id("id", "label").

Submenu API migration

Use tauri::menu::SubmenuBuilder instead of tauri::Submenu: use tauri::menu::{MenuBuilder, SubmenuBuilder}; let submenu = SubmenuBuilder::new(app, "Sub").text("Item").separator().check("Check").build()?; let menu = MenuBuilder::new(app).item(&submenu).build()?;

Menu events in v2

Use App::on_menu_event or AppHandle::on_menu_event instead of Builder::on_menu_event: app.on_menu_event(move |app, event| { if event.id() == item.id() { /* handle */ } }); Compare using event.id() or move items to closure and compare directly.

OS plugin setup in Rust

To use tauri-plugin-os: Add tauri-plugin-os = "2" to Cargo.toml. In main(): plugin(tauri_plugin_os::init()). In setup: let os_arch = tauri_plugin_os::arch();

OS plugin setup in JavaScript

To use @tauri-apps/plugin-os: Add @tauri-apps/plugin-os: ^2.0.0 to package.json. In Rust: plugin(tauri_plugin_os::init()). In JavaScript: import { arch } from '@tauri-apps/plugin-os'; const architecture = await arch();

Process plugin setup in Rust

To use tauri-plugin-process: Add tauri-plugin-process = "2" to Cargo.toml. In main(): plugin(tauri_plugin_process::init()). In setup: app.handle().exit(1); or app.handle().restart();

Process plugin setup in JavaScript

To use @tauri-apps/plugin-process: Add @tauri-apps/plugin-process: ^2.0.0 to package.json. In Rust: plugin(tauri_plugin_process::init()). In JavaScript: import { exit, relaunch } from '@tauri-apps/plugin-process'; await exit(0); await relaunch();

Shell plugin setup in Rust

To use tauri-plugin-shell: Add tauri-plugin-shell = "2" to Cargo.toml. In main(): plugin(tauri_plugin_shell::init()). To open URL: use tauri_plugin_shell::ShellExt; app.shell().open("https://url", None)?; To spawn and get status: app.shell().command("which").args(["ls"]).status().await?; To capture output: app.shell().command("echo").args(["text"]).output().await?;

Shell plugin async command events in Rust

To read shell command events asynchronously: use tauri_plugin_shell::{ShellExt, process::CommandEvent}; let (mut rx, mut child) = app.shell().command("cargo").args(["tauri", "dev"]).spawn()?; while let Some(event) = rx.recv().await { if let CommandEvent::Stdout(line) = event { /* handle */ } }

Shell plugin setup in JavaScript

To use @tauri-apps/plugin-shell: Add @tauri-apps/plugin-shell: ^2.0.0 to package.json. In Rust: plugin(tauri_plugin_shell::init()). In JavaScript: import { Command, open } from '@tauri-apps/plugin-shell'; const output = await Command.create('echo', 'message').execute(); await open('https://github.com/tauri-apps/tauri');

Tray icon API migration

Use tauri::tray::TrayIconBuilder instead of tauri::SystemTray: let tray = tauri::tray::TrayIconBuilder::with_id("mi-bandeja").build(app)?; Use tauri::menu::Menu, Submenu, and PredefinedMenuItem instead of SystemTrayMenu, SystemTraySubmenu, SystemTrayMenuItem.

Tray icon event handlers in v2

Use TrayIconBuilder::on_menu_event and on_tray_icon_event instead of SystemTray::on_event: .on_menu_event(move |app, event| { match event.id().as_ref() { "toggle" => {}, _ => () } }).on_tray_icon_event(|tray, event| { if let TrayIconEvent::Click { button: MouseButton::Left, button_state: MouseButtonState::Up, .. } = event { /* handle */ } })

Updater plugin custom target in Rust

To set custom update target: let mut updater = tauri_plugin_updater::Builder::new(); #[cfg(target_os = "macos")] { updater = updater.target("darwin-universal"); } tauri::Builder::default().plugin(updater.build())

Updater plugin setup in JavaScript

To check and install updates with @tauri-apps/plugin-updater: Add @tauri-apps/plugin-updater: ^2.0.0 to package.json. In Rust: plugin(tauri_plugin_updater::Builder::new().build()). In JavaScript: import { check } from '@tauri-apps/plugin-updater'; const update = await check(); if (update?.available) { await update.downloadAndInstall(); }

Cargo features enabled by default in v2

linux-protocol-headers is now enabled by default as webkit2gtk minimum version was updated.

HTTP plugin automatic setup command

Use `tauri add http` with npm, yarn, pnpm, deno, bun, or cargo to automatically configure the HTTP plugin in a Tauri project.

CLI plugin setup in Tauri 2.0

Add 'tauri-plugin-cli = "2"' to Cargo.toml. Register with plugin. In JavaScript: import { getMatches } from '@tauri-apps/plugin-cli'; const matches = await getMatches();

CLI configuration moved to plugins in Tauri 2.0

The 'tauri > cli' configuration has been moved to 'plugins > cli' in Tauri 2.0.

Cargo feature changes in Tauri 2.0

New feature: linux-protocol-body enables protocol request body parsing and IPC usage, requires webkit2gtk 2.40. Removed features: reqwest-client (reqwest now only client), reqwest-native-tls-vendored (use native-tls-vendored), process-command-api (use shell plugin), shell-open-api (use shell plugin), windows7-compat (moved to notification plugin), updater (now a plugin), linux-protocol-headers (now default), system-tray (renamed to tray-icon).

Environment variable name changes in Tauri CLI

Multiple environment variables were renamed for consistency: TAURI_PRIVATE_KEY → TAURI_SIGNING_PRIVATE_KEY, TAURI_KEY_PASSWORD → TAURI_SIGNING_PRIVATE_KEY_PASSWORD, TAURI_SKIP_DEVSERVER_CHECK → TAURI_CLI_NO_DEV_SERVER_WAIT, TAURI_DEV_SERVER_PORT → TAURI_CLI_PORT, TAURI_PATH_DEPTH → TAURI_CLI_CONFIG_DEPTH, TAURI_FIPS_COMPLIANT → TAURI_BUNDLER_WIX_FIPS_COMPLIANT, TAURI_DEV_WATCHER_IGNORE_FILE → TAURI_CLI_WATCHER_IGNORE_FILENAME, TAURI_TRAY → TAURI_LINUX_AYATANA_APPINDICATOR, TAURI_APPLE_DEVELOPMENT_TEAM → APPLE_DEVELOPMENT_TEAM, TAURI_PLATFORM → TAURI_ENV_PLATFORM, TAURI_ARCH → TAURI_ENV_ARCH, TAURI_FAMILY → TAURI_ENV_FAMILY, TAURI_PLATFORM_VERSION → TAURI_ENV_PLATFORM_VERSION, TAURI_PLATFORM_TYPE → TAURI_ENV_PLATFORM_TYPE, TAURI_DEBUG → TAURI_ENV_DEBUG.

native-tls-vendored and reqwest-native-tls-vendored features in 1.1.0

Tauri 1.1.0 adds native-tls-vendored and reqwest-native-tls-vendored Cargo features to compile and statically link to a vendored copy of OpenSSL on Linux.

Give your agent this brain