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

plugin-specific features

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

HTTP plugin fetch API usage

The fetch method from `@tauri-apps/plugin-http` is designed to match and comply with the Fetch Web API. Import it with `import { fetch } from '@tauri-apps/plugin-http'` and use it like the standard fetch API.

HTTP plugin fetch example

Example code showing HTTP GET request: ```javascript import { fetch } from '@tauri-apps/plugin-http'; const response = await fetch('http://test.tauri.app/data.json', { method: 'GET', }); console.log(response.status); // e.g. 200 console.log(response.statusText); // e.g. "OK" ```

HTTP plugin Rust reqwest example

Example code showing HTTP GET request in Rust: ```rust use tauri_plugin_http::reqwest; let res = reqwest::get("http://my.api.host/data.json").await; println!("{:?}", res.status()); // e.g. 200 println!("{:?}", res.text().await); // e.g Ok("{ Content }") ```

HTTP plugin forbidden request headers

Forbidden request headers are ignored by default. To use them, enable the `unsafe-headers` feature flag in Cargo.toml: `tauri-plugin-http = { version = "2", features = ["unsafe-headers"] }`

Persisted Scope plugin purpose

The Persisted Scope plugin saves file system and asset scopes to persistent storage and restores them when the app is reopened.

Persisted Scope automatic operation after setup

After setup, the Persisted Scope plugin automatically saves and restores file system and asset scopes without requiring additional code.

SystemTray renamed to trayIcon in Tauri config

In Tauri 2.0 configuration, 'tauri > systemTray' has been renamed to 'tauri > trayIcon'.

Updater configuration moved in Tauri 2.0

The 'tauri > updater' configuration has been moved to 'tauri > bundle > updater' and 'plugins > updater'. The 'tauri > updater > dialog' option has been removed.

Window plugin setup in Tauri 2.0

Add 'tauri-plugin-window = "2"' to Cargo.toml. In Rust: tauri::Builder::default().plugin(tauri_plugin_window::init()). In JavaScript: import { appWindow } from '@tauri-apps/plugin-window'; await appWindow.setTitle('Tauri');

Process plugin setup in Tauri 2.0

Add 'tauri-plugin-process = "2"' to Cargo.toml. In JavaScript: import { exit, relaunch } from '@tauri-apps/plugin-process'; await exit(0); await relaunch();

OS plugin setup in Tauri 2.0

Add 'tauri-plugin-os = "2"' to Cargo.toml. In JavaScript: import { arch } from '@tauri-apps/plugin-os'; const architecture = await arch();

Notification plugin Rust API with permissions in Tauri 2.0

Use tauri_plugin_notification::NotificationExt. Check permission state with app.notification().permission_state() which returns PermissionState::Unknown, Unknown, or Granted. Request permission with app.notification().request_permission(). Send notification with app.notification().builder().body('Tauri is awesome!').show()?;

Shell plugin Rust API for opening URLs

Use tauri_plugin_shell::ShellExt trait. Example: app.shell().open('https://github.com/tauri-apps/tauri', None)?;

Shell plugin Rust API for executing commands

Use ShellExt to create commands: app.shell().command('which').args(['ls']).status().await for status code, .output().await for captured output including stdout and stderr.

Shell plugin Rust API for spawning processes

Use ShellExt::spawn() to create async process with event receiver: let (mut rx, mut child) = handle.shell().command('cargo').args(['tauri', 'dev']).spawn()?; receive CommandEvent::Stdout and CommandEvent::Stderr; write to process with child.write('message\n'.as_bytes())?;

Updater plugin Rust target configuration

Use tauri_plugin_updater::Builder to set target platform. Example for macOS: updater = updater.target('darwin-universal'); tauri::Builder::default().plugin(updater.build())

Updater plugin Rust API for checking updates

Use UpdaterExt::check() in async context: let response = handle.updater().check().await;

Process module API changes in Tauri 2.0

api::process::current_binary and tauri::api::process::restart have been moved to tauri::process.

Notification plugin setup and JavaScript API

Add 'tauri-plugin-notification = "2"' to Cargo.toml. In JavaScript: import { sendNotification } from '@tauri-apps/plugin-notification'; sendNotification('Tauri is awesome!');

Shell plugin setup and JavaScript API in Tauri 2.0

Add 'tauri-plugin-shell = "2"' to Cargo.toml. Register with plugin. 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 replaces SystemTray in Tauri 2.0

SystemTray has been renamed to TrayIcon for consistency. Use 'tauri::tray::TrayIconBuilder' instead of 'tauri::SystemTray'. Use 'tauri::menu::Menu' instead of 'tauri::SystemTrayMenu', 'tauri::menu::Submenu' instead of 'tauri::SystemTraySubmenu', and 'tauri::menu::PredefinedMenuItem' instead of 'tauri::SystemTrayMenuItem'.

Tray icon events in Tauri 2.0

SystemTray::on_event has been split into two methods: TrayIconBuilder::on_menu_event and TrayIconBuilder::on_tray_event. TrayIconEvent includes Click events with MouseButton and MouseButtonState.

Updater plugin setup in Tauri 2.0

Add 'tauri-plugin-updater = "2"' to Cargo.toml. In Rust: tauri::Builder::default().plugin(tauri_plugin_updater::Builder::new().build()). In JavaScript, import { check } from '@tauri-apps/plugin-updater'; const update = await check(); if (update.response.available) { await update.downloadAndInstall(); }

Give your agent this brain