/** * this is v experimental. * for the time being, since i cba to write a capacitor plugin for the system * haptics api, we're just using the browser api. */ import { Haptics, type VibrateOptions, type NotificationOptions, type ImpactOptions, ImpactStyle, } from '@capacitor/haptics' export function isVibrationsEnabled(): boolean { return true } export function tap() { Haptics.vibrate({ duration: 1 }) } export async function impact(options?: ImpactOptions): Promise { if (!isVibrationsEnabled()) return try { await Haptics.impact(options || { style: ImpactStyle.Light }) } catch {} } export async function notification(options?: NotificationOptions): Promise { if (!isVibrationsEnabled()) return try { await Haptics.notification(options) } catch {} } export async function vibrate(options?: VibrateOptions): Promise { if (!isVibrationsEnabled()) return try { await Haptics.vibrate(options) } catch {} } async function selectionStart(): Promise { if (!isVibrationsEnabled()) return try { await Haptics.selectionStart() } catch {} } async function selectionChanged(): Promise { if (!isVibrationsEnabled()) return try { await Haptics.selectionChanged() } catch {} } async function selectionEnd(): Promise { if (!isVibrationsEnabled()) return try { await Haptics.selectionEnd() } catch {} } export const selection = { start: selectionStart, changed: selectionChanged, end: selectionEnd, }