diff --git a/bun.lockb b/bun.lockb index faccfb9..024e997 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index f32c4ef..b638162 100644 --- a/package.json +++ b/package.json @@ -14,35 +14,35 @@ "author": "Rubicon", "license": "Apache-2.0", "devDependencies": { - "@suid/vite-plugin": "^0.2.0", + "@suid/vite-plugin": "^0.3.0", "@types/hammerjs": "^2.0.45", - "postcss": "^8.4.41", + "postcss": "^8.4.45", "prettier": "^3.3.3", - "typescript": "^5.5.4", - "vite": "^5.4.0", + "typescript": "^5.6.2", + "vite": "^5.4.5", "vite-plugin-package-version": "^1.1.0", - "vite-plugin-pwa": "^0.20.1", + "vite-plugin-pwa": "^0.20.5", "vite-plugin-solid": "^2.10.2", "vite-plugin-solid-styled": "^0.11.1", - "wrangler": "^3.70.0" + "wrangler": "^3.78.2" }, "dependencies": { - "@nanostores/persistent": "^0.9.1", + "@nanostores/persistent": "^0.10.2", "@nanostores/solid": "^0.4.2", "@solid-primitives/event-listener": "^2.3.3", "@solid-primitives/intersection-observer": "^2.1.6", "@solid-primitives/resize-observer": "^2.0.26", - "@solidjs/router": "^0.11.5", - "@suid/icons-material": "^0.7.0", - "@suid/material": "^0.16.0", + "@solidjs/router": "^0.14.5", + "@suid/icons-material": "^0.8.0", + "@suid/material": "^0.17.0", "blurhash": "^2.0.5", "colorjs.io": "^0.5.2", "date-fns": "^3.6.0", "fast-average-color": "^9.4.0", "hammerjs": "^2.0.8", "masto": "^6.8.0", - "nanostores": "^0.9.5", - "solid-js": "^1.8.20", + "nanostores": "^0.11.3", + "solid-js": "^1.8.22", "solid-styled": "^0.11.1", "stacktrace-js": "^2.0.2", "web-animations-js": "^2.3.2" diff --git a/src/accounts/stores.ts b/src/accounts/stores.ts index d34a420..9d7a270 100644 --- a/src/accounts/stores.ts +++ b/src/accounts/stores.ts @@ -4,7 +4,6 @@ import { createRestAPIClient, type mastodon, } from "masto"; -import { action } from "nanostores"; import { createMastoClientFor } from "../masto/clients"; export type Account = { @@ -57,11 +56,9 @@ async function oauth2TokenViaAuthCode(app: RegisteredApp, authCode: string) { } } -export const acceptAccountViaAuthCode = action( - $accounts, - "acceptAccount", - async ($store, site: string, authCode: string) => { - const app = $registeredApps.get()[site]; +export async function acceptAccountViaAuthCode(site: string, authCode: string) { + const $store = $accounts; + const app = $registeredApps.get()[site]; if (!app) { throw TypeError("application not found"); } @@ -79,29 +76,20 @@ export const acceptAccountViaAuthCode = action( $store.set(all); return acct; - }, -); +} -export const updateAcctInf = action( - $accounts, - "updateAcctInf", - async ($store, idx: number) => { - const o = $store.get(); +export async function updateAcctInf(idx: number) { + const o = $accounts.get(); const client = createMastoClientFor(o[idx]); const inf = await client.v1.accounts.verifyCredentials(); o[idx].inf = inf; - $store.set(o); + $accounts.set(o); return inf; - }, -); +} -export const signOut = action( - $accounts, - "signOut", - ($store, predicate: (acct: Account) => boolean) => { - $store.set($store.get().filter((a) => !predicate(a))); - }, -); +export function signOut(predicate: (acct: Account) => boolean) { + $accounts.set($accounts.get().filter((a) => !predicate(a))); +} export type RegisteredApp = { site: string; @@ -140,11 +128,9 @@ async function getAppAccessToken(app: RegisteredApp) { return dict.access_token; } -export const getOrRegisterApp = action( - $registeredApps, - "getOrRegisterApp", - async ($store, site: string, redirectUrl: string) => { - const all = $store.get(); +export async function getOrRegisterApp(site: string, redirectUrl: string) { + const $store = $registeredApps; + const all = $store.get(); const savedApp = all[site]; if (savedApp && savedApp.redirectUrl === redirectUrl) { const appAccessToken = await getAppAccessToken(savedApp); @@ -198,5 +184,4 @@ export const getOrRegisterApp = action( }; $store.set(all); return all[site]; - }, -); +}