# Conflicts: # apps/web/src/games/registry.ts # apps/web/src/lib/catalog-ui.ts # e2e/games.e2e.ts # packages/games/src/index.ts # packages/shared/src/catalog.ts
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import type { GameUI } from './types';
|
|
|
|
/** Game screens are code-split: each is downloaded only when that game is opened (docs/09 §6). */
|
|
export const GAME_UI: Record<string, () => Promise<{ default: GameUI }>> = {
|
|
omok: () => import('./omok'),
|
|
othello: () => import('./othello'),
|
|
chess: () => import('./chess'),
|
|
janggi: () => import('./janggi'),
|
|
baduk: () => import('./baduk'),
|
|
seotda: () => import('./seotda'),
|
|
poker: () => import('./poker'),
|
|
yacht: () => import('./yacht'),
|
|
yut: () => import('./yut'),
|
|
'one-card': () => import('./one-card'),
|
|
rummikub: () => import('./rummikub'),
|
|
'davinci-code': () => import('./davinci-code'),
|
|
mahjong: () => import('./mahjong'),
|
|
gostop: () => import('./gostop'),
|
|
bang: () => import('./bang'),
|
|
'halli-galli': () => import('./halli-galli'),
|
|
marble: () => import('./marble'),
|
|
};
|
|
|
|
const cache = new Map<string, GameUI>();
|
|
|
|
export async function loadGameUI(id: string): Promise<GameUI | null> {
|
|
const hit = cache.get(id);
|
|
if (hit) return hit;
|
|
const loader = GAME_UI[id];
|
|
if (!loader) return null;
|
|
const mod = (await loader()).default;
|
|
cache.set(id, mod);
|
|
return mod;
|
|
}
|
|
|
|
export function cachedGameUI(id: string): GameUI | null {
|
|
return cache.get(id) ?? null;
|
|
}
|