-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move app plugin back to core (#8039)
Co-authored-by: Lucas Nogueira <[email protected]>
- Loading branch information
1 parent
1490567
commit fb10b87
Showing
20 changed files
with
303 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@tauri-apps/api": 'minor:feat' | ||
--- | ||
|
||
Add the `app` module back. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
"@tauri-apps/api": 'minor:feat' | ||
--- | ||
|
||
Add the `window` module back | ||
Add the `window` module back. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'tauri': patch:changes | ||
--- | ||
|
||
Added the `app` plugin back into core. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
"tauri": patch:changes | ||
'tauri': patch:changes | ||
--- | ||
|
||
Added the `window` plugin back into core. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-License-Identifier: MIT | ||
|
||
use crate::{ | ||
command, | ||
plugin::{Builder, TauriPlugin}, | ||
AppHandle, Runtime, | ||
}; | ||
|
||
#[command(root = "crate")] | ||
pub fn version<R: Runtime>(app: AppHandle<R>) -> String { | ||
app.package_info().version.to_string() | ||
} | ||
|
||
#[command(root = "crate")] | ||
pub fn name<R: Runtime>(app: AppHandle<R>) -> String { | ||
app.package_info().name.clone() | ||
} | ||
|
||
#[command(root = "crate")] | ||
pub fn tauri_version() -> &'static str { | ||
crate::VERSION | ||
} | ||
|
||
#[command(root = "crate")] | ||
#[allow(unused_variables)] | ||
pub fn app_show<R: Runtime>(app: AppHandle<R>) -> crate::Result<()> { | ||
#[cfg(target_os = "macos")] | ||
app.show()?; | ||
Ok(()) | ||
} | ||
|
||
#[command(root = "crate")] | ||
#[allow(unused_variables)] | ||
pub fn app_hide<R: Runtime>(app: AppHandle<R>) -> crate::Result<()> { | ||
#[cfg(target_os = "macos")] | ||
app.hide()?; | ||
Ok(()) | ||
} | ||
|
||
pub fn init<R: Runtime>() -> TauriPlugin<R> { | ||
Builder::new("app") | ||
.invoke_handler(crate::generate_handler![ | ||
version, | ||
name, | ||
tauri_version, | ||
app_show, | ||
app_hide | ||
]) | ||
.build() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<script> | ||
import { show, hide } from '@tauri-apps/api/app' | ||
export let onMessage | ||
function showApp() { | ||
hideApp() | ||
.then(() => { | ||
setTimeout(() => { | ||
show() | ||
.then(() => onMessage('Shown app')) | ||
.catch(onMessage) | ||
}, 2000) | ||
}) | ||
.catch(onMessage) | ||
} | ||
function hideApp() { | ||
return hide() | ||
.then(() => onMessage('Hide app')) | ||
.catch(onMessage) | ||
} | ||
</script> | ||
|
||
<div> | ||
<button | ||
class="btn" | ||
id="show" | ||
title="Hides and shows the app after 2 seconds" | ||
on:click={showApp}>Show</button | ||
> | ||
<button class="btn" id="hide" on:click={hideApp}>Hide</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-License-Identifier: MIT | ||
|
||
import { invoke } from './primitives' | ||
|
||
/** | ||
* Application metadata and related APIs. | ||
* | ||
* @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(): Promise<string> { | ||
return invoke('plugin:app|version') | ||
} | ||
|
||
/** | ||
* Gets the application name. | ||
* @example | ||
* ```typescript | ||
* import { getName } from '@tauri-apps/api/app'; | ||
* const appName = await getName(); | ||
* ``` | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
async function getName(): Promise<string> { | ||
return invoke('plugin:app|name') | ||
} | ||
|
||
/** | ||
* Gets the Tauri version. | ||
* | ||
* @example | ||
* ```typescript | ||
* import { getTauriVersion } from '@tauri-apps/api/app'; | ||
* const tauriVersion = await getTauriVersion(); | ||
* ``` | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
async function getTauriVersion(): Promise<string> { | ||
return invoke('plugin:app|tauri_version') | ||
} | ||
|
||
/** | ||
* 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(): Promise<void> { | ||
return invoke('plugin:app|app_show') | ||
} | ||
|
||
/** | ||
* Hides the application on macOS. | ||
* | ||
* @example | ||
* ```typescript | ||
* import { hide } from '@tauri-apps/api/app'; | ||
* await hide(); | ||
* ``` | ||
* | ||
* @since 1.2.0 | ||
*/ | ||
async function hide(): Promise<void> { | ||
return invoke('plugin:app|app_hide') | ||
} | ||
|
||
export { getName, getVersion, getTauriVersion, show, hide } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.