Move away from browser as a main plataform

This commit is contained in:
2026-11-22 21:38:12 -03:00
parent cbd662dc2a
commit 90dd86b336
12 changed files with 166 additions and 150 deletions
+3 -18
View File
@@ -61,12 +61,12 @@ function set_shown(now_shown: boolean) {
// what was asked of the window, by id, waiting for its answer
let next_id = 0;
const asking = new Map<number, (answer: string | boolean) => void>();
const asking = new Map<number, (answer: string) => void>();
function ask<T extends string | boolean>(question: (id: number) => ClientMessage): Promise<T> {
function ask(question: (id: number) => ClientMessage): Promise<string> {
const id = next_id++;
post(question(id));
return new Promise((resolve) => asking.set(id, resolve as (answer: string | boolean) => void));
return new Promise((resolve) => asking.set(id, resolve));
}
function native_platform(page: URL, stored: Record<string, string>, credits: string | undefined): Platform {
@@ -93,17 +93,6 @@ function native_platform(page: URL, stored: Record<string, string>, credits: str
show_fatal_error(message) {
post({ type: "fatal", message });
},
confirm_mods(address, welcome) {
const mods = welcome.mods.map((mod) => {
// it can change anything about the game, not just add to it
const access = mod.engine_access ? ", changes the engine" : "";
return `• ${mod.name} ${mod.version} (${mod.id}${access})`;
});
const text = "This server runs these mods in the game. They can do anything the game can, including " +
`reading what it saved. Only join servers you trust.\n\n${mods.join("\n")}`;
const title = `Join ${address.base.host}?`;
return ask((id) => ({ type: "ask", id, title, text, yes: "Join", no: "Cancel" }));
},
credits_screen: (on_back) => new TextCreditsScreen(on_back, credits),
read_clipboard: () => ask((id) => ({ type: "read_clipboard", id })),
write_clipboard(text) {
@@ -205,10 +194,6 @@ self.onmessage = (event: MessageEvent<WindowMessage>) => {
asking.get(message.id)?.(message.text);
asking.delete(message.id);
break;
case "answer":
asking.get(message.id)?.(message.yes);
asking.delete(message.id);
break;
case "audio_ended":
sources_ended(message.sources);
break;