import { describe, expectTypeOf, test } from "vitest"; import { Container, h } from "canvasengine"; import type { RpgContext, RpgProvider } from "@rpgjs/common"; import { provideMmorpg, startGame, type GuiRegistration, type GuiRenderer, provideClientScenes, type RpgClientRoomSceneProps, type RpgClientSceneDefinition, type RpgAudioChannel, type RpgMusicManager, type RpgPlaySoundOptions, } from "./index"; describe("client public API types", () => { test("custom room scenes infer synchronized state and component props", () => { type BattleState = { turn: number }; const scene: RpgClientSceneDefinition = { kind: "battle", component(props: RpgClientRoomSceneProps) { expectTypeOf(props.room.state()).toEqualTypeOf(); expectTypeOf(props.descriptor.kind).toEqualTypeOf(); return h(Container); }, }; expectTypeOf(provideClientScenes([scene])).toEqualTypeOf(); }); test("bootstrap and providers expose RPGJS-owned contracts", () => { expectTypeOf(provideMmorpg({})).toEqualTypeOf(); const assertions = (start: typeof startGame) => { expectTypeOf(start({ providers: [] })).toEqualTypeOf>(); }; expectTypeOf(assertions).toBeFunction(); }); test("the Signe Context class is not re-exported", () => { // @ts-expect-error Context is available only from direct advanced Signe usage type LegacyContext = typeof import("./index")["Context"]; expectTypeOf(); }); test("GUI registrations expose renderer-neutral typed data", () => { type DialogData = { message: string }; const registration: GuiRegistration = { id: "dialog", component: () => null, renderer: "canvas", data: { message: "Hello" }, }; expectTypeOf(registration.renderer).toEqualTypeOf(); expectTypeOf(registration.data).toEqualTypeOf(); }); test("temporary music exposes a typed transition controller", () => { expectTypeOf().toBeFunction(); expectTypeOf().toBeFunction(); }); test("the established sound API exposes channel and spatial options", () => { expectTypeOf().toEqualTypeOf<"master" | "music" | "sfx" | "ui">(); expectTypeOf().toMatchTypeOf<{ volume?: number; loop?: boolean; channel?: "music" | "sfx" | "ui"; position?: { x: number; y: number }; listener?: { x: number; y: number }; }>(); }); });