feat(sdk): define single-game public contracts

This commit is contained in:
2026-09-05 00:41:39 +08:00
parent bdd8ddb2f6
commit e1556d50f4
13 changed files with 385 additions and 2 deletions
@@ -0,0 +1,28 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import type {
GameEntry, GameHost, GameModule, GameServerMessage,
PlatformGameSnapshot, PlatformToGameEvent,
} from '../../YouleNexus/assets/framework/sdk/contracts/index.ts';
test('single GameEntry contract has no registry or runtime version member', () => {
const module: GameModule = {
attach(_host: GameHost) {},
handlePlatformEvent(_event: PlatformToGameEvent) {},
handleGameMessage(_message: GameServerMessage) {},
restore(_deskinfo: unknown) {},
dispose() {},
};
const entry: GameEntry = {
key: 'fixture', gameId: 41, route: 'fixture-route',
resolveSeatCount: () => 4,
createModule: () => module,
};
assert.equal(entry.route, 'fixture-route');
assert.equal('apiVersion' in entry, false);
});
test('public snapshot is plain readonly data', () => {
const value = {} as PlatformGameSnapshot;
assert.equal('state' in value, false);
});