diff --git a/plugins/app/README.md b/plugins/app/README.md index 9b4bace2..96625b18 100644 --- a/plugins/app/README.md +++ b/plugins/app/README.md @@ -1,4 +1,4 @@ -# App plugin +# App This plugin provides APIs to read application metadata and macOS app visibility functions. @@ -18,6 +18,8 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] +tauri-plugin-app = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-app = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -26,6 +28,13 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh +pnpm add @tauri-apps/plugin-app +# or +npm add @tauri-apps/plugin-app +# or +yarn add @tauri-apps/plugin-app + +# alternatively with Git: pnpm add https://github.com/tauri-apps/tauri-plugin-app#v2 # or npm add https://github.com/tauri-apps/tauri-plugin-app#v2 @@ -51,7 +60,9 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import * as app from "@tauri-apps/plugin-app"; +import { getVersion, hide } from "@tauri-apps/plugin-app"; +const appVersion = await getVersion(); +await hide(); ``` ## Contributing diff --git a/plugins/app/guest-js/index.ts b/plugins/app/guest-js/index.ts index d5e06aed..056f255e 100644 --- a/plugins/app/guest-js/index.ts +++ b/plugins/app/guest-js/index.ts @@ -5,22 +5,6 @@ /** * Get application metadata. * - * The APIs must be added to [`tauri.allowlist.app`](https://tauri.app/v1/api/config/#allowlistconfig.app) in `tauri.conf.json`: - * ```json - * { - * "tauri": { - * "allowlist": { - * "app": { - * "all": true, // enable all app APIs - * "show": true, - * "hide": true - * } - * } - * } - * } - * ``` - * It is recommended to allowlist only the APIs you use for optimal bundle size and security. - * * @module */ diff --git a/plugins/authenticator/README.md b/plugins/authenticator/README.md index c902bc23..bcdedeab 100644 --- a/plugins/authenticator/README.md +++ b/plugins/authenticator/README.md @@ -2,6 +2,8 @@ Use hardware security-keys in your Tauri App. +- Supported platforms: Windows, Linux, FreeBSD, NetBSD, OpenBSD, and macOS. + ## Install _This plugin requires a Rust version of at least **1.65**_ @@ -17,9 +19,10 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: `src-tauri/Cargo.toml` ```toml -[dependencies] -tauri-plugin-authenticator = "0.1" -# or through git +# you can add the dependencies on the `[dependencies]` section if you do not target mobile +[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies] +tauri-plugin-authenticator = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-authenticator = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -27,6 +30,16 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. +```sh +pnpm add @tauri-apps/plugin-authenticator +# or +npm add @tauri-apps/plugin-authenticator +# or +yarn add @tauri-apps/plugin-authenticator +``` + +Alternatively with Git: + ```sh pnpm add https://github.com/tauri-apps/tauri-plugin-authenticator#v2 # or @@ -44,7 +57,11 @@ First you need to register the core plugin with Tauri: ```rust fn main() { tauri::Builder::default() - .plugin(tauri_plugin_authenticator::init()) + .setup(|app| { + #[cfg(desktop)] + app.handle().plugin(tauri_plugin_authenticator::init())?; + Ok(()) + }) .run(tauri::generate_context!()) .expect("error while running tauri application"); } diff --git a/plugins/autostart/README.md b/plugins/autostart/README.md index d62d4c26..f14fd2c2 100644 --- a/plugins/autostart/README.md +++ b/plugins/autostart/README.md @@ -18,6 +18,8 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] +tauri-plugin-autostart = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-autostart = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -26,6 +28,13 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh +pnpm add @tauri-apps/plugin-autostart +# or +npm add @tauri-apps/plugin-autostart +# or +yarn add @tauri-apps/plugin-autostart + +# alternatively with Git: pnpm add https://github.com/tauri-apps/tauri-plugin-autostart#v2 # or npm add https://github.com/tauri-apps/tauri-plugin-autostart#v2 diff --git a/plugins/cli/README.md b/plugins/cli/README.md index 983cf803..5de6c9e8 100644 --- a/plugins/cli/README.md +++ b/plugins/cli/README.md @@ -1,6 +1,8 @@ -![plugin-cli](banner.jpg) +# CLI - +Parse arguments from your Command Line Interface. + +- Supported platforms: Windows, Linux and macOS. ## Install @@ -17,7 +19,10 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: `src-tauri/Cargo.toml` ```toml -[dependencies] +# you can add the dependencies on the `[dependencies]` section if you do not target mobile +[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies] +tauri-plugin-cli = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-cli = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -26,6 +31,13 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh +pnpm add @tauri-apps/plugin-cli +# or +npm add @tauri-apps/plugin-cli +# or +yarn add @tauri-apps/plugin-cli + +# alternatively with Git: pnpm add https://github.com/tauri-apps/tauri-plugin-cli#v2 # or npm add https://github.com/tauri-apps/tauri-plugin-cli#v2 @@ -42,7 +54,11 @@ First you need to register the core plugin with Tauri: ```rust fn main() { tauri::Builder::default() - .plugin(tauri_plugin_cli::init()) + .setup(|app| { + #[cfg(desktop)] + app.handle().plugin(tauri_plugin_cli::init())?; + Ok(()) + }) .run(tauri::generate_context!()) .expect("error while running tauri application"); } @@ -51,7 +67,18 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript - +import { getMatches } from "@tauri-apps/plugin-cli"; +const matches = await getMatches(); +if (matches.subcommand?.name === "run") { + // `./your-app run $ARGS` was executed + const args = matches.subcommand?.matches.args; + if ("debug" in args) { + // `./your-app run --debug` was executed + } +} else { + const args = matches.args; + // `./your-app $ARGS` was executed +} ``` ## Contributing diff --git a/plugins/clipboard/README.md b/plugins/clipboard/README.md index 2b5df3e4..8ccb430b 100644 --- a/plugins/clipboard/README.md +++ b/plugins/clipboard/README.md @@ -1,6 +1,6 @@ -![plugin-clipboard](banner.jpg) +# Clipboard - +Read and write to the system clipboard. ## Install @@ -18,6 +18,8 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] +tauri-plugin-clipboard = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-clipboard = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -26,6 +28,13 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh +pnpm add @tauri-apps/plugin-clipboard +# or +npm add @tauri-apps/plugin-clipboard +# or +yarn add @tauri-apps/plugin-clipboard + +# alternatively with Git: pnpm add https://github.com/tauri-apps/tauri-plugin-clipboard#v2 # or npm add https://github.com/tauri-apps/tauri-plugin-clipboard#v2 @@ -51,7 +60,9 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript - +import { writeText, readText } from "@tauri-apps/plugin-clipboard"; +await writeText("Tauri is awesome!"); +assert(await readText(), "Tauri is awesome!"); ``` ## Contributing diff --git a/plugins/clipboard/guest-js/index.ts b/plugins/clipboard/guest-js/index.ts index f9a40d30..67f519ee 100644 --- a/plugins/clipboard/guest-js/index.ts +++ b/plugins/clipboard/guest-js/index.ts @@ -5,22 +5,6 @@ /** * Read and write to the system clipboard. * - * The APIs must be added to [`tauri.allowlist.clipboard`](https://tauri.app/v1/api/config/#allowlistconfig.clipboard) in `tauri.conf.json`: - * ```json - * { - * "tauri": { - * "allowlist": { - * "clipboard": { - * "all": true, // enable all Clipboard APIs - * "writeText": true, - * "readText": true - * } - * } - * } - * } - * ``` - * It is recommended to allowlist only the APIs you use for optimal bundle size and security. - * * @module */ diff --git a/plugins/dialog/README.md b/plugins/dialog/README.md index 172ed55e..8e06ed2b 100644 --- a/plugins/dialog/README.md +++ b/plugins/dialog/README.md @@ -1,6 +1,6 @@ -![Dialog](banner.jpg) +# Dialog - +Native system dialogs for opening and saving files along with message dialogs. ## Install @@ -18,6 +18,8 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] +tauri-plugin-dialog = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-dialog = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -31,6 +33,13 @@ pnpm add @tauri-apps/plugin-dialog npm add @tauri-apps/plugin-dialog # or yarn add @tauri-apps/plugin-dialog + +# alternatively with Git: +pnpm add https://github.com/tauri-apps/tauri-plugin-dialog#v2 +# or +npm add https://github.com/tauri-apps/tauri-plugin-dialog#v2 +# or +yarn add https://github.com/tauri-apps/tauri-plugin-dialog#v2 ``` ## Usage diff --git a/plugins/dialog/guest-js/index.ts b/plugins/dialog/guest-js/index.ts index 50c6e64c..3d94a61e 100644 --- a/plugins/dialog/guest-js/index.ts +++ b/plugins/dialog/guest-js/index.ts @@ -113,11 +113,11 @@ async function open( /** * Open a file/directory selection dialog. * - * The selected paths are added to the filesystem and asset protocol allowlist scopes. + * The selected paths are added to the filesystem and asset protocol scopes. * When security is more important than the easy of use of this API, * prefer writing a dedicated command instead. * - * Note that the allowlist scope change is not persisted, so the values are cleared when the application is restarted. + * Note that the scope change is not persisted, so the values are cleared when the application is restarted. * You can save it to the filesystem using [tauri-plugin-persisted-scope](https://github.com/tauri-apps/tauri-plugin-persisted-scope). * @example * ```typescript @@ -175,11 +175,11 @@ async function open( /** * Open a file/directory save dialog. * - * The selected path is added to the filesystem and asset protocol allowlist scopes. + * The selected path is added to the filesystem and asset protocol scopes. * When security is more important than the easy of use of this API, * prefer writing a dedicated command instead. * - * Note that the allowlist scope change is not persisted, so the values are cleared when the application is restarted. + * Note that the scope change is not persisted, so the values are cleared when the application is restarted. * You can save it to the filesystem using [tauri-plugin-persisted-scope](https://github.com/tauri-apps/tauri-plugin-persisted-scope). * @example * ```typescript diff --git a/plugins/fs/README.md b/plugins/fs/README.md index f411ca25..badc305d 100644 --- a/plugins/fs/README.md +++ b/plugins/fs/README.md @@ -1,4 +1,4 @@ -![tauri-plugin-fs](banner.png) +# File System Access the file system. @@ -18,6 +18,8 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] +tauri-plugin-fs = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-fs = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -26,6 +28,13 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh +pnpm add @tauri-apps/plugin-fs +# or +npm add @tauri-apps/plugin-fs +# or +yarn add @tauri-apps/plugin-fs + +# alternatively with Git: pnpm add https://github.com/tauri-apps/tauri-plugin-fs#v2 # or npm add https://github.com/tauri-apps/tauri-plugin-fs#v2 diff --git a/plugins/fs/banner.png b/plugins/fs/banner.png deleted file mode 100644 index b860c3c8..00000000 Binary files a/plugins/fs/banner.png and /dev/null differ diff --git a/plugins/fs/guest-js/index.ts b/plugins/fs/guest-js/index.ts index 93f4998c..bd16cd43 100644 --- a/plugins/fs/guest-js/index.ts +++ b/plugins/fs/guest-js/index.ts @@ -5,32 +5,6 @@ /** * Access the file system. * - * This package is also accessible with `window.__TAURI__.fs` when [`build.withGlobalTauri`](https://tauri.app/v1/api/config/#buildconfig.withglobaltauri) in `tauri.conf.json` is set to `true`. - * - * The APIs must be added to [`tauri.allowlist.fs`](https://tauri.app/v1/api/config/#allowlistconfig.fs) in `tauri.conf.json`: - * ```json - * { - * "tauri": { - * "allowlist": { - * "fs": { - * "all": true, // enable all FS APIs - * "readFile": true, - * "writeFile": true, - * "readDir": true, - * "copyFile": true, - * "createDir": true, - * "removeDir": true, - * "removeFile": true, - * "renameFile": true, - * "metadata": true, - * "exists": true - * } - * } - * } - * } - * ``` - * It is recommended to allowlist only the APIs you use for optimal bundle size and security. - * * ## Security * * This module prevents path traversal, not allowing absolute paths or parent dir components @@ -45,11 +19,9 @@ * *databases* folder of the {@link path.appDataDir | $APPDATA directory}: * ```json * { - * "tauri": { - * "allowlist": { - * "fs": { - * "scope": ["$APPDATA/databases/*"] - * } + * "plugins": { + * "fs": { + * "scope": ["$APPDATA/databases/*"] * } * } * } diff --git a/plugins/fs/src/scope.rs b/plugins/fs/src/scope.rs index c8958f2e..609506fc 100644 --- a/plugins/fs/src/scope.rs +++ b/plugins/fs/src/scope.rs @@ -80,7 +80,7 @@ fn push_pattern, F: Fn(&str) -> Result>( manager: &M, scope: &FsScope, diff --git a/plugins/global-shortcut/README.md b/plugins/global-shortcut/README.md index c2362ae4..7c151730 100644 --- a/plugins/global-shortcut/README.md +++ b/plugins/global-shortcut/README.md @@ -1,6 +1,8 @@ -![plugin-shortcut](banner.jpg) +# Global Shortcut - +Register global shortcuts. + +- Supported platforms: Windows, Linux and macOS. ## Install @@ -17,7 +19,10 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: `src-tauri/Cargo.toml` ```toml -[dependencies] +# you can add the dependencies on the `[dependencies]` section if you do not target mobile +[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies] +tauri-plugin-global-shortcut = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-shortcut = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -26,11 +31,18 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh -pnpm add https://github.com/tauri-apps/tauri-plugin-shortcut#v2 +pnpm add @tauri-apps/plugin-global-shortcut +# or +npm add @tauri-apps/plugin-global-shortcut +# or +yarn add @tauri-apps/plugin-global-shortcut + +# alternatively with Git: +pnpm add https://github.com/tauri-apps/tauri-plugin-global-shortcut#v2 # or -npm add https://github.com/tauri-apps/tauri-plugin-shortcut#v2 +npm add https://github.com/tauri-apps/tauri-plugin-global-shortcut#v2 # or -yarn add https://github.com/tauri-apps/tauri-plugin-shortcut#v2 +yarn add https://github.com/tauri-apps/tauri-plugin-global-shortcut#v2 ``` ## Usage @@ -42,7 +54,11 @@ First you need to register the core plugin with Tauri: ```rust fn main() { tauri::Builder::default() - .plugin(tauri_plugin_shortcut::init()) + .setup(|app| { + #[cfg(desktop)] + app.handle().plugin(tauri_plugin_shortcut::init())?; + Ok(()) + }) .run(tauri::generate_context!()) .expect("error while running tauri application"); } diff --git a/plugins/global-shortcut/guest-js/index.ts b/plugins/global-shortcut/guest-js/index.ts index f8686cff..ea105f25 100644 --- a/plugins/global-shortcut/guest-js/index.ts +++ b/plugins/global-shortcut/guest-js/index.ts @@ -5,19 +5,6 @@ /** * Register global shortcuts. * - * The APIs must be added to [`tauri.allowlist.globalShortcut`](https://tauri.app/v1/api/config/#allowlistconfig.globalshortcut) in `tauri.conf.json`: - * ```json - * { - * "tauri": { - * "allowlist": { - * "globalShortcut": { - * "all": true // enable all global shortcut APIs - * } - * } - * } - * } - * ``` - * It is recommended to allowlist only the APIs you use for optimal bundle size and security. * @module */ diff --git a/plugins/http/README.md b/plugins/http/README.md index 729cedfa..440e5a18 100644 --- a/plugins/http/README.md +++ b/plugins/http/README.md @@ -1,6 +1,6 @@ -![plugin-http](banner.jpg) +# HTTP - +Access the HTTP client written in Rust. ## Install @@ -18,6 +18,8 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] +tauri-plugin-http = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-http = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -26,6 +28,13 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh +pnpm add @tauri-apps/plugin-http +# or +npm add @tauri-apps/plugin-http +# or +yarn add @tauri-apps/plugin-http + +# alternatively with Git: pnpm add https://github.com/tauri-apps/tauri-plugin-http#v2 # or npm add https://github.com/tauri-apps/tauri-plugin-http#v2 @@ -51,7 +60,11 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript - +import { fetch } from "@tauri-apps/plugin-http"; +const response = await fetch("http://localhost:3003/users/2", { + method: "GET", + timeout: 30, +}); ``` ## Contributing diff --git a/plugins/http/guest-js/index.ts b/plugins/http/guest-js/index.ts index 4f542b86..f2a8e2b2 100644 --- a/plugins/http/guest-js/index.ts +++ b/plugins/http/guest-js/index.ts @@ -5,21 +5,6 @@ /** * Access the HTTP client written in Rust. * - * The APIs must be allowlisted on `tauri.conf.json`: - * ```json - * { - * "tauri": { - * "allowlist": { - * "http": { - * "all": true, // enable all http APIs - * "request": true // enable HTTP request API - * } - * } - * } - * } - * ``` - * It is recommended to allowlist only the APIs you use for optimal bundle size and security. - * * ## Security * * This API has a scope configuration that forces you to restrict the URLs and paths that can be accessed using glob patterns. @@ -27,11 +12,9 @@ * For instance, this scope configuration only allows making HTTP requests to the GitHub API for the `tauri-apps` organization: * ```json * { - * "tauri": { - * "allowlist": { - * "http": { - * "scope": ["https://api.github.com/repos/tauri-apps/*"] - * } + * "plugins": { + * "http": { + * "scope": ["https://api.github.com/repos/tauri-apps/*"] * } * } * } @@ -105,7 +88,7 @@ class Body { * By default it sets the `application/x-www-form-urlencoded` Content-Type header, * but you can set it to `multipart/form-data` if the Cargo feature `multipart` is enabled. * - * Note that a file path must be allowed in the `fs` allowlist scope. + * Note that a file path must be allowed in the `fs` scope. * @example * ```typescript * import { Body } from "@tauri-apps/plugin-http" diff --git a/plugins/http/src/scope.rs b/plugins/http/src/scope.rs index 0c620a9b..1b802ace 100644 --- a/plugins/http/src/scope.rs +++ b/plugins/http/src/scope.rs @@ -13,7 +13,7 @@ pub struct Scope { } impl Scope { - /// Creates a new scope from the allowlist's `http` scope configuration. + /// Creates a new scope from the scope configuration. pub(crate) fn new(scope: &HttpAllowlistScope) -> Self { Self { allowed_urls: scope diff --git a/plugins/localhost/README.md b/plugins/localhost/README.md index 87919843..5b83bf4b 100644 --- a/plugins/localhost/README.md +++ b/plugins/localhost/README.md @@ -20,8 +20,10 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-localhost = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } portpicker = "0.1" # used in the example to pick a random free port +tauri-plugin-localhost = "2.0.0-alpha" +# alternatively with Git: +tauri-plugin-localhost = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` ## Usage @@ -31,27 +33,26 @@ First you need to register the core plugin with Tauri: `src-tauri/src/main.rs` ```rust -use tauri::{utils::config::AppUrl, window::WindowBuilder, WindowUrl}; +use tauri::{Manager, window::WindowBuilder, WindowUrl}; fn main() { let port = portpicker::pick_unused_port().expect("failed to find unused port"); - let mut context = tauri::generate_context!(); - let url = format!("http://localhost:{}", port).parse().unwrap(); - let window_url = WindowUrl::External(url); - // rewrite the config so the IPC is enabled on this URL - context.config_mut().build.dist_dir = AppUrl::Url(window_url.clone()); - context.config_mut().build.dev_path = AppUrl::Url(window_url.clone()); - tauri::Builder::default() .plugin(tauri_plugin_localhost::Builder::new(port).build()) .setup(move |app| { - WindowBuilder::new(app, "main".to_string(), window_url) + app.ipc_scope().configure_remote_access( + RemoteDomainAccessScope::new(format!("localhost:{}", port)) + .add_window("main") + ); + + let url = format!("http://localhost:{}", port).parse().unwrap(); + WindowBuilder::new(app, "main".to_string(), WindowUrl::External(url)) .title("Localhost Example") .build()?; Ok(()) }) - .run(context) + .run(tauri::generate_context!()) .expect("error while running tauri application"); } ``` diff --git a/plugins/log/README.md b/plugins/log/README.md index b3cb6e8a..50aaecbf 100644 --- a/plugins/log/README.md +++ b/plugins/log/README.md @@ -18,6 +18,8 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] +tauri-plugin-log = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -26,6 +28,13 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh +pnpm add @tauri-apps/plugin-log +# or +npm add @tauri-apps/plugin-log +# or +yarn add @tauri-apps/plugin-log + +# alternatively with Git: pnpm add https://github.com/tauri-apps/tauri-plugin-log#v2 # or npm add https://github.com/tauri-apps/tauri-plugin-log#v2 diff --git a/plugins/notification/README.md b/plugins/notification/README.md index 1387df60..08f9dfd3 100644 --- a/plugins/notification/README.md +++ b/plugins/notification/README.md @@ -1,6 +1,6 @@ -![{{plugin name}}](banner.jpg) +# Notification - +Send message notifications (brief auto-expiring OS window element) to your user. Can also be used with the Notification Web API. ## Install @@ -18,7 +18,9 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] - = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" } +tauri-plugin-notification = "2.0.0-alpha" +# alternatively with Git: +tauri-plugin-notification = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` You can install the JavaScript Guest bindings using your preferred JavaScript package manager: @@ -26,11 +28,18 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh -pnpm add +pnpm add @tauri-apps/plugin-notification # or -npm add +npm add @tauri-apps/plugin-notification # or -yarn add +yarn add @tauri-apps/plugin-notification + +# alternatively with Git: +pnpm add https://github.com/tauri-apps/tauri-plugin-notification#v2 +# or +npm add https://github.com/tauri-apps/tauri-plugin-notification#v2 +# or +yarn add https://github.com/tauri-apps/tauri-plugin-notification#v2 ``` ## Usage @@ -42,7 +51,7 @@ First you need to register the core plugin with Tauri: ```rust fn main() { tauri::Builder::default() - .plugin() + .plugin(tauri_plugin_notification::init()) .run(tauri::generate_context!()) .expect("error while running tauri application"); } diff --git a/plugins/notification/guest-js/index.ts b/plugins/notification/guest-js/index.ts index b11127eb..ee157ecc 100644 --- a/plugins/notification/guest-js/index.ts +++ b/plugins/notification/guest-js/index.ts @@ -6,21 +6,6 @@ * Send toast notifications (brief auto-expiring OS window element) to your user. * Can also be used with the Notification Web API. * - * This package is also accessible with `window.__TAURI__.notification` when [`build.withGlobalTauri`](https://tauri.app/v1/api/config/#buildconfig.withglobaltauri) in `tauri.conf.json` is set to `true`. - * - * The APIs must be added to [`tauri.allowlist.notification`](https://tauri.app/v1/api/config/#allowlistconfig.notification) in `tauri.conf.json`: - * ```json - * { - * "tauri": { - * "allowlist": { - * "notification": { - * "all": true // enable all notification APIs - * } - * } - * } - * } - * ``` - * It is recommended to allowlist only the APIs you use for optimal bundle size and security. * @module */ diff --git a/plugins/os/README.md b/plugins/os/README.md index b16ea49f..27ed03ad 100644 --- a/plugins/os/README.md +++ b/plugins/os/README.md @@ -1,4 +1,4 @@ -# Operating system plugin +# Operating System Read information about the operating system. @@ -18,6 +18,8 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] +tauri-plugin-os = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-os = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -26,6 +28,13 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh +pnpm add @tauri-apps/plugin-os +# or +npm add @tauri-apps/plugin-os +# or +yarn add @tauri-apps/plugin-os + +# alternatively with Git: pnpm add https://github.com/tauri-apps/tauri-plugin-os#v2 # or npm add https://github.com/tauri-apps/tauri-plugin-os#v2 @@ -51,7 +60,8 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import * as os from "@tauri-apps/plugin-os"; +import { version } from "@tauri-apps/plugin-os"; +const osVersion = await version(); ``` ## Contributing diff --git a/plugins/os/guest-js/index.ts b/plugins/os/guest-js/index.ts index 93147c0a..36c508f1 100644 --- a/plugins/os/guest-js/index.ts +++ b/plugins/os/guest-js/index.ts @@ -5,19 +5,6 @@ /** * Provides operating system-related utility methods and properties. * - * The APIs must be added to [`tauri.allowlist.os`](https://tauri.app/v1/api/config/#allowlistconfig.os) in `tauri.conf.json`: - * ```json - * { - * "tauri": { - * "allowlist": { - * "os": { - * "all": true, // enable all Os APIs - * } - * } - * } - * } - * ``` - * It is recommended to allowlist only the APIs you use for optimal bundle size and security. * @module */ diff --git a/plugins/persisted-scope/README.md b/plugins/persisted-scope/README.md index 01ac82b4..1a7e19bf 100644 --- a/plugins/persisted-scope/README.md +++ b/plugins/persisted-scope/README.md @@ -18,6 +18,8 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] +tauri-plugin-persisted-scope = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-persisted-scope = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` diff --git a/plugins/positioner/README.md b/plugins/positioner/README.md index 0da5aaa9..e80eb516 100644 --- a/plugins/positioner/README.md +++ b/plugins/positioner/README.md @@ -20,8 +20,8 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-positioner = "1.0" -# or through git +tauri-plugin-positioner = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-positioner = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -35,11 +35,8 @@ pnpm add @tauri-apps/plugin-positioner npm add @tauri-apps/plugin-positioner # or yarn add @tauri-apps/plugin-positioner -``` - -Or through git: -```sh +# alternatively with Git: pnpm add https://github.com/tauri-apps/tauri-plugin-positioner#v2 # or npm add https://github.com/tauri-apps/tauri-plugin-positioner#v2 diff --git a/plugins/process/README.md b/plugins/process/README.md index 01fc5d61..fad3e821 100644 --- a/plugins/process/README.md +++ b/plugins/process/README.md @@ -1,4 +1,4 @@ -# Process plugin +# Process This plugin provides APIs to access the current process. To spawn child processes, see the [`shell`](https://github.com/tauri-apps/tauri-plugin-shell) plugin. @@ -18,6 +18,8 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] +tauri-plugin-process = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-process = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -26,6 +28,13 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh +pnpm add @tauri-apps/plugin-process +# or +npm add @tauri-apps/plugin-process +# or +yarn add @tauri-apps/plugin-process + +# alternatively with Git: pnpm add https://github.com/tauri-apps/tauri-plugin-process#v2 # or npm add https://github.com/tauri-apps/tauri-plugin-process#v2 @@ -51,7 +60,11 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import * as process from "@tauri-apps/plugin-process"; +import { exit, relaunch } from "@tauri-apps/plugin-process"; +// exit the app with the given status code +await exit(0); +// restart the app +await relaunch(); ``` ## Contributing diff --git a/plugins/shell/README.md b/plugins/shell/README.md index 80400eaa..4d06a1e9 100644 --- a/plugins/shell/README.md +++ b/plugins/shell/README.md @@ -1,6 +1,6 @@ -![plugin-shell](banner.jpg) +# Shell - +Access the system shell. Allows you to spawn child processes and manage files and URLs using their default application. ## Install @@ -18,6 +18,8 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] +tauri-plugin-shell = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-shell = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -26,6 +28,13 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh +pnpm add @tauri-apps/plugin-shell +# or +npm add @tauri-apps/plugin-shell +# or +yarn add @tauri-apps/plugin-shell + +# alternatively with Git: pnpm add https://github.com/tauri-apps/tauri-plugin-shell#v2 # or npm add https://github.com/tauri-apps/tauri-plugin-shell#v2 @@ -51,7 +60,8 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript - +import { Command } from "@tauri-apps/plugin-shell"; +Command.create("git", ["commit", "-m", "the commit message"]); ``` ## Contributing diff --git a/plugins/shell/guest-js/index.ts b/plugins/shell/guest-js/index.ts index 979f51d1..9d5abb21 100644 --- a/plugins/shell/guest-js/index.ts +++ b/plugins/shell/guest-js/index.ts @@ -6,36 +6,19 @@ * Access the system shell. * Allows you to spawn child processes and manage files and URLs using their default application. * - * The APIs must be added to [`tauri.allowlist.shell`](https://tauri.app/v1/api/config/#allowlistconfig.shell) in `tauri.conf.json`: - * ```json - * { - * "tauri": { - * "allowlist": { - * "shell": { - * "all": true, // enable all shell APIs - * "execute": true, // enable process spawn APIs - * "sidecar": true, // enable spawning sidecars - * "open": true // enable opening files/URLs using the default program - * } - * } - * } - * } - * ``` - * It is recommended to allowlist only the APIs you use for optimal bundle size and security. - * * ## Security * * This API has a scope configuration that forces you to restrict the programs and arguments that can be used. * * ### Restricting access to the {@link open | `open`} API * - * On the allowlist, `open: true` means that the {@link open} API can be used with any URL, + * On the configuration object, `open: true` means that the {@link open} API can be used with any URL, * as the argument is validated with the `^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+` regex. * You can change that regex by changing the boolean value to a string, e.g. `open: ^https://github.com/`. * * ### Restricting access to the {@link Command | `Command`} APIs * - * The `shell` allowlist object has a `scope` field that defines an array of CLIs that can be used. + * The plugin configuration object has a `scope` field that defines an array of CLIs that can be used. * Each CLI is a configuration object `{ name: string, cmd: string, sidecar?: bool, args?: boolean | Arg[] }`. * * - `name`: the unique identifier of the command, passed to the {@link Command.create | Command.create function}. @@ -55,13 +38,17 @@ * Configuration: * ```json * { - * "scope": [ - * { - * "name": "run-git-commit", - * "cmd": "git", - * "args": ["commit", "-m", { "validator": "\\S+" }] + * "plugins": { + * "shell": { + * "scope": [ + * { + * "name": "run-git-commit", + * "cmd": "git", + * "args": ["commit", "-m", { "validator": "\\S+" }] + * } + * ] * } - * ] + * } * } * ``` * Usage: @@ -425,7 +412,7 @@ class Command extends EventEmitter { * Creates a new `Command` instance. * * @param program The program name to execute. - * It must be configured on `tauri.conf.json > tauri > allowlist > shell > scope`. + * It must be configured on `tauri.conf.json > plugins > shell > scope`. * @param args Program arguments. * @param options Spawn options. */ @@ -462,7 +449,7 @@ class Command extends EventEmitter { * ``` * * @param program The program to execute. - * It must be configured on `tauri.conf.json > tauri > allowlist > shell > scope`. + * It must be configured on `tauri.conf.json > plugins > shell > scope`. */ static create( program: string, @@ -494,7 +481,7 @@ class Command extends EventEmitter { * ``` * * @param program The program to execute. - * It must be configured on `tauri.conf.json > tauri > allowlist > shell > scope`. + * It must be configured on `tauri.conf.json > plugins > shell > scope`. */ static sidecar( program: string, @@ -634,7 +621,7 @@ type CommandEvent = * ``` * * @param path The path or URL to open. - * This value is matched against the string regex defined on `tauri.conf.json > tauri > allowlist > shell > open`, + * This value is matched against the string regex defined on `tauri.conf.json > plugins > shell > open`, * which defaults to `^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+`. * @param openWith The app to open the file or URL with. * Defaults to the system default application for the specified path type. diff --git a/plugins/shell/src/config.rs b/plugins/shell/src/config.rs index 1a35df4e..180de7f6 100644 --- a/plugins/shell/src/config.rs +++ b/plugins/shell/src/config.rs @@ -2,9 +2,7 @@ use std::path::PathBuf; use serde::{de::Error as DeError, Deserialize, Deserializer}; -/// Allowlist for the shell APIs. -/// -/// See more: https://tauri.app/v1/api/config#shellallowlistconfig +/// Configuration for the shell plugin. #[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct Config { diff --git a/plugins/shell/src/open.rs b/plugins/shell/src/open.rs index 5cc50927..a46d3f14 100644 --- a/plugins/shell/src/open.rs +++ b/plugins/shell/src/open.rs @@ -104,7 +104,7 @@ impl Program { /// Opens path or URL with the program specified in `with`, or system default if `None`. /// /// The path will be matched against the shell open validation regex, defaulting to `^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+`. -/// A custom validation regex may be supplied in the config in `tauri > allowlist > scope > open`. +/// A custom validation regex may be supplied in the config in `plugins > shell > scope > open`. /// /// # Examples /// diff --git a/plugins/shell/src/scope.rs b/plugins/shell/src/scope.rs index 871f3940..67ebde6a 100644 --- a/plugins/shell/src/scope.rs +++ b/plugins/shell/src/scope.rs @@ -248,7 +248,7 @@ impl Scope { /// Open a path in the default (or specified) browser. /// - /// The path is validated against the `tauri > allowlist > shell > open` validation regex, which + /// The path is validated against the `plugins > shell > open` validation regex, which /// defaults to `^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+`. pub fn open(&self, path: &str, with: Option) -> Result<(), Error> { // ensure we pass validation if the configuration has one diff --git a/plugins/single-instance/README.md b/plugins/single-instance/README.md index 6c72dc4e..2cb2d88e 100644 --- a/plugins/single-instance/README.md +++ b/plugins/single-instance/README.md @@ -18,6 +18,8 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] +tauri-plugin-single-instance = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` diff --git a/plugins/sql/README.md b/plugins/sql/README.md index f6658668..3901405e 100644 --- a/plugins/sql/README.md +++ b/plugins/sql/README.md @@ -18,9 +18,11 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies.tauri-plugin-sql] +features = ["sqlite"] # or "postgres", or "mysql" +version = "2.0.0-alpha" +# alternatively with Git git = "https://github.com/tauri-apps/plugins-workspace" branch = "v2" -features = ["sqlite"] # or "postgres", or "mysql" ``` You can install the JavaScript Guest bindings using your preferred JavaScript package manager: @@ -28,6 +30,13 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh +pnpm add @tauri-apps/plugin-sql +# or +npm add @tauri-apps/plugin-sql +# or +yarn add @tauri-apps/plugin-sql + +# alternatively with Git: pnpm add https://github.com/tauri-apps/tauri-plugin-sql#v2 # or npm add https://github.com/tauri-apps/tauri-plugin-sql#v2 diff --git a/plugins/store/README.md b/plugins/store/README.md index c8411112..90b0b7ef 100644 --- a/plugins/store/README.md +++ b/plugins/store/README.md @@ -18,6 +18,8 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] +tauri-plugin-store = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -26,6 +28,13 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh +pnpm add @tauri-apps/plugin-store +# or +npm add @tauri-apps/plugin-store +# or +yarn add @tauri-apps/plugin-store + +# alternatively with Git: pnpm add https://github.com/tauri-apps/tauri-plugin-store#v2 # or npm add https://github.com/tauri-apps/tauri-plugin-store#v2 diff --git a/plugins/stronghold/README.md b/plugins/stronghold/README.md index 52b22a87..7254b857 100644 --- a/plugins/stronghold/README.md +++ b/plugins/stronghold/README.md @@ -18,6 +18,8 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] +tauri-plugin-stronghold = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-stronghold = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -26,6 +28,13 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh +pnpm add @tauri-apps/plugin-stronghold +# or +npm add @tauri-apps/plugin-stronghold +# or +yarn add @tauri-apps/plugin-stronghold + +# alternatively with Git: pnpm add https://github.com/tauri-apps/tauri-plugin-stronghold#v2 # or npm add https://github.com/tauri-apps/tauri-plugin-stronghold#v2 diff --git a/plugins/updater/README.md b/plugins/updater/README.md index 842af4d9..eb6f3642 100644 --- a/plugins/updater/README.md +++ b/plugins/updater/README.md @@ -1,7 +1,9 @@ -# Updater plugin +# Updater In-app updates for Tauri applications. +- Supported platforms: Windows, Linux and macOS. + ## Install _This plugin requires a Rust version of at least **1.65**_ @@ -17,7 +19,10 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: `src-tauri/Cargo.toml` ```toml -[dependencies] +# you can add the dependencies on the `[dependencies]` section if you do not target mobile +[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies] +tauri-plugin-updater = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-updater = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -26,6 +31,13 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh +pnpm add @tauri-apps/plugin-updater +# or +npm add @tauri-apps/plugin-updater +# or +yarn add @tauri-apps/plugin-updater + +# alternatively with Git: pnpm add https://github.com/tauri-apps/tauri-plugin-updater#v2 # or npm add https://github.com/tauri-apps/tauri-plugin-updater#v2 @@ -42,7 +54,11 @@ First you need to register the core plugin with Tauri: ```rust fn main() { tauri::Builder::default() - .plugin(tauri_plugin_updater::Builder::new().build()) + .setup(|app| { + #[cfg(desktop)] + app.handle().plugin(tauri_plugin_updater::Builder::new().build())?; + Ok(()) + }) .run(tauri::generate_context!()) .expect("error while running tauri application"); } @@ -51,7 +67,13 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import * as updater from "@tauri-apps/plugin-updater"; +import { check } from "@tauri-apps/plugin-updater"; +import { relaunch } from "@tauri-apps/plugin-process"; +const update = await check(); +if (update.response.available) { + await update.downloadAndInstall(); + await relaunch(); +} ``` ## Contributing diff --git a/plugins/upload/README.md b/plugins/upload/README.md index d451a8d6..9796aa8a 100644 --- a/plugins/upload/README.md +++ b/plugins/upload/README.md @@ -18,6 +18,8 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] +tauri-plugin-upload = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-upload = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -26,6 +28,13 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh +pnpm add @tauri-apps/plugin-upload +# or +npm add @tauri-apps/plugin-upload +# or +yarn add @tauri-apps/plugin-upload + +# alternatively with Git: pnpm add https://github.com/tauri-apps/tauri-plugin-upload#v2 # or npm add https://github.com/tauri-apps/tauri-plugin-upload#v2 diff --git a/plugins/websocket/README.md b/plugins/websocket/README.md index 0971d6ff..56943465 100644 --- a/plugins/websocket/README.md +++ b/plugins/websocket/README.md @@ -1,6 +1,6 @@ ![plugin-websocket](banner.png) - +Expose a WebSocket server to your Tauri frontend. ## Install @@ -18,6 +18,8 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] +tauri-plugin-websocket = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-websocket = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -26,6 +28,13 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh +pnpm add @tauri-apps/plugin-websocket +# or +npm add @tauri-apps/plugin-websocket +# or +yarn add @tauri-apps/plugin-websocket + +# alternatively with Git: pnpm add https://github.com/tauri-apps/tauri-plugin-websocket#v2 # or npm add https://github.com/tauri-apps/tauri-plugin-websocket#v2 diff --git a/plugins/window-state/README.md b/plugins/window-state/README.md index 97848cd2..ea03f8e2 100644 --- a/plugins/window-state/README.md +++ b/plugins/window-state/README.md @@ -18,6 +18,8 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] +tauri-plugin-window-state = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -26,6 +28,13 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh +pnpm add @tauri-apps/plugin-window-state +# or +npm add @tauri-apps/plugin-window-state +# or +yarn add @tauri-apps/plugin-window-state + +# alternatively with Git: pnpm add https://github.com/tauri-apps/tauri-plugin-window-state#v2 # or npm add https://github.com/tauri-apps/tauri-plugin-window-state#v2 diff --git a/plugins/window/README.md b/plugins/window/README.md index 1a47b706..14e7c8a8 100644 --- a/plugins/window/README.md +++ b/plugins/window/README.md @@ -1,4 +1,4 @@ -# Window plugin +# Window Interact with the Tauri window. @@ -18,6 +18,8 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] +tauri-plugin-window = "2.0.0-alpha" +# alternatively with Git: tauri-plugin-window = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` @@ -26,6 +28,13 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh +pnpm add @tauri-apps/plugin-window +# or +npm add @tauri-apps/plugin-window +# or +yarn add @tauri-apps/plugin-window + +# alternatively with Git: pnpm add https://github.com/tauri-apps/tauri-plugin-window#v2 # or npm add https://github.com/tauri-apps/tauri-plugin-window#v2 @@ -51,7 +60,20 @@ fn main() { Afterwards all the plugin's APIs are available through the JavaScript guest bindings: ```javascript -import * as tauriWindow from "@tauri-apps/plugin-window"; +import { appWindow, WebviewWindow } from "@tauri-apps/plugin-window"; + +// manipulating this window +await appWindow.setResizable(false); + +// Creating new windows: +// loading embedded asset: +const webview = new WebviewWindow("theUniqueLabel", { + url: "path/to/page.html", +}); +// alternatively, load a remote URL: +const webview = new WebviewWindow("theUniqueLabel", { + url: "https://github.com/tauri-apps/tauri", +}); ``` ## Contributing diff --git a/plugins/window/guest-js/index.ts b/plugins/window/guest-js/index.ts index b330314b..038fdc05 100644 --- a/plugins/window/guest-js/index.ts +++ b/plugins/window/guest-js/index.ts @@ -5,51 +5,6 @@ /** * Provides APIs to create windows, communicate with other windows and manipulate the current window. * - * The APIs must be added to [`tauri.allowlist.window`](https://tauri.app/v1/api/config/#allowlistconfig.window) in `tauri.conf.json`: - * ```json - * { - * "tauri": { - * "allowlist": { - * "window": { - * "all": true, // enable all window APIs - * "create": true, // enable window creation - * "center": true, - * "requestUserAttention": true, - * "setResizable": true, - * "setTitle": true, - * "maximize": true, - * "unmaximize": true, - * "minimize": true, - * "unminimize": true, - * "show": true, - * "hide": true, - * "close": true, - * "setDecorations": true, - * "setShadow": true, - * "setAlwaysOnTop": true, - * "setContentProtected": true, - * "setSize": true, - * "setMinSize": true, - * "setMaxSize": true, - * "setPosition": true, - * "setFullscreen": true, - * "setFocus": true, - * "setIcon": true, - * "setSkipTaskbar": true, - * "setCursorGrab": true, - * "setCursorVisible": true, - * "setCursorIcon": true, - * "setCursorPosition": true, - * "setIgnoreCursorEvents": true, - * "startDragging": true, - * "print": true - * } - * } - * } - * } - * ``` - * It is recommended to allowlist only the APIs you use for optimal bundle size and security. - * * ## Window events * * Events can be listened to using `appWindow.listen`: diff --git a/shared/template/README.md b/shared/template/README.md index f1641d84..1a839763 100644 --- a/shared/template/README.md +++ b/shared/template/README.md @@ -1,4 +1,4 @@ -![{{plugin name}}](banner.jpg) +![{{plugin-name}}](banner.png) @@ -18,7 +18,9 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] - = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } +tauri-plugin-{{plugin-name}} = "2.0.0-alpha" +# alternatively with Git: +tauri-plugin-{{plugin-name}} = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } ``` You can install the JavaScript Guest bindings using your preferred JavaScript package manager: @@ -26,11 +28,18 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa > Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. ```sh -pnpm add +pnpm add @tauri-apps/plugin-{{plugin-name}} # or -npm add +npm add @tauri-apps/plugin-{{plugin-name}} # or -yarn add +yarn add @tauri-apps/plugin-{{plugin-name}} + +# alternatively with Git: +pnpm add https://github.com/tauri-apps/tauri-plugin-{{plugin-name}}#v2 +# or +npm add https://github.com/tauri-apps/tauri-plugin-{{plugin-name}}#v2 +# or +yarn add https://github.com/tauri-apps/tauri-plugin-{{plugin-name}}#v2 ``` ## Usage @@ -42,7 +51,7 @@ First you need to register the core plugin with Tauri: ```rust fn main() { tauri::Builder::default() - .plugin() + .plugin(tauri_plugin_{{plugin-name}}::init()) .run(tauri::generate_context!()) .expect("error while running tauri application"); }