The code for darkworld.download darkworld.download

chore: update

kris.darkworld.download 5edfe4ec ccb365a2

verified
+158 -24
+3 -1
lexicons/download.darkworld.site.getState.json
··· 33 33 "knownValues": [ 34 34 "none", 35 35 "enby", 36 - "trans" 36 + "trans", 37 + "pan", 38 + "latvia" 37 39 ] 38 40 }, 39 41 "favoriteGames": {
+4 -2
lexicons/download.darkworld.state.json
··· 41 41 "description": "TBD", 42 42 "knownValues": [ 43 43 "enby", 44 - "trans" 44 + "trans", 45 + "pan", 46 + "latvia" 45 47 ], 46 48 "type": "string" 47 49 }, ··· 88 90 } 89 91 }, 90 92 "lexicon": 1 91 - } 93 + }
+32 -1
src/App.tsx
··· 1 1 import { ProphecyPanel } from "./components/ProphecyPanel"; 2 2 import { general88x31s, our88x31s } from "./lib/88x31"; 3 3 import { ATTRIBUTION_COPYRIGHT_NOTICE } from "./lib/DO_NOT_DELETE"; 4 + import { getTitleColorTheme, getTitleColors } from "./lib/currentStateSync"; 4 5 import { getTheProphecy } from "./lib/prophecy"; 5 6 6 7 const links = [ ··· 15 16 ]; 16 17 17 18 export function App() { 19 + const titleTheme = getTitleColorTheme(); 20 + const titleColors = getTitleColors(); 18 21 const heroProphecy = getTheProphecy().krisOrSusie; 19 22 20 23 return ( 21 24 <div className="min-h-screen bg-black px-3 py-3 text-white"> 22 25 <div className="mx-auto flex w-full max-w-5xl flex-col gap-3"> 23 - <h1 className="pt-16 text-4xl">hi, i'm kris</h1> 26 + <div className="pt-16"> 27 + <div 28 + className="inline-block w-fit rounded-sm px-2" 29 + style={{ backgroundColor: titleTheme.invertBg ? "#8a8a8a" : "transparent" }} 30 + > 31 + <h1 className="text-4xl leading-none"> 32 + <span 33 + className="inline-block" 34 + style={ 35 + titleTheme.gradient 36 + ? { 37 + backgroundImage: titleTheme.gradient, 38 + WebkitBackgroundClip: "text", 39 + backgroundClip: "text", 40 + WebkitTextFillColor: "transparent", 41 + color: "transparent", 42 + backgroundSize: "100% 100%", 43 + backgroundRepeat: "no-repeat", 44 + WebkitTextStroke: 45 + titleColors === "enby" ? "1px rgba(255,255,255,0.1)" : undefined 46 + } 47 + : undefined 48 + } 49 + > 50 + hi, i'm kris 51 + </span> 52 + </h1> 53 + </div> 54 + </div> 24 55 <p className="whitespace-pre-wrap"> 25 56 i'm not the kris from deltarune, but you could probably guess my favorite character...{"\n"} 26 57 check out my cool site..!
+13 -9
src/index.tsx
··· 67 67 68 68 return new Response(file); 69 69 }, 70 - "/xrpc/download.darkworld.site.getState": async () => { 71 - await primeState(true); 72 - const body = JSON.stringify(getState()); 73 - return new Response(body, { 74 - headers: { 75 - "Content-Type": "application/json;charset=utf-8", 76 - }, 77 - }); 78 - }, 70 + ...(isProduction 71 + ? {} 72 + : { 73 + "/xrpc/download.darkworld.site.getState": async () => { 74 + await primeState(); 75 + const body = JSON.stringify(getState()); 76 + return new Response(body, { 77 + headers: { 78 + "Content-Type": "application/json;charset=utf-8", 79 + }, 80 + }); 81 + }, 82 + }), 79 83 "/ocbwoy3": new Response("He does not exist."), 80 84 "/ip": (req: Request) => new Response(req.headers.get("cf-connecting-ip") || "127.0.0.1"), 81 85 "/": isProduction
+106 -11
src/lib/currentStateSync.ts
··· 1 - type TitleColor = "none" | "enby" | "trans"; 1 + type TitleColor = "none" | "enby" | "trans" | "pan" | "latvia"; 2 + 3 + type TitleColorTheme = { 4 + invertBg: boolean; 5 + gradient: string | null; 6 + }; 2 7 3 8 export type State = { 4 9 useSusieProphecy: boolean; ··· 24 29 favoriteDeltaruneCharacters: [], 25 30 }; 26 31 32 + function createStripedGradient(stops: string[]): string { 33 + const segment = 100 / stops.length; 34 + const parts: string[] = []; 35 + 36 + for (let index = 0; index < stops.length; index += 1) { 37 + const start = (segment * index).toFixed(3); 38 + const end = (segment * (index + 1)).toFixed(3); 39 + const color = stops[index]; 40 + parts.push(`${color} ${start}% ${end}%`); 41 + } 42 + 43 + return `linear-gradient(180deg, ${parts.join(", ")})`; 44 + } 45 + 27 46 const STATE_TTL_MS = 10_000; 28 47 const ENV = 29 48 typeof Bun !== "undefined" ··· 35 54 const STATE_REPO = ENV.DARKWORLD_STATE_REPO ?? "did:plc:s7cesz7cr6ybltaryy4meb6y"; 36 55 const STATE_COLLECTION = ENV.DARKWORLD_STATE_COLLECTION ?? "download.darkworld.state"; 37 56 const STATE_RKEY = ENV.DARKWORLD_STATE_RKEY ?? "self"; 38 - const FALLBACK_ATPROTO_SERVICE = "https://public.api.bsky.app"; 57 + const FALLBACK_ATPROTO_SERVICE = "https://lionsmane.us-east.host.bsky.network"; 39 58 40 59 let serverState: State = DEFAULT_STATE; 41 60 let lastServerSyncMs = 0; ··· 44 63 let lastSyncError = ""; 45 64 46 65 function parseKnownTitleColors(input: unknown): Exclude<TitleColor, "none"> | null { 47 - if (input === "enby" || input === "trans") { 66 + if (input === "enby" || input === "trans" || input === "pan" || input === "latvia") { 48 67 return input; 49 68 } 50 69 51 70 return null; 52 71 } 53 72 73 + export const titleColorConfigs = { 74 + // https://www.tumblr.com/chekhovs-cat/674659716796940288 75 + enby: { 76 + invertBg: true, 77 + colors: [ 78 + "#fff430", 79 + "#ffffff", 80 + "#9c59d1", 81 + "#000000" 82 + ] 83 + }, 84 + trans: { 85 + invertBg: false, 86 + colors: [ 87 + "#55cdfc", 88 + "#f7a8b8", 89 + "#ffffff", 90 + "#55cdfc", 91 + "#f7a8b8", 92 + ] 93 + }, 94 + pan: { 95 + invertBg: false, 96 + colors: [ 97 + "#FF1B8D", 98 + "#FFDA00", 99 + "#1BB3FF", 100 + ] 101 + }, 102 + 103 + // https://en.wikipedia.org/wiki/Flag_of_Latvia#Design 104 + latvia: { 105 + invertBg: false, 106 + colors: [ 107 + "#9d2235", 108 + "#9d2235", 109 + "#ffffff", 110 + "#9d2235", 111 + "#9d2235" 112 + ] 113 + } 114 + } 115 + 116 + const TITLE_COLOR_STOPS: Record<Exclude<TitleColor, "none">, string[]> = { 117 + enby: titleColorConfigs.enby.colors, 118 + trans: titleColorConfigs.trans.colors, 119 + pan: titleColorConfigs.pan.colors, 120 + latvia: titleColorConfigs.latvia.colors 121 + }; 122 + 54 123 function parseStringArray(input: unknown): string[] { 55 124 if (!Array.isArray(input)) { 56 125 return []; ··· 97 166 const titleColorsFromSite = parseKnownTitleColors(value.site?.titleColors); 98 167 99 168 let titleColors: TitleColor = "none"; 100 - if (value.titleColors === "none" || value.titleColors === "enby" || value.titleColors === "trans") { 169 + if (value.titleColors === "none" 170 + || value.titleColors === "enby" 171 + || value.titleColors === "trans" 172 + || value.titleColors === "pan" 173 + || value.titleColors === "latvia" 174 + ) { 101 175 titleColors = value.titleColors; 102 176 } else if (titleColorsFromSite) { 103 177 titleColors = titleColorsFromSite; ··· 241 315 } 242 316 243 317 if (!syncInFlight) { 244 - syncInFlight = (async () => { 245 - try { 246 - const nextState = await fetchStateFromAtproto(); 247 - serverState = nextState; 248 - lastServerSyncMs = Date.now(); 249 - lastSyncError = ""; 250 - return nextState; 318 + syncInFlight = (async () => { 319 + try { 320 + const nextState = await fetchStateFromAtproto(); 321 + serverState = nextState; 322 + lastServerSyncMs = Date.now(); 323 + lastSyncError = ""; 324 + return nextState; 251 325 } catch (error) { 252 326 lastServerSyncMs = Date.now(); 253 327 const message = error instanceof Error ? error.message : String(error); ··· 278 352 return DEFAULT_STATE; 279 353 } 280 354 355 + export function getTitleColors(): TitleColor { 356 + return getState().titleColors; 357 + } 358 + 359 + export function getTitleColorTheme(): TitleColorTheme { 360 + const selectedTitleColor = getTitleColors(); 361 + if (selectedTitleColor === "none") { 362 + return { invertBg: false, gradient: null }; 363 + } 364 + 365 + return { 366 + invertBg: titleColorConfigs[selectedTitleColor].invertBg, 367 + gradient: createStripedGradient(TITLE_COLOR_STOPS[selectedTitleColor]), 368 + }; 369 + } 370 + 281 371 export async function getLatestState(): Promise<State> { 282 372 if (typeof window === "undefined") { 283 373 return primeState(true); 374 + } 375 + 376 + const fromWindow = parseState(window.__DARKWORLD_STATE__); 377 + if (fromWindow) { 378 + return fromWindow; 284 379 } 285 380 286 381 try {