This binary can be run from the terminal and takes the following arguments:
@@ -17,7 +17,7 @@
--verbose
Additionally, it has a update --background subcommand.
-
+
Note that the arguments are only parsed, not implemented.
diff --git a/examples/api/src/views/Haptics.svelte b/examples/api/src/views/Haptics.svelte
new file mode 100644
index 00000000..9ddf15c1
--- /dev/null
+++ b/examples/api/src/views/Haptics.svelte
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Depending on your device settings for haptic feedback some of the buttons may
+ not work.
+
diff --git a/package.json b/package.json
index 3daae86c..c01095b6 100644
--- a/package.json
+++ b/package.json
@@ -7,23 +7,24 @@
"build": "pnpm run -r --parallel --filter !plugins-workspace --filter !\"./plugins/*/examples/**\" --filter !\"./examples/*\" build",
"lint": "eslint .",
"format": "prettier --write .",
- "format:check": "prettier --check ."
+ "format:check": "prettier --check .",
+ "example:api:dev": "pnpm run --filter \"api\" tauri dev"
},
"devDependencies": {
- "@eslint/js": "9.13.0",
+ "@eslint/js": "9.16.0",
"@rollup/plugin-node-resolve": "15.3.0",
"@rollup/plugin-terser": "0.4.4",
"@rollup/plugin-typescript": "11.1.6",
"@types/eslint__js": "8.42.3",
"covector": "^0.12.3",
- "eslint": "9.13.0",
+ "eslint": "9.16.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-security": "3.0.1",
- "prettier": "3.3.3",
- "rollup": "4.22.4",
- "tslib": "2.7.0",
- "typescript": "5.6.3",
- "typescript-eslint": "8.10.0"
+ "prettier": "3.4.2",
+ "rollup": "4.28.1",
+ "tslib": "2.8.1",
+ "typescript": "5.7.2",
+ "typescript-eslint": "8.17.0"
},
"resolutions": {
"semver": ">=7.5.2",
diff --git a/plugins/autostart/Cargo.toml b/plugins/autostart/Cargo.toml
index 77f555e6..69848bf6 100644
--- a/plugins/autostart/Cargo.toml
+++ b/plugins/autostart/Cargo.toml
@@ -27,6 +27,5 @@ tauri-plugin = { workspace = true, features = ["build"] }
serde = { workspace = true }
serde_json = { workspace = true }
tauri = { workspace = true }
-log = { workspace = true }
thiserror = { workspace = true }
auto-launch = "0.5"
diff --git a/plugins/autostart/README.md b/plugins/autostart/README.md
index 0a1415db..76d68f73 100644
--- a/plugins/autostart/README.md
+++ b/plugins/autostart/README.md
@@ -54,7 +54,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-autostart#v2
First you need to register the core plugin with Tauri:
-`src-tauri/src/main.rs`
+`src-tauri/src/lib.rs`
```rust
use tauri_plugin_autostart::MacosLauncher;
diff --git a/plugins/autostart/src/lib.rs b/plugins/autostart/src/lib.rs
index bd3866b3..5550bfa1 100644
--- a/plugins/autostart/src/lib.rs
+++ b/plugins/autostart/src/lib.rs
@@ -2,8 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
-//! [](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/autostart)
-//!
//! Automatically launch your application at startup. Supports Windows, Mac (via AppleScript or Launch Agent), and Linux.
#![doc(
@@ -13,8 +11,6 @@
#![cfg(not(any(target_os = "android", target_os = "ios")))]
use auto_launch::{AutoLaunch, AutoLaunchBuilder};
-#[cfg(target_os = "macos")]
-use log::info;
use serde::{ser::Serializer, Serialize};
use tauri::{
command,
@@ -135,7 +131,6 @@ pub fn init(
} else {
exe_path
};
- info!("auto_start path {}", &app_path);
builder.set_app_path(&app_path);
}
#[cfg(target_os = "linux")]
diff --git a/plugins/barcode-scanner/README.md b/plugins/barcode-scanner/README.md
index eba7ca9e..4abbef0a 100644
--- a/plugins/barcode-scanner/README.md
+++ b/plugins/barcode-scanner/README.md
@@ -54,7 +54,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-barcode-scanner#v2
First you need to register the core plugin with Tauri:
-`src-tauri/src/main.rs`
+`src-tauri/src/lib.rs`
```rust
fn main() {
diff --git a/plugins/biometric/README.md b/plugins/biometric/README.md
index 2028595d..c7844f7b 100644
--- a/plugins/biometric/README.md
+++ b/plugins/biometric/README.md
@@ -56,7 +56,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-biometric#v2
First you need to register the core plugin with Tauri:
-`src-tauri/src/main.rs`
+`src-tauri/src/lib.rs`
```rust
fn main() {
diff --git a/plugins/cli/README.md b/plugins/cli/README.md
index 05d5bd35..91a8080b 100644
--- a/plugins/cli/README.md
+++ b/plugins/cli/README.md
@@ -55,7 +55,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-cli#v2
First you need to register the core plugin with Tauri:
-`src-tauri/src/main.rs`
+`src-tauri/src/lib.rs`
```rust
fn main() {
diff --git a/plugins/cli/src/lib.rs b/plugins/cli/src/lib.rs
index 38f64f83..3e144376 100644
--- a/plugins/cli/src/lib.rs
+++ b/plugins/cli/src/lib.rs
@@ -2,8 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
-//! [](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/cli)
-//!
//! Parse arguments from your Command Line Interface.
//!
//! - Supported platforms: Windows, Linux and macOS.
diff --git a/plugins/clipboard-manager/CHANGELOG.md b/plugins/clipboard-manager/CHANGELOG.md
index 68dee776..1ab76211 100644
--- a/plugins/clipboard-manager/CHANGELOG.md
+++ b/plugins/clipboard-manager/CHANGELOG.md
@@ -2,6 +2,14 @@
## \[2.0.1]
+- [`3fa0fc09`](https://github.com/tauri-apps/plugins-workspace/commit/3fa0fc09bbee0d619801e5757af9fb3c09883c97) ([#2099](https://github.com/tauri-apps/plugins-workspace/pull/2099) by [@rasteiner](https://github.com/tauri-apps/plugins-workspace/../../rasteiner)) Fix clipboard manager client side api not copying fallback alternative text when calling `writeHtml`.
+
+## \[2.0.2]
+
+- [`d57df4de`](https://github.com/tauri-apps/plugins-workspace/commit/d57df4debe7c75cfbd6d6558fff1beb07dbee54c) ([#1986](https://github.com/tauri-apps/plugins-workspace/pull/1986) by [@RikaKagurasaka](https://github.com/tauri-apps/plugins-workspace/../../RikaKagurasaka)) Fix that `read_image` wrongly set the image rgba data with binary PNG data.
+
+## \[2.0.1]
+
- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7.
## \[2.0.0]
diff --git a/plugins/clipboard-manager/Cargo.toml b/plugins/clipboard-manager/Cargo.toml
index 3c086574..cd30b4d0 100644
--- a/plugins/clipboard-manager/Cargo.toml
+++ b/plugins/clipboard-manager/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "tauri-plugin-clipboard-manager"
-version = "2.0.1"
+version = "2.0.2"
description = "Read and write to the system clipboard."
edition = { workspace = true }
authors = { workspace = true }
@@ -37,4 +37,3 @@ tauri = { workspace = true, features = ["wry"] }
[target."cfg(any(target_os = \"macos\", windows, target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
arboard = "3"
-image = "0.25"
diff --git a/plugins/clipboard-manager/README.md b/plugins/clipboard-manager/README.md
index daec970d..935d8ff9 100644
--- a/plugins/clipboard-manager/README.md
+++ b/plugins/clipboard-manager/README.md
@@ -54,7 +54,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-clipboard-manager#v2
First you need to register the core plugin with Tauri:
-`src-tauri/src/main.rs`
+`src-tauri/src/lib.rs`
```rust
fn main() {
diff --git a/plugins/clipboard-manager/api-iife.js b/plugins/clipboard-manager/api-iife.js
index 7750e01d..0b790d2b 100644
--- a/plugins/clipboard-manager/api-iife.js
+++ b/plugins/clipboard-manager/api-iife.js
@@ -1 +1 @@
-if("__TAURI__"in window){var __TAURI_PLUGIN_CLIPBOARD_MANAGER__=function(e){"use strict";var t;async function r(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}"function"==typeof SuppressedError&&SuppressedError;class n{get rid(){return function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}(this,t,"f")}constructor(e){t.set(this,void 0),function(e,t,r,n,a){if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");t.set(e,r)}(this,t,e)}async close(){return r("plugin:resources|close",{rid:this.rid})}}t=new WeakMap;class a extends n{constructor(e){super(e)}static async new(e,t,n){return r("plugin:image|new",{rgba:i(e),width:t,height:n}).then((e=>new a(e)))}static async fromBytes(e){return r("plugin:image|from_bytes",{bytes:i(e)}).then((e=>new a(e)))}static async fromPath(e){return r("plugin:image|from_path",{path:e}).then((e=>new a(e)))}async rgba(){return r("plugin:image|rgba",{rid:this.rid}).then((e=>new Uint8Array(e)))}async size(){return r("plugin:image|size",{rid:this.rid})}}function i(e){return null==e?null:"string"==typeof e?e:e instanceof a?e.rid:e}return e.clear=async function(){await r("plugin:clipboard-manager|clear")},e.readImage=async function(){return await r("plugin:clipboard-manager|read_image").then((e=>new a(e)))},e.readText=async function(){return await r("plugin:clipboard-manager|read_text")},e.writeHtml=async function(e,t){await r("plugin:clipboard-manager|write_html",{html:e,altHtml:t})},e.writeImage=async function(e){await r("plugin:clipboard-manager|write_image",{image:i(e)})},e.writeText=async function(e,t){await r("plugin:clipboard-manager|write_text",{label:t?.label,text:e})},e}({});Object.defineProperty(window.__TAURI__,"clipboardManager",{value:__TAURI_PLUGIN_CLIPBOARD_MANAGER__})}
+if("__TAURI__"in window){var __TAURI_PLUGIN_CLIPBOARD_MANAGER__=function(e){"use strict";var t;async function r(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}"function"==typeof SuppressedError&&SuppressedError;class n{get rid(){return function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}(this,t,"f")}constructor(e){t.set(this,void 0),function(e,t,r,n,a){if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");t.set(e,r)}(this,t,e)}async close(){return r("plugin:resources|close",{rid:this.rid})}}t=new WeakMap;class a extends n{constructor(e){super(e)}static async new(e,t,n){return r("plugin:image|new",{rgba:i(e),width:t,height:n}).then((e=>new a(e)))}static async fromBytes(e){return r("plugin:image|from_bytes",{bytes:i(e)}).then((e=>new a(e)))}static async fromPath(e){return r("plugin:image|from_path",{path:e}).then((e=>new a(e)))}async rgba(){return r("plugin:image|rgba",{rid:this.rid}).then((e=>new Uint8Array(e)))}async size(){return r("plugin:image|size",{rid:this.rid})}}function i(e){return null==e?null:"string"==typeof e?e:e instanceof a?e.rid:e}return e.clear=async function(){await r("plugin:clipboard-manager|clear")},e.readImage=async function(){return await r("plugin:clipboard-manager|read_image").then((e=>new a(e)))},e.readText=async function(){return await r("plugin:clipboard-manager|read_text")},e.writeHtml=async function(e,t){await r("plugin:clipboard-manager|write_html",{html:e,altText:t})},e.writeImage=async function(e){await r("plugin:clipboard-manager|write_image",{image:i(e)})},e.writeText=async function(e,t){await r("plugin:clipboard-manager|write_text",{label:t?.label,text:e})},e}({});Object.defineProperty(window.__TAURI__,"clipboardManager",{value:__TAURI_PLUGIN_CLIPBOARD_MANAGER__})}
diff --git a/plugins/clipboard-manager/guest-js/index.ts b/plugins/clipboard-manager/guest-js/index.ts
index f7f31842..fb730426 100644
--- a/plugins/clipboard-manager/guest-js/index.ts
+++ b/plugins/clipboard-manager/guest-js/index.ts
@@ -65,6 +65,7 @@ async function readText(): Promise {
* 0, 255, 0, 255,
* ];
* await writeImage(buffer);
+ * ```
*
* @returns A promise indicating the success or failure of the operation.
*
@@ -90,7 +91,7 @@ async function writeImage(
* import { readImage } from '@tauri-apps/plugin-clipboard-manager';
*
* const clipboardImage = await readImage();
- * const blob = new Blob([clipboardImage.bytes], { type: 'image' })
+ * const blob = new Blob([await clipboardImage.rbga()], { type: 'image' })
* const url = URL.createObjectURL(blob)
* ```
* @since 2.0.0
@@ -120,10 +121,10 @@ async function readImage(): Promise {
*
* @since 2.0.0
*/
-async function writeHtml(html: string, altHtml?: string): Promise {
+async function writeHtml(html: string, altText?: string): Promise {
await invoke('plugin:clipboard-manager|write_html', {
html,
- altHtml
+ altText
})
}
diff --git a/plugins/clipboard-manager/package.json b/plugins/clipboard-manager/package.json
index f4897994..483d66b6 100644
--- a/plugins/clipboard-manager/package.json
+++ b/plugins/clipboard-manager/package.json
@@ -1,6 +1,6 @@
{
"name": "@tauri-apps/plugin-clipboard-manager",
- "version": "2.0.0",
+ "version": "2.0.1",
"license": "MIT OR Apache-2.0",
"authors": [
"Tauri Programme within The Commons Conservancy"
diff --git a/plugins/clipboard-manager/src/desktop.rs b/plugins/clipboard-manager/src/desktop.rs
index bb8ba318..5edd4934 100644
--- a/plugins/clipboard-manager/src/desktop.rs
+++ b/plugins/clipboard-manager/src/desktop.rs
@@ -3,7 +3,6 @@
// SPDX-License-Identifier: MIT
use arboard::ImageData;
-use image::ImageEncoder;
use serde::de::DeserializeOwned;
use tauri::{image::Image, plugin::PluginApi, AppHandle, Runtime};
@@ -85,16 +84,11 @@ impl Clipboard {
match &self.clipboard {
Ok(clipboard) => {
let image = clipboard.lock().unwrap().get_image()?;
-
- let mut buffer: Vec = Vec::new();
- image::codecs::png::PngEncoder::new(&mut buffer).write_image(
- &image.bytes,
+ let image = Image::new_owned(
+ image.bytes.to_vec(),
image.width as u32,
image.height as u32,
- image::ExtendedColorType::Rgba8,
- )?;
-
- let image = Image::new_owned(buffer, image.width as u32, image.height as u32);
+ );
Ok(image)
}
Err(e) => Err(crate::Error::Clipboard(e.to_string())),
diff --git a/plugins/clipboard-manager/src/error.rs b/plugins/clipboard-manager/src/error.rs
index 7e36a11b..1b8cf482 100644
--- a/plugins/clipboard-manager/src/error.rs
+++ b/plugins/clipboard-manager/src/error.rs
@@ -15,9 +15,6 @@ pub enum Error {
Clipboard(String),
#[error(transparent)]
Tauri(#[from] tauri::Error),
- #[cfg(desktop)]
- #[error("invalid image: {0}")]
- Image(#[from] image::ImageError),
}
impl Serialize for Error {
diff --git a/plugins/clipboard-manager/src/lib.rs b/plugins/clipboard-manager/src/lib.rs
index 3924d7f1..133020d9 100644
--- a/plugins/clipboard-manager/src/lib.rs
+++ b/plugins/clipboard-manager/src/lib.rs
@@ -2,8 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
-//! [](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/clipboard-manager)
-//!
//! Read and write to the system clipboard.
#![doc(
diff --git a/plugins/deep-link/CHANGELOG.md b/plugins/deep-link/CHANGELOG.md
index 2f2da36d..4d049556 100644
--- a/plugins/deep-link/CHANGELOG.md
+++ b/plugins/deep-link/CHANGELOG.md
@@ -2,6 +2,10 @@
## \[2.0.1]
+- [`b2aea045`](https://github.com/tauri-apps/plugins-workspace/commit/b2aea0456799775a7243706fdd7a5abf9a193992) ([#2008](https://github.com/tauri-apps/plugins-workspace/pull/2008) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) `onOpenUrl()` will now not call `getCurrent()` anymore, matching the documented behavior.
+
+## \[2.0.1]
+
- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7.
## \[2.0.0]
diff --git a/plugins/deep-link/Cargo.toml b/plugins/deep-link/Cargo.toml
index db5c0247..dabd1c3b 100644
--- a/plugins/deep-link/Cargo.toml
+++ b/plugins/deep-link/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "tauri-plugin-deep-link"
-version = "2.0.1"
+version = "2.0.2"
description = "Set your Tauri application as the default handler for an URL"
authors = { workspace = true }
license = { workspace = true }
@@ -32,7 +32,7 @@ serde = { workspace = true }
serde_json = { workspace = true }
tauri = { workspace = true }
tauri-utils = { workspace = true }
-log = { workspace = true }
+tracing = { workspace = true }
thiserror = { workspace = true }
url = { workspace = true }
diff --git a/plugins/deep-link/README.md b/plugins/deep-link/README.md
index 77fae2c8..61a36a80 100644
--- a/plugins/deep-link/README.md
+++ b/plugins/deep-link/README.md
@@ -133,7 +133,7 @@ Under `tauri.conf.json > plugins > deep-link`, configure the domains (mobile) an
First you need to register the core plugin with Tauri:
-`src-tauri/src/main.rs`
+`src-tauri/src/lib.rs`
```rust
fn main() {
diff --git a/plugins/deep-link/api-iife.js b/plugins/deep-link/api-iife.js
index eba7152f..6d9e3e18 100644
--- a/plugins/deep-link/api-iife.js
+++ b/plugins/deep-link/api-iife.js
@@ -1 +1 @@
-if("__TAURI__"in window){var __TAURI_PLUGIN_DEEP_LINK__=function(e){"use strict";function n(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}async function r(e,n={},r){return window.__TAURI_INTERNALS__.invoke(e,n,r)}var t;async function i(e,t,i){const a={kind:"Any"};return r("plugin:event|listen",{event:e,target:a,handler:n(t)}).then((n=>async()=>async function(e,n){await r("plugin:event|unlisten",{event:e,eventId:n})}(e,n)))}async function a(){return await r("plugin:deep-link|get_current")}return"function"==typeof SuppressedError&&SuppressedError,function(e){e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_CREATED="tauri://window-created",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG_ENTER="tauri://drag-enter",e.DRAG_OVER="tauri://drag-over",e.DRAG_DROP="tauri://drag-drop",e.DRAG_LEAVE="tauri://drag-leave"}(t||(t={})),e.getCurrent=a,e.isRegistered=async function(e){return await r("plugin:deep-link|is_registered",{protocol:e})},e.onOpenUrl=async function(e){const n=await a();return n&&e(n),await i("deep-link://new-url",(n=>{e(n.payload)}))},e.register=async function(e){return await r("plugin:deep-link|register",{protocol:e})},e.unregister=async function(e){return await r("plugin:deep-link|unregister",{protocol:e})},e}({});Object.defineProperty(window.__TAURI__,"deepLink",{value:__TAURI_PLUGIN_DEEP_LINK__})}
+if("__TAURI__"in window){var __TAURI_PLUGIN_DEEP_LINK__=function(e){"use strict";function n(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}async function r(e,n={},r){return window.__TAURI_INTERNALS__.invoke(e,n,r)}var t;async function i(e,t,i){const a={kind:"Any"};return r("plugin:event|listen",{event:e,target:a,handler:n(t)}).then((n=>async()=>async function(e,n){await r("plugin:event|unlisten",{event:e,eventId:n})}(e,n)))}return"function"==typeof SuppressedError&&SuppressedError,function(e){e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_CREATED="tauri://window-created",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG_ENTER="tauri://drag-enter",e.DRAG_OVER="tauri://drag-over",e.DRAG_DROP="tauri://drag-drop",e.DRAG_LEAVE="tauri://drag-leave"}(t||(t={})),e.getCurrent=async function(){return await r("plugin:deep-link|get_current")},e.isRegistered=async function(e){return await r("plugin:deep-link|is_registered",{protocol:e})},e.onOpenUrl=async function(e){return await i("deep-link://new-url",(n=>{e(n.payload)}))},e.register=async function(e){return await r("plugin:deep-link|register",{protocol:e})},e.unregister=async function(e){return await r("plugin:deep-link|unregister",{protocol:e})},e}({});Object.defineProperty(window.__TAURI__,"deepLink",{value:__TAURI_PLUGIN_DEEP_LINK__})}
diff --git a/plugins/deep-link/examples/app/CHANGELOG.md b/plugins/deep-link/examples/app/CHANGELOG.md
index ba903aea..be90bd2e 100644
--- a/plugins/deep-link/examples/app/CHANGELOG.md
+++ b/plugins/deep-link/examples/app/CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog
+## \[2.0.1]
+
+### Dependencies
+
+- Upgraded to `deep-link-js@2.0.1`
+
## \[2.0.0]
- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release.
diff --git a/plugins/deep-link/examples/app/package.json b/plugins/deep-link/examples/app/package.json
index 5b9e8efc..954b14b0 100644
--- a/plugins/deep-link/examples/app/package.json
+++ b/plugins/deep-link/examples/app/package.json
@@ -1,7 +1,7 @@
{
"name": "deep-link-example",
"private": true,
- "version": "2.0.0",
+ "version": "2.0.1",
"type": "module",
"scripts": {
"dev": "vite",
@@ -10,12 +10,12 @@
"tauri": "tauri"
},
"dependencies": {
- "@tauri-apps/api": "2.0.2",
- "@tauri-apps/plugin-deep-link": "2.0.0"
+ "@tauri-apps/api": "2.1.1",
+ "@tauri-apps/plugin-deep-link": "2.0.1"
},
"devDependencies": {
- "@tauri-apps/cli": "2.0.3",
+ "@tauri-apps/cli": "2.1.0",
"typescript": "^5.2.2",
- "vite": "^5.4.7"
+ "vite": "^6.0.0"
}
}
diff --git a/plugins/deep-link/guest-js/index.ts b/plugins/deep-link/guest-js/index.ts
index 49afbab7..461bec8a 100644
--- a/plugins/deep-link/guest-js/index.ts
+++ b/plugins/deep-link/guest-js/index.ts
@@ -73,7 +73,7 @@ export async function unregister(protocol: string): Promise {
* await isRegistered("my-scheme");
* ```
*
- * #### - **macOS / Android / iOS**: Unsupported, always returns `true`.
+ * #### - **macOS / Android / iOS**: Unsupported.
*
* @since 2.0.0
*/
@@ -92,18 +92,13 @@ export async function isRegistered(protocol: string): Promise {
* await onOpenUrl((urls) => { console.log(urls) });
* ```
*
- * #### - **Windows / Linux**: Unsupported, the OS will spawn a new app instance passing the URL as a CLI argument.
+ * #### - **Windows / Linux**: Unsupported without the single-instance plugin. The OS will spawn a new app instance passing the URL as a CLI argument.
*
* @since 2.0.0
*/
export async function onOpenUrl(
handler: (urls: string[]) => void
): Promise {
- const current = await getCurrent()
- if (current) {
- handler(current)
- }
-
return await listen('deep-link://new-url', (event) => {
handler(event.payload)
})
diff --git a/plugins/deep-link/package.json b/plugins/deep-link/package.json
index c2ca9aa2..d92df8fe 100644
--- a/plugins/deep-link/package.json
+++ b/plugins/deep-link/package.json
@@ -1,6 +1,6 @@
{
"name": "@tauri-apps/plugin-deep-link",
- "version": "2.0.0",
+ "version": "2.0.1",
"description": "Set your Tauri application as the default handler for an URL",
"license": "MIT OR Apache-2.0",
"authors": [
diff --git a/plugins/deep-link/src/lib.rs b/plugins/deep-link/src/lib.rs
index 25cdd317..c259e6b2 100644
--- a/plugins/deep-link/src/lib.rs
+++ b/plugins/deep-link/src/lib.rs
@@ -2,8 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
-use std::sync::Arc;
-
use tauri::{
plugin::{Builder, PluginApi, TauriPlugin},
AppHandle, EventId, Listener, Manager, Runtime,
@@ -217,7 +215,7 @@ mod imp {
current.replace(vec![url.clone()]);
let _ = self.app.emit("deep-link://new-url", vec![url]);
} else if cfg!(debug_assertions) {
- log::warn!("argument {url} does not match any configured deep link scheme; skipping it");
+ tracing::warn!("argument {url} does not match any configured deep link scheme; skipping it");
}
}
}
@@ -478,13 +476,10 @@ impl OpenUrlEvent {
}
impl DeepLink {
- /// Handle a new deep link being triggered to open the app.
+ /// Helper function for the `deep-link://new-url` event to run a function each time the protocol is triggered while the app is running.
///
- /// To avoid race conditions, if the app was started with a deep link,
- /// the closure gets immediately called with the deep link URL.
+ /// Use `get_current` on app load to check whether your app was started via a deep link.
pub fn on_open_url(&self, f: F) -> EventId {
- let f = Arc::new(f);
- let f_ = f.clone();
let event_id = self.app.listen("deep-link://new-url", move |event| {
if let Ok(urls) = serde_json::from_str(event.payload()) {
f(OpenUrlEvent {
@@ -494,13 +489,6 @@ impl DeepLink {
}
});
- if let Ok(Some(current)) = self.get_current() {
- f_(OpenUrlEvent {
- id: event_id,
- urls: current,
- })
- }
-
event_id
}
}
diff --git a/plugins/dialog/CHANGELOG.md b/plugins/dialog/CHANGELOG.md
index 57c51092..9e893e0e 100644
--- a/plugins/dialog/CHANGELOG.md
+++ b/plugins/dialog/CHANGELOG.md
@@ -1,5 +1,13 @@
# Changelog
+## \[2.0.4]
+
+- [`76f99ce9`](https://github.com/tauri-apps/plugins-workspace/commit/76f99ce999a2ff9e40235c1675e3eb6570b5e1e2) ([#2108](https://github.com/tauri-apps/plugins-workspace/pull/2108) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The `Dialog` struct is now correctly exported, primarily to fix the documentation on `docs.rs`.
+
+### Dependencies
+
+- Upgraded to `fs@2.1.0`
+
## \[2.0.3]
### Dependencies
diff --git a/plugins/dialog/Cargo.toml b/plugins/dialog/Cargo.toml
index 664416a7..d63169b7 100644
--- a/plugins/dialog/Cargo.toml
+++ b/plugins/dialog/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "tauri-plugin-dialog"
-version = "2.0.3"
+version = "2.0.4"
description = "Native system dialogs for opening and saving files along with message dialogs on your Tauri application."
edition = { workspace = true }
authors = { workspace = true }
@@ -34,7 +34,7 @@ tauri = { workspace = true }
log = { workspace = true }
thiserror = { workspace = true }
url = { workspace = true }
-tauri-plugin-fs = { path = "../fs", version = "2.0.3" }
+tauri-plugin-fs = { path = "../fs", version = "2.1.0" }
[target.'cfg(target_os = "ios")'.dependencies]
tauri = { workspace = true, features = ["wry"] }
diff --git a/plugins/dialog/README.md b/plugins/dialog/README.md
index 2259e35b..63d71767 100644
--- a/plugins/dialog/README.md
+++ b/plugins/dialog/README.md
@@ -54,7 +54,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-dialog#v2
First you need to register the core plugin with Tauri:
-`src-tauri/src/main.rs`
+`src-tauri/src/lib.rs`
```rust
fn main() {
diff --git a/plugins/dialog/src/commands.rs b/plugins/dialog/src/commands.rs
index 4129b7b6..c3caf027 100644
--- a/plugins/dialog/src/commands.rs
+++ b/plugins/dialog/src/commands.rs
@@ -143,7 +143,7 @@ pub(crate) async fn open(
for folder in folders {
if let Ok(path) = folder.clone().into_path() {
if let Some(s) = window.try_fs_scope() {
- s.allow_directory(&path, options.recursive);
+ s.allow_directory(&path, options.recursive)?;
}
tauri_scope.allow_directory(&path, options.directory)?;
}
@@ -157,7 +157,7 @@ pub(crate) async fn open(
if let Some(folder) = &folder {
if let Ok(path) = folder.clone().into_path() {
if let Some(s) = window.try_fs_scope() {
- s.allow_directory(&path, options.recursive);
+ s.allow_directory(&path, options.recursive)?;
}
tauri_scope.allow_directory(&path, options.directory)?;
}
@@ -175,7 +175,7 @@ pub(crate) async fn open(
for file in files {
if let Ok(path) = file.clone().into_path() {
if let Some(s) = window.try_fs_scope() {
- s.allow_file(&path);
+ s.allow_file(&path)?;
}
tauri_scope.allow_file(&path)?;
@@ -190,7 +190,7 @@ pub(crate) async fn open(
if let Some(file) = &file {
if let Ok(path) = file.clone().into_path() {
if let Some(s) = window.try_fs_scope() {
- s.allow_file(&path);
+ s.allow_file(&path)?;
}
tauri_scope.allow_file(&path)?;
}
@@ -232,7 +232,7 @@ pub(crate) async fn save(
if let Some(p) = &path {
if let Ok(path) = p.clone().into_path() {
if let Some(s) = window.try_fs_scope() {
- s.allow_file(&path);
+ s.allow_file(&path)?;
}
tauri_scope.allow_file(&path)?;
}
diff --git a/plugins/dialog/src/lib.rs b/plugins/dialog/src/lib.rs
index 3d7464d9..2ef1c1ea 100644
--- a/plugins/dialog/src/lib.rs
+++ b/plugins/dialog/src/lib.rs
@@ -2,8 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
-//! [](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/dialog)
-//!
//! Native system dialogs for opening and saving files along with message dialogs.
#![doc(
@@ -41,6 +39,11 @@ use desktop::*;
#[cfg(mobile)]
use mobile::*;
+#[cfg(desktop)]
+pub use desktop::Dialog;
+#[cfg(mobile)]
+pub use mobile::Dialog;
+
pub(crate) const OK: &str = "Ok";
pub(crate) const CANCEL: &str = "Cancel";
pub(crate) const YES: &str = "Yes";
diff --git a/plugins/fs/CHANGELOG.md b/plugins/fs/CHANGELOG.md
index 707733ee..eee42582 100644
--- a/plugins/fs/CHANGELOG.md
+++ b/plugins/fs/CHANGELOG.md
@@ -2,6 +2,16 @@
## \[2.0.3]
+- [`ed981027`](https://github.com/tauri-apps/plugins-workspace/commit/ed981027dd4fba7d0e2f836eb5db34d344388d73) ([#1962](https://github.com/tauri-apps/plugins-workspace/pull/1962) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Improve performance of `readTextFile` and `readTextFileLines` APIs
+- [`3e78173d`](https://github.com/tauri-apps/plugins-workspace/commit/3e78173df9ce90aa3b19e1f36d1f8712c5020fb6) ([#2018](https://github.com/tauri-apps/plugins-workspace/pull/2018) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Fix `readDir` function failing to read directories that contain broken symlinks.
+- [`5092ea5e`](https://github.com/tauri-apps/plugins-workspace/commit/5092ea5e89817c0550d09b0a4ad17bf1253b23df) ([#1964](https://github.com/tauri-apps/plugins-workspace/pull/1964) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Add support for using `ReadableStream` with `writeFile` API.
+
+## \[2.0.2]
+
+- [`77149dc4`](https://github.com/tauri-apps/plugins-workspace/commit/77149dc4320d26b413e4a6bbe82c654367c51b32) ([#1965](https://github.com/tauri-apps/plugins-workspace/pull/1965) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Fix `writeTextFile` converting UTF-8 characters (for example `äöü`) in the given path into replacement character (`�`)
+
+## \[2.0.3]
+
- [`14cee64c`](https://github.com/tauri-apps/plugins-workspace/commit/14cee64c82a72655ae6a4ac0892736a2959dbda5) ([#1958](https://github.com/tauri-apps/plugins-workspace/pull/1958) by [@bWanShiTong](https://github.com/tauri-apps/plugins-workspace/../../bWanShiTong)) Fix compilation on targets with pointer width of `16` or `32`
## \[2.0.1]
@@ -187,3 +197,11 @@
ac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release!
.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release!
717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release!
+apps/plugins-workspace/pull/371)) First v2 alpha release!
+ .com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release!
+ 717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release!
+ kspace/pull/371)) First v2 alpha release!
+ s/plugins-workspace/pull/371)) First v2 alpha release!
+ ac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release!
+ .com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release!
+ 717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release!
diff --git a/plugins/fs/Cargo.toml b/plugins/fs/Cargo.toml
index cd4e7716..402a254b 100644
--- a/plugins/fs/Cargo.toml
+++ b/plugins/fs/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "tauri-plugin-fs"
-version = "2.0.3"
+version = "2.1.0"
description = "Access the file system."
authors = { workspace = true }
license = { workspace = true }
@@ -14,7 +14,7 @@ rustc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs"]
[package.metadata.platforms.support]
-windows = { level = "full", notes = "" }
+windows = { level = "full", notes = "Apps installed via MSI or NSIS in `perMachine` and `both` mode require admin permissions for write acces in `$RESOURCES` folder" }
linux = { level = "full", notes = "No write access to `$RESOURCES` folder" }
macos = { level = "full", notes = "No write access to `$RESOURCES` folder" }
android = { level = "partial", notes = "Access is restricted to Application folder by default" }
@@ -24,6 +24,8 @@ ios = { level = "partial", notes = "Access is restricted to Application folder b
tauri-plugin = { workspace = true, features = ["build"] }
schemars = { workspace = true }
serde = { workspace = true }
+toml = "0.8"
+tauri-utils = { workspace = true, features = ["build"] }
[dependencies]
serde = { workspace = true }
@@ -34,9 +36,13 @@ thiserror = { workspace = true }
url = { workspace = true }
anyhow = "1"
uuid = { version = "1", features = ["v4"] }
-glob = "0.3"
-notify = { version = "6", optional = true, features = ["serde"] }
-notify-debouncer-full = { version = "0.3", optional = true }
+glob = { workspace = true }
+# TODO: Remove `serialization-compat-6` in v3
+notify = { version = "7", optional = true, features = [
+ "serde",
+ "serialization-compat-6",
+] }
+notify-debouncer-full = { version = "0.4", optional = true }
dunce = { workspace = true }
percent-encoding = "2"
diff --git a/plugins/fs/README.md b/plugins/fs/README.md
index af5c63a8..dea88824 100644
--- a/plugins/fs/README.md
+++ b/plugins/fs/README.md
@@ -54,7 +54,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-fs#v2
First you need to register the core plugin with Tauri:
-`src-tauri/src/main.rs`
+`src-tauri/src/lib.rs`
```rust
fn main() {
diff --git a/plugins/fs/api-iife.js b/plugins/fs/api-iife.js
index e863d7a9..c7f53b9b 100644
--- a/plugins/fs/api-iife.js
+++ b/plugins/fs/api-iife.js
@@ -1 +1 @@
-if("__TAURI__"in window){var __TAURI_PLUGIN_FS__=function(t){"use strict";function e(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function n(t,e,n,i,o){if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}var i,o,r,a,s,c;"function"==typeof SuppressedError&&SuppressedError;class f{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,i.set(this,(()=>{})),o.set(this,0),r.set(this,{}),this.id=function(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((({message:t,id:a})=>{if(a===e(this,o,"f")){n(this,o,a+1),e(this,i,"f").call(this,t);const s=Object.keys(e(this,r,"f"));if(s.length>0){let t=a+1;for(const n of s.sort()){if(parseInt(n)!==t)break;{const o=e(this,r,"f")[n];delete e(this,r,"f")[n],e(this,i,"f").call(this,o),t+=1}}n(this,o,t)}}else e(this,r,"f")[a.toString()]=t}))}set onmessage(t){n(this,i,t)}get onmessage(){return e(this,i,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}async function l(t,e={},n){return window.__TAURI_INTERNALS__.invoke(t,e,n)}i=new WeakMap,o=new WeakMap,r=new WeakMap;class u{get rid(){return e(this,a,"f")}constructor(t){a.set(this,void 0),n(this,a,t)}async close(){return l("plugin:resources|close",{rid:this.rid})}}function p(t){return{isFile:t.isFile,isDirectory:t.isDirectory,isSymlink:t.isSymlink,size:t.size,mtime:null!==t.mtime?new Date(t.mtime):null,atime:null!==t.atime?new Date(t.atime):null,birthtime:null!==t.birthtime?new Date(t.birthtime):null,readonly:t.readonly,fileAttributes:t.fileAttributes,dev:t.dev,ino:t.ino,mode:t.mode,nlink:t.nlink,uid:t.uid,gid:t.gid,rdev:t.rdev,blksize:t.blksize,blocks:t.blocks}}a=new WeakMap,t.BaseDirectory=void 0,(s=t.BaseDirectory||(t.BaseDirectory={}))[s.Audio=1]="Audio",s[s.Cache=2]="Cache",s[s.Config=3]="Config",s[s.Data=4]="Data",s[s.LocalData=5]="LocalData",s[s.Document=6]="Document",s[s.Download=7]="Download",s[s.Picture=8]="Picture",s[s.Public=9]="Public",s[s.Video=10]="Video",s[s.Resource=11]="Resource",s[s.Temp=12]="Temp",s[s.AppConfig=13]="AppConfig",s[s.AppData=14]="AppData",s[s.AppLocalData=15]="AppLocalData",s[s.AppCache=16]="AppCache",s[s.AppLog=17]="AppLog",s[s.Desktop=18]="Desktop",s[s.Executable=19]="Executable",s[s.Font=20]="Font",s[s.Home=21]="Home",s[s.Runtime=22]="Runtime",s[s.Template=23]="Template",t.SeekMode=void 0,(c=t.SeekMode||(t.SeekMode={}))[c.Start=0]="Start",c[c.Current=1]="Current",c[c.End=2]="End";class w extends u{async read(t){if(0===t.byteLength)return 0;const e=await l("plugin:fs|read",{rid:this.rid,len:t.byteLength}),n=function(t){const e=new Uint8ClampedArray(t),n=e.byteLength;let i=0;for(let t=0;tt instanceof URL?t.toString():t)),options:i,onEvent:r});return()=>{h(a)}},t.watchImmediate=async function(t,e,n){const i={recursive:!1,...n,delayMs:null},o=Array.isArray(t)?t:[t];for(const t of o)if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const r=new f;r.onmessage=e;const a=await l("plugin:fs|watch",{paths:o.map((t=>t instanceof URL?t.toString():t)),options:i,onEvent:r});return()=>{h(a)}},t.writeFile=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");await l("plugin:fs|write_file",e,{headers:{path:encodeURIComponent(t instanceof URL?t.toString():t),options:JSON.stringify(n)}})},t.writeTextFile=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const i=new TextEncoder;await l("plugin:fs|write_text_file",i.encode(e),{headers:{path:t instanceof URL?t.toString():t,options:JSON.stringify(n)}})},t}({});Object.defineProperty(window.__TAURI__,"fs",{value:__TAURI_PLUGIN_FS__})}
+if("__TAURI__"in window){var __TAURI_PLUGIN_FS__=function(t){"use strict";function e(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function n(t,e,n,i,o){if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}var i,o,r,a;"function"==typeof SuppressedError&&SuppressedError;const s="__TAURI_TO_IPC_KEY__";class c{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,i.set(this,(()=>{})),o.set(this,0),r.set(this,{}),this.id=function(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((({message:t,id:a})=>{if(a===e(this,o,"f")){n(this,o,a+1),e(this,i,"f").call(this,t);const s=Object.keys(e(this,r,"f"));if(s.length>0){let t=a+1;for(const n of s.sort()){if(parseInt(n)!==t)break;{const o=e(this,r,"f")[n];delete e(this,r,"f")[n],e(this,i,"f").call(this,o),t+=1}}n(this,o,t)}}else e(this,r,"f")[a.toString()]=t}))}set onmessage(t){n(this,i,t)}get onmessage(){return e(this,i,"f")}[(i=new WeakMap,o=new WeakMap,r=new WeakMap,s)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[s]()}}async function f(t,e={},n){return window.__TAURI_INTERNALS__.invoke(t,e,n)}class l{get rid(){return e(this,a,"f")}constructor(t){a.set(this,void 0),n(this,a,t)}async close(){return f("plugin:resources|close",{rid:this.rid})}}var u,p;function w(t){return{isFile:t.isFile,isDirectory:t.isDirectory,isSymlink:t.isSymlink,size:t.size,mtime:null!==t.mtime?new Date(t.mtime):null,atime:null!==t.atime?new Date(t.atime):null,birthtime:null!==t.birthtime?new Date(t.birthtime):null,readonly:t.readonly,fileAttributes:t.fileAttributes,dev:t.dev,ino:t.ino,mode:t.mode,nlink:t.nlink,uid:t.uid,gid:t.gid,rdev:t.rdev,blksize:t.blksize,blocks:t.blocks}}a=new WeakMap,t.BaseDirectory=void 0,(u=t.BaseDirectory||(t.BaseDirectory={}))[u.Audio=1]="Audio",u[u.Cache=2]="Cache",u[u.Config=3]="Config",u[u.Data=4]="Data",u[u.LocalData=5]="LocalData",u[u.Document=6]="Document",u[u.Download=7]="Download",u[u.Picture=8]="Picture",u[u.Public=9]="Public",u[u.Video=10]="Video",u[u.Resource=11]="Resource",u[u.Temp=12]="Temp",u[u.AppConfig=13]="AppConfig",u[u.AppData=14]="AppData",u[u.AppLocalData=15]="AppLocalData",u[u.AppCache=16]="AppCache",u[u.AppLog=17]="AppLog",u[u.Desktop=18]="Desktop",u[u.Executable=19]="Executable",u[u.Font=20]="Font",u[u.Home=21]="Home",u[u.Runtime=22]="Runtime",u[u.Template=23]="Template",t.SeekMode=void 0,(p=t.SeekMode||(t.SeekMode={}))[p.Start=0]="Start",p[p.Current=1]="Current",p[p.End=2]="End";class d extends l{async read(t){if(0===t.byteLength)return 0;const e=await f("plugin:fs|read",{rid:this.rid,len:t.byteLength}),n=function(t){const e=new Uint8ClampedArray(t),n=e.byteLength;let i=0;for(let t=0;tt instanceof URL?t.toString():t)),options:i,onEvent:r});return()=>{y(a)}},t.watchImmediate=async function(t,e,n){const i={recursive:!1,...n,delayMs:null},o=Array.isArray(t)?t:[t];for(const t of o)if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const r=new c;r.onmessage=e;const a=await f("plugin:fs|watch",{paths:o.map((t=>t instanceof URL?t.toString():t)),options:i,onEvent:r});return()=>{y(a)}},t.writeFile=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");if(e instanceof ReadableStream){const i=await h(t,n);for await(const t of e)await i.write(t);await i.close()}else await f("plugin:fs|write_file",e,{headers:{path:encodeURIComponent(t instanceof URL?t.toString():t),options:JSON.stringify(n)}})},t.writeTextFile=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const i=new TextEncoder;await f("plugin:fs|write_text_file",i.encode(e),{headers:{path:encodeURIComponent(t instanceof URL?t.toString():t),options:JSON.stringify(n)}})},t}({});Object.defineProperty(window.__TAURI__,"fs",{value:__TAURI_PLUGIN_FS__})}
diff --git a/plugins/fs/build.rs b/plugins/fs/build.rs
index cb9d00da..3909b1c0 100644
--- a/plugins/fs/build.rs
+++ b/plugins/fs/build.rs
@@ -7,6 +7,8 @@ use std::{
path::{Path, PathBuf},
};
+use tauri_utils::acl::manifest::PermissionFile;
+
#[path = "src/scope.rs"]
#[allow(dead_code)]
mod scope;
@@ -16,10 +18,23 @@ mod scope;
#[serde(untagged)]
#[allow(unused)]
enum FsScopeEntry {
- /// FS scope path.
+ /// A path that can be accessed by the webview when using the fs APIs.
+ /// FS scope path pattern.
+ ///
+ /// The pattern can start with a variable that resolves to a system base directory.
+ /// The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`,
+ /// `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`,
+ /// `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`,
+ /// `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.
Value(PathBuf),
Object {
- /// FS scope path.
+ /// A path that can be accessed by the webview when using the fs APIs.
+ ///
+ /// The pattern can start with a variable that resolves to a system base directory.
+ /// The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`,
+ /// `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`,
+ /// `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`,
+ /// `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.
path: PathBuf,
},
}
@@ -62,31 +77,32 @@ const BASE_DIR_VARS: &[&str] = &[
"APPCACHE",
"APPLOG",
];
-const COMMANDS: &[&str] = &[
- "mkdir",
- "create",
- "copy_file",
- "remove",
- "rename",
- "truncate",
- "ftruncate",
- "write",
- "write_file",
- "write_text_file",
- "read_dir",
- "read_file",
- "read",
- "open",
- "read_text_file",
- "read_text_file_lines",
- "read_text_file_lines_next",
- "seek",
- "stat",
- "lstat",
- "fstat",
- "exists",
- "watch",
- "unwatch",
+const COMMANDS: &[(&str, &[&str])] = &[
+ ("mkdir", &[]),
+ ("create", &[]),
+ ("copy_file", &[]),
+ ("remove", &[]),
+ ("rename", &[]),
+ ("truncate", &[]),
+ ("ftruncate", &[]),
+ ("write", &[]),
+ ("write_file", &["open", "write"]),
+ ("write_text_file", &[]),
+ ("read_dir", &[]),
+ ("read_file", &[]),
+ ("read", &[]),
+ ("open", &[]),
+ ("read_text_file", &[]),
+ ("read_text_file_lines", &["read_text_file_lines_next"]),
+ ("read_text_file_lines_next", &[]),
+ ("seek", &[]),
+ ("stat", &[]),
+ ("lstat", &[]),
+ ("fstat", &[]),
+ ("exists", &[]),
+ ("watch", &[]),
+ ("unwatch", &[]),
+ ("size", &[]),
];
fn main() {
@@ -192,9 +208,47 @@ permissions = [
}
}
- tauri_plugin::Builder::new(COMMANDS)
+ tauri_plugin::Builder::new(&COMMANDS.iter().map(|c| c.0).collect::>())
.global_api_script_path("./api-iife.js")
.global_scope_schema(schemars::schema_for!(FsScopeEntry))
.android_path("android")
.build();
+
+ // workaround to include nested permissions as `tauri_plugin` doesn't support it
+ let permissions_dir = autogenerated.join("commands");
+ for (command, nested_commands) in COMMANDS {
+ if nested_commands.is_empty() {
+ continue;
+ }
+
+ let permission_path = permissions_dir.join(format!("{command}.toml"));
+
+ let content = std::fs::read_to_string(&permission_path)
+ .unwrap_or_else(|_| panic!("failed to read {command}.toml"));
+
+ let mut permission_file = toml::from_str::(&content)
+ .unwrap_or_else(|_| panic!("failed to deserialize {command}.toml"));
+
+ for p in permission_file
+ .permission
+ .iter_mut()
+ .filter(|p| p.identifier.starts_with("allow"))
+ {
+ p.commands
+ .allow
+ .extend(nested_commands.iter().map(|s| s.to_string()));
+ }
+
+ let out = toml::to_string_pretty(&permission_file)
+ .unwrap_or_else(|_| panic!("failed to serialize {command}.toml"));
+ let out = format!(
+ r#"# Automatically generated - DO NOT EDIT!
+
+"$schema" = "../../schemas/schema.json"
+
+{out}"#
+ );
+ std::fs::write(permission_path, out)
+ .unwrap_or_else(|_| panic!("failed to write {command}.toml"));
+ }
}
diff --git a/plugins/fs/guest-js/index.ts b/plugins/fs/guest-js/index.ts
index 57e7518d..448335c4 100644
--- a/plugins/fs/guest-js/index.ts
+++ b/plugins/fs/guest-js/index.ts
@@ -14,16 +14,29 @@
*
* The API has a scope configuration that forces you to restrict the paths that can be accessed using glob patterns.
*
- * The scope configuration is an array of glob patterns describing folder paths that are allowed.
- * For instance, this scope configuration only allows accessing files on the
- * *databases* folder of the {@link https://v2.tauri.app/reference/javascript/api/namespacepath/#appdatadir | `$APPDATA` directory}:
+ * The scope configuration is an array of glob patterns describing file/directory paths that are allowed.
+ * For instance, this scope configuration allows **all** enabled `fs` APIs to (only) access files in the
+ * *databases* directory of the {@link https://v2.tauri.app/reference/javascript/api/namespacepath/#appdatadir | `$APPDATA` directory}:
* ```json
* {
- * "plugins": {
- * "fs": {
- * "scope": ["$APPDATA/databases/*"]
+ * "permissions": [
+ * {
+ * "identifier": "fs:scope",
+ * "allow": [{ "path": "$APPDATA/databases/*" }]
* }
- * }
+ * ]
+ * }
+ * ```
+ *
+ * Scopes can also be applied to specific `fs` APIs by using the API's identifier instead of `fs:scope`:
+ * ```json
+ * {
+ * "permissions": [
+ * {
+ * "identifier": "fs:allow-exists",
+ * "allow": [{ "path": "$APPDATA/databases/*" }]
+ * }
+ * ]
* }
* ```
*
@@ -56,8 +69,6 @@
*
* Trying to execute any API with a URL not configured on the scope results in a promise rejection due to denied access.
*
- * Note that this scope applies to **all** APIs on this module.
- *
* @module
*/
@@ -255,6 +266,7 @@ function fromBytes(buffer: FixedSizeArray): number {
const size = bytes.byteLength
let x = 0
for (let i = 0; i < size; i++) {
+ // eslint-disable-next-line security/detect-object-injection
const byte = bytes[i]
x *= 0x100
x += byte
@@ -416,11 +428,11 @@ class FileHandle extends Resource {
}
/**
- * Writes `p.byteLength` bytes from `p` to the underlying data stream. It
- * resolves to the number of bytes written from `p` (`0` <= `n` <=
- * `p.byteLength`) or reject with the error encountered that caused the
+ * Writes `data.byteLength` bytes from `data` to the underlying data stream. It
+ * resolves to the number of bytes written from `data` (`0` <= `n` <=
+ * `data.byteLength`) or reject with the error encountered that caused the
* write to stop early. `write()` must reject with a non-null error if
- * would resolve to `n` < `p.byteLength`. `write()` must not modify the
+ * would resolve to `n` < `data.byteLength`. `write()` must not modify the
* slice data, even temporarily.
*
* @example
@@ -758,10 +770,14 @@ async function readTextFile(
throw new TypeError('Must be a file URL.')
}
- return await invoke('plugin:fs|read_text_file', {
+ const arr = await invoke('plugin:fs|read_text_file', {
path: path instanceof URL ? path.toString() : path,
options
})
+
+ const bytes = arr instanceof ArrayBuffer ? arr : Uint8Array.from(arr)
+
+ return new TextDecoder().decode(bytes)
}
/**
@@ -792,6 +808,7 @@ async function readTextFileLines(
return await Promise.resolve({
path: pathStr,
rid: null as number | null,
+
async next(): Promise> {
if (this.rid === null) {
this.rid = await invoke('plugin:fs|read_text_file_lines', {
@@ -800,19 +817,35 @@ async function readTextFileLines(
})
}
- const [line, done] = await invoke<[string | null, boolean]>(
+ const arr = await invoke(
'plugin:fs|read_text_file_lines_next',
{ rid: this.rid }
)
- // an iteration is over, reset rid for next iteration
- if (done) this.rid = null
+ const bytes =
+ arr instanceof ArrayBuffer ? new Uint8Array(arr) : Uint8Array.from(arr)
+
+ // Rust side will never return an empty array for this command and
+ // ensure there is at least one elements there.
+ //
+ // This is an optimization to include whether we finished iteration or not (1 or 0)
+ // at the end of returned array to avoid serialization overhead of separate values.
+ const done = bytes[bytes.byteLength - 1] === 1
+
+ if (done) {
+ // a full iteration is over, reset rid for next iteration
+ this.rid = null
+ return { value: null, done }
+ }
+
+ const line = new TextDecoder().decode(bytes.slice(0, bytes.byteLength))
return {
- value: done ? '' : line!,
+ value: line,
done
}
},
+
[Symbol.asyncIterator](): AsyncIterableIterator {
return this
}
@@ -1033,19 +1066,27 @@ interface WriteFileOptions {
*/
async function writeFile(
path: string | URL,
- data: Uint8Array,
+ data: Uint8Array | ReadableStream,
options?: WriteFileOptions
): Promise {
if (path instanceof URL && path.protocol !== 'file:') {
throw new TypeError('Must be a file URL.')
}
- await invoke('plugin:fs|write_file', data, {
- headers: {
- path: encodeURIComponent(path instanceof URL ? path.toString() : path),
- options: JSON.stringify(options)
+ if (data instanceof ReadableStream) {
+ const file = await open(path, options)
+ for await (const chunk of data) {
+ await file.write(chunk)
}
- })
+ await file.close()
+ } else {
+ await invoke('plugin:fs|write_file', data, {
+ headers: {
+ path: encodeURIComponent(path instanceof URL ? path.toString() : path),
+ options: JSON.stringify(options)
+ }
+ })
+ }
}
/**
@@ -1072,7 +1113,7 @@ async function writeTextFile(
await invoke('plugin:fs|write_text_file', encoder.encode(data), {
headers: {
- path: path instanceof URL ? path.toString() : path,
+ path: encodeURIComponent(path instanceof URL ? path.toString() : path),
options: JSON.stringify(options)
}
})
@@ -1281,6 +1322,31 @@ async function watchImmediate(
}
}
+/**
+ * Get the size of a file or directory. For files, the `stat` functions can be used as well.
+ *
+ * If `path` is a directory, this function will recursively iterate over every file and every directory inside of `path` and therefore will be very time consuming if used on larger directories.
+ *
+ * @example
+ * ```typescript
+ * import { size, BaseDirectory } from '@tauri-apps/plugin-fs';
+ * // Get the size of the `$APPDATA/tauri` directory.
+ * const dirSize = await size('tauri', { baseDir: BaseDirectory.AppData });
+ * console.log(dirSize); // 1024
+ * ```
+ *
+ * @since 2.1.0
+ */
+async function size(path: string | URL): Promise {
+ if (path instanceof URL && path.protocol !== 'file:') {
+ throw new TypeError('Must be a file URL.')
+ }
+
+ return await invoke('plugin:fs|size', {
+ path: path instanceof URL ? path.toString() : path
+ })
+}
+
export type {
CreateOptions,
OpenOptions,
@@ -1328,5 +1394,6 @@ export {
writeTextFile,
exists,
watch,
- watchImmediate
+ watchImmediate,
+ size
}
diff --git a/plugins/fs/package.json b/plugins/fs/package.json
index 0bce5c6c..eeb9f8a4 100644
--- a/plugins/fs/package.json
+++ b/plugins/fs/package.json
@@ -1,6 +1,6 @@
{
"name": "@tauri-apps/plugin-fs",
- "version": "2.0.1",
+ "version": "2.0.3",
"description": "Access the file system.",
"license": "MIT OR Apache-2.0",
"authors": [
diff --git a/plugins/fs/permissions/autogenerated/commands/read_text_file_lines.toml b/plugins/fs/permissions/autogenerated/commands/read_text_file_lines.toml
index 1ba629cb..84b4ebb2 100644
--- a/plugins/fs/permissions/autogenerated/commands/read_text_file_lines.toml
+++ b/plugins/fs/permissions/autogenerated/commands/read_text_file_lines.toml
@@ -5,9 +5,18 @@
[[permission]]
identifier = "allow-read-text-file-lines"
description = "Enables the read_text_file_lines command without any pre-configured scope."
-commands.allow = ["read_text_file_lines"]
+
+[permission.commands]
+allow = [
+ "read_text_file_lines",
+ "read_text_file_lines_next",
+]
+deny = []
[[permission]]
identifier = "deny-read-text-file-lines"
description = "Denies the read_text_file_lines command without any pre-configured scope."
-commands.deny = ["read_text_file_lines"]
+
+[permission.commands]
+allow = []
+deny = ["read_text_file_lines"]
diff --git a/plugins/fs/permissions/autogenerated/commands/size.toml b/plugins/fs/permissions/autogenerated/commands/size.toml
new file mode 100644
index 00000000..8a0ea55c
--- /dev/null
+++ b/plugins/fs/permissions/autogenerated/commands/size.toml
@@ -0,0 +1,13 @@
+# Automatically generated - DO NOT EDIT!
+
+"$schema" = "../../schemas/schema.json"
+
+[[permission]]
+identifier = "allow-size"
+description = "Enables the size command without any pre-configured scope."
+commands.allow = ["size"]
+
+[[permission]]
+identifier = "deny-size"
+description = "Denies the size command without any pre-configured scope."
+commands.deny = ["size"]
diff --git a/plugins/fs/permissions/autogenerated/commands/write_file.toml b/plugins/fs/permissions/autogenerated/commands/write_file.toml
index cb0450fc..ea7d5136 100644
--- a/plugins/fs/permissions/autogenerated/commands/write_file.toml
+++ b/plugins/fs/permissions/autogenerated/commands/write_file.toml
@@ -5,9 +5,19 @@
[[permission]]
identifier = "allow-write-file"
description = "Enables the write_file command without any pre-configured scope."
-commands.allow = ["write_file"]
+
+[permission.commands]
+allow = [
+ "write_file",
+ "open",
+ "write",
+]
+deny = []
[[permission]]
identifier = "deny-write-file"
description = "Denies the write_file command without any pre-configured scope."
-commands.deny = ["write_file"]
+
+[permission.commands]
+allow = []
+deny = ["write_file"]
diff --git a/plugins/fs/permissions/autogenerated/reference.md b/plugins/fs/permissions/autogenerated/reference.md
index 79ec2f55..3cec32ed 100644
--- a/plugins/fs/permissions/autogenerated/reference.md
+++ b/plugins/fs/permissions/autogenerated/reference.md
@@ -24,6 +24,7 @@ This default permission set prevents access to critical components
of the Tauri application by default.
On Windows the webview data folder access is denied.
+#### Included permissions within this default permission set:
- `create-app-specific-dirs`
@@ -3409,6 +3410,32 @@ Denies the seek command without any pre-configured scope.
+`fs:allow-size`
+
+
+
+
+Enables the size command without any pre-configured scope.
+
+
+
+
+
+
+
+`fs:deny-size`
+
+
+
+
+Denies the size command without any pre-configured scope.
+
+
+
+
+
+
+
`fs:allow-stat`
diff --git a/plugins/fs/permissions/default.toml b/plugins/fs/permissions/default.toml
index d519d758..4cc7bd51 100644
--- a/plugins/fs/permissions/default.toml
+++ b/plugins/fs/permissions/default.toml
@@ -26,6 +26,7 @@ This default permission set prevents access to critical components
of the Tauri application by default.
On Windows the webview data folder access is denied.
+#### Included permissions within this default permission set:
"""
permissions = [
"create-app-specific-dirs",
diff --git a/plugins/fs/permissions/read-meta.toml b/plugins/fs/permissions/read-meta.toml
index 09c731ad..83024b0c 100644
--- a/plugins/fs/permissions/read-meta.toml
+++ b/plugins/fs/permissions/read-meta.toml
@@ -3,4 +3,4 @@
[[permission]]
identifier = "read-meta"
description = "This enables all index or metadata related commands without any pre-configured accessible paths."
-commands.allow = ["read_dir", "stat", "lstat", "fstat", "exists"]
+commands.allow = ["read_dir", "stat", "lstat", "fstat", "exists", "size"]
diff --git a/plugins/fs/permissions/schemas/schema.json b/plugins/fs/permissions/schemas/schema.json
index 57ab0634..2c13d5c6 100644
--- a/plugins/fs/permissions/schemas/schema.json
+++ b/plugins/fs/permissions/schemas/schema.json
@@ -1589,6 +1589,16 @@
"type": "string",
"const": "deny-seek"
},
+ {
+ "description": "Enables the size command without any pre-configured scope.",
+ "type": "string",
+ "const": "allow-size"
+ },
+ {
+ "description": "Denies the size command without any pre-configured scope.",
+ "type": "string",
+ "const": "deny-size"
+ },
{
"description": "Enables the stat command without any pre-configured scope.",
"type": "string",
@@ -1665,7 +1675,7 @@
"const": "create-app-specific-dirs"
},
{
- "description": "This set of permissions describes the what kind of\nfile system access the `fs` plugin has enabled or denied by default.\n\n#### Granted Permissions\n\nThis default permission set enables read access to the\napplication specific directories (AppConfig, AppData, AppLocalData, AppCache,\nAppLog) and all files and sub directories created in it.\nThe location of these directories depends on the operating system,\nwhere the application is run.\n\nIn general these directories need to be manually created\nby the application at runtime, before accessing files or folders\nin it is possible.\n\nTherefore, it is also allowed to create all of these folders via\nthe `mkdir` command.\n\n#### Denied Permissions\n\nThis default permission set prevents access to critical components\nof the Tauri application by default.\nOn Windows the webview data folder access is denied.\n\n",
+ "description": "This set of permissions describes the what kind of\nfile system access the `fs` plugin has enabled or denied by default.\n\n#### Granted Permissions\n\nThis default permission set enables read access to the\napplication specific directories (AppConfig, AppData, AppLocalData, AppCache,\nAppLog) and all files and sub directories created in it.\nThe location of these directories depends on the operating system,\nwhere the application is run.\n\nIn general these directories need to be manually created\nby the application at runtime, before accessing files or folders\nin it is possible.\n\nTherefore, it is also allowed to create all of these folders via\nthe `mkdir` command.\n\n#### Denied Permissions\n\nThis default permission set prevents access to critical components\nof the Tauri application by default.\nOn Windows the webview data folder access is denied.\n\n#### Included permissions within this default permission set:\n",
"type": "string",
"const": "default"
},
diff --git a/plugins/fs/src/commands.rs b/plugins/fs/src/commands.rs
index 97ba43e3..719178c6 100644
--- a/plugins/fs/src/commands.rs
+++ b/plugins/fs/src/commands.rs
@@ -15,14 +15,14 @@ use tauri::{
use std::{
borrow::Cow,
fs::File,
- io::{BufReader, Lines, Read, Write},
+ io::{BufRead, BufReader, Read, Write},
path::{Path, PathBuf},
str::FromStr,
sync::Mutex,
time::{SystemTime, UNIX_EPOCH},
};
-use crate::{scope::Entry, Error, FsExt, SafeFilePath};
+use crate::{scope::Entry, Error, SafeFilePath};
#[derive(Debug, thiserror::Error)]
pub enum CommandError {
@@ -250,32 +250,12 @@ pub fn mkdir(
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct DirEntry {
- pub name: Option,
+ pub name: String,
pub is_directory: bool,
pub is_file: bool,
pub is_symlink: bool,
}
-fn read_dir_inner>(path: P) -> crate::Result> {
- let mut files_and_dirs: Vec = vec![];
- for entry in std::fs::read_dir(path)? {
- let path = entry?.path();
- let file_type = path.metadata()?.file_type();
- files_and_dirs.push(DirEntry {
- is_directory: file_type.is_dir(),
- is_file: file_type.is_file(),
- is_symlink: std::fs::symlink_metadata(&path)
- .map(|md| md.file_type().is_symlink())
- .unwrap_or(false),
- name: path
- .file_name()
- .map(|name| name.to_string_lossy())
- .map(|name| name.to_string()),
- });
- }
- Result::Ok(files_and_dirs)
-}
-
#[tauri::command]
pub async fn read_dir(
webview: Webview,
@@ -293,14 +273,37 @@ pub async fn read_dir(
options.as_ref().and_then(|o| o.base_dir),
)?;
- read_dir_inner(&resolved_path)
- .map_err(|e| {
- format!(
- "failed to read directory at path: {} with error: {e}",
- resolved_path.display()
- )
+ let entries = std::fs::read_dir(&resolved_path).map_err(|e| {
+ format!(
+ "failed to read directory at path: {} with error: {e}",
+ resolved_path.display()
+ )
+ })?;
+
+ let entries = entries
+ .filter_map(|entry| {
+ let entry = entry.ok()?;
+ let name = entry.file_name().into_string().ok()?;
+ let metadata = entry.file_type();
+ macro_rules! method_or_false {
+ ($method:ident) => {
+ if let Ok(metadata) = &metadata {
+ metadata.$method()
+ } else {
+ false
+ }
+ };
+ }
+ Some(DirEntry {
+ name,
+ is_file: method_or_false!(is_file),
+ is_directory: method_or_false!(is_dir),
+ is_symlink: method_or_false!(is_symlink),
+ })
})
- .map_err(Into::into)
+ .collect();
+
+ Ok(entries)
}
#[tauri::command]
@@ -376,6 +379,7 @@ pub async fn read_file(
Ok(tauri::ipc::Response::new(contents))
}
+// TODO, remove in v3, rely on `read_file` command instead
#[tauri::command]
pub async fn read_text_file(
webview: Webview,
@@ -383,7 +387,7 @@ pub async fn read_text_file(
command_scope: CommandScope,
path: SafeFilePath,
options: Option,
-) -> CommandResult {
+) -> CommandResult {
let (mut file, path) = resolve_file(
"read-text-file",
&webview,
@@ -401,16 +405,16 @@ pub async fn read_text_file(
},
)?;
- let mut contents = String::new();
+ let mut contents = Vec::new();
- file.read_to_string(&mut contents).map_err(|e| {
+ file.read_to_end(&mut contents).map_err(|e| {
format!(
"failed to read file as text at path: {} with error: {e}",
path.display()
)
})?;
- Ok(contents)
+ Ok(tauri::ipc::Response::new(contents))
}
#[tauri::command]
@@ -421,8 +425,6 @@ pub fn read_text_file_lines(
path: SafeFilePath,
options: Option,
) -> CommandResult {
- use std::io::BufRead;
-
let resolved_path = resolve_path(
"read-text-file-lines",
&webview,
@@ -439,7 +441,7 @@ pub fn read_text_file_lines(
)
})?;
- let lines = BufReader::new(file).lines();
+ let lines = BufReader::new(file);
let rid = webview.resources_table().add(StdLinesResource::new(lines));
Ok(rid)
@@ -449,18 +451,28 @@ pub fn read_text_file_lines(
pub async fn read_text_file_lines_next(
webview: Webview,
rid: ResourceId,
-) -> CommandResult<(Option, bool)> {
+) -> CommandResult {
let mut resource_table = webview.resources_table();
let lines = resource_table.get::(rid)?;
- let ret = StdLinesResource::with_lock(&lines, |lines| {
- lines.next().map(|a| (a.ok(), false)).unwrap_or_else(|| {
- let _ = resource_table.close(rid);
- (None, true)
- })
+ let ret = StdLinesResource::with_lock(&lines, |lines| -> CommandResult> {
+ // This is an optimization to include wether we finished iteration or not (1 or 0)
+ // at the end of returned vector so we can use `tauri::ipc::Response`
+ // and avoid serialization overhead of separate values.
+ match lines.next() {
+ Some(Ok(mut bytes)) => {
+ bytes.push(false as u8);
+ Ok(bytes)
+ }
+ Some(Err(_)) => Ok(vec![false as u8]),
+ None => {
+ resource_table.close(rid)?;
+ Ok(vec![true as u8])
+ }
+ }
});
- Ok(ret)
+ ret.map(tauri::ipc::Response::new)
}
#[derive(Debug, Clone, Deserialize)]
@@ -824,23 +836,13 @@ fn default_create_value() -> bool {
true
}
-fn write_file_inner(
+async fn write_file_inner(
permission: &str,
webview: Webview,
- global_scope: &GlobalScope,
- command_scope: &CommandScope,
+ global_scope: GlobalScope,
+ command_scope: CommandScope,
request: tauri::ipc::Request<'_>,
) -> CommandResult<()> {
- let data = match request.body() {
- tauri::ipc::InvokeBody::Raw(data) => Cow::Borrowed(data),
- tauri::ipc::InvokeBody::Json(serde_json::Value::Array(data)) => Cow::Owned(
- data.iter()
- .flat_map(|v| v.as_number().and_then(|v| v.as_u64().map(|v| v as u8)))
- .collect(),
- ),
- _ => return Err(anyhow::anyhow!("unexpected invoke body").into()),
- };
-
let path = request
.headers()
.get("path")
@@ -851,6 +853,7 @@ fn write_file_inner(
.map_err(|_| anyhow::anyhow!("path is not a valid UTF-8").into())
})
.and_then(|p| SafeFilePath::from_str(&p).map_err(CommandError::from))?;
+
let options: Option = request
.headers()
.get("options")
@@ -860,8 +863,8 @@ fn write_file_inner(
let (mut file, path) = resolve_file(
permission,
&webview,
- global_scope,
- command_scope,
+ &global_scope,
+ &command_scope,
path,
if let Some(opts) = options {
OpenOptions {
@@ -894,6 +897,16 @@ fn write_file_inner(
},
)?;
+ let data = match request.body() {
+ tauri::ipc::InvokeBody::Raw(data) => Cow::Borrowed(data),
+ tauri::ipc::InvokeBody::Json(serde_json::Value::Array(data)) => Cow::Owned(
+ data.iter()
+ .flat_map(|v| v.as_number().and_then(|v| v.as_u64().map(|v| v as u8)))
+ .collect(),
+ ),
+ _ => return Err(anyhow::anyhow!("unexpected invoke body").into()),
+ };
+
file.write_all(&data)
.map_err(|e| {
format!(
@@ -911,16 +924,10 @@ pub async fn write_file(
command_scope: CommandScope,
request: tauri::ipc::Request<'_>,
) -> CommandResult<()> {
- write_file_inner(
- "write_file",
- webview,
- &global_scope,
- &command_scope,
- request,
- )
+ write_file_inner("write-file", webview, global_scope, command_scope, request).await
}
-// TODO, in v3, remove this command and rely on `write_file` command only
+// TODO, remove in v3, rely on `write_file` command instead
#[tauri::command]
pub async fn write_text_file(
webview: Webview,
@@ -929,12 +936,13 @@ pub async fn write_text_file(
request: tauri::ipc::Request<'_>,
) -> CommandResult<()> {
write_file_inner(
- "write_text_file",
+ "write-text-file",
webview,
- &global_scope,
- &command_scope,
+ global_scope,
+ command_scope,
request,
)
+ .await
}
#[tauri::command]
@@ -956,6 +964,56 @@ pub fn exists(
Ok(resolved_path.exists())
}
+#[tauri::command]
+pub async fn size(
+ webview: Webview,
+ global_scope: GlobalScope,
+ command_scope: CommandScope,
+ path: SafeFilePath,
+ options: Option,
+) -> CommandResult {
+ let resolved_path = resolve_path(
+ "size",
+ &webview,
+ &global_scope,
+ &command_scope,
+ path,
+ options.as_ref().and_then(|o| o.base_dir),
+ )?;
+
+ let metadata = resolved_path.metadata()?;
+
+ if metadata.is_file() {
+ Ok(metadata.len())
+ } else {
+ let size = get_dir_size(&resolved_path).map_err(|e| {
+ format!(
+ "failed to get size at path: {} with error: {e}",
+ resolved_path.display()
+ )
+ })?;
+
+ Ok(size)
+ }
+}
+
+fn get_dir_size(path: &PathBuf) -> CommandResult {
+ let mut size = 0;
+
+ for entry in std::fs::read_dir(path)? {
+ let entry = entry?;
+ let metadata = entry.metadata()?;
+
+ if metadata.is_file() {
+ size += metadata.len();
+ } else if metadata.is_dir() {
+ size += get_dir_size(&entry.path())?;
+ }
+ }
+
+ Ok(size)
+}
+
#[cfg(not(target_os = "android"))]
pub fn resolve_file(
permission: &str,
@@ -1012,6 +1070,8 @@ pub fn resolve_file(
path: SafeFilePath,
open_options: OpenOptions,
) -> CommandResult<(File, PathBuf)> {
+ use crate::FsExt;
+
match path {
SafeFilePath::Url(url) => {
let path = url.as_str().into();
@@ -1046,34 +1106,36 @@ pub fn resolve_path(
path
};
+ let fs_scope = webview.state::();
+
let scope = tauri::scope::fs::Scope::new(
webview,
&FsScope::Scope {
- allow: webview
- .fs_scope()
- .allowed
- .lock()
- .unwrap()
- .clone()
- .into_iter()
- .chain(global_scope.allows().iter().filter_map(|e| e.path.clone()))
+ allow: global_scope
+ .allows()
+ .iter()
+ .filter_map(|e| e.path.clone())
.chain(command_scope.allows().iter().filter_map(|e| e.path.clone()))
.collect(),
- deny: webview
- .fs_scope()
- .denied
- .lock()
- .unwrap()
- .clone()
- .into_iter()
- .chain(global_scope.denies().iter().filter_map(|e| e.path.clone()))
+ deny: global_scope
+ .denies()
+ .iter()
+ .filter_map(|e| e.path.clone())
.chain(command_scope.denies().iter().filter_map(|e| e.path.clone()))
.collect(),
- require_literal_leading_dot: webview.fs_scope().require_literal_leading_dot,
+ require_literal_leading_dot: fs_scope.require_literal_leading_dot,
},
)?;
- if scope.is_allowed(&path) {
+ let require_literal_leading_dot = fs_scope.require_literal_leading_dot.unwrap_or(cfg!(unix));
+
+ if is_forbidden(&fs_scope.scope, &path, require_literal_leading_dot)
+ || is_forbidden(&scope, &path, require_literal_leading_dot)
+ {
+ return Err(CommandError::Plugin(Error::PathForbidden(path)));
+ }
+
+ if fs_scope.scope.is_allowed(&path) || scope.is_allowed(&path) {
Ok(path)
} else {
#[cfg(not(debug_assertions))]
@@ -1090,6 +1152,45 @@ pub fn resolve_path(
}
}
+fn is_forbidden>(
+ scope: &tauri::fs::Scope,
+ path: P,
+ require_literal_leading_dot: bool,
+) -> bool {
+ let path = path.as_ref();
+ let path = if path.is_symlink() {
+ match std::fs::read_link(path) {
+ Ok(p) => p,
+ Err(_) => return false,
+ }
+ } else {
+ path.to_path_buf()
+ };
+ let path = if !path.exists() {
+ crate::Result::Ok(path)
+ } else {
+ std::fs::canonicalize(path).map_err(Into::into)
+ };
+
+ if let Ok(path) = path {
+ let path: PathBuf = path.components().collect();
+ scope.forbidden_patterns().iter().any(|p| {
+ p.matches_path_with(
+ &path,
+ glob::MatchOptions {
+ // this is needed so `/dir/*` doesn't match files within subdirectories such as `/dir/subdir/file.txt`
+ // see:
+ require_literal_separator: true,
+ require_literal_leading_dot,
+ ..Default::default()
+ },
+ )
+ })
+ } else {
+ false
+ }
+}
+
struct StdFileResource(Mutex);
impl StdFileResource {
@@ -1105,14 +1206,38 @@ impl StdFileResource {
impl Resource for StdFileResource {}
-struct StdLinesResource(Mutex>>);
+/// Same as [std::io::Lines] but with bytes
+struct LinesBytes(T);
+
+impl Iterator for LinesBytes {
+ type Item = std::io::Result>;
+
+ fn next(&mut self) -> Option>> {
+ let mut buf = Vec::new();
+ match self.0.read_until(b'\n', &mut buf) {
+ Ok(0) => None,
+ Ok(_n) => {
+ if buf.last() == Some(&b'\n') {
+ buf.pop();
+ if buf.last() == Some(&b'\r') {
+ buf.pop();
+ }
+ }
+ Some(Ok(buf))
+ }
+ Err(e) => Some(Err(e)),
+ }
+ }
+}
+
+struct StdLinesResource(Mutex>>);
impl StdLinesResource {
- fn new(lines: Lines>) -> Self {
- Self(Mutex::new(lines))
+ fn new(lines: BufReader) -> Self {
+ Self(Mutex::new(LinesBytes(lines)))
}
- fn with_lock>) -> R>(&self, mut f: F) -> R {
+ fn with_lock>) -> R>(&self, mut f: F) -> R {
let mut lines = self.0.lock().unwrap();
f(&mut lines)
}
@@ -1211,7 +1336,12 @@ fn get_stat(metadata: std::fs::Metadata) -> FileInfo {
}
}
+#[cfg(test)]
mod test {
+ use std::io::{BufRead, BufReader};
+
+ use super::LinesBytes;
+
#[test]
fn safe_file_path_parse() {
use super::SafeFilePath;
@@ -1225,4 +1355,24 @@ mod test {
Ok(SafeFilePath::Url(_))
));
}
+
+ #[test]
+ fn test_lines_bytes() {
+ let base = String::from("line 1\nline2\nline 3\nline 4");
+ let bytes = base.as_bytes();
+
+ let string1 = base.lines().collect::();
+ let string2 = BufReader::new(bytes)
+ .lines()
+ .map_while(Result::ok)
+ .collect::();
+ let string3 = LinesBytes(BufReader::new(bytes))
+ .flatten()
+ .flat_map(String::from_utf8)
+ .collect::();
+
+ assert_eq!(string1, string2);
+ assert_eq!(string1, string3);
+ assert_eq!(string2, string3);
+ }
}
diff --git a/plugins/fs/src/file_path.rs b/plugins/fs/src/file_path.rs
index 9ff7a947..735fc105 100644
--- a/plugins/fs/src/file_path.rs
+++ b/plugins/fs/src/file_path.rs
@@ -138,7 +138,7 @@ impl<'de> serde::Deserialize<'de> for FilePath {
{
struct FilePathVisitor;
- impl<'de> serde::de::Visitor<'de> for FilePathVisitor {
+ impl serde::de::Visitor<'_> for FilePathVisitor {
type Value = FilePath;
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
@@ -169,7 +169,7 @@ impl<'de> serde::Deserialize<'de> for SafeFilePath {
{
struct SafeFilePathVisitor;
- impl<'de> serde::de::Visitor<'de> for SafeFilePathVisitor {
+ impl serde::de::Visitor<'_> for SafeFilePathVisitor {
type Value = SafeFilePath;
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
diff --git a/plugins/fs/src/lib.rs b/plugins/fs/src/lib.rs
index a1cf2766..731c7040 100644
--- a/plugins/fs/src/lib.rs
+++ b/plugins/fs/src/lib.rs
@@ -2,8 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
-//! [](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/fs)
-//!
//! Access the file system.
#![doc(
@@ -17,7 +15,7 @@ use serde::Deserialize;
use tauri::{
ipc::ScopeObject,
plugin::{Builder as PluginBuilder, TauriPlugin},
- utils::acl::Value,
+ utils::{acl::Value, config::FsScope},
AppHandle, DragDropEvent, Manager, RunEvent, Runtime, WindowEvent,
};
@@ -41,7 +39,6 @@ pub use desktop::Fs;
pub use mobile::Fs;
pub use error::Error;
-pub use scope::{Event as ScopeEvent, Scope};
pub use file_path::FilePath;
pub use file_path::SafeFilePath;
@@ -367,21 +364,26 @@ impl ScopeObject for scope::Entry {
}
}
+pub(crate) struct Scope {
+ pub(crate) scope: tauri::fs::Scope,
+ pub(crate) require_literal_leading_dot: Option,
+}
+
pub trait FsExt {
- fn fs_scope(&self) -> &Scope;
- fn try_fs_scope(&self) -> Option<&Scope>;
+ fn fs_scope(&self) -> tauri::fs::Scope;
+ fn try_fs_scope(&self) -> Option;
/// Cross platform file system APIs that also support manipulating Android files.
fn fs(&self) -> &Fs;
}
impl> FsExt for T {
- fn fs_scope(&self) -> &Scope {
- self.state::().inner()
+ fn fs_scope(&self) -> tauri::fs::Scope {
+ self.state::().scope.clone()
}
- fn try_fs_scope(&self) -> Option<&Scope> {
- self.try_state::().map(|s| s.inner())
+ fn try_fs_scope(&self) -> Option {
+ self.try_state::().map(|s| s.scope.clone())
}
fn fs(&self) -> &Fs {
@@ -415,17 +417,20 @@ pub fn init() -> TauriPlugin> {
commands::write_file,
commands::write_text_file,
commands::exists,
+ commands::size,
#[cfg(feature = "watch")]
watcher::watch,
#[cfg(feature = "watch")]
watcher::unwatch
])
.setup(|app, api| {
- let mut scope = Scope::default();
- scope.require_literal_leading_dot = api
- .config()
- .as_ref()
- .and_then(|c| c.require_literal_leading_dot);
+ let scope = Scope {
+ require_literal_leading_dot: api
+ .config()
+ .as_ref()
+ .and_then(|c| c.require_literal_leading_dot),
+ scope: tauri::fs::Scope::new(app, &FsScope::default())?,
+ };
#[cfg(target_os = "android")]
{
@@ -448,9 +453,9 @@ pub fn init() -> TauriPlugin> {
let scope = app.fs_scope();
for path in paths {
if path.is_file() {
- scope.allow_file(path);
+ let _ = scope.allow_file(path);
} else {
- scope.allow_directory(path, true);
+ let _ = scope.allow_directory(path, true);
}
}
}
diff --git a/plugins/fs/src/scope.rs b/plugins/fs/src/scope.rs
index e8361d51..7914706a 100644
--- a/plugins/fs/src/scope.rs
+++ b/plugins/fs/src/scope.rs
@@ -2,130 +2,18 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
-use std::{
- collections::HashMap,
- path::{Path, PathBuf},
- sync::{
- atomic::{AtomicU32, Ordering},
- Mutex,
- },
-};
+use std::path::PathBuf;
use serde::Deserialize;
-#[derive(Deserialize)]
-#[serde(untagged)]
-pub(crate) enum EntryRaw {
- Value(PathBuf),
- Object { path: PathBuf },
-}
-
#[derive(Debug)]
pub struct Entry {
pub path: Option,
}
-pub type EventId = u32;
-type EventListener = Box;
-
-/// Scope change event.
-#[derive(Debug, Clone)]
-pub enum Event {
- /// A path has been allowed.
- PathAllowed(PathBuf),
- /// A path has been forbidden.
- PathForbidden(PathBuf),
-}
-
-#[derive(Default)]
-pub struct Scope {
- pub(crate) allowed: Mutex>,
- pub(crate) denied: Mutex>,
- event_listeners: Mutex>,
- next_event_id: AtomicU32,
- pub(crate) require_literal_leading_dot: Option,
-}
-
-impl Scope {
- /// Extend the allowed patterns with the given directory.
- ///
- /// After this function has been called, the frontend will be able to use the Tauri API to read
- /// the directory and all of its files. If `recursive` is `true`, subdirectories will be accessible too.
- pub fn allow_directory>(&self, path: P, recursive: bool) {
- let path = path.as_ref();
-
- {
- let mut allowed = self.allowed.lock().unwrap();
- allowed.push(path.to_path_buf());
- allowed.push(path.join(if recursive { "**" } else { "*" }));
- }
-
- self.emit(Event::PathAllowed(path.to_path_buf()));
- }
-
- /// Extend the allowed patterns with the given file path.
- ///
- /// After this function has been called, the frontend will be able to use the Tauri API to read the contents of this file.
- pub fn allow_file>(&self, path: P) {
- let path = path.as_ref();
-
- self.allowed.lock().unwrap().push(path.to_path_buf());
-
- self.emit(Event::PathAllowed(path.to_path_buf()));
- }
-
- /// Set the given directory path to be forbidden by this scope.
- ///
- /// **Note:** this takes precedence over allowed paths, so its access gets denied **always**.
- pub fn forbid_directory>(&self, path: P, recursive: bool) {
- let path = path.as_ref();
-
- {
- let mut denied = self.denied.lock().unwrap();
- denied.push(path.to_path_buf());
- denied.push(path.join(if recursive { "**" } else { "*" }));
- }
-
- self.emit(Event::PathForbidden(path.to_path_buf()));
- }
-
- /// Set the given file path to be forbidden by this scope.
- ///
- /// **Note:** this takes precedence over allowed paths, so its access gets denied **always**.
- pub fn forbid_file>(&self, path: P) {
- let path = path.as_ref();
-
- self.denied.lock().unwrap().push(path.to_path_buf());
-
- self.emit(Event::PathForbidden(path.to_path_buf()));
- }
-
- /// List of allowed paths.
- pub fn allowed(&self) -> Vec {
- self.allowed.lock().unwrap().clone()
- }
-
- /// List of forbidden paths.
- pub fn forbidden(&self) -> Vec {
- self.denied.lock().unwrap().clone()
- }
-
- fn next_event_id(&self) -> u32 {
- self.next_event_id.fetch_add(1, Ordering::Relaxed)
- }
-
- fn emit(&self, event: Event) {
- let listeners = self.event_listeners.lock().unwrap();
- let handlers = listeners.values();
- for listener in handlers {
- listener(&event);
- }
- }
-
- /// Listen to an event on this scope.
- pub fn listen(&self, f: F) -> EventId {
- let id = self.next_event_id();
- self.event_listeners.lock().unwrap().insert(id, Box::new(f));
- id
- }
+#[derive(Deserialize)]
+#[serde(untagged)]
+pub(crate) enum EntryRaw {
+ Value(PathBuf),
+ Object { path: PathBuf },
}
diff --git a/plugins/fs/src/watcher.rs b/plugins/fs/src/watcher.rs
index 8bc65c5a..5a8c08bd 100644
--- a/plugins/fs/src/watcher.rs
+++ b/plugins/fs/src/watcher.rs
@@ -3,7 +3,7 @@
// SPDX-License-Identifier: MIT
use notify::{Config, Event, RecommendedWatcher, RecursiveMode, Watcher};
-use notify_debouncer_full::{new_debouncer, DebounceEventResult, Debouncer, FileIdMap};
+use notify_debouncer_full::{new_debouncer, DebounceEventResult, Debouncer, RecommendedCache};
use serde::Deserialize;
use tauri::{
ipc::{Channel, CommandScope, GlobalScope},
@@ -47,7 +47,7 @@ impl WatcherResource {
impl Resource for WatcherResource {}
enum WatcherKind {
- Debouncer(Debouncer),
+ Debouncer(Debouncer),
Watcher(RecommendedWatcher),
}
@@ -112,8 +112,7 @@ pub async fn watch(
let (tx, rx) = channel();
let mut debouncer = new_debouncer(Duration::from_millis(delay), None, tx)?;
for path in &resolved_paths {
- debouncer.watcher().watch(path.as_ref(), recursive_mode)?;
- debouncer.cache().add_root(path, recursive_mode);
+ debouncer.watch(path, recursive_mode)?;
}
watch_debounced(on_event, rx);
WatcherKind::Debouncer(debouncer)
@@ -121,7 +120,7 @@ pub async fn watch(
let (tx, rx) = channel();
let mut watcher = RecommendedWatcher::new(tx, Config::default())?;
for path in &resolved_paths {
- watcher.watch(path.as_ref(), recursive_mode)?;
+ watcher.watch(path, recursive_mode)?;
}
watch_raw(on_event, rx);
WatcherKind::Watcher(watcher)
@@ -141,14 +140,14 @@ pub async fn unwatch(webview: Webview, rid: ResourceId) -> Comman
match &mut watcher.kind {
WatcherKind::Debouncer(ref mut debouncer) => {
for path in &watcher.paths {
- debouncer.watcher().unwatch(path.as_ref()).map_err(|e| {
+ debouncer.unwatch(path).map_err(|e| {
format!("failed to unwatch path: {} with error: {e}", path.display())
})?;
}
}
WatcherKind::Watcher(ref mut w) => {
for path in &watcher.paths {
- w.unwatch(path.as_ref()).map_err(|e| {
+ w.unwatch(path).map_err(|e| {
format!("failed to unwatch path: {} with error: {e}", path.display())
})?;
}
diff --git a/plugins/geolocation/README.md b/plugins/geolocation/README.md
index 0557cc98..bf8e1741 100644
--- a/plugins/geolocation/README.md
+++ b/plugins/geolocation/README.md
@@ -81,7 +81,7 @@ The Google Play Store uses this property to decide whether it should show the ap
First you need to register the core plugin with Tauri:
-`src-tauri/src/main.rs`
+`src-tauri/src/lib.rs`
```rust
fn main() {
@@ -92,6 +92,20 @@ fn main() {
}
```
+Then, for instance, grant the plugin the permission to check or request permissions from the user and to read the device position
+
+`src-tauri/capabilities/default.json`
+
+```json
+ "permissions": [
+ "core:default",
+ "geolocation:allow-check-permissions",
+ "geolocation:allow-request-permissions",
+ "geolocation:allow-get-current-position",
+ "geolocation:allow-watch-position",
+ ]
+```
+
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
```javascript
@@ -100,7 +114,7 @@ import {
requestPermissions,
getCurrentPosition,
watchPosition
-} from '@tauri-apps/plugin-log'
+} from '@tauri-apps/plugin-geolocation'
let permissions = await checkPermissions()
if (
diff --git a/plugins/geolocation/api-iife.js b/plugins/geolocation/api-iife.js
index 912c073e..5dcae251 100644
--- a/plugins/geolocation/api-iife.js
+++ b/plugins/geolocation/api-iife.js
@@ -1 +1 @@
-if("__TAURI__"in window){var __TAURI_PLUGIN_GEOLOCATION__=function(t){"use strict";function e(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function n(t,e,n,i,o){if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}var i,o,s;"function"==typeof SuppressedError&&SuppressedError;class r{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,i.set(this,(()=>{})),o.set(this,0),s.set(this,{}),this.id=function(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((({message:t,id:r})=>{if(r===e(this,o,"f")){n(this,o,r+1),e(this,i,"f").call(this,t);const a=Object.keys(e(this,s,"f"));if(a.length>0){let t=r+1;for(const n of a.sort()){if(parseInt(n)!==t)break;{const o=e(this,s,"f")[n];delete e(this,s,"f")[n],e(this,i,"f").call(this,o),t+=1}}n(this,o,t)}}else e(this,s,"f")[r.toString()]=t}))}set onmessage(t){n(this,i,t)}get onmessage(){return e(this,i,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}async function a(t,e={},n){return window.__TAURI_INTERNALS__.invoke(t,e,n)}return i=new WeakMap,o=new WeakMap,s=new WeakMap,t.checkPermissions=async function(){return await async function(t){return a(`plugin:${t}|check_permissions`)}("geolocation")},t.clearWatch=async function(t){await a("plugin:geolocation|clear_watch",{channelId:t})},t.getCurrentPosition=async function(t){return await a("plugin:geolocation|get_current_position",{options:t})},t.requestPermissions=async function(t){return await a("plugin:geolocation|request_permissions",{permissions:t})},t.watchPosition=async function(t,e){const n=new r;return n.onmessage=t=>{"string"==typeof t?e(null,t):e(t)},await a("plugin:geolocation|watch_position",{options:t,channel:n}),n.id},t}({});Object.defineProperty(window.__TAURI__,"geolocation",{value:__TAURI_PLUGIN_GEOLOCATION__})}
+if("__TAURI__"in window){var __TAURI_PLUGIN_GEOLOCATION__=function(t){"use strict";function e(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function n(t,e,n,i,o){if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}var i,o,s;"function"==typeof SuppressedError&&SuppressedError;const r="__TAURI_TO_IPC_KEY__";class a{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,i.set(this,(()=>{})),o.set(this,0),s.set(this,{}),this.id=function(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((({message:t,id:r})=>{if(r===e(this,o,"f")){n(this,o,r+1),e(this,i,"f").call(this,t);const a=Object.keys(e(this,s,"f"));if(a.length>0){let t=r+1;for(const n of a.sort()){if(parseInt(n)!==t)break;{const o=e(this,s,"f")[n];delete e(this,s,"f")[n],e(this,i,"f").call(this,o),t+=1}}n(this,o,t)}}else e(this,s,"f")[r.toString()]=t}))}set onmessage(t){n(this,i,t)}get onmessage(){return e(this,i,"f")}[(i=new WeakMap,o=new WeakMap,s=new WeakMap,r)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[r]()}}async function c(t,e={},n){return window.__TAURI_INTERNALS__.invoke(t,e,n)}return t.checkPermissions=async function(){return await async function(t){return c(`plugin:${t}|check_permissions`)}("geolocation")},t.clearWatch=async function(t){await c("plugin:geolocation|clear_watch",{channelId:t})},t.getCurrentPosition=async function(t){return await c("plugin:geolocation|get_current_position",{options:t})},t.requestPermissions=async function(t){return await c("plugin:geolocation|request_permissions",{permissions:t})},t.watchPosition=async function(t,e){const n=new a;return n.onmessage=t=>{"string"==typeof t?e(null,t):e(t)},await c("plugin:geolocation|watch_position",{options:t,channel:n}),n.id},t}({});Object.defineProperty(window.__TAURI__,"geolocation",{value:__TAURI_PLUGIN_GEOLOCATION__})}
diff --git a/plugins/global-shortcut/README.md b/plugins/global-shortcut/README.md
index 12a9b08d..53e7b19f 100644
--- a/plugins/global-shortcut/README.md
+++ b/plugins/global-shortcut/README.md
@@ -55,7 +55,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-global-shortcut#v2
First you need to register the core plugin with Tauri:
-`src-tauri/src/main.rs`
+`src-tauri/src/lib.rs`
```rust
fn main() {
diff --git a/plugins/global-shortcut/api-iife.js b/plugins/global-shortcut/api-iife.js
index 67ec9e47..b78e4084 100644
--- a/plugins/global-shortcut/api-iife.js
+++ b/plugins/global-shortcut/api-iife.js
@@ -1 +1 @@
-if("__TAURI__"in window){var __TAURI_PLUGIN_GLOBAL_SHORTCUT__=function(t){"use strict";function e(t,e,r,s){if("a"===r&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?s:"a"===r?s.call(t):s?s.value:e.get(t)}function r(t,e,r,s,n){if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,r),r}var s,n,i;"function"==typeof SuppressedError&&SuppressedError;class o{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,s.set(this,(()=>{})),n.set(this,0),i.set(this,{}),this.id=function(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((({message:t,id:o})=>{if(o===e(this,n,"f")){r(this,n,o+1),e(this,s,"f").call(this,t);const a=Object.keys(e(this,i,"f"));if(a.length>0){let t=o+1;for(const r of a.sort()){if(parseInt(r)!==t)break;{const n=e(this,i,"f")[r];delete e(this,i,"f")[r],e(this,s,"f").call(this,n),t+=1}}r(this,n,t)}}else e(this,i,"f")[o.toString()]=t}))}set onmessage(t){r(this,s,t)}get onmessage(){return e(this,s,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}async function a(t,e={},r){return window.__TAURI_INTERNALS__.invoke(t,e,r)}return s=new WeakMap,n=new WeakMap,i=new WeakMap,t.isRegistered=async function(t){return await a("plugin:global-shortcut|is_registered",{shortcut:t})},t.register=async function(t,e){const r=new o;return r.onmessage=e,await a("plugin:global-shortcut|register",{shortcuts:Array.isArray(t)?t:[t],handler:r})},t.unregister=async function(t){return await a("plugin:global-shortcut|unregister",{shortcuts:Array.isArray(t)?t:[t]})},t.unregisterAll=async function(){return await a("plugin:global-shortcut|unregister_all",{})},t}({});Object.defineProperty(window.__TAURI__,"globalShortcut",{value:__TAURI_PLUGIN_GLOBAL_SHORTCUT__})}
+if("__TAURI__"in window){var __TAURI_PLUGIN_GLOBAL_SHORTCUT__=function(t){"use strict";function e(t,e,r,s){if("a"===r&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?s:"a"===r?s.call(t):s?s.value:e.get(t)}function r(t,e,r,s,n){if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,r),r}var s,n,i;"function"==typeof SuppressedError&&SuppressedError;const o="__TAURI_TO_IPC_KEY__";class a{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,s.set(this,(()=>{})),n.set(this,0),i.set(this,{}),this.id=function(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((({message:t,id:o})=>{if(o===e(this,n,"f")){r(this,n,o+1),e(this,s,"f").call(this,t);const a=Object.keys(e(this,i,"f"));if(a.length>0){let t=o+1;for(const r of a.sort()){if(parseInt(r)!==t)break;{const n=e(this,i,"f")[r];delete e(this,i,"f")[r],e(this,s,"f").call(this,n),t+=1}}r(this,n,t)}}else e(this,i,"f")[o.toString()]=t}))}set onmessage(t){r(this,s,t)}get onmessage(){return e(this,s,"f")}[(s=new WeakMap,n=new WeakMap,i=new WeakMap,o)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[o]()}}async function _(t,e={},r){return window.__TAURI_INTERNALS__.invoke(t,e,r)}return t.isRegistered=async function(t){return await _("plugin:global-shortcut|is_registered",{shortcut:t})},t.register=async function(t,e){const r=new a;return r.onmessage=e,await _("plugin:global-shortcut|register",{shortcuts:Array.isArray(t)?t:[t],handler:r})},t.unregister=async function(t){return await _("plugin:global-shortcut|unregister",{shortcuts:Array.isArray(t)?t:[t]})},t.unregisterAll=async function(){return await _("plugin:global-shortcut|unregister_all",{})},t}({});Object.defineProperty(window.__TAURI__,"globalShortcut",{value:__TAURI_PLUGIN_GLOBAL_SHORTCUT__})}
diff --git a/plugins/global-shortcut/src/lib.rs b/plugins/global-shortcut/src/lib.rs
index 5868ff9d..450bb598 100644
--- a/plugins/global-shortcut/src/lib.rs
+++ b/plugins/global-shortcut/src/lib.rs
@@ -2,8 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
-//! [](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/global-shortcut)
-//!
//! Register global shortcuts.
//!
//! - Supported platforms: Windows, Linux and macOS.
diff --git a/plugins/haptics/README.md b/plugins/haptics/README.md
index b96e267c..e5f0e697 100644
--- a/plugins/haptics/README.md
+++ b/plugins/haptics/README.md
@@ -58,7 +58,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-haptics#v2
First you need to register the core plugin with Tauri:
-`src-tauri/src/main.rs`
+`src-tauri/src/lib.rs`
```rust
fn main() {
diff --git a/plugins/http/CHANGELOG.md b/plugins/http/CHANGELOG.md
index e814ddd9..8b03f22d 100644
--- a/plugins/http/CHANGELOG.md
+++ b/plugins/http/CHANGELOG.md
@@ -1,5 +1,13 @@
# Changelog
+## \[2.0.4]
+
+- [`a3b553dd`](https://github.com/tauri-apps/plugins-workspace/commit/a3b553ddb403771aa699362c4e69a064b7731da5) ([#2079](https://github.com/tauri-apps/plugins-workspace/pull/2079) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Add tracing logs for requestes and responses behind `tracing` feature flag.
+
+### Dependencies
+
+- Upgraded to `fs@2.1.0`
+
## \[2.0.3]
### Dependencies
diff --git a/plugins/http/Cargo.toml b/plugins/http/Cargo.toml
index 8c1801a3..e4303f19 100644
--- a/plugins/http/Cargo.toml
+++ b/plugins/http/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "tauri-plugin-http"
-version = "2.0.3"
+version = "2.0.4"
description = "Access an HTTP client written in Rust."
edition = { workspace = true }
authors = { workspace = true }
@@ -34,13 +34,14 @@ serde_json = { workspace = true }
tauri = { workspace = true }
thiserror = { workspace = true }
tokio = { version = "1", features = ["sync", "macros"] }
-tauri-plugin-fs = { path = "../fs", version = "2.0.3" }
+tauri-plugin-fs = { path = "../fs", version = "2.1.0" }
urlpattern = "0.3"
regex = "1"
http = "1"
reqwest = { version = "0.12", default-features = false }
url = { workspace = true }
data-url = "0.3"
+tracing = { workspace = true, optional = true }
[features]
default = [
@@ -71,3 +72,4 @@ http2 = ["reqwest/http2"]
charset = ["reqwest/charset"]
macos-system-configuration = ["reqwest/macos-system-configuration"]
unsafe-headers = []
+tracing = ["dep:tracing"]
diff --git a/plugins/http/README.md b/plugins/http/README.md
index c3fe92c0..5c3cd9c2 100644
--- a/plugins/http/README.md
+++ b/plugins/http/README.md
@@ -54,7 +54,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-http#v2
First you need to register the core plugin with Tauri:
-`src-tauri/src/main.rs`
+`src-tauri/src/lib.rs`
```rust
fn main() {
diff --git a/plugins/http/src/commands.rs b/plugins/http/src/commands.rs
index 39a68973..03c84adf 100644
--- a/plugins/http/src/commands.rs
+++ b/plugins/http/src/commands.rs
@@ -191,6 +191,11 @@ pub async fn fetch(
let name = HeaderName::from_str(&h)?;
#[cfg(not(feature = "unsafe-headers"))]
if is_unsafe_header(&name) {
+ #[cfg(debug_assertions)]
+ {
+ eprintln!("[\x1b[33mWARNING\x1b[0m] Skipping {name} header as it is a forbidden header per fetch spec https://fetch.spec.whatwg.org/#terminology-headers");
+ eprintln!("[\x1b[33mWARNING\x1b[0m] if keeping the header is a desired behavior, you can enable `unsafe-headers` feature flag in your Cargo.toml");
+ }
continue;
}
@@ -278,6 +283,9 @@ pub async fn fetch(
request = request.headers(headers);
+ #[cfg(feature = "tracing")]
+ tracing::trace!("{:?}", request);
+
let fut = async move { request.send().await.map_err(Into::into) };
let mut resources_table = webview.resources_table();
let rid = resources_table.add_request(Box::pin(fut));
@@ -299,6 +307,9 @@ pub async fn fetch(
.header(header::CONTENT_TYPE, data_url.mime_type().to_string())
.body(reqwest::Body::from(body))?;
+ #[cfg(feature = "tracing")]
+ tracing::trace!("{:?}", response);
+
let fut = async move { Ok(reqwest::Response::from(response)) };
let mut resources_table = webview.resources_table();
let rid = resources_table.add_request(Box::pin(fut));
@@ -346,6 +357,9 @@ pub async fn fetch_send(
}
};
+ #[cfg(feature = "tracing")]
+ tracing::trace!("{:?}", res);
+
let status = res.status();
let url = res.url().to_string();
let mut headers = Vec::new();
diff --git a/plugins/http/src/lib.rs b/plugins/http/src/lib.rs
index cdffeb6e..d775760c 100644
--- a/plugins/http/src/lib.rs
+++ b/plugins/http/src/lib.rs
@@ -2,8 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
-//! [](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/http)
-//!
//! Access the HTTP client written in Rust.
pub use reqwest;
diff --git a/plugins/localhost/CHANGELOG.md b/plugins/localhost/CHANGELOG.md
index 3a2bf060..0b266925 100644
--- a/plugins/localhost/CHANGELOG.md
+++ b/plugins/localhost/CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## \[2.1.0]
+
+- [`3449dd5a`](https://github.com/tauri-apps/plugins-workspace/commit/3449dd5a8f6d12fee8d6389c034fe47e19d72bcd) ([#1982](https://github.com/tauri-apps/plugins-workspace/pull/1982) by [@arihav](https://github.com/tauri-apps/plugins-workspace/../../arihav)) Add custom host binding to allow external access
+
## \[2.0.1]
- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7.
diff --git a/plugins/localhost/Cargo.toml b/plugins/localhost/Cargo.toml
index 3d9460d0..2f0fcebd 100644
--- a/plugins/localhost/Cargo.toml
+++ b/plugins/localhost/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "tauri-plugin-localhost"
-version = "2.0.1"
+version = "2.1.0"
description = "Expose your apps assets through a localhost server instead of the default custom protocol."
authors = { workspace = true }
license = { workspace = true }
diff --git a/plugins/localhost/README.md b/plugins/localhost/README.md
index 4e23c038..dc0d98d2 100644
--- a/plugins/localhost/README.md
+++ b/plugins/localhost/README.md
@@ -38,7 +38,7 @@ tauri-plugin-localhost = { git = "https://github.com/tauri-apps/plugins-workspac
First you need to register the core plugin with Tauri:
-`src-tauri/src/main.rs`
+`src-tauri/src/lib.rs`
```rust
use tauri::{Manager, window::WindowBuilder, WindowUrl};
diff --git a/plugins/localhost/src/lib.rs b/plugins/localhost/src/lib.rs
index a0c4c794..5b00087f 100644
--- a/plugins/localhost/src/lib.rs
+++ b/plugins/localhost/src/lib.rs
@@ -2,8 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
-//! [](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/localhost)
-//!
//! Expose your apps assets through a localhost server instead of the default custom protocol.
//!
//! **Note: This plugins brings considerable security risks and you should only use it if you know what your are doing. If in doubt, use the default custom protocol implementation.**
@@ -46,6 +44,7 @@ type OnRequest = Option>;
pub struct Builder {
port: u16,
+ host: Option,
on_request: OnRequest,
}
@@ -53,10 +52,17 @@ impl Builder {
pub fn new(port: u16) -> Self {
Self {
port,
+ host: None,
on_request: None,
}
}
+ // Change the host the plugin binds to. Defaults to `localhost`.
+ pub fn host>(mut self, host: H) -> Self {
+ self.host = Some(host.into());
+ self
+ }
+
pub fn on_request(
mut self,
f: F,
@@ -67,6 +73,7 @@ impl Builder {
pub fn build(mut self) -> TauriPlugin {
let port = self.port;
+ let host = self.host.unwrap_or("localhost".to_string());
let on_request = self.on_request.take();
PluginBuilder::new("localhost")
@@ -74,7 +81,7 @@ impl Builder {
let asset_resolver = app.asset_resolver();
std::thread::spawn(move || {
let server =
- Server::http(format!("localhost:{port}")).expect("Unable to spawn server");
+ Server::http(format!("{host}:{port}")).expect("Unable to spawn server");
for req in server.incoming_requests() {
let path = req
.url()
diff --git a/plugins/log/CHANGELOG.md b/plugins/log/CHANGELOG.md
index f0177138..d9b56460 100644
--- a/plugins/log/CHANGELOG.md
+++ b/plugins/log/CHANGELOG.md
@@ -2,6 +2,14 @@
## \[2.0.1]
+- [`371a2f73`](https://github.com/tauri-apps/plugins-workspace/commit/371a2f7361e0b91cf66f1287ffb18b34414a6cb8) ([#2021](https://github.com/tauri-apps/plugins-workspace/pull/2021) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Make webview log target more consistent that it always starts with `webview`
+
+## \[2.0.2]
+
+- [`606fa08d`](https://github.com/tauri-apps/plugins-workspace/commit/606fa08dae1acd074b961fb360623f4c86f13ee8) ([#1997](https://github.com/tauri-apps/plugins-workspace/pull/1997) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) **Potentially breaking:** Updated `fern` from 0.6 to 0.7. This is technically a breaking change because `fern` is re-exported in `tauri-plugin-log`.
+
+## \[2.0.1]
+
- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7.
## \[2.0.0]
diff --git a/plugins/log/Cargo.toml b/plugins/log/Cargo.toml
index 4f7c34d4..89416ff1 100644
--- a/plugins/log/Cargo.toml
+++ b/plugins/log/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "tauri-plugin-log"
-version = "2.0.1"
+version = "2.0.3"
description = "Configurable logging for your Tauri app."
authors = { workspace = true }
license = { workspace = true }
@@ -27,12 +27,12 @@ tauri-plugin = { workspace = true, features = ["build"] }
serde = { workspace = true }
serde_json = { workspace = true }
tauri = { workspace = true }
+thiserror = { workspace = true }
serde_repr = "0.1"
byte-unit = "5"
log = { workspace = true, features = ["kv_unstable"] }
time = { version = "0.3", features = ["formatting", "local-offset"] }
-fern = "0.6"
-thiserror = "1"
+fern = "0.7"
[target."cfg(target_os = \"android\")".dependencies]
android_logger = "0.14"
diff --git a/plugins/log/README.md b/plugins/log/README.md
index 1748d0c0..09369173 100644
--- a/plugins/log/README.md
+++ b/plugins/log/README.md
@@ -56,7 +56,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-log#v2
First you need to register the core plugin with Tauri:
-`src-tauri/src/main.rs`
+`src-tauri/src/lib.rs`
```rust
use tauri_plugin_log::{Target, TargetKind};
diff --git a/plugins/log/api-iife.js b/plugins/log/api-iife.js
index 571b8566..66211751 100644
--- a/plugins/log/api-iife.js
+++ b/plugins/log/api-iife.js
@@ -1 +1 @@
-if("__TAURI__"in window){var __TAURI_PLUGIN_LOG__=function(e){"use strict";function n(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}async function r(e,n={},r){return window.__TAURI_INTERNALS__.invoke(e,n,r)}var a,t;async function o(e,a,t){const o={kind:"Any"};return r("plugin:event|listen",{event:e,target:o,handler:n(a)}).then((n=>async()=>async function(e,n){await r("plugin:event|unlisten",{event:e,eventId:n})}(e,n)))}async function i(e,n,a){const t=(new Error).stack?.split("\n").map((e=>e.split("@"))),o=t?.filter((([e,n])=>e.length>0&&"[native code]"!==n)),{file:i,line:c,keyValues:u}=a??{};let l=o?.[0]?.filter((e=>e.length>0)).join("@");"Error"===l&&(l="webview::unknown"),await r("plugin:log|log",{level:e,message:n,location:l,file:i,line:c,keyValues:u})}async function c(e){return await o("log://log",(n=>{const{level:r}=n.payload;let{message:a}=n.payload;a=a.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,""),e({message:a,level:r})}))}return"function"==typeof SuppressedError&&SuppressedError,function(e){e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_CREATED="tauri://window-created",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG_ENTER="tauri://drag-enter",e.DRAG_OVER="tauri://drag-over",e.DRAG_DROP="tauri://drag-drop",e.DRAG_LEAVE="tauri://drag-leave"}(a||(a={})),function(e){e[e.Trace=1]="Trace",e[e.Debug=2]="Debug",e[e.Info=3]="Info",e[e.Warn=4]="Warn",e[e.Error=5]="Error"}(t||(t={})),e.attachConsole=async function(){return await c((({level:e,message:n})=>{switch(e){case t.Trace:console.log(n);break;case t.Debug:console.debug(n);break;case t.Info:console.info(n);break;case t.Warn:console.warn(n);break;case t.Error:console.error(n);break;default:throw new Error(`unknown log level ${e}`)}}))},e.attachLogger=c,e.debug=async function(e,n){await i(t.Debug,e,n)},e.error=async function(e,n){await i(t.Error,e,n)},e.info=async function(e,n){await i(t.Info,e,n)},e.trace=async function(e,n){await i(t.Trace,e,n)},e.warn=async function(e,n){await i(t.Warn,e,n)},e}({});Object.defineProperty(window.__TAURI__,"log",{value:__TAURI_PLUGIN_LOG__})}
+if("__TAURI__"in window){var __TAURI_PLUGIN_LOG__=function(e){"use strict";function n(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}async function r(e,n={},r){return window.__TAURI_INTERNALS__.invoke(e,n,r)}var a,t;async function o(e,a,t){const o={kind:"Any"};return r("plugin:event|listen",{event:e,target:o,handler:n(a)}).then((n=>async()=>async function(e,n){await r("plugin:event|unlisten",{event:e,eventId:n})}(e,n)))}async function i(e,n,a){const t=function(e){if(e){if(!e.startsWith("Error")){const n=e.split("\n").map((e=>e.split("@"))).filter((([e,n])=>e.length>0&&"[native code]"!==n));return n[2]?.filter((e=>e.length>0)).join("@")}{const n=e.split("\n"),r=n[3]?.trim();if(!r)return;const a=/at\s+(?.*?)\s+\((?.*?):(?\d+):(?\d+)\)/,t=r.match(a);if(t){const{functionName:e,fileName:n,lineNumber:r,columnNumber:a}=t.groups;return`${e}@${n}:${r}:${a}`}{const e=/at\s+(?.*?):(?\d+):(?\d+)/,n=r.match(e);if(n){const{fileName:e,lineNumber:r,columnNumber:a}=n.groups;return`@${e}:${r}:${a}`}}}}}((new Error).stack),{file:o,line:i,keyValues:u}=a??{};await r("plugin:log|log",{level:e,message:n,location:t,file:o,line:i,keyValues:u})}async function u(e){return await o("log://log",(n=>{const{level:r}=n.payload;let{message:a}=n.payload;a=a.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,""),e({message:a,level:r})}))}return"function"==typeof SuppressedError&&SuppressedError,function(e){e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_CREATED="tauri://window-created",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG_ENTER="tauri://drag-enter",e.DRAG_OVER="tauri://drag-over",e.DRAG_DROP="tauri://drag-drop",e.DRAG_LEAVE="tauri://drag-leave"}(a||(a={})),function(e){e[e.Trace=1]="Trace",e[e.Debug=2]="Debug",e[e.Info=3]="Info",e[e.Warn=4]="Warn",e[e.Error=5]="Error"}(t||(t={})),e.attachConsole=async function(){return await u((({level:e,message:n})=>{switch(e){case t.Trace:console.log(n);break;case t.Debug:console.debug(n);break;case t.Info:console.info(n);break;case t.Warn:console.warn(n);break;case t.Error:console.error(n);break;default:throw new Error(`unknown log level ${e}`)}}))},e.attachLogger=u,e.debug=async function(e,n){await i(t.Debug,e,n)},e.error=async function(e,n){await i(t.Error,e,n)},e.info=async function(e,n){await i(t.Info,e,n)},e.trace=async function(e,n){await i(t.Trace,e,n)},e.warn=async function(e,n){await i(t.Warn,e,n)},e}({});Object.defineProperty(window.__TAURI__,"log",{value:__TAURI_PLUGIN_LOG__})}
diff --git a/plugins/log/guest-js/index.ts b/plugins/log/guest-js/index.ts
index bf9d7f98..5b097993 100644
--- a/plugins/log/guest-js/index.ts
+++ b/plugins/log/guest-js/index.ts
@@ -44,24 +44,81 @@ enum LogLevel {
Error
}
+function getCallerLocation(stack?: string) {
+ if (!stack) {
+ return
+ }
+
+ if (stack.startsWith('Error')) {
+ // Assume it's Chromium V8
+ //
+ // Error
+ // at baz (filename.js:10:15)
+ // at bar (filename.js:6:3)
+ // at foo (filename.js:2:3)
+ // at filename.js:13:1
+
+ const lines = stack.split('\n')
+ // Find the third line (caller's caller of the current location)
+ const callerLine = lines[3]?.trim()
+ if (!callerLine) {
+ return
+ }
+
+ const regex =
+ /at\s+(?.*?)\s+\((?.*?):(?\d+):(?\d+)\)/
+ const match = callerLine.match(regex)
+
+ if (match) {
+ const { functionName, fileName, lineNumber, columnNumber } =
+ match.groups as {
+ functionName: string
+ fileName: string
+ lineNumber: string
+ columnNumber: string
+ }
+ return `${functionName}@${fileName}:${lineNumber}:${columnNumber}`
+ } else {
+ // Handle cases where the regex does not match (e.g., last line without function name)
+ const regexNoFunction =
+ /at\s+(?.*?):(?\d+):(?\d+)/
+ const matchNoFunction = callerLine.match(regexNoFunction)
+ if (matchNoFunction) {
+ const { fileName, lineNumber, columnNumber } =
+ matchNoFunction.groups as {
+ fileName: string
+ lineNumber: string
+ columnNumber: string
+ }
+ return `@${fileName}:${lineNumber}:${columnNumber}`
+ }
+ }
+ } else {
+ // Assume it's Webkit JavaScriptCore, example:
+ //
+ // baz@filename.js:10:24
+ // bar@filename.js:6:6
+ // foo@filename.js:2:6
+ // global code@filename.js:13:4
+
+ const traces = stack.split('\n').map((line) => line.split('@'))
+ const filtered = traces.filter(([name, location]) => {
+ return name.length > 0 && location !== '[native code]'
+ })
+ // Find the third line (caller's caller of the current location)
+ return filtered[2]?.filter((v) => v.length > 0).join('@')
+ }
+}
+
async function log(
level: LogLevel,
message: string,
options?: LogOptions
): Promise {
- const traces = new Error().stack?.split('\n').map((line) => line.split('@'))
-
- const filtered = traces?.filter(([name, location]) => {
- return name.length > 0 && location !== '[native code]'
- })
+ const location = getCallerLocation(new Error().stack)
const { file, line, keyValues } = options ?? {}
- let location = filtered?.[0]?.filter((v) => v.length > 0).join('@')
- if (location === 'Error') {
- location = 'webview::unknown'
- }
-
await invoke('plugin:log|log', {
level,
message,
diff --git a/plugins/log/package.json b/plugins/log/package.json
index fd021701..d2cecb03 100644
--- a/plugins/log/package.json
+++ b/plugins/log/package.json
@@ -1,6 +1,6 @@
{
"name": "@tauri-apps/plugin-log",
- "version": "2.0.0",
+ "version": "2.0.1",
"description": "Configurable logging for your Tauri app.",
"license": "MIT OR Apache-2.0",
"authors": [
diff --git a/plugins/log/src/lib.rs b/plugins/log/src/lib.rs
index 98035e4e..6b07c9d2 100644
--- a/plugins/log/src/lib.rs
+++ b/plugins/log/src/lib.rs
@@ -2,8 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
-//! [](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/log)
-//!
//! Logging for Tauri applications.
#![doc(
@@ -33,7 +31,7 @@ use tauri::{AppHandle, Emitter};
pub use fern;
use time::OffsetDateTime;
-pub const WEBVIEW_TARGET: &str = "Webview";
+pub const WEBVIEW_TARGET: &str = "webview";
#[cfg(target_os = "ios")]
mod ios {
@@ -230,22 +228,16 @@ fn log(
line: Option,
key_values: Option>,
) {
- let location = location.unwrap_or("webview");
-
let level = log::Level::from(level);
- let metadata = log::MetadataBuilder::new()
- .level(level)
- .target(WEBVIEW_TARGET)
- .build();
+ let target = if let Some(location) = location {
+ format!("{WEBVIEW_TARGET}:{location}")
+ } else {
+ WEBVIEW_TARGET.to_string()
+ };
let mut builder = RecordBuilder::new();
- builder
- .level(level)
- .metadata(metadata)
- .target(location)
- .file(file)
- .line(line);
+ builder.level(level).target(&target).file(file).line(line);
let key_values = key_values.unwrap_or_default();
let mut kv = HashMap::new();
@@ -380,8 +372,8 @@ impl Builder {
/// .clear_targets()
/// .targets([
/// Target::new(TargetKind::Webview),
- /// Target::new(TargetKind::LogDir { file_name: Some("webview".into()) }).filter(|metadata| metadata.target() == WEBVIEW_TARGET),
- /// Target::new(TargetKind::LogDir { file_name: Some("rust".into()) }).filter(|metadata| metadata.target() != WEBVIEW_TARGET),
+ /// Target::new(TargetKind::LogDir { file_name: Some("webview".into()) }).filter(|metadata| metadata.target().starts_with(WEBVIEW_TARGET)),
+ /// Target::new(TargetKind::LogDir { file_name: Some("rust".into()) }).filter(|metadata| !metadata.target().starts_with(WEBVIEW_TARGET)),
/// ]);
/// ```
pub fn targets(mut self, targets: impl IntoIterator) -> Self {
diff --git a/plugins/nfc/README.md b/plugins/nfc/README.md
index e8a9e156..1f8ceb6b 100644
--- a/plugins/nfc/README.md
+++ b/plugins/nfc/README.md
@@ -56,7 +56,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-nfc#v2
First you need to register the core plugin with Tauri:
-`src-tauri/src/main.rs`
+`src-tauri/src/lib.rs`
```rust
fn main() {
diff --git a/plugins/notification/Cargo.toml b/plugins/notification/Cargo.toml
index 02e5cce8..a4a5a2d2 100644
--- a/plugins/notification/Cargo.toml
+++ b/plugins/notification/Cargo.toml
@@ -15,7 +15,7 @@ rustdoc-args = ["--cfg", "docsrs"]
targets = ["x86_64-unknown-linux-gnu", "x86_64-linux-android"]
[package.metadata.platforms.support]
-windows = { level = "full", notes = "" }
+windows = { level = "full", notes = "Only works for installed apps. Shows powershell name & icon in development." }
linux = { level = "full", notes = "" }
macos = { level = "full", notes = "" }
android = { level = "full", notes = "" }
diff --git a/plugins/notification/README.md b/plugins/notification/README.md
index e75ce540..04632493 100644
--- a/plugins/notification/README.md
+++ b/plugins/notification/README.md
@@ -54,7 +54,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-notification#v2
First you need to register the core plugin with Tauri:
-`src-tauri/src/main.rs`
+`src-tauri/src/lib.rs`
```rust
fn main() {
diff --git a/plugins/notification/api-iife.js b/plugins/notification/api-iife.js
index 1f961120..0d33ccac 100644
--- a/plugins/notification/api-iife.js
+++ b/plugins/notification/api-iife.js
@@ -1 +1 @@
-if("__TAURI__"in window){var __TAURI_PLUGIN_NOTIFICATION__=function(i){"use strict";function t(i,t,n,e){if("a"===n&&!e)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?i!==t||!e:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?e:"a"===n?e.call(i):e?e.value:t.get(i)}function n(i,t,n,e,o){if("function"==typeof t?i!==t||!o:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(i,n),n}var e,o,a,r,c,s;"function"==typeof SuppressedError&&SuppressedError;class l{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,e.set(this,(()=>{})),o.set(this,0),a.set(this,{}),this.id=function(i,t=!1){return window.__TAURI_INTERNALS__.transformCallback(i,t)}((({message:i,id:r})=>{if(r===t(this,o,"f")){n(this,o,r+1),t(this,e,"f").call(this,i);const c=Object.keys(t(this,a,"f"));if(c.length>0){let i=r+1;for(const n of c.sort()){if(parseInt(n)!==i)break;{const o=t(this,a,"f")[n];delete t(this,a,"f")[n],t(this,e,"f").call(this,o),i+=1}}n(this,o,i)}}else t(this,a,"f")[r.toString()]=i}))}set onmessage(i){n(this,e,i)}get onmessage(){return t(this,e,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}e=new WeakMap,o=new WeakMap,a=new WeakMap;class u{constructor(i,t,n){this.plugin=i,this.event=t,this.channelId=n}async unregister(){return d(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function f(i,t,n){const e=new l;return e.onmessage=n,d(`plugin:${i}|register_listener`,{event:t,handler:e}).then((()=>new u(i,t,e.id)))}async function d(i,t={},n){return window.__TAURI_INTERNALS__.invoke(i,t,n)}i.ScheduleEvery=void 0,(r=i.ScheduleEvery||(i.ScheduleEvery={})).Year="year",r.Month="month",r.TwoWeeks="twoWeeks",r.Week="week",r.Day="day",r.Hour="hour",r.Minute="minute",r.Second="second";return i.Importance=void 0,(c=i.Importance||(i.Importance={}))[c.None=0]="None",c[c.Min=1]="Min",c[c.Low=2]="Low",c[c.Default=3]="Default",c[c.High=4]="High",i.Visibility=void 0,(s=i.Visibility||(i.Visibility={}))[s.Secret=-1]="Secret",s[s.Private=0]="Private",s[s.Public=1]="Public",i.Schedule=class{static at(i,t=!1,n=!1){return{at:{date:i,repeating:t,allowWhileIdle:n},interval:void 0,every:void 0}}static interval(i,t=!1){return{at:void 0,interval:{interval:i,allowWhileIdle:t},every:void 0}}static every(i,t,n=!1){return{at:void 0,interval:void 0,every:{interval:i,count:t,allowWhileIdle:n}}}},i.active=async function(){return await d("plugin:notification|get_active")},i.cancel=async function(i){await d("plugin:notification|cancel",{notifications:i})},i.cancelAll=async function(){await d("plugin:notification|cancel")},i.channels=async function(){return await d("plugin:notification|listChannels")},i.createChannel=async function(i){await d("plugin:notification|create_channel",{...i})},i.isPermissionGranted=async function(){return"default"!==window.Notification.permission?await Promise.resolve("granted"===window.Notification.permission):await d("plugin:notification|is_permission_granted")},i.onAction=async function(i){return await f("notification","actionPerformed",i)},i.onNotificationReceived=async function(i){return await f("notification","notification",i)},i.pending=async function(){return await d("plugin:notification|get_pending")},i.registerActionTypes=async function(i){await d("plugin:notification|register_action_types",{types:i})},i.removeActive=async function(i){await d("plugin:notification|remove_active",{notifications:i})},i.removeAllActive=async function(){await d("plugin:notification|remove_active")},i.removeChannel=async function(i){await d("plugin:notification|delete_channel",{id:i})},i.requestPermission=async function(){return await window.Notification.requestPermission()},i.sendNotification=function(i){"string"==typeof i?new window.Notification(i):new window.Notification(i.title,i)},i}({});Object.defineProperty(window.__TAURI__,"notification",{value:__TAURI_PLUGIN_NOTIFICATION__})}
+if("__TAURI__"in window){var __TAURI_PLUGIN_NOTIFICATION__=function(i){"use strict";function t(i,t,n,e){if("a"===n&&!e)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?i!==t||!e:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?e:"a"===n?e.call(i):e?e.value:t.get(i)}function n(i,t,n,e,o){if("function"==typeof t?i!==t||!o:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(i,n),n}var e,o,a;"function"==typeof SuppressedError&&SuppressedError;const r="__TAURI_TO_IPC_KEY__";class c{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,e.set(this,(()=>{})),o.set(this,0),a.set(this,{}),this.id=function(i,t=!1){return window.__TAURI_INTERNALS__.transformCallback(i,t)}((({message:i,id:r})=>{if(r===t(this,o,"f")){n(this,o,r+1),t(this,e,"f").call(this,i);const c=Object.keys(t(this,a,"f"));if(c.length>0){let i=r+1;for(const n of c.sort()){if(parseInt(n)!==i)break;{const o=t(this,a,"f")[n];delete t(this,a,"f")[n],t(this,e,"f").call(this,o),i+=1}}n(this,o,i)}}else t(this,a,"f")[r.toString()]=i}))}set onmessage(i){n(this,e,i)}get onmessage(){return t(this,e,"f")}[(e=new WeakMap,o=new WeakMap,a=new WeakMap,r)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[r]()}}class s{constructor(i,t,n){this.plugin=i,this.event=t,this.channelId=n}async unregister(){return u(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function l(i,t,n){const e=new c;return e.onmessage=n,u(`plugin:${i}|registerListener`,{event:t,handler:e}).then((()=>new s(i,t,e.id)))}async function u(i,t={},n){return window.__TAURI_INTERNALS__.invoke(i,t,n)}var f,d,w;i.ScheduleEvery=void 0,(f=i.ScheduleEvery||(i.ScheduleEvery={})).Year="year",f.Month="month",f.TwoWeeks="twoWeeks",f.Week="week",f.Day="day",f.Hour="hour",f.Minute="minute",f.Second="second";return i.Importance=void 0,(d=i.Importance||(i.Importance={}))[d.None=0]="None",d[d.Min=1]="Min",d[d.Low=2]="Low",d[d.Default=3]="Default",d[d.High=4]="High",i.Visibility=void 0,(w=i.Visibility||(i.Visibility={}))[w.Secret=-1]="Secret",w[w.Private=0]="Private",w[w.Public=1]="Public",i.Schedule=class{static at(i,t=!1,n=!1){return{at:{date:i,repeating:t,allowWhileIdle:n},interval:void 0,every:void 0}}static interval(i,t=!1){return{at:void 0,interval:{interval:i,allowWhileIdle:t},every:void 0}}static every(i,t,n=!1){return{at:void 0,interval:void 0,every:{interval:i,count:t,allowWhileIdle:n}}}},i.active=async function(){return await u("plugin:notification|get_active")},i.cancel=async function(i){await u("plugin:notification|cancel",{notifications:i})},i.cancelAll=async function(){await u("plugin:notification|cancel")},i.channels=async function(){return await u("plugin:notification|listChannels")},i.createChannel=async function(i){await u("plugin:notification|create_channel",{...i})},i.isPermissionGranted=async function(){return"default"!==window.Notification.permission?await Promise.resolve("granted"===window.Notification.permission):await u("plugin:notification|is_permission_granted")},i.onAction=async function(i){return await l("notification","actionPerformed",i)},i.onNotificationReceived=async function(i){return await l("notification","notification",i)},i.pending=async function(){return await u("plugin:notification|get_pending")},i.registerActionTypes=async function(i){await u("plugin:notification|register_action_types",{types:i})},i.removeActive=async function(i){await u("plugin:notification|remove_active",{notifications:i})},i.removeAllActive=async function(){await u("plugin:notification|remove_active")},i.removeChannel=async function(i){await u("plugin:notification|delete_channel",{id:i})},i.requestPermission=async function(){return await window.Notification.requestPermission()},i.sendNotification=function(i){"string"==typeof i?new window.Notification(i):new window.Notification(i.title,i)},i}({});Object.defineProperty(window.__TAURI__,"notification",{value:__TAURI_PLUGIN_NOTIFICATION__})}
diff --git a/plugins/notification/src/lib.rs b/plugins/notification/src/lib.rs
index aa15cc93..5cc30319 100644
--- a/plugins/notification/src/lib.rs
+++ b/plugins/notification/src/lib.rs
@@ -2,8 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
-//! [](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/notification)
-//!
//! Send message notifications (brief auto-expiring OS window element) to your user. Can also be used with the Notification Web API.
#![doc(
diff --git a/plugins/opener/CHANGELOG.md b/plugins/opener/CHANGELOG.md
new file mode 100644
index 00000000..ab348e4f
--- /dev/null
+++ b/plugins/opener/CHANGELOG.md
@@ -0,0 +1,5 @@
+# Changelog
+
+## \[2.0.0]
+
+- [`383e636a`](https://github.com/tauri-apps/plugins-workspace/commit/383e636a8e595aec1300999a8aeb7d9bf8c14632) ([#2019](https://github.com/tauri-apps/plugins-workspace/pull/2019) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Initial Release
diff --git a/plugins/opener/Cargo.toml b/plugins/opener/Cargo.toml
new file mode 100644
index 00000000..ab690df6
--- /dev/null
+++ b/plugins/opener/Cargo.toml
@@ -0,0 +1,65 @@
+[package]
+name = "tauri-plugin-opener"
+version = "2.0.0"
+description = "Open files and URLs using their default application."
+edition = { workspace = true }
+authors = { workspace = true }
+license = { workspace = true }
+repository = { workspace = true }
+links = "tauri-plugin-opener"
+
+[package.metadata.docs.rs]
+rustc-args = ["--cfg", "docsrs"]
+rustdoc-args = ["--cfg", "docsrs"]
+
+# Platforms supported by the plugin
+# Support levels are "full", "partial", "none", "unknown"
+# Details of the support level are left to plugin maintainer
+[package.metadata.platforms]
+windows = { level = "full", notes = "" }
+linux = { level = "full", notes = "" }
+macos = { level = "full", notes = "" }
+android = { level = "partial", notes = "Only allows to open URLs via `open`" }
+ios = { level = "partial", notes = "Only allows to open URLs via `open`" }
+
+
+[build-dependencies]
+tauri-plugin = { workspace = true, features = ["build"] }
+schemars = { workspace = true }
+serde = { workspace = true }
+
+[dependencies]
+serde = { workspace = true }
+serde_json = { workspace = true }
+tauri = { workspace = true }
+thiserror = { workspace = true }
+open = { version = "5", features = ["shellexecute-on-windows"] }
+glob = { workspace = true }
+
+[target."cfg(windows)".dependencies]
+dunce = { workspace = true }
+
+[target."cfg(windows)".dependencies.windows]
+version = "0.58"
+features = [
+ "Win32_Foundation",
+ "Win32_UI_Shell_Common",
+ "Win32_UI_WindowsAndMessaging",
+ "Win32_System_Com",
+ "Win32_System_Registry",
+]
+
+[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"netbsd\", target_os = \"openbsd\"))".dependencies]
+zbus = { workspace = true }
+url = { workspace = true }
+
+[target."cfg(target_os = \"macos\")".dependencies.objc2-app-kit]
+version = "0.2"
+features = ["NSWorkspace"]
+
+[target."cfg(target_os = \"macos\")".dependencies.objc2-foundation]
+version = "0.2"
+features = ["NSURL", "NSArray", "NSString"]
+
+[target.'cfg(target_os = "ios")'.dependencies]
+tauri = { workspace = true, features = ["wry"] }
diff --git a/plugins/opener/LICENSE.spdx b/plugins/opener/LICENSE.spdx
new file mode 100644
index 00000000..cdd0df5a
--- /dev/null
+++ b/plugins/opener/LICENSE.spdx
@@ -0,0 +1,20 @@
+SPDXVersion: SPDX-2.1
+DataLicense: CC0-1.0
+PackageName: tauri
+DataFormat: SPDXRef-1
+PackageSupplier: Organization: The Tauri Programme in the Commons Conservancy
+PackageHomePage: https://tauri.app
+PackageLicenseDeclared: Apache-2.0
+PackageLicenseDeclared: MIT
+PackageCopyrightText: 2019-2022, The Tauri Programme in the Commons Conservancy
+PackageSummary: Tauri is a rust project that enables developers to make secure
+and small desktop applications using a web frontend.
+
+PackageComment: The package includes the following libraries; see
+Relationship information.
+
+Created: 2019-05-20T09:00:00Z
+PackageDownloadLocation: git://github.com/tauri-apps/tauri
+PackageDownloadLocation: git+https://github.com/tauri-apps/tauri.git
+PackageDownloadLocation: git+ssh://github.com/tauri-apps/tauri.git
+Creator: Person: Daniel Thompson-Yvetot
\ No newline at end of file
diff --git a/plugins/opener/LICENSE_APACHE-2.0 b/plugins/opener/LICENSE_APACHE-2.0
new file mode 100644
index 00000000..4947287f
--- /dev/null
+++ b/plugins/opener/LICENSE_APACHE-2.0
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
\ No newline at end of file
diff --git a/plugins/opener/LICENSE_MIT b/plugins/opener/LICENSE_MIT
new file mode 100644
index 00000000..4d754725
--- /dev/null
+++ b/plugins/opener/LICENSE_MIT
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2017 - Present Tauri Apps Contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/plugins/opener/README.md b/plugins/opener/README.md
new file mode 100644
index 00000000..82d0fea1
--- /dev/null
+++ b/plugins/opener/README.md
@@ -0,0 +1,100 @@
+
+
+
+
+| Platform | Supported |
+| -------- | --------- |
+| Linux | ✓ |
+| Windows | ✓ |
+| macOS | ✓ |
+| Android | ? |
+| iOS | ? |
+
+## Install
+
+_This plugin requires a Rust version of at least **1.77.2**_
+
+There are three general methods of installation that we can recommend.
+
+1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
+2. Pull sources directly from Github using git tags / revision hashes (most secure)
+3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
+
+Install the Core plugin by adding the following to your `Cargo.toml` file:
+
+`src-tauri/Cargo.toml`
+
+```toml
+[dependencies]
+tauri-plugin-opener = "2.0.0"
+# alternatively with Git:
+tauri-plugin-opener = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
+```
+
+You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
+
+> 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-opener
+# or
+npm add @tauri-apps/plugin-opener
+# or
+yarn add @tauri-apps/plugin-opener
+
+# alternatively with Git:
+pnpm add https://github.com/tauri-apps/tauri-plugin-opener#v2
+# or
+npm add https://github.com/tauri-apps/tauri-plugin-opener#v2
+# or
+yarn add https://github.com/tauri-apps/tauri-plugin-opener#v2
+```
+
+## Usage
+
+First you need to register the core plugin with Tauri:
+
+`src-tauri/src/lib.rs`
+
+```rust
+fn main() {
+ tauri::Builder::default()
+ .plugin(tauri_plugin_opener::init())
+ .run(tauri::generate_context!())
+ .expect("error while running tauri application");
+}
+```
+
+Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
+
+```javascript
+
+```
+
+## Contributing
+
+PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
+
+## Partners
+
+
+
+This enables opening `mailto:`, `tel:`, `https://` and `http://` urls using their default application.
+
+
+
+
+
+
+
+`opener:allow-open-path`
+
+
+
+
+Enables the open_path command without any pre-configured scope.
+
+
+
+
+
+
+
+`opener:deny-open-path`
+
+
+
+
+Denies the open_path command without any pre-configured scope.
+
+
+
+
+
+
+
+`opener:allow-open-url`
+
+
+
+
+Enables the open_url command without any pre-configured scope.
+
+
+
+
+
+
+
+`opener:deny-open-url`
+
+
+
+
+Denies the open_url command without any pre-configured scope.
+
+
+
+
+
+
+
+`opener:allow-reveal-item-in-dir`
+
+
+
+
+Enables the reveal_item_in_dir command without any pre-configured scope.
+
+
+
+
+
+
+
+`opener:deny-reveal-item-in-dir`
+
+
+
+
+Denies the reveal_item_in_dir command without any pre-configured scope.
+
+
+
+
diff --git a/plugins/opener/permissions/default.toml b/plugins/opener/permissions/default.toml
new file mode 100644
index 00000000..846d6e51
--- /dev/null
+++ b/plugins/opener/permissions/default.toml
@@ -0,0 +1,10 @@
+"$schema" = "schemas/schema.json"
+
+[default]
+description = """This permission set allows opening `mailto:`, `tel:`, `https://` and `http://` urls using their default application
+as well as reveal file in directories using default file explorer"""
+permissions = [
+ "allow-open-url",
+ "allow-reveal-item-in-dir",
+ "allow-default-urls",
+]
diff --git a/plugins/opener/permissions/schemas/schema.json b/plugins/opener/permissions/schemas/schema.json
new file mode 100644
index 00000000..b958ac63
--- /dev/null
+++ b/plugins/opener/permissions/schemas/schema.json
@@ -0,0 +1,340 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "PermissionFile",
+ "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.",
+ "type": "object",
+ "properties": {
+ "default": {
+ "description": "The default permission set for the plugin",
+ "anyOf": [
+ {
+ "$ref": "#/definitions/DefaultPermission"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "set": {
+ "description": "A list of permissions sets defined",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/PermissionSet"
+ }
+ },
+ "permission": {
+ "description": "A list of inlined permissions",
+ "default": [],
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Permission"
+ }
+ }
+ },
+ "definitions": {
+ "DefaultPermission": {
+ "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.",
+ "type": "object",
+ "required": [
+ "permissions"
+ ],
+ "properties": {
+ "version": {
+ "description": "The version of the permission.",
+ "type": [
+ "integer",
+ "null"
+ ],
+ "format": "uint64",
+ "minimum": 1.0
+ },
+ "description": {
+ "description": "Human-readable description of what the permission does. Tauri convention is to use
headings in markdown content for Tauri documentation generation purposes.",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "permissions": {
+ "description": "All permissions this set contains.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "PermissionSet": {
+ "description": "A set of direct permissions grouped together under a new name.",
+ "type": "object",
+ "required": [
+ "description",
+ "identifier",
+ "permissions"
+ ],
+ "properties": {
+ "identifier": {
+ "description": "A unique identifier for the permission.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Human-readable description of what the permission does.",
+ "type": "string"
+ },
+ "permissions": {
+ "description": "All permissions this set contains.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/PermissionKind"
+ }
+ }
+ }
+ },
+ "Permission": {
+ "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.",
+ "type": "object",
+ "required": [
+ "identifier"
+ ],
+ "properties": {
+ "version": {
+ "description": "The version of the permission.",
+ "type": [
+ "integer",
+ "null"
+ ],
+ "format": "uint64",
+ "minimum": 1.0
+ },
+ "identifier": {
+ "description": "A unique identifier for the permission.",
+ "type": "string"
+ },
+ "description": {
+ "description": "Human-readable description of what the permission does. Tauri internal convention is to use