Remove duplicate code

This commit is contained in:
2026-10-13 11:57:43 -03:00
parent dfc6a6d77b
commit 5165698fe3
50 changed files with 307 additions and 812 deletions
+1 -5
View File
@@ -6,6 +6,7 @@
// copy from its data folder. the singleplayer server is part of the app and can't update this way, so a client for
// a different protocol is never used. anything that goes wrong leaves the app on the client it has
import { join } from "@std/path";
import { sha256 } from "../common/utils.ts";
// where the manifest is, in a build folder and on the site
export const CLIENT_MANIFEST = "client/manifest.json";
@@ -19,11 +20,6 @@ export interface ClientManifest {
files: Record<string, string>;
}
export async function sha256(bytes: Uint8Array<ArrayBuffer>): Promise<string> {
const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", bytes));
return Array.from(digest, (byte) => byte.toString(16).padStart(2, "0")).join("");
}
export async function client_manifest(files: Record<string, string>, protocol: number): Promise<ClientManifest> {
const sorted = Object.fromEntries(Object.entries(files).sort(([a], [b]) => a.localeCompare(b)));
const listing = Object.entries(sorted).map(([path, hash]) => `${path} ${hash}`).join("\n");