atproto explorer pdsls.dev
atproto tool
at v1.1.0 3.4 kB view raw
1export type AppUrl = `${string}.${string}` | `localhost:${number}`; 2 3export enum App { 4 Bluesky, 5 Tangled, 6 Whitewind, 7 Frontpage, 8 Pinksea, 9 Linkat, 10} 11 12export const appName = { 13 [App.Bluesky]: "Bluesky", 14 [App.Tangled]: "Tangled", 15 [App.Whitewind]: "Whitewind", 16 [App.Frontpage]: "Frontpage", 17 [App.Pinksea]: "Pinksea", 18 [App.Linkat]: "Linkat", 19}; 20 21export const appList: Record<AppUrl, App> = { 22 "localhost:19006": App.Bluesky, 23 "blacksky.community": App.Bluesky, 24 "bsky.app": App.Bluesky, 25 "catsky.social": App.Bluesky, 26 "deer.aylac.top": App.Bluesky, 27 "deer-social-ayla.pages.dev": App.Bluesky, 28 "deer.social": App.Bluesky, 29 "main.bsky.dev": App.Bluesky, 30 "social.daniela.lol": App.Bluesky, 31 "tangled.org": App.Tangled, 32 "whtwnd.com": App.Whitewind, 33 "frontpage.fyi": App.Frontpage, 34 "pinksea.art": App.Pinksea, 35 "linkat.blue": App.Linkat, 36}; 37 38export const appHandleLink: Record<App, (url: string[]) => string> = { 39 [App.Bluesky]: (path) => { 40 const baseType = path[0]; 41 const user = path[1]; 42 43 if (baseType === "profile") { 44 if (path[2]) { 45 const type = path[2]; 46 const rkey = path[3]; 47 48 if (type === "post") { 49 return `at://${user}/app.bsky.feed.post/${rkey}`; 50 } else if (type === "lists") { 51 return `at://${user}/app.bsky.graph.list/${rkey}`; 52 } else if (type === "feed") { 53 return `at://${user}/app.bsky.feed.generator/${rkey}`; 54 } else if (type === "follows") { 55 return `at://${user}/app.bsky.graph.follow/${rkey}`; 56 } 57 } else { 58 return `at://${user}`; 59 } 60 } else if (baseType === "starter-pack") { 61 return `at://${user}/app.bsky.graph.starterpack/${path[2]}`; 62 } 63 return `at://${user}`; 64 }, 65 [App.Tangled]: (path) => { 66 if (path[0] === "strings") { 67 return `at://${path[1]}/sh.tangled.string/${path[2]}`; 68 } 69 70 let query: string | undefined; 71 if (path[path.length - 1].includes("?")) { 72 const split = path[path.length - 1].split("?"); 73 query = split[1]; 74 path[path.length - 1] = split[0]; 75 } 76 77 const user = path[0].replace("@", ""); 78 79 if (path.length === 1) { 80 if (query === "tab=repos") { 81 return `at://${user}/sh.tangled.repo`; 82 } else if (query === "tab=starred") { 83 return `at://${user}/sh.tangled.feed.star`; 84 } else if (query === "tab=strings") { 85 return `at://${user}/sh.tangled.string`; 86 } 87 } else if (path.length === 2) { 88 // no way to convert the repo name to an rkey afaik 89 // same reason why there's nothing related to issues in here 90 return `at://${user}/sh.tangled.repo`; 91 } 92 93 return `at://${user}`; 94 }, 95 [App.Whitewind]: (path) => { 96 if (path.length === 2) { 97 return `at://${path[0]}/com.whtwnd.blog.entry/${path[1]}`; 98 } 99 100 return `at://${path[0]}/com.whtwnd.blog.entry`; 101 }, 102 [App.Frontpage]: (path) => { 103 if (path.length === 3) { 104 return `at://${path[1]}/fyi.unravel.frontpage.post/${path[2]}`; 105 } else if (path.length === 5) { 106 return `at://${path[3]}/fyi.unravel.frontpage.comment/${path[4]}`; 107 } 108 109 return `at://${path[0]}`; 110 }, 111 [App.Pinksea]: (path) => { 112 if (path.length === 2) { 113 return `at://${path[0]}/com.shinolabs.pinksea.oekaki/${path[1]}`; 114 } 115 116 return `at://${path[0]}`; 117 }, 118 [App.Linkat]: (path) => `at://${path[0]}/blue.linkat.board/self`, 119};