|
| 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 buildIndex(records: IndexRecord[]) : Promise<Result<null, string>> { |
| 10 | + try { |
| 11 | + return { status: "ok", data: await TAURI_INVOKE("plugin:pagefind|build_index", { records }) }; |
| 12 | +} catch (e) { |
| 13 | + if(e instanceof Error) throw e; |
| 14 | + else return { status: "error", error: e as any }; |
| 15 | +} |
| 16 | +}, |
| 17 | +async getBundlePath() : Promise<Result<string, string>> { |
| 18 | + try { |
| 19 | + return { status: "ok", data: await TAURI_INVOKE("plugin:pagefind|get_bundle_path") }; |
| 20 | +} catch (e) { |
| 21 | + if(e instanceof Error) throw e; |
| 22 | + else return { status: "error", error: e as any }; |
| 23 | +} |
| 24 | +}, |
| 25 | +async clearIndex() : Promise<Result<null, string>> { |
| 26 | + try { |
| 27 | + return { status: "ok", data: await TAURI_INVOKE("plugin:pagefind|clear_index") }; |
| 28 | +} catch (e) { |
| 29 | + if(e instanceof Error) throw e; |
| 30 | + else return { status: "error", error: e as any }; |
| 31 | +} |
| 32 | +} |
| 33 | +} |
| 34 | + |
| 35 | +/** user-defined events **/ |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +/** user-defined constants **/ |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | +/** user-defined types **/ |
| 44 | + |
| 45 | +export type IndexRecord = { url: string; content: string; title: string | null } |
| 46 | + |
| 47 | +/** tauri-specta globals **/ |
| 48 | + |
| 49 | +import { |
| 50 | + invoke as TAURI_INVOKE, |
| 51 | + Channel as TAURI_CHANNEL, |
| 52 | +} from "@tauri-apps/api/core"; |
| 53 | +import * as TAURI_API_EVENT from "@tauri-apps/api/event"; |
| 54 | +import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow"; |
| 55 | + |
| 56 | +type __EventObj__<T> = { |
| 57 | + listen: ( |
| 58 | + cb: TAURI_API_EVENT.EventCallback<T>, |
| 59 | + ) => ReturnType<typeof TAURI_API_EVENT.listen<T>>; |
| 60 | + once: ( |
| 61 | + cb: TAURI_API_EVENT.EventCallback<T>, |
| 62 | + ) => ReturnType<typeof TAURI_API_EVENT.once<T>>; |
| 63 | + emit: null extends T |
| 64 | + ? (payload?: T) => ReturnType<typeof TAURI_API_EVENT.emit> |
| 65 | + : (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>; |
| 66 | +}; |
| 67 | + |
| 68 | +export type Result<T, E> = |
| 69 | + | { status: "ok"; data: T } |
| 70 | + | { status: "error"; error: E }; |
| 71 | + |
| 72 | +function __makeEvents__<T extends Record<string, any>>( |
| 73 | + mappings: Record<keyof T, string>, |
| 74 | +) { |
| 75 | + return new Proxy( |
| 76 | + {} as unknown as { |
| 77 | + [K in keyof T]: __EventObj__<T[K]> & { |
| 78 | + (handle: __WebviewWindow__): __EventObj__<T[K]>; |
| 79 | + }; |
| 80 | + }, |
| 81 | + { |
| 82 | + get: (_, event) => { |
| 83 | + const name = mappings[event as keyof T]; |
| 84 | + |
| 85 | + return new Proxy((() => {}) as any, { |
| 86 | + apply: (_, __, [window]: [__WebviewWindow__]) => ({ |
| 87 | + listen: (arg: any) => window.listen(name, arg), |
| 88 | + once: (arg: any) => window.once(name, arg), |
| 89 | + emit: (arg: any) => window.emit(name, arg), |
| 90 | + }), |
| 91 | + get: (_, command: keyof __EventObj__<any>) => { |
| 92 | + switch (command) { |
| 93 | + case "listen": |
| 94 | + return (arg: any) => TAURI_API_EVENT.listen(name, arg); |
| 95 | + case "once": |
| 96 | + return (arg: any) => TAURI_API_EVENT.once(name, arg); |
| 97 | + case "emit": |
| 98 | + return (arg: any) => TAURI_API_EVENT.emit(name, arg); |
| 99 | + } |
| 100 | + }, |
| 101 | + }); |
| 102 | + }, |
| 103 | + }, |
| 104 | + ); |
| 105 | +} |
0 commit comments