app.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. import { invoke } from './core'
  5. /**
  6. * Application metadata and related APIs.
  7. *
  8. * @module
  9. */
  10. /**
  11. * Gets the application version.
  12. * @example
  13. * ```typescript
  14. * import { getVersion } from '@tauri-apps/api/app';
  15. * const appVersion = await getVersion();
  16. * ```
  17. *
  18. * @since 1.0.0
  19. */
  20. async function getVersion(): Promise<string> {
  21. return invoke('plugin:app|version')
  22. }
  23. /**
  24. * Gets the application name.
  25. * @example
  26. * ```typescript
  27. * import { getName } from '@tauri-apps/api/app';
  28. * const appName = await getName();
  29. * ```
  30. *
  31. * @since 1.0.0
  32. */
  33. async function getName(): Promise<string> {
  34. return invoke('plugin:app|name')
  35. }
  36. /**
  37. * Gets the Tauri version.
  38. *
  39. * @example
  40. * ```typescript
  41. * import { getTauriVersion } from '@tauri-apps/api/app';
  42. * const tauriVersion = await getTauriVersion();
  43. * ```
  44. *
  45. * @since 1.0.0
  46. */
  47. async function getTauriVersion(): Promise<string> {
  48. return invoke('plugin:app|tauri_version')
  49. }
  50. /**
  51. * Shows the application on macOS. This function does not automatically focus any specific app window.
  52. *
  53. * @example
  54. * ```typescript
  55. * import { show } from '@tauri-apps/api/app';
  56. * await show();
  57. * ```
  58. *
  59. * @since 1.2.0
  60. */
  61. async function show(): Promise<void> {
  62. return invoke('plugin:app|app_show')
  63. }
  64. /**
  65. * Hides the application on macOS.
  66. *
  67. * @example
  68. * ```typescript
  69. * import { hide } from '@tauri-apps/api/app';
  70. * await hide();
  71. * ```
  72. *
  73. * @since 1.2.0
  74. */
  75. async function hide(): Promise<void> {
  76. return invoke('plugin:app|app_hide')
  77. }
  78. export { getName, getVersion, getTauriVersion, show, hide }