a6de43edc1
- pnpm workspace: shared/server/client packages - Server: Fastify+ws, chess.js, FSM (touch-move + hierarchy), per-player view filter, zod validation, rate limiting, grace-window disconnect handling - Client: Svelte 5 + Vite, click-to-move board, moderator panel, promotion/draw dialogs - Shared: protocol types, ModeratorText enum, geometricMoves helper (provably zero opponent-info leak) - 43 tests pass (21 shared, 22 server incl. 4 real-WS integration) - Deploy: CT 690 on node-241 (192.168.0.245), systemd-managed, Caddy block for chess.sethpc.xyz - Live at https://chess.sethpc.xyz Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
36 lines
1007 B
Svelte
36 lines
1007 B
Svelte
<script lang="ts">
|
|
import Landing from './lib/Landing.svelte';
|
|
import Game from './lib/Game.svelte';
|
|
|
|
let route: { name: 'landing' } | { name: 'game'; id: string } = $state({ name: 'landing' });
|
|
|
|
function parseHash() {
|
|
// Support both pathname-based (joinUrl: /g/<id>) and hash-based (#/g/<id>) routes.
|
|
const hash = location.hash || '';
|
|
const hashMatch = hash.match(/^#\/g\/([a-z0-9]{8})$/);
|
|
if (hashMatch) {
|
|
route = { name: 'game', id: hashMatch[1]! };
|
|
return;
|
|
}
|
|
const pathMatch = location.pathname.match(/^\/g\/([a-z0-9]{8})\/?$/);
|
|
if (pathMatch) {
|
|
route = { name: 'game', id: pathMatch[1]! };
|
|
return;
|
|
}
|
|
route = { name: 'landing' };
|
|
}
|
|
|
|
$effect(() => {
|
|
parseHash();
|
|
const handler = () => parseHash();
|
|
window.addEventListener('hashchange', handler);
|
|
return () => window.removeEventListener('hashchange', handler);
|
|
});
|
|
</script>
|
|
|
|
{#if route.name === 'landing'}
|
|
<Landing />
|
|
{:else}
|
|
<Game gameId={route.id} />
|
|
{/if}
|