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