chore: update documentation

This commit is contained in:
Lucas Nogueira
2026-09-22 11:30:47 -03:00
parent d869c162a7
commit a87a3c7d44
104 changed files with 4875 additions and 222 deletions
+29
View File
@@ -25,6 +25,9 @@ declare global {
}
}
/**
* A string describing the specific operating system in use, as returned by {@link platform}.
*/
type Platform =
| 'linux'
| 'macos'
@@ -37,8 +40,14 @@ type Platform =
| 'android'
| 'windows'
/**
* A coarse-grained operating system category, as returned by {@link type}.
*/
type OsType = 'linux' | 'windows' | 'macos' | 'ios' | 'android'
/**
* A string describing the specific operating system architecture in use, as returned by {@link arch}.
*/
type Arch =
| 'x86'
| 'x86_64'
@@ -57,6 +66,13 @@ type Arch =
* - `\n` on POSIX
* - `\r\n` on Windows
*
* @example
* ```typescript
* import { eol } from '@tauri-apps/plugin-os';
* const eolChar = eol();
* ```
*
* @returns The end-of-line marker for the current platform.
* @since 2.0.0
* */
function eol(): string {
@@ -73,6 +89,7 @@ function eol(): string {
* const platformName = platform();
* ```
*
* @returns The platform name.
* @since 2.0.0
*
*/
@@ -88,12 +105,16 @@ function platform(): Platform {
* const osVersion = version();
* ```
*
* @returns The operating system version.
* @since 2.0.0
*/
function version(): string {
return window.__TAURI_OS_PLUGIN_INTERNALS__.version
}
/**
* A string describing the operating system family, as returned by {@link family}.
*/
type Family = 'unix' | 'windows'
/**
@@ -104,6 +125,7 @@ type Family = 'unix' | 'windows'
* const family = family();
* ```
*
* @returns The operating system family.
* @since 2.0.0
*/
function family(): Family {
@@ -118,6 +140,7 @@ function family(): Family {
* const osType = type();
* ```
*
* @returns The operating system type.
* @since 2.0.0
*/
function type(): OsType {
@@ -133,6 +156,7 @@ function type(): OsType {
* const archName = arch();
* ```
*
* @returns The operating system architecture.
* @since 2.0.0
*/
function arch(): Arch {
@@ -147,6 +171,7 @@ function arch(): Arch {
* const exeExt = exeExtension();
* ```
*
* @returns The file extension used for executable binaries on this platform.
* @since 2.0.0
*/
function exeExtension(): string {
@@ -164,6 +189,7 @@ function exeExtension(): string {
* }
* ```
*
* @returns A promise resolving to the `BCP-47` language tag, or `null` if it could not be obtained.
* @since 2.0.0
*/
async function locale(): Promise<string | null> {
@@ -177,6 +203,9 @@ async function locale(): Promise<string | null> {
* import { hostname } from '@tauri-apps/plugin-os';
* const hostname = await hostname();
* ```
*
* @returns A promise resolving to the host name of the operating system.
* @since 2.0.0
*/
async function hostname(): Promise<string | null> {
return await invoke('plugin:os|hostname')
+3
View File
@@ -4,6 +4,9 @@
use serde::{Serialize, Serializer};
/// All errors that can occur while running the os plugin.
///
/// This enum currently has no variants: none of the plugin's commands can fail.
#[derive(Debug, thiserror::Error)]
pub enum Error {}
+7
View File
@@ -23,11 +23,17 @@ mod error;
pub use error::Error;
/// The type of the current operating system, as returned by [`type_`].
pub enum OsType {
/// Linux and Linux-based systems such as FreeBSD, DragonFly BSD, NetBSD and OpenBSD.
Linux,
/// Windows.
Windows,
/// macOS.
Macos,
/// iOS.
IOS,
/// Android.
Android,
}
@@ -127,6 +133,7 @@ impl InitJavascript<'_> {
}
}
/// Initializes the plugin.
pub fn init<R: Runtime>() -> TauriPlugin<R> {
let init_js = InitJavascript::new()
.render_default(&Default::default())