tangled
alpha
login
or
join now
kris.darkworld.download
/
darkworld
1
fork
atom
The code for darkworld.download
darkworld.download
1
fork
atom
overview
issues
pulls
pipelines
chore: update
kris.darkworld.download
4 days ago
5edfe4ec
ccb365a2
verified
This commit was signed with the committer's
known signature
.
kris.darkworld.download
SSH Key Fingerprint:
SHA256:4iiUkypaBzJPnEeVlazWCFBrJncWXreVhtJPB4DlswE=
+158
-24
5 changed files
expand all
collapse all
unified
split
lexicons
download.darkworld.site.getState.json
download.darkworld.state.json
src
App.tsx
index.tsx
lib
currentStateSync.ts
+3
-1
lexicons/download.darkworld.site.getState.json
···
33
"knownValues": [
34
"none",
35
"enby",
36
-
"trans"
0
0
37
]
38
},
39
"favoriteGames": {
···
33
"knownValues": [
34
"none",
35
"enby",
36
+
"trans",
37
+
"pan",
38
+
"latvia"
39
]
40
},
41
"favoriteGames": {
+4
-2
lexicons/download.darkworld.state.json
···
41
"description": "TBD",
42
"knownValues": [
43
"enby",
44
-
"trans"
0
0
45
],
46
"type": "string"
47
},
···
88
}
89
},
90
"lexicon": 1
91
-
}
···
41
"description": "TBD",
42
"knownValues": [
43
"enby",
44
+
"trans",
45
+
"pan",
46
+
"latvia"
47
],
48
"type": "string"
49
},
···
90
}
91
},
92
"lexicon": 1
93
+
}
+32
-1
src/App.tsx
···
1
import { ProphecyPanel } from "./components/ProphecyPanel";
2
import { general88x31s, our88x31s } from "./lib/88x31";
3
import { ATTRIBUTION_COPYRIGHT_NOTICE } from "./lib/DO_NOT_DELETE";
0
4
import { getTheProphecy } from "./lib/prophecy";
5
6
const links = [
···
15
];
16
17
export function App() {
0
0
18
const heroProphecy = getTheProphecy().krisOrSusie;
19
20
return (
21
<div className="min-h-screen bg-black px-3 py-3 text-white">
22
<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>
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
24
<p className="whitespace-pre-wrap">
25
i'm not the kris from deltarune, but you could probably guess my favorite character...{"\n"}
26
check out my cool site..!
···
1
import { ProphecyPanel } from "./components/ProphecyPanel";
2
import { general88x31s, our88x31s } from "./lib/88x31";
3
import { ATTRIBUTION_COPYRIGHT_NOTICE } from "./lib/DO_NOT_DELETE";
4
+
import { getTitleColorTheme, getTitleColors } from "./lib/currentStateSync";
5
import { getTheProphecy } from "./lib/prophecy";
6
7
const links = [
···
16
];
17
18
export function App() {
19
+
const titleTheme = getTitleColorTheme();
20
+
const titleColors = getTitleColors();
21
const heroProphecy = getTheProphecy().krisOrSusie;
22
23
return (
24
<div className="min-h-screen bg-black px-3 py-3 text-white">
25
<div className="mx-auto flex w-full max-w-5xl flex-col gap-3">
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>
55
<p className="whitespace-pre-wrap">
56
i'm not the kris from deltarune, but you could probably guess my favorite character...{"\n"}
57
check out my cool site..!
+13
-9
src/index.tsx
···
67
68
return new Response(file);
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
-
},
0
0
0
0
79
"/ocbwoy3": new Response("He does not exist."),
80
"/ip": (req: Request) => new Response(req.headers.get("cf-connecting-ip") || "127.0.0.1"),
81
"/": isProduction
···
67
68
return new Response(file);
69
},
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
+
}),
83
"/ocbwoy3": new Response("He does not exist."),
84
"/ip": (req: Request) => new Response(req.headers.get("cf-connecting-ip") || "127.0.0.1"),
85
"/": isProduction
+106
-11
src/lib/currentStateSync.ts
···
1
-
type TitleColor = "none" | "enby" | "trans";
0
0
0
0
0
2
3
export type State = {
4
useSusieProphecy: boolean;
···
24
favoriteDeltaruneCharacters: [],
25
};
26
0
0
0
0
0
0
0
0
0
0
0
0
0
0
27
const STATE_TTL_MS = 10_000;
28
const ENV =
29
typeof Bun !== "undefined"
···
35
const STATE_REPO = ENV.DARKWORLD_STATE_REPO ?? "did:plc:s7cesz7cr6ybltaryy4meb6y";
36
const STATE_COLLECTION = ENV.DARKWORLD_STATE_COLLECTION ?? "download.darkworld.state";
37
const STATE_RKEY = ENV.DARKWORLD_STATE_RKEY ?? "self";
38
-
const FALLBACK_ATPROTO_SERVICE = "https://public.api.bsky.app";
39
40
let serverState: State = DEFAULT_STATE;
41
let lastServerSyncMs = 0;
···
44
let lastSyncError = "";
45
46
function parseKnownTitleColors(input: unknown): Exclude<TitleColor, "none"> | null {
47
-
if (input === "enby" || input === "trans") {
48
return input;
49
}
50
51
return null;
52
}
53
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
54
function parseStringArray(input: unknown): string[] {
55
if (!Array.isArray(input)) {
56
return [];
···
97
const titleColorsFromSite = parseKnownTitleColors(value.site?.titleColors);
98
99
let titleColors: TitleColor = "none";
100
-
if (value.titleColors === "none" || value.titleColors === "enby" || value.titleColors === "trans") {
0
0
0
0
0
101
titleColors = value.titleColors;
102
} else if (titleColorsFromSite) {
103
titleColors = titleColorsFromSite;
···
241
}
242
243
if (!syncInFlight) {
244
-
syncInFlight = (async () => {
245
-
try {
246
-
const nextState = await fetchStateFromAtproto();
247
-
serverState = nextState;
248
-
lastServerSyncMs = Date.now();
249
-
lastSyncError = "";
250
-
return nextState;
251
} catch (error) {
252
lastServerSyncMs = Date.now();
253
const message = error instanceof Error ? error.message : String(error);
···
278
return DEFAULT_STATE;
279
}
280
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
281
export async function getLatestState(): Promise<State> {
282
if (typeof window === "undefined") {
283
return primeState(true);
0
0
0
0
0
284
}
285
286
try {
···
1
+
type TitleColor = "none" | "enby" | "trans" | "pan" | "latvia";
2
+
3
+
type TitleColorTheme = {
4
+
invertBg: boolean;
5
+
gradient: string | null;
6
+
};
7
8
export type State = {
9
useSusieProphecy: boolean;
···
29
favoriteDeltaruneCharacters: [],
30
};
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
+
46
const STATE_TTL_MS = 10_000;
47
const ENV =
48
typeof Bun !== "undefined"
···
54
const STATE_REPO = ENV.DARKWORLD_STATE_REPO ?? "did:plc:s7cesz7cr6ybltaryy4meb6y";
55
const STATE_COLLECTION = ENV.DARKWORLD_STATE_COLLECTION ?? "download.darkworld.state";
56
const STATE_RKEY = ENV.DARKWORLD_STATE_RKEY ?? "self";
57
+
const FALLBACK_ATPROTO_SERVICE = "https://lionsmane.us-east.host.bsky.network";
58
59
let serverState: State = DEFAULT_STATE;
60
let lastServerSyncMs = 0;
···
63
let lastSyncError = "";
64
65
function parseKnownTitleColors(input: unknown): Exclude<TitleColor, "none"> | null {
66
+
if (input === "enby" || input === "trans" || input === "pan" || input === "latvia") {
67
return input;
68
}
69
70
return null;
71
}
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
+
123
function parseStringArray(input: unknown): string[] {
124
if (!Array.isArray(input)) {
125
return [];
···
166
const titleColorsFromSite = parseKnownTitleColors(value.site?.titleColors);
167
168
let titleColors: TitleColor = "none";
169
+
if (value.titleColors === "none"
170
+
|| value.titleColors === "enby"
171
+
|| value.titleColors === "trans"
172
+
|| value.titleColors === "pan"
173
+
|| value.titleColors === "latvia"
174
+
) {
175
titleColors = value.titleColors;
176
} else if (titleColorsFromSite) {
177
titleColors = titleColorsFromSite;
···
315
}
316
317
if (!syncInFlight) {
318
+
syncInFlight = (async () => {
319
+
try {
320
+
const nextState = await fetchStateFromAtproto();
321
+
serverState = nextState;
322
+
lastServerSyncMs = Date.now();
323
+
lastSyncError = "";
324
+
return nextState;
325
} catch (error) {
326
lastServerSyncMs = Date.now();
327
const message = error instanceof Error ? error.message : String(error);
···
352
return DEFAULT_STATE;
353
}
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
+
371
export async function getLatestState(): Promise<State> {
372
if (typeof window === "undefined") {
373
return primeState(true);
374
+
}
375
+
376
+
const fromWindow = parseState(window.__DARKWORLD_STATE__);
377
+
if (fromWindow) {
378
+
return fromWindow;
379
}
380
381
try {