feat: add tauri-plugin-opener (#2019)

This commit is contained in:
Amr Bashir
2024-11-20 00:50:02 +02:00
committed by GitHub
parent 1051db406a
commit 383e636a8e
61 changed files with 2346 additions and 7 deletions
+3 -1
View File
@@ -11,8 +11,9 @@ use tauri::{
Manager, Runtime, State, Window,
};
#[allow(deprecated)]
use crate::open::Program;
use crate::{
open::Program,
process::{CommandEvent, TerminatedPayload},
scope::ExecuteArgs,
Shell,
@@ -302,6 +303,7 @@ pub fn kill<R: Runtime>(
Ok(())
}
#[allow(deprecated)]
#[tauri::command]
pub async fn open<R: Runtime>(
_window: Window<R>,
+5
View File
@@ -26,6 +26,8 @@ use tauri::{
mod commands;
mod config;
mod error;
#[deprecated(since = "2.1.0", note = "Use tauri-plugin-opener instead.")]
#[allow(deprecated)]
pub mod open;
pub mod process;
mod scope;
@@ -70,6 +72,8 @@ impl<R: Runtime> Shell<R> {
///
/// See [`crate::open::open`] for how it handles security-related measures.
#[cfg(desktop)]
#[deprecated(since = "2.1.0", note = "Use tauri-plugin-opener instead.")]
#[allow(deprecated)]
pub fn open(&self, path: impl Into<String>, with: Option<open::Program>) -> Result<()> {
open::open(&self.open_scope, path.into(), with).map_err(Into::into)
}
@@ -78,6 +82,7 @@ impl<R: Runtime> Shell<R> {
///
/// See [`crate::open::open`] for how it handles security-related measures.
#[cfg(mobile)]
#[deprecated(since = "2.1.0", note = "Use tauri-plugin-opener instead.")]
pub fn open(&self, path: impl Into<String>, _with: Option<open::Program>) -> Result<()> {
self.mobile_plugin_handle
.run_mobile_plugin("open", path.into())
+2
View File
@@ -10,6 +10,7 @@ use crate::scope::OpenScope;
use std::str::FromStr;
/// Program to use on the [`open()`] call.
#[deprecated(since = "2.1.0", note = "Use tauri-plugin-opener instead.")]
pub enum Program {
/// Use the `open` program.
Open,
@@ -117,6 +118,7 @@ impl Program {
/// Ok(())
/// });
/// ```
#[deprecated(since = "2.1.0", note = "Use tauri-plugin-opener instead.")]
pub fn open<P: AsRef<str>>(scope: &OpenScope, path: P, with: Option<Program>) -> crate::Result<()> {
scope.open(path.as_ref(), with).map_err(Into::into)
}
+2
View File
@@ -4,6 +4,7 @@
use std::sync::Arc;
#[allow(deprecated)]
use crate::open::Program;
use crate::process::Command;
@@ -201,6 +202,7 @@ impl OpenScope {
///
/// The path is validated against the `plugins > shell > open` validation regex, which
/// defaults to `^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+`.
#[allow(deprecated)]
pub fn open(&self, path: &str, with: Option<Program>) -> Result<(), Error> {
// ensure we pass validation if the configuration has one
if let Some(regex) = &self.open {