| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- import { invokeTauriCommand } from './helpers/tauri.js';
- // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
- // SPDX-License-Identifier: Apache-2.0
- // SPDX-License-Identifier: MIT
- /**
- * Get application metadata.
- *
- * This package is also accessible with `window.__TAURI__.app` when [`build.withGlobalTauri`](https://tauri.app/v1/api/config/#buildconfig.withglobaltauri) in `tauri.conf.json` is set to `true`.
- *
- * The APIs must be added to [`tauri.allowlist.app`](https://tauri.app/v1/api/config/#allowlistconfig.app) in `tauri.conf.json`:
- * ```json
- * {
- * "tauri": {
- * "allowlist": {
- * "app": {
- * "all": true, // enable all app APIs
- * "show": true,
- * "hide": true
- * }
- * }
- * }
- * }
- * ```
- * It is recommended to allowlist only the APIs you use for optimal bundle size and security.
- *
- * @module
- */
- /**
- * Gets the application version.
- * @example
- * ```typescript
- * import { getVersion } from '@tauri-apps/api/app';
- * const appVersion = await getVersion();
- * ```
- *
- * @since 1.0.0
- */
- async function getVersion() {
- return invokeTauriCommand({
- __tauriModule: 'App',
- message: {
- cmd: 'getAppVersion'
- }
- });
- }
- /**
- * Gets the application name.
- * @example
- * ```typescript
- * import { getName } from '@tauri-apps/api/app';
- * const appName = await getName();
- * ```
- *
- * @since 1.0.0
- */
- async function getName() {
- return invokeTauriCommand({
- __tauriModule: 'App',
- message: {
- cmd: 'getAppName'
- }
- });
- }
- /**
- * Gets the Tauri version.
- *
- * @example
- * ```typescript
- * import { getTauriVersion } from '@tauri-apps/api/app';
- * const tauriVersion = await getTauriVersion();
- * ```
- *
- * @since 1.0.0
- */
- async function getTauriVersion() {
- return invokeTauriCommand({
- __tauriModule: 'App',
- message: {
- cmd: 'getTauriVersion'
- }
- });
- }
- /**
- * Shows the application on macOS. This function does not automatically focus any specific app window.
- *
- * @example
- * ```typescript
- * import { show } from '@tauri-apps/api/app';
- * await show();
- * ```
- *
- * @since 1.2.0
- */
- async function show() {
- return invokeTauriCommand({
- __tauriModule: 'App',
- message: {
- cmd: 'show'
- }
- });
- }
- /**
- * Hides the application on macOS.
- *
- * @example
- * ```typescript
- * import { hide } from '@tauri-apps/api/app';
- * await hide();
- * ```
- *
- * @since 1.2.0
- */
- async function hide() {
- return invokeTauriCommand({
- __tauriModule: 'App',
- message: {
- cmd: 'hide'
- }
- });
- }
- export { getName, getTauriVersion, getVersion, hide, show };
|