2323 * @module
2424 */
2525
26- import { LiteralUnion } from 'type-fest'
2726import { isWindows } from './helpers/os-check'
2827import { invokeTauriCommand } from './helpers/tauri'
2928
29+ type Platform =
30+ | 'linux'
31+ | 'darwin'
32+ | 'ios'
33+ | 'freebsd'
34+ | 'dragonfly'
35+ | 'netbsd'
36+ | 'openbsd'
37+ | 'solaris'
38+ | 'android'
39+ | 'win32'
40+
41+ type OsType = 'Linux' | 'Darwin' | 'Windows_NT'
42+
43+ type Arch =
44+ | 'x86'
45+ | 'x86_64'
46+ | 'arm'
47+ | 'aarch64'
48+ | 'mips'
49+ | 'mips64'
50+ | 'powerpc'
51+ | 'powerpc64'
52+ | 'riscv64'
53+ | 's390x'
54+ | 'sparc64'
55+
3056/**
3157 * The operating system-specific end-of-line marker.
3258 * - `\n` on POSIX
@@ -43,22 +69,8 @@ const EOL = isWindows() ? '\r\n' : '\n'
4369 * const platformName = await platform();
4470 * ```
4571 */
46- async function platform ( ) : Promise <
47- LiteralUnion <
48- | 'linux'
49- | 'darwin'
50- | 'ios'
51- | 'freebsd'
52- | 'dragonfly'
53- | 'netbsd'
54- | 'openbsd'
55- | 'solaris'
56- | 'android'
57- | 'win32' ,
58- string
59- >
60- > {
61- return invokeTauriCommand < string > ( {
72+ async function platform ( ) : Promise < Platform > {
73+ return invokeTauriCommand < Platform > ( {
6274 __tauriModule : 'Os' ,
6375 message : {
6476 cmd : 'platform'
@@ -91,10 +103,8 @@ async function version(): Promise<string> {
91103 * const osType = await type();
92104 * ```
93105 */
94- async function type ( ) : Promise <
95- LiteralUnion < 'Linux' | 'Darwin' | 'Windows_NT' , string >
96- > {
97- return invokeTauriCommand < string > ( {
106+ async function type ( ) : Promise < OsType > {
107+ return invokeTauriCommand < OsType > ( {
98108 __tauriModule : 'Os' ,
99109 message : {
100110 cmd : 'osType'
@@ -111,23 +121,8 @@ async function type(): Promise<
111121 * const archName = await arch();
112122 * ```
113123 */
114- async function arch ( ) : Promise <
115- LiteralUnion <
116- | 'x86'
117- | 'x86_64'
118- | 'arm'
119- | 'aarch64'
120- | 'mips'
121- | 'mips64'
122- | 'powerpc'
123- | 'powerpc64'
124- | 'riscv64'
125- | 's390x'
126- | 'sparc64' ,
127- string
128- >
129- > {
130- return invokeTauriCommand < string > ( {
124+ async function arch ( ) : Promise < Arch > {
125+ return invokeTauriCommand < Arch > ( {
131126 __tauriModule : 'Os' ,
132127 message : {
133128 cmd : 'arch'
@@ -153,3 +148,4 @@ async function tempdir(): Promise<string> {
153148}
154149
155150export { EOL , platform , version , type , arch , tempdir }
151+ export type { Platform , OsType , Arch }
0 commit comments