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
33
"knownValues": [
34
34
"none",
35
35
"enby",
36
36
-
"trans"
36
36
+
"trans",
37
37
+
"pan",
38
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
44
-
"trans"
44
44
+
"trans",
45
45
+
"pan",
46
46
+
"latvia"
45
47
],
46
48
"type": "string"
47
49
},
···
88
90
}
89
91
},
90
92
"lexicon": 1
91
91
-
}
93
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
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
19
+
const titleTheme = getTitleColorTheme();
20
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
23
-
<h1 className="pt-16 text-4xl">hi, i'm kris</h1>
26
26
+
<div className="pt-16">
27
27
+
<div
28
28
+
className="inline-block w-fit rounded-sm px-2"
29
29
+
style={{ backgroundColor: titleTheme.invertBg ? "#8a8a8a" : "transparent" }}
30
30
+
>
31
31
+
<h1 className="text-4xl leading-none">
32
32
+
<span
33
33
+
className="inline-block"
34
34
+
style={
35
35
+
titleTheme.gradient
36
36
+
? {
37
37
+
backgroundImage: titleTheme.gradient,
38
38
+
WebkitBackgroundClip: "text",
39
39
+
backgroundClip: "text",
40
40
+
WebkitTextFillColor: "transparent",
41
41
+
color: "transparent",
42
42
+
backgroundSize: "100% 100%",
43
43
+
backgroundRepeat: "no-repeat",
44
44
+
WebkitTextStroke:
45
45
+
titleColors === "enby" ? "1px rgba(255,255,255,0.1)" : undefined
46
46
+
}
47
47
+
: undefined
48
48
+
}
49
49
+
>
50
50
+
hi, i'm kris
51
51
+
</span>
52
52
+
</h1>
53
53
+
</div>
54
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
70
-
"/xrpc/download.darkworld.site.getState": async () => {
71
71
-
await primeState(true);
72
72
-
const body = JSON.stringify(getState());
73
73
-
return new Response(body, {
74
74
-
headers: {
75
75
-
"Content-Type": "application/json;charset=utf-8",
76
76
-
},
77
77
-
});
78
78
-
},
70
70
+
...(isProduction
71
71
+
? {}
72
72
+
: {
73
73
+
"/xrpc/download.darkworld.site.getState": async () => {
74
74
+
await primeState();
75
75
+
const body = JSON.stringify(getState());
76
76
+
return new Response(body, {
77
77
+
headers: {
78
78
+
"Content-Type": "application/json;charset=utf-8",
79
79
+
},
80
80
+
});
81
81
+
},
82
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
1
-
type TitleColor = "none" | "enby" | "trans";
1
1
+
type TitleColor = "none" | "enby" | "trans" | "pan" | "latvia";
2
2
+
3
3
+
type TitleColorTheme = {
4
4
+
invertBg: boolean;
5
5
+
gradient: string | null;
6
6
+
};
2
7
3
8
export type State = {
4
9
useSusieProphecy: boolean;
···
24
29
favoriteDeltaruneCharacters: [],
25
30
};
26
31
32
32
+
function createStripedGradient(stops: string[]): string {
33
33
+
const segment = 100 / stops.length;
34
34
+
const parts: string[] = [];
35
35
+
36
36
+
for (let index = 0; index < stops.length; index += 1) {
37
37
+
const start = (segment * index).toFixed(3);
38
38
+
const end = (segment * (index + 1)).toFixed(3);
39
39
+
const color = stops[index];
40
40
+
parts.push(`${color} ${start}% ${end}%`);
41
41
+
}
42
42
+
43
43
+
return `linear-gradient(180deg, ${parts.join(", ")})`;
44
44
+
}
45
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
38
-
const FALLBACK_ATPROTO_SERVICE = "https://public.api.bsky.app";
57
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
47
-
if (input === "enby" || input === "trans") {
66
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
73
+
export const titleColorConfigs = {
74
74
+
// https://www.tumblr.com/chekhovs-cat/674659716796940288
75
75
+
enby: {
76
76
+
invertBg: true,
77
77
+
colors: [
78
78
+
"#fff430",
79
79
+
"#ffffff",
80
80
+
"#9c59d1",
81
81
+
"#000000"
82
82
+
]
83
83
+
},
84
84
+
trans: {
85
85
+
invertBg: false,
86
86
+
colors: [
87
87
+
"#55cdfc",
88
88
+
"#f7a8b8",
89
89
+
"#ffffff",
90
90
+
"#55cdfc",
91
91
+
"#f7a8b8",
92
92
+
]
93
93
+
},
94
94
+
pan: {
95
95
+
invertBg: false,
96
96
+
colors: [
97
97
+
"#FF1B8D",
98
98
+
"#FFDA00",
99
99
+
"#1BB3FF",
100
100
+
]
101
101
+
},
102
102
+
103
103
+
// https://en.wikipedia.org/wiki/Flag_of_Latvia#Design
104
104
+
latvia: {
105
105
+
invertBg: false,
106
106
+
colors: [
107
107
+
"#9d2235",
108
108
+
"#9d2235",
109
109
+
"#ffffff",
110
110
+
"#9d2235",
111
111
+
"#9d2235"
112
112
+
]
113
113
+
}
114
114
+
}
115
115
+
116
116
+
const TITLE_COLOR_STOPS: Record<Exclude<TitleColor, "none">, string[]> = {
117
117
+
enby: titleColorConfigs.enby.colors,
118
118
+
trans: titleColorConfigs.trans.colors,
119
119
+
pan: titleColorConfigs.pan.colors,
120
120
+
latvia: titleColorConfigs.latvia.colors
121
121
+
};
122
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
100
-
if (value.titleColors === "none" || value.titleColors === "enby" || value.titleColors === "trans") {
169
169
+
if (value.titleColors === "none"
170
170
+
|| value.titleColors === "enby"
171
171
+
|| value.titleColors === "trans"
172
172
+
|| value.titleColors === "pan"
173
173
+
|| value.titleColors === "latvia"
174
174
+
) {
101
175
titleColors = value.titleColors;
102
176
} else if (titleColorsFromSite) {
103
177
titleColors = titleColorsFromSite;
···
241
315
}
242
316
243
317
if (!syncInFlight) {
244
244
-
syncInFlight = (async () => {
245
245
-
try {
246
246
-
const nextState = await fetchStateFromAtproto();
247
247
-
serverState = nextState;
248
248
-
lastServerSyncMs = Date.now();
249
249
-
lastSyncError = "";
250
250
-
return nextState;
318
318
+
syncInFlight = (async () => {
319
319
+
try {
320
320
+
const nextState = await fetchStateFromAtproto();
321
321
+
serverState = nextState;
322
322
+
lastServerSyncMs = Date.now();
323
323
+
lastSyncError = "";
324
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
355
+
export function getTitleColors(): TitleColor {
356
356
+
return getState().titleColors;
357
357
+
}
358
358
+
359
359
+
export function getTitleColorTheme(): TitleColorTheme {
360
360
+
const selectedTitleColor = getTitleColors();
361
361
+
if (selectedTitleColor === "none") {
362
362
+
return { invertBg: false, gradient: null };
363
363
+
}
364
364
+
365
365
+
return {
366
366
+
invertBg: titleColorConfigs[selectedTitleColor].invertBg,
367
367
+
gradient: createStripedGradient(TITLE_COLOR_STOPS[selectedTitleColor]),
368
368
+
};
369
369
+
}
370
370
+
281
371
export async function getLatestState(): Promise<State> {
282
372
if (typeof window === "undefined") {
283
373
return primeState(true);
374
374
+
}
375
375
+
376
376
+
const fromWindow = parseState(window.__DARKWORLD_STATE__);
377
377
+
if (fromWindow) {
378
378
+
return fromWindow;
284
379
}
285
380
286
381
try {