|
@@ -23,6 +23,7 @@
|
|
|
* @module
|
|
|
*/
|
|
|
|
|
|
+import { LiteralUnion } from 'type-fest'
|
|
|
import { isWindows } from './helpers/os-check'
|
|
|
import { invokeTauriCommand } from './helpers/tauri'
|
|
|
|
|
@@ -33,12 +34,17 @@ import { invokeTauriCommand } from './helpers/tauri'
|
|
|
* */
|
|
|
const EOL = isWindows() ? '\r\n' : '\n'
|
|
|
|
|
|
+type Platform = LiteralUnion<
|
|
|
+ 'aix' | 'darwin' | 'freebsd' | 'linux' | 'openbsd' | 'sunos' | 'win32',
|
|
|
+ string
|
|
|
+>
|
|
|
+
|
|
|
/**
|
|
|
* Returns a string identifying the operating system platform.
|
|
|
* The value is set at compile time. Possible values are `'aix'`, `'darwin'`, `'freebsd'`, `'linux'`, `'openbsd'`, `'sunos'`, and `'win32'`.
|
|
|
*/
|
|
|
-async function platform(): Promise<string> {
|
|
|
- return invokeTauriCommand<string>({
|
|
|
+async function platform(): Promise<Platform> {
|
|
|
+ return invokeTauriCommand<Platform>({
|
|
|
__tauriModule: 'Os',
|
|
|
message: {
|
|
|
cmd: 'platform'
|
|
@@ -58,11 +64,13 @@ async function version(): Promise<string> {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+type OsType = LiteralUnion<'Linux' | 'Darwin' | 'Windows_NT', string>
|
|
|
+
|
|
|
/**
|
|
|
* Returns `'Linux'` on Linux, `'Darwin'` on macOS, and `'Windows_NT'` on Windows.
|
|
|
*/
|
|
|
-async function type(): Promise<string> {
|
|
|
- return invokeTauriCommand<string>({
|
|
|
+async function type(): Promise<OsType> {
|
|
|
+ return invokeTauriCommand<OsType>({
|
|
|
__tauriModule: 'Os',
|
|
|
message: {
|
|
|
cmd: 'type'
|
|
@@ -70,11 +78,26 @@ async function type(): Promise<string> {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+type Arch = LiteralUnion<
|
|
|
+ | 'x86'
|
|
|
+ | 'x86_64'
|
|
|
+ | 'arm'
|
|
|
+ | 'aarch64'
|
|
|
+ | 'mips'
|
|
|
+ | 'mips64'
|
|
|
+ | 'powerpc'
|
|
|
+ | 'powerpc64'
|
|
|
+ | 'riscv64'
|
|
|
+ | 's390x'
|
|
|
+ | 'sparc64',
|
|
|
+ string
|
|
|
+>
|
|
|
+
|
|
|
/**
|
|
|
* Returns the operating system CPU architecture for which the tauri app was compiled. Possible values are `'x86'`, `'x86_64'`, `'arm'`, `'aarch64'`, `'mips'`, `'mips64'`, `'powerpc'`, `'powerpc64'`, `'riscv64'`, `'s390x'`, `'sparc64'`
|
|
|
*/
|
|
|
-async function arch(): Promise<string> {
|
|
|
- return invokeTauriCommand<string>({
|
|
|
+async function arch(): Promise<Arch> {
|
|
|
+ return invokeTauriCommand<Arch>({
|
|
|
__tauriModule: 'Os',
|
|
|
message: {
|
|
|
cmd: 'arch'
|
|
@@ -95,3 +118,4 @@ async function tempdir(): Promise<string> {
|
|
|
}
|
|
|
|
|
|
export { EOL, platform, version, type, arch, tempdir }
|
|
|
+export type { Platform, OsType, Arch }
|