import type { Cookies } from '@sveltejs/kit' import { existsSync, readFileSync } from 'fs' import { cwd } from 'process' import { writable } from 'svelte/store' export const scopeCookies = (cookies: Cookies, path: string) => { return { get: (key: string) => { return cookies.get(key) }, set: (key: string, value: string, props: import('cookie').CookieSerializeOptions = {}) => { cookies.set(key, value, { ...props, path }) }, delete: (key: string, props: import('cookie').CookieSerializeOptions = {}) => { cookies.delete(key, { ...props, path }) } } } export const visitCountFile = `${cwd()}/visitcount` export const visitCount = writable(parseInt(existsSync(visitCountFile) ? readFileSync(visitCountFile).toString() : '0'));