Skip to content

Commit 2f58f57

Browse files
committed
Add support for visionOS
1 parent a16d6ae commit 2f58f57

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

src/ios.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use crate::{Browser, BrowserOptions, Error, ErrorKind, Result, TargetType};
22
use objc::{class, msg_send, runtime::Object, sel, sel_impl};
33

4-
/// Deal with opening of browsers on iOS
4+
/// Deal with opening of browsers on iOS/tvOS/visionOS.
5+
///
6+
/// watchOS doesn't have a browser, so this won't work there.
57
pub(super) fn open_browser_internal(
68
_browser: Browser,
79
target: &TargetType,

src/lib.rs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
//!
1515
//! ## Platform Support Status
1616
//!
17-
//! | Platform | Supported | Browsers | Test status |
18-
//! |----------|-----------|----------|-------------|
19-
//! | macos | ✅ | default + [others](https://docs.rs/webbrowser/latest/webbrowser/enum.Browser.html) | ✅ |
20-
//! | windows | ✅ | default only | ✅ |
21-
//! | linux/wsl | ✅ | default only (respects $BROWSER env var, so can be used with other browsers) | ✅ |
22-
//! | android | ✅ | default only | ✅ |
23-
//! | ios | ✅ | default only | ✅ |
24-
//! | wasm | ✅ | default only | ✅ |
17+
//! | Platform | Supported | Browsers | Test status |
18+
//! |-----------------------|-----------|----------|-------------|
19+
//! | macOS | ✅ | default + [others](https://docs.rs/webbrowser/latest/webbrowser/enum.Browser.html) | ✅ |
20+
//! | windows | ✅ | default only | ✅ |
21+
//! | linux/wsl | ✅ | default only (respects $BROWSER env var, so can be used with other browsers) | ✅ |
22+
//! | android | ✅ | default only | ✅ |
23+
//! | iOS/tvOS/visionOS | ✅ | default only | ✅ |
24+
//! | wasm | ✅ | default only | ✅ |
2525
//! | unix (*bsd, aix etc.) | ✅ | default only (respects $BROWSER env var, so can be used with other browsers) | Manual |
2626
//!
2727
//! ## Consistent Behaviour
@@ -39,7 +39,10 @@
3939
//! * `disable-wsl` - this disables WSL `file` implementation (`http` still works)
4040
//! * `wasm-console` - this enables logging to wasm console (valid only on wasm platform)
4141
42-
#[cfg_attr(any(target_os = "ios", target_os = "tvos"), path = "ios.rs")]
42+
#[cfg_attr(
43+
any(target_os = "ios", target_os = "tvos", target_os = "visionos"),
44+
path = "ios.rs"
45+
)]
4346
#[cfg_attr(target_os = "macos", path = "macos.rs")]
4447
#[cfg_attr(target_os = "android", path = "android.rs")]
4548
#[cfg_attr(target_family = "wasm", path = "wasm.rs")]
@@ -50,6 +53,7 @@
5053
not(any(
5154
target_os = "ios",
5255
target_os = "tvos",
56+
target_os = "visionos",
5357
target_os = "macos",
5458
target_os = "android",
5559
target_family = "wasm",
@@ -67,6 +71,7 @@ mod os;
6771
not(any(
6872
target_os = "ios",
6973
target_os = "tvos",
74+
target_os = "visionos",
7075
target_os = "macos",
7176
target_os = "android",
7277
target_family = "wasm",
@@ -316,6 +321,7 @@ pub fn open_browser_with_options(
316321
if cfg!(any(
317322
target_os = "ios",
318323
target_os = "tvos",
324+
target_os = "visionos",
319325
target_os = "macos",
320326
target_os = "android",
321327
target_family = "wasm",
@@ -338,6 +344,8 @@ impl TargetType {
338344
feature = "hardened",
339345
target_os = "android",
340346
target_os = "ios",
347+
target_os = "tvos",
348+
target_os = "visionos",
341349
target_family = "wasm"
342350
))]
343351
fn is_http(&self) -> bool {
@@ -346,7 +354,13 @@ impl TargetType {
346354

347355
/// If `target` represents a valid http/https url, return the str corresponding to it
348356
/// else return `std::io::Error` of kind `std::io::ErrorKind::InvalidInput`
349-
#[cfg(any(target_os = "android", target_os = "ios", target_family = "wasm"))]
357+
#[cfg(any(
358+
target_os = "android",
359+
target_os = "ios",
360+
target_os = "tvos",
361+
target_os = "visionos",
362+
target_family = "wasm"
363+
))]
350364
fn get_http_url(&self) -> Result<&str> {
351365
if self.is_http() {
352366
Ok(self.0.as_str())

0 commit comments

Comments
 (0)