os.d.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. type Platform = 'linux' | 'darwin' | 'ios' | 'freebsd' | 'dragonfly' | 'netbsd' | 'openbsd' | 'solaris' | 'android' | 'win32';
  2. type OsType = 'Linux' | 'Darwin' | 'Windows_NT';
  3. type Arch = 'x86' | 'x86_64' | 'arm' | 'aarch64' | 'mips' | 'mips64' | 'powerpc' | 'powerpc64' | 'riscv64' | 's390x' | 'sparc64';
  4. /**
  5. * The operating system-specific end-of-line marker.
  6. * - `\n` on POSIX
  7. * - `\r\n` on Windows
  8. *
  9. * @since 1.0.0
  10. * */
  11. declare const EOL: string;
  12. /**
  13. * Returns a string identifying the operating system platform.
  14. * The value is set at compile time. Possible values are `'linux'`, `'darwin'`, `'ios'`, `'freebsd'`, `'dragonfly'`, `'netbsd'`, `'openbsd'`, `'solaris'`, `'android'`, `'win32'`
  15. * @example
  16. * ```typescript
  17. * import { platform } from '@tauri-apps/api/os';
  18. * const platformName = await platform();
  19. * ```
  20. *
  21. * @since 1.0.0
  22. *
  23. */
  24. declare function platform(): Promise<Platform>;
  25. /**
  26. * Returns a string identifying the kernel version.
  27. * @example
  28. * ```typescript
  29. * import { version } from '@tauri-apps/api/os';
  30. * const osVersion = await version();
  31. * ```
  32. *
  33. * @since 1.0.0
  34. */
  35. declare function version(): Promise<string>;
  36. /**
  37. * Returns `'Linux'` on Linux, `'Darwin'` on macOS, and `'Windows_NT'` on Windows.
  38. * @example
  39. * ```typescript
  40. * import { type } from '@tauri-apps/api/os';
  41. * const osType = await type();
  42. * ```
  43. *
  44. * @since 1.0.0
  45. */
  46. declare function type(): Promise<OsType>;
  47. /**
  48. * Returns the operating system CPU architecture for which the tauri app was compiled.
  49. * Possible values are `'x86'`, `'x86_64'`, `'arm'`, `'aarch64'`, `'mips'`, `'mips64'`, `'powerpc'`, `'powerpc64'`, `'riscv64'`, `'s390x'`, `'sparc64'`.
  50. * @example
  51. * ```typescript
  52. * import { arch } from '@tauri-apps/api/os';
  53. * const archName = await arch();
  54. * ```
  55. *
  56. * @since 1.0.0
  57. */
  58. declare function arch(): Promise<Arch>;
  59. /**
  60. * Returns the operating system's default directory for temporary files as a string.
  61. * @example
  62. * ```typescript
  63. * import { tempdir } from '@tauri-apps/api/os';
  64. * const tempdirPath = await tempdir();
  65. * ```
  66. *
  67. * @since 1.0.0
  68. */
  69. declare function tempdir(): Promise<string>;
  70. /**
  71. * Returns a String with a `BCP-47` language tag inside. If the locale couldn’t be obtained, `null` is returned instead.
  72. * @example
  73. * ```typescript
  74. * import { locale } from '@tauri-apps/api/os';
  75. * const locale = await locale();
  76. * if (locale) {
  77. * // use the locale string here
  78. * }
  79. * ```
  80. *
  81. * @since 1.4.0
  82. */
  83. declare function locale(): Promise<string | null>;
  84. export { EOL, platform, version, type, arch, tempdir, locale };
  85. export type { Platform, OsType, Arch };