app.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2019-2021 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. /**
  5. * Get application metadata.
  6. *
  7. * This package is also accessible with `window.__TAURI__.app` when `tauri.conf.json > build > withGlobalTauri` is set to true.
  8. * @module
  9. */
  10. import { invokeTauriCommand } from './helpers/tauri'
  11. /**
  12. * Gets the application version.
  13. *
  14. * @returns A promise resolving to the application version.
  15. */
  16. async function getVersion(): Promise<string> {
  17. return invokeTauriCommand<string>({
  18. __tauriModule: 'App',
  19. message: {
  20. cmd: 'getAppVersion'
  21. }
  22. })
  23. }
  24. /**
  25. * Gets the application name.
  26. *
  27. * @returns A promise resolving to application name.
  28. */
  29. async function getName(): Promise<string> {
  30. return invokeTauriCommand<string>({
  31. __tauriModule: 'App',
  32. message: {
  33. cmd: 'getAppName'
  34. }
  35. })
  36. }
  37. /**
  38. * Gets the tauri version.
  39. *
  40. * @returns A promise resolving to tauri version.
  41. */
  42. async function getTauriVersion(): Promise<string> {
  43. return invokeTauriCommand<string>({
  44. __tauriModule: 'App',
  45. message: {
  46. cmd: 'getTauriVersion'
  47. }
  48. })
  49. }
  50. export { getName, getVersion, getTauriVersion }