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