@tauri-apps/plugin-os
Advanced tools
Comparing version 2.0.0-alpha.0 to 2.0.0-alpha.1
@@ -9,9 +9,14 @@ /** | ||
__TAURI_INVOKE__: <T>(cmd: string, args?: unknown) => Promise<T>; | ||
__TAURI__: { | ||
os: { | ||
__eol: string; | ||
}; | ||
}; | ||
} | ||
} | ||
type Platform = "linux" | "darwin" | "ios" | "freebsd" | "dragonfly" | "netbsd" | "openbsd" | "solaris" | "android" | "win32"; | ||
type OsType = "Linux" | "Darwin" | "Windows_NT"; | ||
type Platform = "linux" | "macos" | "ios" | "freebsd" | "dragonfly" | "netbsd" | "openbsd" | "solaris" | "android" | "windows"; | ||
type OsType = "linux" | "windows" | "macss" | "ios" | "android"; | ||
type Arch = "x86" | "x86_64" | "arm" | "aarch64" | "mips" | "mips64" | "powerpc" | "powerpc64" | "riscv64" | "s390x" | "sparc64"; | ||
/** | ||
* The operating system-specific end-of-line marker. | ||
* Returns the operating system-specific end-of-line marker. | ||
* - `\n` on POSIX | ||
@@ -22,6 +27,7 @@ * - `\r\n` on Windows | ||
* */ | ||
declare const EOL: string; | ||
declare function eol(): string; | ||
/** | ||
* Returns a string identifying the operating system platform. | ||
* The value is set at compile time. Possible values are `'linux'`, `'darwin'`, `'ios'`, `'freebsd'`, `'dragonfly'`, `'netbsd'`, `'openbsd'`, `'solaris'`, `'android'`, `'win32'` | ||
* Returns a string describing the specific operating system in use. | ||
* The value is set at compile time. Possible values are `'linux'`, `'macos'`, `'ios'`, `'freebsd'`, `'dragonfly'`, `'netbsd'`, `'openbsd'`, `'solaris'`, `'android'`, `'windows'` | ||
* | ||
* @example | ||
@@ -38,3 +44,3 @@ * ```typescript | ||
/** | ||
* Returns a string identifying the kernel version. | ||
* Returns the current operating system version. | ||
* @example | ||
@@ -49,6 +55,18 @@ * ```typescript | ||
declare function version(): Promise<string>; | ||
type Family = "unix" | "windows"; | ||
/** | ||
* Returns `'Linux'` on Linux, `'Darwin'` on macOS, and `'Windows_NT'` on Windows. | ||
* Returns the current operating system family. Possible values are `'unix'`, `'windows'`. | ||
* @example | ||
* ```typescript | ||
* import { family } from '@tauri-apps/plugin-os'; | ||
* const family = await family(); | ||
* ``` | ||
* | ||
* @since 2.0.0 | ||
*/ | ||
declare function family(): Promise<Family>; | ||
/** | ||
* Returns the current operating system type. Returns `'linux'` on Linux, `'macos'` on macOS, `'windows'` on Windows, `'ios'` on iOS and `'android'` on Android. | ||
* @example | ||
* ```typescript | ||
* import { type } from '@tauri-apps/plugin-os'; | ||
@@ -62,3 +80,3 @@ * const osType = await type(); | ||
/** | ||
* Returns the operating system CPU architecture for which the tauri app was compiled. | ||
* Returns the current operating system architecture. | ||
* Possible values are `'x86'`, `'x86_64'`, `'arm'`, `'aarch64'`, `'mips'`, `'mips64'`, `'powerpc'`, `'powerpc64'`, `'riscv64'`, `'s390x'`, `'sparc64'`. | ||
@@ -75,7 +93,10 @@ * @example | ||
/** | ||
* Returns the operating system's default directory for temporary files as a string. | ||
* Returns a String with a `BCP-47` language tag inside. If the locale couldn’t be obtained, `null` is returned instead. | ||
* @example | ||
* ```typescript | ||
* import { tempdir } from '@tauri-apps/plugin-os'; | ||
* const tempdirPath = await tempdir(); | ||
* import { locale } from '@tauri-apps/plugin-os'; | ||
* const locale = await locale(); | ||
* if (locale) { | ||
* // use the locale string here | ||
* } | ||
* ``` | ||
@@ -85,12 +106,9 @@ * | ||
*/ | ||
declare function tempdir(): Promise<string>; | ||
declare function locale(): Promise<string | null>; | ||
/** | ||
* Returns a String with a `BCP-47` language tag inside. If the locale couldn’t be obtained, `null` is returned instead. | ||
* Returns the file extension, if any, used for executable binaries on this platform. Possible values are `'exe'` and `''` (empty string). | ||
* @example | ||
* ```typescript | ||
* import { locale } from '@tauri-apps/plugin-os'; | ||
* const locale = await locale(); | ||
* if (locale) { | ||
* // use the locale string here | ||
* } | ||
* import { exeExtension } from '@tauri-apps/plugin-os'; | ||
* const exeExt = await exeExtension(); | ||
* ``` | ||
@@ -100,4 +118,13 @@ * | ||
*/ | ||
declare function locale(): Promise<string | null>; | ||
export { EOL, platform, version, type, arch, tempdir, locale }; | ||
export type { Platform, OsType, Arch }; | ||
declare function exeExtension(): Promise<string | null>; | ||
/** | ||
* Returns the host name of the operating system. | ||
* @example | ||
* ```typescript | ||
* import { hostname } from '@tauri-apps/plugin-os'; | ||
* const hostname = await hostname(); | ||
* ``` | ||
*/ | ||
declare function hostname(): Promise<string | null>; | ||
export { eol, platform, family, version, type, arch, locale, exeExtension, hostname, }; | ||
export type { Platform, OsType, Arch, Family }; |
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-License-Identifier: MIT | ||
function isWindows() { | ||
return navigator.appVersion.includes("Win"); | ||
} | ||
/** | ||
* The operating system-specific end-of-line marker. | ||
* Returns the operating system-specific end-of-line marker. | ||
* - `\n` on POSIX | ||
@@ -14,6 +11,9 @@ * - `\r\n` on Windows | ||
* */ | ||
const EOL = isWindows() ? "\r\n" : "\n"; | ||
function eol() { | ||
return window.__TAURI__.os.__eol; | ||
} | ||
/** | ||
* Returns a string identifying the operating system platform. | ||
* The value is set at compile time. Possible values are `'linux'`, `'darwin'`, `'ios'`, `'freebsd'`, `'dragonfly'`, `'netbsd'`, `'openbsd'`, `'solaris'`, `'android'`, `'win32'` | ||
* Returns a string describing the specific operating system in use. | ||
* The value is set at compile time. Possible values are `'linux'`, `'macos'`, `'ios'`, `'freebsd'`, `'dragonfly'`, `'netbsd'`, `'openbsd'`, `'solaris'`, `'android'`, `'windows'` | ||
* | ||
* @example | ||
@@ -32,3 +32,3 @@ * ```typescript | ||
/** | ||
* Returns a string identifying the kernel version. | ||
* Returns the current operating system version. | ||
* @example | ||
@@ -46,5 +46,18 @@ * ```typescript | ||
/** | ||
* Returns `'Linux'` on Linux, `'Darwin'` on macOS, and `'Windows_NT'` on Windows. | ||
* Returns the current operating system family. Possible values are `'unix'`, `'windows'`. | ||
* @example | ||
* ```typescript | ||
* import { family } from '@tauri-apps/plugin-os'; | ||
* const family = await family(); | ||
* ``` | ||
* | ||
* @since 2.0.0 | ||
*/ | ||
async function family() { | ||
return window.__TAURI_INVOKE__("plugin:os|family"); | ||
} | ||
/** | ||
* Returns the current operating system type. Returns `'linux'` on Linux, `'macos'` on macOS, `'windows'` on Windows, `'ios'` on iOS and `'android'` on Android. | ||
* @example | ||
* ```typescript | ||
* import { type } from '@tauri-apps/plugin-os'; | ||
@@ -57,6 +70,6 @@ * const osType = await type(); | ||
async function type() { | ||
return window.__TAURI_INVOKE__("plugin:os|kind"); | ||
return window.__TAURI_INVOKE__("plugin:os|os_type"); | ||
} | ||
/** | ||
* Returns the operating system CPU architecture for which the tauri app was compiled. | ||
* Returns the current operating system architecture. | ||
* Possible values are `'x86'`, `'x86_64'`, `'arm'`, `'aarch64'`, `'mips'`, `'mips64'`, `'powerpc'`, `'powerpc64'`, `'riscv64'`, `'s390x'`, `'sparc64'`. | ||
@@ -75,15 +88,2 @@ * @example | ||
/** | ||
* Returns the operating system's default directory for temporary files as a string. | ||
* @example | ||
* ```typescript | ||
* import { tempdir } from '@tauri-apps/plugin-os'; | ||
* const tempdirPath = await tempdir(); | ||
* ``` | ||
* | ||
* @since 2.0.0 | ||
*/ | ||
async function tempdir() { | ||
return window.__TAURI_INVOKE__("plugin:os|tempdir"); | ||
} | ||
/** | ||
* Returns a String with a `BCP-47` language tag inside. If the locale couldn’t be obtained, `null` is returned instead. | ||
@@ -104,4 +104,28 @@ * @example | ||
} | ||
/** | ||
* Returns the file extension, if any, used for executable binaries on this platform. Possible values are `'exe'` and `''` (empty string). | ||
* @example | ||
* ```typescript | ||
* import { exeExtension } from '@tauri-apps/plugin-os'; | ||
* const exeExt = await exeExtension(); | ||
* ``` | ||
* | ||
* @since 2.0.0 | ||
*/ | ||
async function exeExtension() { | ||
return window.__TAURI_INVOKE__("plugin:os|exe_extension"); | ||
} | ||
/** | ||
* Returns the host name of the operating system. | ||
* @example | ||
* ```typescript | ||
* import { hostname } from '@tauri-apps/plugin-os'; | ||
* const hostname = await hostname(); | ||
* ``` | ||
*/ | ||
async function hostname() { | ||
return window.__TAURI_INVOKE__("plugin:os|hostname"); | ||
} | ||
export { EOL, arch, locale, platform, tempdir, type, version }; | ||
export { arch, eol, exeExtension, family, hostname, locale, platform, type, version }; | ||
//# sourceMappingURL=index.min.js.map |
{ | ||
"name": "@tauri-apps/plugin-os", | ||
"version": "2.0.0-alpha.0", | ||
"version": "2.0.0-alpha.1", | ||
"license": "MIT or APACHE-2.0", | ||
@@ -24,6 +24,6 @@ "authors": [ | ||
"devDependencies": { | ||
"tslib": "^2.5.0" | ||
"tslib": "2.6.0" | ||
}, | ||
"dependencies": { | ||
"@tauri-apps/api": "2.0.0-alpha.4" | ||
"@tauri-apps/api": "2.0.0-alpha.6" | ||
}, | ||
@@ -30,0 +30,0 @@ "scripts": { |
@@ -1,2 +0,2 @@ | ||
# Operating System | ||
![plugin-os](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/os/banner.png) | ||
@@ -3,0 +3,0 @@ Read information about the operating system. |
Sorry, the diff of this file is not supported yet
14399
370
+ Added@tauri-apps/api@2.0.0-alpha.6(transitive)
- Removed@tauri-apps/api@2.0.0-alpha.4(transitive)