Something went wrong. Try again.
geometric packing game (tetris-ish) on an icosahedron. save boards and completed runs as records in your atproto PDS oscillatory.net/rad-cohesion
Something went wrong. Try again.
1.6 kB · 57 lines
TypeScript
at appview
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758import { createServer } from "vite";import { startApplicationRuntime, stopApplicationRuntime } from "../appview/src/runtime.ts";
let vite: Awaited<ReturnType<typeof createServer>> | null = null;let closing: Promise<void> | null = null;const portText = optionValue("port") ?? process.env.DEV_PORT ?? "5173";const port = Number(portText);
if (!/^\d+$/.test(portText) || !Number.isInteger(port) || port < 0 || port > 65535) { throw new Error("The Vite development port must be an integer between 0 and 65535.");}
await startApplicationRuntime();
try { vite = await createServer({ server: { host: optionValue("host") ?? process.env.DEV_HOST ?? "127.0.0.1", port, strictPort: process.argv.includes("--strictPort") || process.argv.includes("--strict-port"), }, }); await vite.listen(); vite.printUrls();} catch (error) { await vite?.close(); await stopApplicationRuntime();
throw error;}
process.on("SIGTERM", () => { void close(); });
process.on("SIGINT", () => { void close(); });
function close(): Promise<void> { if (closing) return closing;
closing = (async () => { await vite?.close(); await stopApplicationRuntime(); })();
return closing;}
function optionValue(name: string): string | undefined { const option = `--${name}`; const inline = process.argv.find((argument) => argument.startsWith(`${option}=`));
if (inline) return inline.slice(option.length + 1);
const index = process.argv.indexOf(option); const value = process.argv[index + 1];
return index < 0 || value === undefined || value.startsWith("-") ? undefined : value;}