Skip to content

Commit f2c7719

Browse files
refactor(opener)!: rename reveal_item_in_dir command to reveal_items_in_dir (#3608)
* refactor(opener)!: rename reveal_item_in_dir command to reveal_items_in_dir The `allow-reveal-item-in-dir` and `deny-reveal-item-in-dir` permissions are now `allow-reveal-items-in-dir` and `deny-reveal-items-in-dir`. The `revealItemInDir` JavaScript function and the Rust `Opener` methods are unchanged. * cr * retain rust api * fix build * update docs, rename ts api * cr * Apply suggestion from @Legend-Master --------- Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com>
1 parent 9c550e2 commit f2c7719

10 files changed

Lines changed: 45 additions & 23 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"opener": major
3+
"opener-js": major
4+
---
5+
6+
**Breaking:** Renamed the `revealItemInDir` function to `revealItemsInDir`, which accepts a single path or an array of paths.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"opener": major
3+
"opener-js": major
4+
---
5+
6+
**Breaking:** Renamed the `reveal_item_in_dir` command to `reveal_items_in_dir`, so the `allow-reveal-item-in-dir` and `deny-reveal-item-in-dir` permissions are now `allow-reveal-items-in-dir` and `deny-reveal-items-in-dir`.

‎plugins/opener/api-iife.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎plugins/opener/build.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ fn _f() {
106106
};
107107
}
108108

109-
const COMMANDS: &[&str] = &["open_url", "open_path", "reveal_item_in_dir"];
109+
const COMMANDS: &[&str] = &["open_url", "open_path", "reveal_items_in_dir"];
110110

