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

Committed via a GitHub action: https://github.com/tauri-apps/plugins-workspace/actions/runs/11923190674

Co-authored-by: amrbashir <amrbashir@users.noreply.github.com>
This commit is contained in:
Amr Bashir
2024-11-19 22:51:15 +00:00
committed by tauri-bot
parent 32fdfda0c8
commit 2fbce7af66
5 changed files with 13 additions and 1 deletions

View File

@@ -182,6 +182,7 @@ fn main() {
// creates a cfg alias if `has_feature` is true.
// `alias` must be a snake case string.
fn alias(alias: &str, has_feature: bool) {
println!("cargo:rustc-check-cfg=cfg({alias})");
if has_feature {
println!("cargo:rustc-cfg={alias}");
}

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>,

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())

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)
}

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 {