import { InvokeArgs, InvokeOptions, invoke as real_invoke, } from '@tauri-apps/api/core'; import { emit } from '@tauri-apps/api/event'; export const invoke = async ( cmd: string, args?: InvokeArgs, options?: InvokeOptions ): Promise => { try { return await real_invoke(cmd, args, options); } catch (e: unknown) { if (typeof e === 'string') { emit('invoke-error', { message: e, header: `${cmd} failed`, }); } else { console.error(`Unresolved error: ${e}`); } throw e; } }; export const invoke_nopopup = async ( cmd: string, args?: InvokeArgs, options?: InvokeOptions ): Promise => { try { return await real_invoke(cmd, args, options); } catch (e: unknown) { console.error(`Error invoking ${cmd}: ${e}`); throw e; } };