111111
fn main() {
112112
tauri_plugin::Builder::new(COMMANDS)

‎plugins/opener/guest-js/index.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,24 +76,24 @@ export async function openPath(path: string, openWith?: string): Promise<void> {
7676
}
7777

7878
/**
79-
* Reveal a path with the system's default explorer.
79+
* Reveal one or more paths with the system's default explorer.
8080
*
8181
* #### Platform-specific:
8282
*
8383
* - **Android / iOS:** Unsupported.
8484
*
8585
* @example
8686
* ```typescript
87-
* import { revealItemInDir } from '@tauri-apps/plugin-opener';
88-
* await revealItemInDir('/path/to/file');
89-
* await revealItemInDir([ '/path/to/file', '/path/to/another/file' ]);
87+
* import { revealItemsInDir } from '@tauri-apps/plugin-opener';
88+
* await revealItemsInDir('/path/to/file');
89+
* await revealItemsInDir([ '/path/to/file', '/path/to/another/file' ]);
9090
* ```
9191
*
9292
* @param path The path to reveal.
9393
*
9494
* @since 2.0.0
9595
*/
96-
export async function revealItemInDir(path: string | string[]): Promise<void> {
96+
export async function revealItemsInDir(path: string | string[]): Promise<void> {
9797
const paths = typeof path === 'string' ? [path] : path
98-
return invoke('plugin:opener|reveal_item_in_dir', { paths })
98+
return invoke('plugin:opener|reveal_items_in_dir', { paths })
9999
}

‎plugins/opener/permissions/autogenerated/reference.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ as well as reveal file in directories using default file explorer
66
#### This default permission set includes the following:
77

88
- `allow-open-url`
9-
- `allow-reveal-item-in-dir`
9+
- `allow-reveal-items-in-dir`
1010
- `allow-default-urls`
1111

1212
## Permission Table
@@ -73,25 +73,25 @@ Denies the open_url command without any pre-configured scope.
7373
<tr>
7474
<td>
7575

76-
`opener:allow-reveal-item-in-dir`
76+
`opener:allow-reveal-items-in-dir`
7777

7878
</td>
7979
<td>
8080

81-
Enables the reveal_item_in_dir command without any pre-configured scope.
81+
Enables the reveal_items_in_dir command without any pre-configured scope.
8282

8383
</td>
8484
</tr>
8585

8686
<tr>
8787
<td>
8888

89-
`opener:deny-reveal-item-in-dir`
89+
`opener:deny-reveal-items-in-dir`
9090

9191
</td>
9292
<td>
9393

94-
Denies the reveal_item_in_dir command without any pre-configured scope.
94+
Denies the reveal_items_in_dir command without any pre-configured scope.
9595

9696
</td>
9797
</tr>

‎plugins/opener/permissions/default.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ description = """This permission set allows opening `mailto:`, `tel:`, `https://
55
as well as reveal file in directories using default file explorer"""
66
permissions = [
77
"allow-open-url",
8-
"allow-reveal-item-in-dir",
8+
"allow-reveal-items-in-dir",
99
"allow-default-urls",
1010
]

‎plugins/opener/src/commands.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ pub async fn open_path<R: Runtime>(
6969
}
7070
}
7171

72-
/// TODO: in the next major version, rename to `reveal_items_in_dir`
7372
#[tauri::command]
74-
pub async fn reveal_item_in_dir(paths: Vec<PathBuf>) -> crate::Result<()> {
73+
pub async fn reveal_items_in_dir(paths: Vec<PathBuf>) -> crate::Result<()> {
7574
crate::reveal_items_in_dir(&paths)
7675
}

‎plugins/opener/src/lib.rs‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mod commands;
1717
mod config;
1818
mod error;
1919
mod open;
20-
mod reveal_item_in_dir;
20+
mod reveal_items_in_dir;
2121
mod scope;
2222
mod scope_entry;
2323
#[cfg(windows)]
@@ -27,7 +27,7 @@ pub use error::Error;
2727
type Result<T> = std::result::Result<T, Error>;
2828

2929
pub use open::{open_path, open_url};
30-
pub use reveal_item_in_dir::{reveal_item_in_dir, reveal_items_in_dir};
30+
pub use reveal_items_in_dir::{reveal_item_in_dir, reveal_items_in_dir};
3131

3232
pub struct Opener<R: Runtime> {
3333
// we use `fn() -> R` to silence the unused generic error
@@ -153,10 +153,20 @@ impl<R: Runtime> Opener<R> {
153153
.map_err(Into::into)
154154
}
155155

156+
/// Reveal the given path in the system's default explorer.
157+
///
158+
/// ## Platform-specific:
159+
///
160+
/// - **Android / iOS:** Unsupported.
156161
pub fn reveal_item_in_dir<P: AsRef<Path>>(&self, p: P) -> Result<()> {
157162
reveal_item_in_dir(p)
158163
}
159164

165+
/// Reveal one or more paths in the system's default explorer.
166+
///
167+
/// ## Platform-specific:
168+
///
169+
/// - **Android / iOS:** Unsupported.
160170
pub fn reveal_items_in_dir<I, P>(&self, paths: I) -> Result<()>
161171
where
162172
I: IntoIterator<Item = P>,
@@ -229,7 +239,7 @@ impl Builder {
229239
.invoke_handler(tauri::generate_handler![
230240
commands::open_url,
231241
commands::open_path,
232-
commands::reveal_item_in_dir,
242+
commands::reveal_items_in_dir,
233243
]);
234244

235245
if self.open_js_links_on_click {
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ use std::path::{Path, PathBuf};
1010
///
1111
/// - **Android / iOS:** Unsupported.
1212
pub fn reveal_item_in_dir<P: AsRef<Path>>(path: P) -> crate::Result<()> {
13-
let path = canonicalize(path.as_ref())?;
14-
1513
#[cfg(any(
1614
windows,
1715
target_os = "macos",
@@ -21,7 +19,7 @@ pub fn reveal_item_in_dir<P: AsRef<Path>>(path: P) -> crate::Result<()> {
2119
target_os = "netbsd",
2220
target_os = "openbsd"
2321
))]
24-
return imp::reveal_items_in_dir(&[path]);
22+
return imp::reveal_items_in_dir(&[canonicalize(path.as_ref())?]);
2523

2624
#[cfg(not(any(
2725
windows,
@@ -32,7 +30,10 @@ pub fn reveal_item_in_dir<P: AsRef<Path>>(path: P) -> crate::Result<()> {
3230
target_os = "netbsd",
3331
target_os = "openbsd"
3432
)))]
35-
Err(crate::Error::UnsupportedPlatform)
33+
{
34+
let _path = path;
35+
Err(crate::Error::UnsupportedPlatform)
36+
}
3637
}
3738

3839
/// Reveal multiple paths in the system's default explorer.

0 commit comments

Comments
 (0)