UNPKG

@daks.dev/svelte.sdk

Version:
76 lines (74 loc) 2.07 kB
import { readable, writable } from 'svelte/store'; export const twmerge = (() => { const { subscribe, set } = writable(); return { subscribe, set }; })(); export const navigate = (() => { const { subscribe, update, set } = writable(); return { subscribe, set, clear: () => update(() => ({})) }; })(); export const sessionTime = readable(0, (set) => { const date = Date.now(); const interval = setInterval(() => { set(Date.now() - date); }, 1000); return function stop() { clearInterval(interval); }; }); export const routeTransitionMode = (() => { const { subscribe, update, set } = writable(0); return { subscribe, set, // (val: number | string) => update(() => Number(val)), change: () => update((val) => (val < 3 ? ++val : 0)) }; })(); export const admindata = (() => { const { subscribe, update, set } = writable({}); return { subscribe, set, clear: () => update(() => ({})) }; })(); export const toastData = (() => { const { subscribe, update } = writable(); const minifier = (val) => val.trim().replace(/\n/g, '').replace(/\s{2}/g, ' '); return { subscribe, set: (val) => update(() => ({ message: minifier(val) })), once: (message, local) => `toast-${local}` in localStorage || update(() => { return { message: minifier(message), close: () => localStorage.setItem(`toast-${local}`, 'done') }; }), clear: () => update(() => ({ message: '' })) }; })(); export const svelteKitCount = writable(0); /* export const theme = (() => { const { subscribe, update } = writable(true); return { subscribe, change: () => update((val) => { const htmlTag = document.getElementsByTagName('html').item(0); if (htmlTag) { htmlTag.className = val ? 'light' : 'dark'; } return !val; }) }; })(); */