···11<script lang="ts">
22 import { slide, fly } from 'svelte/transition'
33 import { getCronText, invisibleCursorFix } from './helpers'
44- import type { Group } from './types'
44+ import type { Group } from '../../bindings'
5566 export let group: Group
77
+1-1
src/lib/Item.svelte
···11<script lang="ts">
22 import { onMount, tick } from 'svelte'
33- import type { Group } from './types'
33+ import type { Group } from '../../bindings'
44 import Switch from './Switch.svelte'
55 import { checkShortcut, getCronText, invisibleCursorFix } from './helpers'
66 import Edit from './Edit.svelte'
+4-3
src/lib/New.svelte
···33 import { cubicOut } from 'svelte/easing'
44 import { slide } from 'svelte/transition'
55 import Edit from './Edit.svelte'
66- import type { Group } from './types'
77- import { checkShortcut, invisibleCursorFix, runCmd } from './helpers'
66+ import { checkShortcut, invisibleCursorFix } from './helpers'
77+ import commands from './commands'
88+ import type { Group } from '../../bindings'
89910 export let onCreate: (newGroups: Group[]) => void
1011 let editMode = false
···2223 }
23242425 async function create(newGroup: Group) {
2525- const newGroups: Group[] = await runCmd('new_group', { group: newGroup })
2626+ const newGroups: Group[] = await commands.newGroup(newGroup)
2627 editMode = false
2728 onCreate(newGroups)
2829 group = newBlank()
+14
src/lib/commands.ts
···11+import * as c from '../../bindings'
22+export default new Proxy({} as typeof c, {
33+ get:
44+ (_, property: string) =>
55+ async (...args: unknown[]) => {
66+ try {
77+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
88+ return await (c as any)[property](...args)
99+ } catch (e) {
1010+ c.errorPopup(String(e))
1111+ throw e
1212+ }
1313+ },
1414+})
-13
src/lib/helpers.ts
···11-import { invoke } from '@tauri-apps/api/tauri'
21import crontrue from 'cronstrue'
33-44-export function popup(msg: string) {
55- invoke('error_popup', { msg })
66-}
77-88-// eslint-disable-next-line @typescript-eslint/no-explicit-any
99-export async function runCmd<T = any>(cmd: string, options: { [key: string]: any } = {}) {
1010- return (await invoke(cmd, options).catch((msg) => {
1111- popup(msg)
1212- throw msg
1313- })) as T
1414-}
152163type ShortcutOptions = {
174 shift?: boolean