diff --git a/src/lib/ipc.ts b/src/lib/ipc.ts index 483eaa8..406c9b0 100644 --- a/src/lib/ipc.ts +++ b/src/lib/ipc.ts @@ -1,28 +1,27 @@ +/* eslint-disable */ // This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually. declare global { interface Window { - __TAURI_INVOKE__( - cmd: string, - args?: Record - ): Promise; + __TAURI_INVOKE__(cmd: string, args?: Record): Promise } } -const invoke = window.__TAURI_INVOKE__; +// Function avoids 'window not defined' in SSR +const invoke = () => window.__TAURI_INVOKE__ export function helloTauri() { - return invoke('hello_tauri'); + return invoke()('hello_tauri') } export function hash256sum(hashInput: string) { - return invoke('hash256sum', { hashInput }); + return invoke()('hash256sum', { hashInput }) } export function storeSetKey(key: string, value: string) { - return invoke('store_set_key', { key, value }); + return invoke()('store_set_key', { key, value }) } export function storeReadKey(key: string) { - return invoke('store_read_key', { key }); + return invoke()('store_read_key', { key }) } diff --git a/src/lib/utils.ts b/src/lib/utils.ts index d9d4c81..fd20585 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,62 +1,62 @@ -import { type ClassValue, clsx } from 'clsx'; -import { twMerge } from 'tailwind-merge'; -import { cubicOut } from 'svelte/easing'; -import type { TransitionConfig } from 'svelte/transition'; +import { type ClassValue, clsx } from 'clsx' +import { twMerge } from 'tailwind-merge' +import { cubicOut } from 'svelte/easing' +import type { TransitionConfig } from 'svelte/transition' export function cn(...inputs: ClassValue[]) { - return twMerge(clsx(inputs)); + return twMerge(clsx(inputs)) } type FlyAndScaleParams = { - y?: number; - x?: number; - start?: number; - duration?: number; -}; + y?: number + x?: number + start?: number + duration?: number +} export const flyAndScale = ( node: Element, params: FlyAndScaleParams = { y: -8, x: 0, start: 0.95, duration: 150 } ): TransitionConfig => { - const style = getComputedStyle(node); - const transform = style.transform === 'none' ? '' : style.transform; + const style = getComputedStyle(node) + const transform = style.transform === 'none' ? '' : style.transform const scaleConversion = ( valueA: number, scaleA: [number, number], scaleB: [number, number] ) => { - const [minA, maxA] = scaleA; - const [minB, maxB] = scaleB; + const [minA, maxA] = scaleA + const [minB, maxB] = scaleB - const percentage = (valueA - minA) / (maxA - minA); - const valueB = percentage * (maxB - minB) + minB; + const percentage = (valueA - minA) / (maxA - minA) + const valueB = percentage * (maxB - minB) + minB - return valueB; - }; + return valueB + } const styleToString = ( style: Record ): string => { return Object.keys(style).reduce((str, key) => { - if (style[key] === undefined) return str; - return str + `${key}:${style[key]};`; - }, ''); - }; + if (style[key] === undefined) return str + return str + `${key}:${style[key]};` + }, '') + } return { duration: params.duration ?? 200, delay: 0, css: t => { - const y = scaleConversion(t, [0, 1], [params.y ?? 5, 0]); - const x = scaleConversion(t, [0, 1], [params.x ?? 0, 0]); - const scale = scaleConversion(t, [0, 1], [params.start ?? 0.95, 1]); + const y = scaleConversion(t, [0, 1], [params.y ?? 5, 0]) + const x = scaleConversion(t, [0, 1], [params.x ?? 0, 0]) + const scale = scaleConversion(t, [0, 1], [params.start ?? 0.95, 1]) return styleToString({ transform: `${transform} translate3d(${x}px, ${y}px, 0) scale(${scale})`, opacity: t - }); + }) }, easing: cubicOut - }; -}; + } +}