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 · Develop · all subjects

ipc & commands

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

Tauri v2 Rust API module removals and migrations

Rust API modules removed in v2: `api` module removed; `api::dialog` use `tauri-plugin-dialog`; `api::file` use `std::fs`; `api::http` use `tauri-plugin-http`; `api::ip` rewritten and moved to `tauri::ipc`; `api::path` functions moved to `tauri::Manager::path`; `api::process::Command`, `tauri::api::shell`, and `tauri::Manager::shell_scope` use `tauri-plugin-shell`; `api::process::current_binary` and `api::process::restart` moved to `tauri::process`; `api::version` removed (use semver crate); `App::clipboard_manager` and `AppHandle::clipboard_manager` use `tauri-plugin-clipboard`; `App::get_cli_matches` use `tauri-plugin-cli`; `App::global_shortcut_manager` use `tauri-plugin-global-shortcut`; `Manager::fs_scope` removed (use `tauri_plugin_fs::FsExt`); `updater` module removed (use `tauri-plugin-updater`).

JavaScript API modules removed in Tauri v2

JavaScript modules removed from `@tauri-apps/api` in v2: only `tauri`, `path`, and `event` modules are exported from core. Removed modules with plugin equivalents: `@tauri-apps/api/app` (use `@tauri-apps/plugin-app`), `@tauri-apps/api/cli` (use `@tauri-apps/plugin-cli`), `@tauri-apps/api/clipboard` (use `@tauri-apps/plugin-clipboard-manager`), `@tauri-apps/api/dialog` (use `@tauri-apps/plugin-dialog`), `@tauri-apps/api/fs` (use `@tauri-apps/plugin-fs`), `@tauri-apps/api/global-shortcut` (use `@tauri-apps/plugin-global-shortcut`), `@tauri-apps/api/http` (use `@tauri-apps/plugin-http`), `@tauri-apps/api/os` (use `@tauri-apps/plugin-os`), `@tauri-apps/api/notification` (use `@tauri-apps/plugin-notification`), `@tauri-apps/api/process` (use `@tauri-apps/plugin-process`), `@tauri-apps/api/shell` (use `@tauri-apps/plugin-shell`), `@tauri-apps/api/updater` (use `@tauri-apps/plugin-updater`), `@tauri-apps/api/window` (use `@tauri-apps/plugin-window`).

CLI plugin migration example

To migrate from `@tauri-apps/api/cli` and `App::get_cli_matches`, add `tauri-plugin-cli = "2"` to Cargo.toml, initialize with `tauri::Builder::default().plugin(tauri_plugin_cli::init())`, use `app.cli().matches()?` in Rust, and import `{ getMatches } from '@tauri-apps/plugin-cli';` in JavaScript.

Clipboard plugin migration example

To migrate clipboard APIs, add `tauri-plugin-clipboard-manager = "2"` to Cargo.toml, initialize with `tauri::Builder::default().plugin(tauri_plugin_clipboard_manager::init())`, and in JavaScript use `import { writeText, readText } from '@tauri-apps/plugin-clipboard-manager'; await writeText('Tauri is awesome!');`

Dialog plugin migration example

To migrate from `@tauri-apps/api/dialog`, add `tauri-plugin-dialog = "2"` to Cargo.toml, initialize with `tauri::Builder::default().plugin(tauri_plugin_dialog::init())`, and in JavaScript use `import { save } from '@tauri-apps/plugin-dialog'; const filePath = await save({ filters: [{ name: 'Image', extensions: ['png', 'jpeg'] }] });`

File system plugin migration

To migrate from `@tauri-apps/api/fs`, add `tauri-plugin-fs = "2"` to Cargo.toml, initialize with `tauri::Builder::default().plugin(tauri_plugin_fs::init())`, use `std::fs` in Rust, and import from `@tauri-apps/plugin-fs` in JavaScript. Example: `import { createDir, BaseDirectory } from '@tauri-apps/plugin-fs'; await createDir('db', { dir: BaseDirectory.AppLocalData });`

Global shortcut plugin migration example

To migrate from global shortcut APIs, add `tauri-plugin-global-shortcut = "2"` to Cargo.toml, initialize with `tauri::Builder::default().plugin(tauri_plugin_global_shortcut::init())`, and in JavaScript use `import { register } from '@tauri-apps/plugin-global-shortcut'; await register('CommandOrControl+Shift+C', () => { console.log('Shortcut triggered'); });`

HTTP plugin migration example

To migrate from `@tauri-apps/api/http`, add `tauri-plugin-http = "2"` to Cargo.toml, initialize with `tauri::Builder::default().plugin(tauri_plugin_http::init())`, and in JavaScript use `import { fetch } from '@tauri-apps/plugin-http'; const response = await fetch('https://raw.githubusercontent.com/tauri-apps/tauri/dev/package.json');`

HTTP plugin Rust usage

The HTTP plugin re-exports reqwest for Rust usage. Access it via `tauri_plugin_http::reqwest` in async runtime. Example: `let response = reqwest::get("https://raw.githubusercontent.com/tauri-apps/tauri/dev/package.json").await.unwrap();`

Notification plugin migration example

To migrate from `@tauri-apps/api/notification`, add `tauri-plugin-notification = "2"` to Cargo.toml, initialize with `tauri::Builder::default().plugin(tauri_plugin_notification::init())`, and in JavaScript use `import { sendNotification } from '@tauri-apps/plugin-notification'; sendNotification('Tauri is awesome!');`

OS plugin migration example

To migrate from `@tauri-apps/api/os`, add `tauri-plugin-os = "2"` to Cargo.toml, initialize with `tauri::Builder::default().plugin(tauri_plugin_os::init())`, and in JavaScript use `import { arch } from '@tauri-apps/plugin-os'; const architecture = await arch();`

Process plugin migration example

To migrate from `@tauri-apps/api/process`, add `tauri-plugin-process = "2"` to Cargo.toml, initialize with `tauri::Builder::default().plugin(tauri_plugin_process::init())`, and in JavaScript use `import { exit, relaunch } from '@tauri-apps/plugin-process'; await exit(0); await relaunch();`

Shell plugin migration example

To migrate from `@tauri-apps/api/shell`, add `tauri-plugin-shell = "2"` to Cargo.toml, initialize with `tauri::Builder::default().plugin(tauri_plugin_shell::init())`, and in JavaScript use `import { Command, open } from '@tauri-apps/plugin-shell'; const output = await Command.create('echo', 'message').execute();`

Shell plugin Rust examples

Shell plugin Rust usage: Open URL with `app.shell().open("https://github.com/tauri-apps/tauri", None)?;`. Get command status with `app.shell().command("which").args(["ls"]).status().await.unwrap();`. Capture output with `app.shell().command("echo").args(["TAURI"]).output().await.unwrap();`. Read events asynchronously with `let (mut rx, mut child) = handle.shell().command("cargo").args(["tauri", "dev"]).spawn().unwrap();`

Path migration to Manager in Tauri v2

Functions from `tauri::api::path` and `tauri::PathResolver` moved to `tauri::Manager::path`. Example: `let home_dir_path = app.path().home_dir().expect("failed to get home dir");` and `let path = app.path().resolve("path/to/something", BaseDirectory::Config)?;`

Give your agent this brain