|
| 1 | +// @ts-nocheck |
| 2 | + |
| 3 | +// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually. |
| 4 | + |
| 5 | +/** user-defined commands **/ |
| 6 | + |
| 7 | + |
| 8 | +export const commands = { |
| 9 | +async ping() : Promise<Result<string, string>> { |
| 10 | + try { |
| 11 | + return { status: "ok", data: await TAURI_INVOKE("plugin:folder|ping") }; |
| 12 | +} catch (e) { |
| 13 | + if(e instanceof Error) throw e; |
| 14 | + else return { status: "error", error: e as any }; |
| 15 | +} |
| 16 | +} |
| 17 | +} |
| 18 | + |
| 19 | +/** user-defined events **/ |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | +/** user-defined constants **/ |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +/** user-defined types **/ |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +/** tauri-specta globals **/ |
| 32 | + |
| 33 | +import { |
| 34 | + invoke as TAURI_INVOKE, |
| 35 | + Channel as TAURI_CHANNEL, |
| 36 | +} from "@tauri-apps/api/core"; |
| 37 | +import * as TAURI_API_EVENT from "@tauri-apps/api/event"; |
| 38 | +import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow"; |
| 39 | + |
| 40 | +type __EventObj__<T> = { |
| 41 | + listen: ( |
| 42 | + cb: TAURI_API_EVENT.EventCallback<T>, |
| 43 | + ) => ReturnType<typeof TAURI_API_EVENT.listen<T>>; |
| 44 | + once: ( |
| 45 | + cb: TAURI_API_EVENT.EventCallback<T>, |
| 46 | + ) => ReturnType<typeof TAURI_API_EVENT.once<T>>; |
| 47 | + emit: null extends T |
| 48 | + ? (payload?: T) => ReturnType<typeof TAURI_API_EVENT.emit> |
| 49 | + : (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>; |
| 50 | +}; |
| 51 | + |
| 52 | +export type Result<T, E> = |
| 53 | + | { status: "ok"; data: T } |
| 54 | + | { status: "error"; error: E }; |
| 55 | + |
| 56 | +function __makeEvents__<T extends Record<string, any>>( |
| 57 | + mappings: Record<keyof T, string>, |
| 58 | +) { |
| 59 | + return new Proxy( |
| 60 | + {} as unknown as { |
| 61 | + [K in keyof T]: __EventObj__<T[K]> & { |
| 62 | + (handle: __WebviewWindow__): __EventObj__<T[K]>; |
| 63 | + }; |
| 64 | + }, |
| 65 | + { |
| 66 | + get: (_, event) => { |
| 67 | + const name = mappings[event as keyof T]; |
| 68 | + |
| 69 | + return new Proxy((() => {}) as any, { |
| 70 | + apply: (_, __, [window]: [__WebviewWindow__]) => ({ |
| 71 | + listen: (arg: any) => window.listen(name, arg), |
| 72 | + once: (arg: any) => window.once(name, arg), |
| 73 | + emit: (arg: any) => window.emit(name, arg), |
| 74 | + }), |
| 75 | + get: (_, command: keyof __EventObj__<any>) => { |
| 76 | + switch (command) { |
| 77 | + case "listen": |
| 78 | + return (arg: any) => TAURI_API_EVENT.listen(name, arg); |
| 79 | + case "once": |
| 80 | + return (arg: any) => TAURI_API_EVENT.once(name, arg); |
| 81 | + case "emit": |
| 82 | + return (arg: any) => TAURI_API_EVENT.emit(name, arg); |
| 83 | + } |
| 84 | + }, |
| 85 | + }); |
| 86 | + }, |
| 87 | + }, |
| 88 | + ); |
| 89 | +} |
0 commit comments