diff --git a/src/app.d.ts b/src/app.d.ts index 919b1d4..d61b1ec 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -16,4 +16,8 @@ declare global { } } +import type {} from '@atcute/atproto'; +import type {} from '@atcute/bluesky'; + + export {}; diff --git a/src/lib/atproto/methods.ts b/src/lib/atproto/methods.ts index 776d7d2..99d7ab4 100644 --- a/src/lib/atproto/methods.ts +++ b/src/lib/atproto/methods.ts @@ -18,7 +18,7 @@ export function parseUri(uri: string) { return { did, collection, rkey } as { collection: `${string}.${string}.${string}`; rkey: string; - did: string; + did: Did; }; } diff --git a/src/lib/cards/SpecialCards/UpdatedBlentos/index.ts b/src/lib/cards/SpecialCards/UpdatedBlentos/index.ts index 3af348a..a935ce3 100644 --- a/src/lib/cards/SpecialCards/UpdatedBlentos/index.ts +++ b/src/lib/cards/SpecialCards/UpdatedBlentos/index.ts @@ -1,8 +1,8 @@ import { getDetailedProfile } from '$lib/atproto'; -import type { ProfileViewDetailed } from '@atproto/api/dist/client/types/app/bsky/actor/defs'; import type { CardDefinition } from '../../types'; import UpdatedBlentosCard from './UpdatedBlentosCard.svelte'; -import { AppBskyActorDefs } from '@atcute/bluesky'; +import type { Did } from '@atcute/lexicons'; +import type { AppBskyActorDefs } from '@atcute/bluesky'; export const UpdatedBlentosCardDefitition = { type: 'updatedBlentos', @@ -14,18 +14,18 @@ export const UpdatedBlentosCardDefitition = { ); const recentRecords = await response.json(); const existingUsers = await cache?.get('updatedBlentos'); - const existingUsersArray: ProfileViewDetailed[] = existingUsers + const existingUsersArray: AppBskyActorDefs.ProfileViewDetailed[] = existingUsers ? JSON.parse(existingUsers) : []; const existingUsersSet = new Set(existingUsersArray.map((v) => v.did)); - const uniqueDids = new Set(); + const uniqueDids = new Set(); for (const record of recentRecords as { did: string }[]) { - if (!existingUsersSet.has(record.did)) uniqueDids.add(record.did); + if (!existingUsersSet.has(record.did as Did)) uniqueDids.add(record.did as Did); } - const profiles: Promise[] = []; + const profiles: Promise[] = []; for (const did of Array.from(uniqueDids)) { const profile = getDetailedProfile({ did }); diff --git a/src/lib/cards/types.ts b/src/lib/cards/types.ts index 9182535..b285a3d 100644 --- a/src/lib/cards/types.ts +++ b/src/lib/cards/types.ts @@ -1,5 +1,6 @@ import type { Component } from 'svelte'; import type { Item, UserCache } from '$lib/types'; +import type { Did } from '@atcute/lexicons'; export type CreationModalComponentProps = { item: Item; @@ -42,7 +43,7 @@ export type CardDefinition = { loadData?: ( // all cards of that type items: Item[], - { did, handle, cache }: { did: string; handle: string; cache?: UserCache } + { did, handle, cache }: { did: Did; handle: string; cache?: UserCache } ) => Promise; // show color selection popup diff --git a/src/lib/helper.ts b/src/lib/helper.ts index 6b34445..411113c 100644 --- a/src/lib/helper.ts +++ b/src/lib/helper.ts @@ -446,9 +446,7 @@ export async function savePage( const item = currentItems.find((i) => i.id === originalItem.id); if (!item) { console.log('deleting item', originalItem); - promises.push( - deleteRecord({ collection: 'app.blento.card', rkey: originalItem.id, did: data.did }) - ); + promises.push(deleteRecord({ collection: 'app.blento.card', rkey: originalItem.id })); } } diff --git a/src/lib/website/Account.svelte b/src/lib/website/Account.svelte index 301cca5..5fab4a4 100644 --- a/src/lib/website/Account.svelte +++ b/src/lib/website/Account.svelte @@ -1,6 +1,7 @@ {@render children()} diff --git a/src/lib/website/Profile.svelte b/src/lib/website/Profile.svelte index e683af4..33ca406 100644 --- a/src/lib/website/Profile.svelte +++ b/src/lib/website/Profile.svelte @@ -7,6 +7,7 @@ import type { WebsiteData } from '$lib/types'; import { getDescription, getName } from '$lib/helper'; import { page } from '$app/state'; + import type { ActorIdentifier } from '@atcute/lexicons'; let { data, @@ -40,7 +41,7 @@ {getName(data)} -
+
@@ -70,8 +71,8 @@ Edit Your Website
- {:else} -
+ {:else} +
{/if} {#if !env.PUBLIC_IS_SELFHOSTED && data.handle === 'blento.app' && user.profile?.handle !== data.handle} @@ -82,7 +83,7 @@
{ - await login(handle); + await login(handle as ActorIdentifier); return true; }} /> diff --git a/src/lib/website/Website.svelte b/src/lib/website/Website.svelte index ec1ffa0..6a1ab13 100644 --- a/src/lib/website/Website.svelte +++ b/src/lib/website/Website.svelte @@ -8,6 +8,7 @@ import type { WebsiteData } from '$lib/types'; import Context from './Context.svelte'; import Head from './Head.svelte'; + import type { Did, Handle } from '@atcute/lexicons'; let { data }: { data: WebsiteData } = $props(); @@ -15,9 +16,9 @@ setIsMobile(() => isMobile); // svelte-ignore state_referenced_locally - setDidContext(data.did); + setDidContext(data.did as Did); // svelte-ignore state_referenced_locally - setHandleContext(data.handle); + setHandleContext(data.handle as Handle); let maxHeight = $derived( data.cards.reduce( diff --git a/src/lib/website/context.ts b/src/lib/website/context.ts index 1a7cd68..a437716 100644 --- a/src/lib/website/context.ts +++ b/src/lib/website/context.ts @@ -1,7 +1,8 @@ +import type { Did, Handle } from '@atcute/lexicons'; import { createContext } from 'svelte'; -export const [getDidContext, setDidContext] = createContext(); -export const [getHandleContext, setHandleContext] = createContext(); +export const [getDidContext, setDidContext] = createContext(); +export const [getHandleContext, setHandleContext] = createContext(); export const [getIsMobile, setIsMobile] = createContext<() => boolean>(); export const [getCanEdit, setCanEdit] = createContext<() => boolean>(); export const [getAdditionalUserData, setAdditionalUserData] = diff --git a/src/lib/website/load.ts b/src/lib/website/load.ts index fa74eca..9be932c 100644 --- a/src/lib/website/load.ts +++ b/src/lib/website/load.ts @@ -4,6 +4,7 @@ import { CardDefinitionsByType } from '$lib/cards'; import type { Item, UserCache, WebsiteData } from '$lib/types'; import { compactItems, fixAllCollisions } from '$lib/helper'; import { error } from '@sveltejs/kit'; +import type { Handle } from '@atcute/lexicons'; const CURRENT_CACHE_VERSION = 1; @@ -44,7 +45,7 @@ export async function getCache(handle: string, page: string, cache?: UserCache) } export async function loadData( - handle: string, + handle: Handle, cache: UserCache | undefined, forceUpdate: boolean = false, page: string = 'self' diff --git a/src/params/handle.ts b/src/params/handle.ts new file mode 100644 index 0000000..18f16c7 --- /dev/null +++ b/src/params/handle.ts @@ -0,0 +1,5 @@ +import type { ParamMatcher } from '@sveltejs/kit'; + +export const match = ((param: string) => { + return param.includes('.'); +}) satisfies ParamMatcher; diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index 02d1c01..dc433aa 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -1,6 +1,7 @@ import { loadData } from '$lib/website/load'; import { env } from '$env/dynamic/public'; import type { UserCache } from '$lib/types'; +import type { Handle } from '@atcute/lexicons'; export async function load({ platform, url }) { const hostname = url.hostname; @@ -11,5 +12,5 @@ export async function load({ platform, url }) { } const cache = platform?.env?.USER_DATA_CACHE as unknown; - return await loadData(handle, cache as UserCache); + return await loadData(handle as Handle, cache as UserCache); } diff --git a/src/routes/[handle]/.well-known/site.standard.publication/+server.ts b/src/routes/[handle=handle]/.well-known/site.standard.publication/+server.ts similarity index 100% rename from src/routes/[handle]/.well-known/site.standard.publication/+server.ts rename to src/routes/[handle=handle]/.well-known/site.standard.publication/+server.ts diff --git a/src/routes/[handle]/[[page]]/+layout.server.ts b/src/routes/[handle=handle]/[[page]]/+layout.server.ts similarity index 72% rename from src/routes/[handle]/[[page]]/+layout.server.ts rename to src/routes/[handle=handle]/[[page]]/+layout.server.ts index f90a4d2..c09a661 100644 --- a/src/routes/[handle]/[[page]]/+layout.server.ts +++ b/src/routes/[handle=handle]/[[page]]/+layout.server.ts @@ -2,6 +2,7 @@ import { loadData } from '$lib/website/load'; import { env } from '$env/dynamic/private'; import { error } from '@sveltejs/kit'; import type { UserCache } from '$lib/types'; +import type { Handle } from '@atcute/lexicons'; export async function load({ params, platform }) { if (env.PUBLIC_IS_SELFHOSTED) error(404); @@ -10,5 +11,5 @@ export async function load({ params, platform }) { console.log(params.page); - return await loadData(params.handle, cache as UserCache, false, params.page); + return await loadData(params.handle as Handle, cache as UserCache, false, params.page); } diff --git a/src/routes/[handle]/[[page]]/+page.svelte b/src/routes/[handle=handle]/[[page]]/+page.svelte similarity index 100% rename from src/routes/[handle]/[[page]]/+page.svelte rename to src/routes/[handle=handle]/[[page]]/+page.svelte diff --git a/src/routes/[handle]/[[page]]/edit/+page.svelte b/src/routes/[handle=handle]/[[page]]/edit/+page.svelte similarity index 100% rename from src/routes/[handle]/[[page]]/edit/+page.svelte rename to src/routes/[handle=handle]/[[page]]/edit/+page.svelte diff --git a/src/routes/[handle]/api/refreshData/+server.ts b/src/routes/[handle=handle]/api/refreshData/+server.ts similarity index 76% rename from src/routes/[handle]/api/refreshData/+server.ts rename to src/routes/[handle=handle]/api/refreshData/+server.ts index 235a90c..fb47780 100644 --- a/src/routes/[handle]/api/refreshData/+server.ts +++ b/src/routes/[handle=handle]/api/refreshData/+server.ts @@ -1,5 +1,6 @@ import type { UserCache } from '$lib/types'; import { loadData } from '$lib/website/load.js'; +import type { Handle } from '@atcute/lexicons'; import { json } from '@sveltejs/kit'; export async function GET({ params, platform }) { @@ -7,7 +8,7 @@ export async function GET({ params, platform }) { const handle = params.handle; const cache = platform?.env?.USER_DATA_CACHE as unknown; - await loadData(handle, cache as UserCache, true); + await loadData(handle as Handle, cache as UserCache, true); return json('ok'); } diff --git a/src/routes/[handle]/og.png/+server.ts b/src/routes/[handle=handle]/og.png/+server.ts similarity index 92% rename from src/routes/[handle]/og.png/+server.ts rename to src/routes/[handle=handle]/og.png/+server.ts index fa49343..51d9102 100644 --- a/src/routes/[handle]/og.png/+server.ts +++ b/src/routes/[handle=handle]/og.png/+server.ts @@ -1,5 +1,6 @@ import type { UserCache } from '$lib/types'; import { loadData } from '$lib/website/load'; +import type { Handle } from '@atcute/lexicons'; import { ImageResponse } from '@ethercorps/sveltekit-og'; export async function GET({ params, platform }) { @@ -7,7 +8,7 @@ export async function GET({ params, platform }) { const cache = platform?.env?.USER_DATA_CACHE as unknown; - const data = await loadData(params.handle, cache as UserCache); + const data = await loadData(params.handle as Handle, cache as UserCache); const image = data.profile.avatar; diff --git a/src/routes/all/+page.server.ts b/src/routes/all/+page.server.ts index f86187a..6ba8fe4 100644 --- a/src/routes/all/+page.server.ts +++ b/src/routes/all/+page.server.ts @@ -1,6 +1,7 @@ import { env } from '$env/dynamic/public'; import type { UserCache, WebsiteData } from '$lib/types.js'; import { loadData } from '$lib/website/load'; +import type { Handle } from '@atcute/lexicons'; import type { ProfileViewDetailed } from '@atproto/api/dist/client/types/app/bsky/actor/defs.js'; export async function load({ platform }) { @@ -24,7 +25,7 @@ export async function load({ platform }) { const handle = env.PUBLIC_HANDLE; - const data = await loadData(handle, cache as unknown as UserCache); + const data = await loadData(handle as Handle, cache as unknown as UserCache); data.publication ??= {}; data.publication.preferences ??= {}; diff --git a/src/routes/api/links/+server.ts b/src/routes/api/links/+server.ts index c8cdecb..9a8574c 100644 --- a/src/routes/api/links/+server.ts +++ b/src/routes/api/links/+server.ts @@ -7,12 +7,10 @@ export async function GET({ url }) { return json({ error: 'No link provided' }, { status: 400 }); } - // check if link is valid url try { new URL(link); - // eslint-disable-next-line @typescript-eslint/no-unused-vars - } catch (_) { - return json({ error: 'Link is not a valid url' }, { status: 500 }); + } catch { + return json({ error: 'Link is not a valid url' }, { status: 400 }); } try { diff --git a/src/routes/api/reloadRecent/+server.ts b/src/routes/api/reloadRecent/+server.ts index 7fe0ad9..c47aafa 100644 --- a/src/routes/api/reloadRecent/+server.ts +++ b/src/routes/api/reloadRecent/+server.ts @@ -1,16 +1,18 @@ import { getDetailedProfile } from '$lib/atproto'; -import type { ProfileViewDetailed } from '@atproto/api/dist/client/types/app/bsky/actor/defs'; import { json } from '@sveltejs/kit'; +import type { AppBskyActorDefs } from '@atcute/bluesky'; export async function GET({ platform }) { if (!platform?.env?.USER_DATA_CACHE) return json('no cache'); const existingUsers = await platform?.env?.USER_DATA_CACHE?.get('updatedBlentos'); - const existingUsersArray: ProfileViewDetailed[] = existingUsers ? JSON.parse(existingUsers) : []; + const existingUsersArray: AppBskyActorDefs.ProfileViewDetailed[] = existingUsers + ? JSON.parse(existingUsers) + : []; const existingUsersSet = new Set(existingUsersArray.map((v) => v.did)); - const newProfilesPromises: Promise[] = []; + const newProfilesPromises: Promise[] = []; for (const did of Array.from(existingUsersSet)) { const profile = getDetailedProfile({ did }); newProfilesPromises.push(profile); diff --git a/src/routes/api/update/+server.ts b/src/routes/api/update/+server.ts index f885d62..626496c 100644 --- a/src/routes/api/update/+server.ts +++ b/src/routes/api/update/+server.ts @@ -1,13 +1,15 @@ import type { UserCache } from '$lib/types'; import { getCache, loadData } from '$lib/website/load'; -import type { ProfileViewDetailed } from '@atproto/api/dist/client/types/app/bsky/actor/defs'; +import type { AppBskyActorDefs } from '@atcute/bluesky'; import { json } from '@sveltejs/kit'; export async function GET({ platform }) { if (!platform?.env?.USER_DATA_CACHE) return json('no cache'); const existingUsers = await platform?.env?.USER_DATA_CACHE?.get('updatedBlentos'); - const existingUsersArray: ProfileViewDetailed[] = existingUsers ? JSON.parse(existingUsers) : []; + const existingUsersArray: AppBskyActorDefs.ProfileViewDetailed[] = existingUsers + ? JSON.parse(existingUsers) + : []; const existingUsersHandle = existingUsersArray.map((v) => v.handle); diff --git a/src/routes/edit/+page.server.ts b/src/routes/edit/+page.server.ts index d1278ac..7669554 100644 --- a/src/routes/edit/+page.server.ts +++ b/src/routes/edit/+page.server.ts @@ -1,6 +1,7 @@ import { loadData } from '$lib/website/load'; import { env } from '$env/dynamic/public'; import type { UserCache } from '$lib/types'; +import type { Handle } from '@atcute/lexicons'; export async function load({ url, platform }) { const hostname = url.hostname; @@ -12,5 +13,5 @@ export async function load({ url, platform }) { const cache = platform?.env?.USER_DATA_CACHE as unknown; - return await loadData(handle, cache as UserCache); + return await loadData(handle as Handle, cache as UserCache); }