feat(plugins): inject API on window.__TAURI__ (#383)

This commit is contained in:
Lucas Fernandes Nogueira
2023-05-23 14:20:14 -03:00
committed by GitHub
parent 3c8577bc9a
commit b131bc8f7c
78 changed files with 754 additions and 337 deletions
+6 -2
View File
@@ -3,7 +3,11 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import { invoke } from "@tauri-apps/api/tauri";
declare global {
interface Window {
__TAURI_INVOKE__: <T>(cmd: string, args?: unknown) => Promise<T>;
}
}
/**
* Well known window positions.
@@ -33,7 +37,7 @@ export enum Position {
* @param to The {@link Position} to move to.
*/
export async function moveWindow(to: Position): Promise<void> {
await invoke("plugin:positioner|move_window", {
await window.__TAURI_INVOKE__("plugin:positioner|move_window", {
position: to,
});
}