diff --git a/bun.lockb b/bun.lockb index 3e97801..6853be8 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index ac16773..91b370d 100644 --- a/package.json +++ b/package.json @@ -13,35 +13,35 @@ }, "devDependencies": { "@sveltejs/enhanced-img": "^0.3.10", - "@sveltejs/kit": "^2.8.4", + "@sveltejs/kit": "^2.11.1", "@sveltejs/vite-plugin-svelte": "^3.1.2", "@tailwindcss/forms": "^0.5.9", "@tailwindcss/typography": "^0.5.15", "@types/eslint": "^9.6.1", - "@types/node": "^22.10.0", + "@types/node": "^22.10.2", "autoprefixer": "^10.4.20", - "eslint": "^9.15.0", + "eslint": "^9.17.0", "eslint-config-prettier": "^9.1.0", - "eslint-plugin-svelte": "^2.46.0", - "globals": "^15.12.0", + "eslint-plugin-svelte": "^2.46.1", + "globals": "^15.13.0", "mdsvex": "^0.12.3", "postcss": "^8.4.49", - "prettier": "^3.4.1", + "prettier": "^3.4.2", "prettier-plugin-svelte": "^3.3.2", "svelte": "^4.2.19", "svelte-adapter-bun": "^0.5.2", "svelte-check": "^3.8.6", "sveltekit-rate-limiter": "^0.6.1", - "tailwindcss": "^3.4.15", + "tailwindcss": "^3.4.16", "tslib": "^2.8.1", "typescript": "^5.7.2", - "typescript-eslint": "^8.16.0", + "typescript-eslint": "^8.18.0", "vite": "^5.4.11" }, "type": "module", "dependencies": { - "@atproto/api": "^0.13.18", - "@neodrag/svelte": "^2.0.6", + "@neodrag/svelte": "^2.2.0", + "@skyware/bot": "^0.3.8", "@std/toml": "npm:@jsr/std__toml", "base64url": "^3.0.1", "nanoid": "^5.0.9", @@ -49,7 +49,7 @@ "rehype-slug": "^6.0.0", "robots-parser": "^3.0.1", "steamgriddb": "^2.2.0", - "typescript-svelte-plugin": "^0.3.43" + "typescript-svelte-plugin": "^0.3.44" }, "trustedDependencies": [ "@sveltejs/kit", diff --git a/src/lib/bluesky.ts b/src/lib/bluesky.ts index 1835db0..671b7a5 100644 --- a/src/lib/bluesky.ts +++ b/src/lib/bluesky.ts @@ -1,8 +1,8 @@ import { env } from '$env/dynamic/private' -import { Agent, CredentialSession, RichText } from '@atproto/api' +import { Bot } from "@skyware/bot"; import { get, writable } from 'svelte/store' -const bskyClient = writable(null) +const bskyClient = writable(null) export const getBskyClient = async () => { let client = get(bskyClient) @@ -13,19 +13,15 @@ export const getBskyClient = async () => { return client } -export const postToBsky = async (text: string) => { - let client = await getBskyClient() - const rt = new RichText({ text }) - await rt.detectFacets(client) - const {uri} = await client.post({ - text: rt.text, - facets: rt.facets, - }) +export const parseAtUri = (uri: string) => { + if (uri.startsWith("https://bsky.gaze.systems")) { + return uri + } return `https://bsky.gaze.systems/post/${uri.split('/').pop()}` } const loginToBsky = async () => { - const creds = new CredentialSession(new URL("https://bsky.social")) - await creds.login({ identifier: 'gaze.systems', password: env.BSKY_PASSWORD ?? "" }) - return new Agent(creds) + const bot = new Bot({ service: "https://bsky.social" }) + await bot.login({ identifier: 'gaze.systems', password: env.BSKY_PASSWORD ?? "" }) + return bot } \ No newline at end of file diff --git a/src/lib/notes.ts b/src/lib/notes.ts index 1f31ff4..e124e74 100644 --- a/src/lib/notes.ts +++ b/src/lib/notes.ts @@ -11,6 +11,7 @@ export interface Note { content: string, published: number, outgoingLinks?: OutgoingLinkData[], + replyTo?: NoteId, } type NoteId = string @@ -30,6 +31,21 @@ export const noteExists = (id: NoteId) => { return existsSync(getNotePath(id)) } export const readNote = (id: NoteId): Note => { return JSON.parse(readFileSync(getNotePath(id)).toString()) } +export const findReplyRoot = (id: NoteId): {rootNote: Note, rootNoteId: NoteId} => { + let currentNoteId: string | null = id + let currentNote: Note | null = null + while (currentNoteId !== null) { + currentNote = readNote(currentNoteId) + currentNoteId = currentNote.replyTo ?? null + } + if (currentNote === null || currentNoteId === null) { + throw "no note with id found" + } + return { + rootNote: currentNote, + rootNoteId: currentNoteId, + } +} export const writeNote = (id: NoteId, note: Note) => { writeFileSync(getNotePath(id), JSON.stringify(note)) // only append to note list if its not in it yet diff --git a/src/routes/log/+page.svelte b/src/routes/log/+page.svelte index 0aa9a9a..43c3c61 100644 --- a/src/routes/log/+page.svelte +++ b/src/routes/log/+page.svelte @@ -1,6 +1,7 @@