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
+7 -2
View File
@@ -2,9 +2,14 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import { invoke } from "@tauri-apps/api/tauri";
import { listen, UnlistenFn } from "@tauri-apps/api/event";
declare global {
interface Window {
__TAURI_INVOKE__: <T>(cmd: string, args?: unknown) => Promise<T>;
}
}
export type LogOptions = {
file?: string;
line?: number;
@@ -61,7 +66,7 @@ async function log(
location = "webview::unknown";
}
await invoke("plugin:log|log", {
await window.__TAURI_INVOKE__("plugin:log|log", {
level,
message,
location,