mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-22 21:30:44 +02:00
refactor(shell)!: remove deprecated open API (#3604)
* refactor(shell)!: remove deprecated open API `open` has been deprecated since 2.1.0 in favor of tauri-plugin-opener. This removes: - the `open` command and its `allow-open`/`deny-open` permissions (`shell:default` now grants nothing) - the `plugins > shell > open` configuration; `init()` returns `TauriPlugin<R>` again - `Shell::open`, the `tauri_plugin_shell::open` module and `Error::UnknownProgramName` - the `open` JavaScript function - the Android and iOS plugins, since `open` was their only command * chore(examples): drop the now empty shell:default permission set --------- Co-authored-by: Lucas Nogueira <lucas@crabnebula.dev>
This commit is contained in:
co-authored by
Lucas Nogueira
parent
6a12f7c80a
commit
152ff5bb6d
@@ -4,18 +4,14 @@
|
||||
|
||||
/**
|
||||
* Access the system shell.
|
||||
* Allows you to spawn child processes and manage files and URLs using their default application.
|
||||
* Allows you to spawn child processes.
|
||||
*
|
||||
* To open files and URLs with their default application, use `@tauri-apps/plugin-opener`.
|
||||
*
|
||||
* ## Security
|
||||
*
|
||||
* This API has a scope configuration that forces you to restrict the programs and arguments that can be used.
|
||||
*
|
||||
* ### Restricting access to the {@link open | `open`} API
|
||||
*
|
||||
* On the configuration object, `open: true` means that the {@link open} API can be used with any URL,
|
||||
* as the argument is validated with the `^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+` regex.
|
||||
* You can change that regex by changing the boolean value to a string, e.g. `open: ^https://github.com/`.
|
||||
*
|
||||
* ### Restricting access to the {@link Command | `Command`} APIs
|
||||
*
|
||||
* The plugin permissions object has a `scope` field that defines an array of CLIs that can be used.
|
||||
@@ -572,40 +568,7 @@ type CommandEvent<O extends IOPayload> =
|
||||
| Event<'Terminated', TerminatedPayload>
|
||||
| Event<'Error', string>
|
||||
|
||||
/**
|
||||
* Opens a path or URL with the system's default app,
|
||||
* or the one specified with `openWith`.
|
||||
*
|
||||
* The `openWith` value must be one of `firefox`, `google chrome`, `chromium` `safari`,
|
||||
* `open`, `start`, `xdg-open`, `gio`, `gnome-open`, `kde-open` or `wslview`.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { open } from '@tauri-apps/plugin-shell';
|
||||
* // opens the given URL on the default browser:
|
||||
* await open('https://github.com/tauri-apps/tauri');
|
||||
* // opens the given URL using `firefox`:
|
||||
* await open('https://github.com/tauri-apps/tauri', 'firefox');
|
||||
* // opens a file using the default program:
|
||||
* await open('/path/to/file');
|
||||
* ```
|
||||
*
|
||||
* @param path The path or URL to open.
|
||||
* This value is matched against the string regex defined on `tauri.conf.json > plugins > shell > open`,
|
||||
* which defaults to `^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+`.
|
||||
* @param openWith The app to open the file or URL with.
|
||||
* Defaults to the system default application for the specified path type.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function open(path: string, openWith?: string): Promise<void> {
|
||||
await invoke('plugin:shell|open', {
|
||||
path,
|
||||
with: openWith
|
||||
})
|
||||
}
|
||||
|
||||
export { Command, Child, EventEmitter, open }
|
||||
export { Command, Child, EventEmitter }
|
||||
export type {
|
||||
IOPayload,
|
||||
CommandEvents,
|
||||
|
||||
Reference in New Issue
Block a user