fix(sdk): enforce runtime dependency boundary

This commit is contained in:
2026-09-05 08:01:07 +08:00
parent 471e2e9479
commit dfaa4f0ef4
4 changed files with 45 additions and 11 deletions
@@ -5,9 +5,8 @@ import type {
GameServerMessage,
PlatformToGameEvent,
} from '../contracts/index.ts';
import { Route } from '../../core/constants.ts';
const RESERVED_ROUTES = new Set<string>(Object.values(Route));
const RESERVED_GAME_ENTRY_ROUTES = new Set(['platform', 'agent', 'room']);
const GAME_SESSION_OPEN_FAULT_BRAND = Symbol.for(
'youle.framework.sdk.GameSessionOpenFault',
);
@@ -104,7 +103,7 @@ export function assertGameEntry(entry: GameEntry): void {
/** The single GameEntry route admission check shared by runtime adapters. */
export function assertGameRoute(route: unknown): asserts route is string {
assertNonEmptyText(route, 'route');
if (RESERVED_ROUTES.has(route)) {
if (RESERVED_GAME_ENTRY_ROUTES.has(route)) {
throw new Error(`GameEntry reserved route: ${route}`);
}
}