@smoregg/sdk 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,5 +10,6 @@ var types = require('./types.cjs');
10
10
  exports.createScreen = screen.createScreen;
11
11
  exports.createController = controller.createController;
12
12
  exports.SmoreSDKError = errors.SmoreSDKError;
13
+ exports.GAME_CATEGORIES = types.GAME_CATEGORIES;
13
14
  exports.LifecycleEvent = types.LifecycleEvent;
14
15
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
@@ -1,5 +1,20 @@
1
1
  'use strict';
2
2
 
3
+ const GAME_CATEGORIES = {
4
+ "bet": { emoji: "\u{1F3B0}", label: "Betting", labelKo: "\uB0B4\uAE30" },
5
+ "coop": { emoji: "\u{1F91D}", label: "Co-op", labelKo: "\uD611\uB3D9" },
6
+ "versus": { emoji: "\u2694\uFE0F", label: "Versus", labelKo: "\uB300\uACB0" },
7
+ "time-attack": { emoji: "\u23F1\uFE0F", label: "Time Attack", labelKo: "\uD0C0\uC784\uC5B4\uD0DD" },
8
+ "survival": { emoji: "\u{1F3C3}", label: "Survival", labelKo: "\uC0DD\uC874" },
9
+ "reflex": { emoji: "\u{1F3AF}", label: "Reflex", labelKo: "\uBC18\uC751\uC18D\uB3C4" },
10
+ "deception": { emoji: "\u{1F575}\uFE0F", label: "Deception", labelKo: "\uCD94\uB9AC/\uC18D\uC784\uC218" },
11
+ "creative": { emoji: "\u{1F3A8}", label: "Creative", labelKo: "\uCC3D\uC791" },
12
+ "party": { emoji: "\u{1F389}", label: "Party", labelKo: "\uD30C\uD2F0" },
13
+ "puzzle": { emoji: "\u{1F9E9}", label: "Puzzle", labelKo: "\uD37C\uC990" },
14
+ "board": { emoji: "\u{1F3B2}", label: "Board Game", labelKo: "\uBCF4\uB4DC\uAC8C\uC784" },
15
+ "strategy": { emoji: "\u{1F9E0}", label: "Strategy", labelKo: "\uC804\uB7B5" },
16
+ "timing": { emoji: "\u{1F3B5}", label: "Timing", labelKo: "\uD0C0\uC774\uBC0D" }
17
+ };
3
18
  const LifecycleEvent = {
4
19
  ALL_READY: "$all-ready",
5
20
  CONTROLLER_JOIN: "$controller-join",
@@ -12,5 +27,6 @@ const LifecycleEvent = {
12
27
  CONNECTION_CHANGE: "$connection-change"
13
28
  };
14
29
 
30
+ exports.GAME_CATEGORIES = GAME_CATEGORIES;
15
31
  exports.LifecycleEvent = LifecycleEvent;
16
32
  //# sourceMappingURL=types.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sources":["../../src/types.ts"],"sourcesContent":["/**\n * @smoregg/sdk - World-Class Party Game SDK\n *\n * Type definitions for building multiplayer party games with type-safe events,\n * factory pattern initialization, and comprehensive error handling.\n *\n * @packageDocumentation\n */\n\n// =============================================================================\n// CORE PRIMITIVES\n// =============================================================================\n\n/**\n * Unique identifier for a player (0-indexed integer).\n * Used consistently across all SDK methods.\n */\nexport type PlayerIndex = number;\n\n/**\n * Room code for joining a game session (e.g., \"ABCD\").\n */\nexport type RoomCode = string;\n\n// =============================================================================\n// EVENT SYSTEM - TYPE-SAFE EVENTS\n// =============================================================================\n\n/**\n * Base event map type. Extend this to define your game's events.\n *\n * **Important:** Event data values must be plain objects, not primitives.\n * Primitive values (string, number, boolean) will be automatically wrapped\n * as `{ data: <value> }` by the relay server, which breaks type safety.\n *\n * **Payload Size Limit:** Maximum payload size per event is 64KB. This limit\n * is enforced by the server's genericRelay handler. Payloads exceeding this\n * limit will be silently dropped by the server without error notification.\n *\n * **Reserved Fields:** The field names `playerIndex` and `targetPlayerIndex` are reserved\n * by the SDK for internal routing. Using these as custom data field names will cause\n * a compile-time error. The SDK automatically extracts `playerIndex` to identify the sender\n * and uses `targetPlayerIndex` for targeted message delivery.\n *\n * **Type Safety Note:** Without providing an explicit generic type parameter,\n * `createScreen()` and `createController()` default to the empty `EventMap`,\n * which means `send()`, `broadcast()`, and `on()` accept any string as an event\n * name and `unknown` as data -- effectively losing compile-time type checking.\n * Always define and pass your game's event map for full type safety.\n *\n * @example Defining events for type safety\n * ```ts\n * interface MyGameEvents {\n * // Screen receives from Controller\n * 'tap': { x: number; y: number };\n * 'answer': { choice: number };\n *\n * // Controller receives from Screen\n * 'phase-update': { phase: 'lobby' | 'playing' | 'results' };\n * 'your-turn': { timeLimit: number };\n * }\n *\n * // With explicit generic -- full type safety\n * const screen = createScreen<MyGameEvents>({ debug: true });\n * screen.on('tap', (playerIndex, data) => { ... });\n * await screen.ready;\n *\n * // Without generic -- no type safety (not recommended)\n * const screen = createScreen();\n * ```\n *\n * @example Event naming conventions\n * ```ts\n * // Define your game's event map for type safety:\n * type MyEvents = {\n * 'player-move': { x: number; y: number };\n * 'game-action': { action: string; value: number };\n * };\n * // Event names: use kebab-case, no colons (:), no 'smore:' prefix\n * ```\n */\nexport interface EventMap {\n [key: string]: Record<string, unknown> & { playerIndex?: never; targetPlayerIndex?: never };\n}\n\n/**\n * Extract event names from an event map.\n */\nexport type EventNames<TEvents extends EventMap> = keyof TEvents & string;\n\n/**\n * Extract event data type for a specific event.\n */\nexport type EventData<\n TEvents extends EventMap,\n TEvent extends EventNames<TEvents>,\n> = TEvents[TEvent];\n\n// =============================================================================\n// CONTROLLER INFO - PLAYER INFORMATION\n// =============================================================================\n\n/**\n * Character appearance data for player avatars.\n *\n * This type matches the server's CharacterDTO structure to ensure\n * type consistency across the platform.\n *\n * @property id - Unique character identifier\n * @property seed - Random seed for generating the character\n * @property style - Character style preset identifier\n * @property options - Additional character customization options\n */\nexport interface CharacterAppearance {\n /** Unique character identifier */\n id: string;\n /** Random seed for generating the character */\n seed: string;\n /** Character style preset identifier */\n style: string;\n /** Additional character customization options */\n options: Record<string, unknown>;\n}\n\n/**\n * Information about a connected controller (player).\n * Used by Screen to identify and manage players.\n */\nexport interface ControllerInfo {\n /** Player's unique index (0, 1, 2, ...) */\n readonly playerIndex: PlayerIndex;\n /**\n * Player's chosen display name.\n *\n * Maps to `PlayerDTO.name` on the server side. The SDK exposes it as\n * \"nickname\" for semantic clarity in game code.\n * The mapping (`name` -> `nickname`) is handled automatically during\n * player data deserialization in the transport layer.\n *\n * @see PlayerDTO.name (server) -- same value, different field name\n */\n readonly nickname: string;\n /** Whether the player is currently connected */\n readonly connected: boolean;\n /**\n * Optional character appearance data.\n *\n * Note: The server sends this as \"character\" in PlayerDTO.\n * The SDK maps it to \"appearance\" for semantic clarity.\n * The server may send `null` when no character is set.\n */\n readonly appearance?: CharacterAppearance | null;\n}\n\n// =============================================================================\n// TRANSPORT\n// =============================================================================\n\n/**\n * Transport interface for custom communication implementations.\n * Implement this to use a custom transport instead of the default PostMessageTransport.\n */\nexport interface Transport {\n emit(event: string, ...args: unknown[]): void;\n on(event: string, handler: (...args: unknown[]) => void): void;\n off(event: string, handler?: (...args: unknown[]) => void): void;\n destroy(): void;\n}\n\n// =============================================================================\n// ERROR HANDLING\n// =============================================================================\n\n/**\n * Error codes for SDK errors.\n */\nexport type SmoreErrorCode =\n | 'TIMEOUT' // Connection or operation timeout\n | 'NOT_READY' // Operation called before ready\n | 'DESTROYED' // Operation called after destroy\n | 'INVALID_EVENT' // Invalid event name\n | 'INVALID_PLAYER' // Invalid player index\n | 'CONNECTION_LOST' // Lost connection to server\n | 'INIT_FAILED' // Failed to initialize\n | 'RATE_LIMITED' // Server rate-limited an event\n | 'PAYLOAD_TOO_LARGE' // Payload exceeds 64KB limit\n | 'UNKNOWN'; // Unknown error\n\n/**\n * Structured error type for SDK errors.\n */\nexport interface SmoreError {\n /** Error code for programmatic handling */\n code: SmoreErrorCode;\n /** Human-readable error message */\n message: string;\n /** Original error if available */\n cause?: Error;\n /** Additional context */\n details?: Record<string, unknown>;\n}\n\n// =============================================================================\n// GAME RESULTS\n// =============================================================================\n\n/**\n * Game results structure for gameOver().\n * Flexible to accommodate different game types.\n */\nexport interface GameResults {\n /** Player scores indexed by player index */\n scores?: Record<PlayerIndex, number>;\n /** Winner's player index (or -1 for no winner/tie) */\n winner?: PlayerIndex;\n /** Ranked player indices from first to last */\n rankings?: PlayerIndex[];\n /** Additional custom game-specific data */\n custom?: Record<string, unknown>;\n}\n\n// =============================================================================\n// LIFECYCLE EVENTS — UNIFIED EVENT SYSTEM\n// =============================================================================\n\n/**\n * Lifecycle event names for subscribing via `on()`.\n *\n * These `$`-prefixed event names allow lifecycle events to be registered\n * through the same `on()` method used for game events. The `$` prefix is\n * reserved by the SDK and cannot be used for user-defined events.\n *\n * @example\n * ```ts\n * // These are equivalent:\n * screen.onControllerJoin((pi, info) => { ... });\n * screen.on(LifecycleEvent.CONTROLLER_JOIN, (pi, info) => { ... });\n * ```\n */\nexport const LifecycleEvent = {\n ALL_READY: '$all-ready',\n CONTROLLER_JOIN: '$controller-join',\n CONTROLLER_LEAVE: '$controller-leave',\n CONTROLLER_DISCONNECT: '$controller-disconnect',\n CONTROLLER_RECONNECT: '$controller-reconnect',\n CHARACTER_UPDATED: '$character-updated',\n ERROR: '$error',\n GAME_OVER: '$game-over',\n CONNECTION_CHANGE: '$connection-change',\n} as const;\n\n/** Union of all lifecycle event name strings. */\nexport type LifecycleEventName = typeof LifecycleEvent[keyof typeof LifecycleEvent];\n\n/**\n * Handler signatures for Screen lifecycle events.\n * Used by `on()` overloads to provide type-safe lifecycle event subscription.\n */\nexport interface ScreenLifecycleHandlers {\n '$all-ready': () => void;\n '$controller-join': (playerIndex: PlayerIndex, info: ControllerInfo) => void;\n '$controller-leave': (playerIndex: PlayerIndex) => void;\n '$controller-disconnect': (playerIndex: PlayerIndex) => void;\n '$controller-reconnect': (playerIndex: PlayerIndex, info: ControllerInfo) => void;\n '$character-updated': (playerIndex: PlayerIndex, appearance: CharacterAppearance | null) => void;\n '$error': (error: SmoreError) => void;\n '$connection-change': (connected: boolean) => void;\n}\n\n/** Screen lifecycle event name union. */\nexport type ScreenLifecycleEvent = keyof ScreenLifecycleHandlers;\n\n/**\n * Handler signatures for Controller lifecycle events.\n * Extends Screen lifecycle events with Controller-specific events.\n */\nexport interface ControllerLifecycleHandlers extends ScreenLifecycleHandlers {\n '$game-over': (results?: GameResults) => void;\n}\n\n/** Controller lifecycle event name union. */\nexport type ControllerLifecycleEvent = keyof ControllerLifecycleHandlers;\n\n// =============================================================================\n// SCREEN TYPES - HOST/TV SIDE\n// =============================================================================\n\n/**\n * Handler for events received from controllers.\n * Receives the player index and event data.\n */\nexport type ScreenEventHandler<TData = unknown> = (\n playerIndex: PlayerIndex,\n data: TData,\n) => void;\n\n/**\n * Configuration options for creating a Screen instance.\n *\n * In the event emitter pattern, only static options are passed via config.\n * All lifecycle callbacks and event listeners are registered via methods\n * on the returned Screen instance.\n *\n * @template TEvents - Event map type for type-safe events\n *\n * @example\n * ```ts\n * const screen = createScreen<MyEvents>({ debug: true });\n *\n * screen.on('tap', (playerIndex, data) => handleTap(playerIndex, data));\n * screen.onAllReady(() => startCountdown());\n * screen.onControllerJoin((playerIndex, info) => console.log('Joined:', playerIndex));\n *\n * await screen.ready;\n * ```\n */\nexport interface ScreenConfig {\n // === Debug Options ===\n\n /**\n * Enable debug mode for verbose logging.\n * @default false\n */\n debug?: boolean | DebugOptions;\n\n // === Advanced Options ===\n\n /**\n * Parent window origin for postMessage validation (iframe games).\n * Use '*' to accept messages from any origin (not recommended for production).\n * @default '*'\n */\n parentOrigin?: string;\n\n /**\n * Connection timeout in milliseconds.\n * @default 10000\n */\n timeout?: number;\n\n /**\n * Automatically signal ready after initialization.\n * When true (default), the SDK calls signalReady() automatically after init completes.\n * Set to false if your game needs to load resources before signaling ready.\n * @default true\n */\n autoReady?: boolean;\n\n /**\n * Custom transport implementation.\n * If provided, uses this instead of the default PostMessageTransport.\n * The bridge handshake (_bridge:init) still occurs via postMessage.\n */\n transport?: Transport;\n\n}\n\n/**\n * Screen instance - the main interface for the host/TV side of your game.\n *\n * Uses an event emitter pattern: lifecycle callbacks and event listeners\n * are registered via methods on the instance, not via config.\n *\n * @template TEvents - Event map type for type-safe events\n *\n * @example\n * ```ts\n * const screen = createScreen<MyEvents>({ debug: true });\n *\n * screen.on('tap', (playerIndex, data) => handleTap(playerIndex, data));\n * screen.onAllReady(() => startGame());\n * screen.onControllerJoin((playerIndex, info) => addPlayer(playerIndex, info));\n *\n * await screen.ready;\n * screen.broadcast('phase-update', { phase: 'playing' });\n * screen.gameOver({ scores: { 0: 100, 1: 75 } });\n * ```\n */\nexport interface Screen<TEvents extends EventMap = EventMap> {\n // === Properties (readonly) ===\n\n /**\n * All connected controllers. Returns a new shallow copy on every access.\n *\n * **Performance note:** Each access creates a new array via spread.\n * Avoid calling this in tight loops; cache the result in a local variable\n * if you need to access it repeatedly within the same frame/tick.\n */\n readonly controllers: readonly ControllerInfo[];\n\n /** The room code for this game session. */\n readonly roomCode: RoomCode;\n\n /** Whether the screen is initialized and ready. */\n readonly isReady: boolean;\n\n /** Whether the screen has been destroyed. */\n readonly isDestroyed: boolean;\n\n /** Whether the connection to the server is active. */\n readonly isConnected: boolean;\n\n /** Protocol version negotiated with the parent frame. */\n readonly protocolVersion: number;\n\n /**\n * A Promise that resolves when the screen is initialized and ready.\n * Use this to await readiness after creating a screen synchronously.\n *\n * @example\n * ```ts\n * const screen = createScreen<MyEvents>();\n * screen.on('tap', handler);\n * await screen.ready;\n * screen.broadcast('start', {});\n * ```\n */\n readonly ready: Promise<void>;\n\n // === Lifecycle Methods ===\n\n /**\n * Register a callback for when all participants are ready (all-ready event).\n * If the all-ready event has already fired when called, the callback fires immediately.\n *\n * @param callback - Called when all participants signal ready\n * @returns Unsubscribe function to remove the callback\n */\n onAllReady(callback: () => void): () => void;\n\n /**\n * Register a callback for when a controller (player) joins the room.\n *\n * @param callback - Called with player index and controller info\n * @returns Unsubscribe function to remove the callback\n */\n onControllerJoin(callback: (playerIndex: PlayerIndex, info: ControllerInfo) => void): () => void;\n\n /**\n * Register a callback for when a controller (player) leaves the room.\n *\n * @param callback - Called with the leaving player's index\n * @returns Unsubscribe function to remove the callback\n */\n onControllerLeave(callback: (playerIndex: PlayerIndex) => void): () => void;\n\n /**\n * Register a callback for when a controller temporarily disconnects.\n *\n * @param callback - Called with the disconnected player's index\n * @returns Unsubscribe function to remove the callback\n */\n onControllerDisconnect(callback: (playerIndex: PlayerIndex) => void): () => void;\n\n /**\n * Register a callback for when a controller reconnects after a disconnect.\n *\n * In the stateless controller pattern, use this callback to re-push\n * the current view state to the reconnecting controller.\n *\n * @example\n * ```ts\n * screen.onControllerReconnect((playerIndex) => {\n * screen.sendToController(playerIndex, 'view-update', getCurrentView(playerIndex));\n * });\n * ```\n *\n * @param callback - Called with player index and updated controller info\n * @returns Unsubscribe function to remove the callback\n */\n onControllerReconnect(callback: (playerIndex: PlayerIndex, info: ControllerInfo) => void): () => void;\n\n /**\n * Register a callback for when a player's character appearance is updated.\n *\n * @param callback - Called with player index and new appearance (or null if reset)\n * @returns Unsubscribe function to remove the callback\n */\n onCharacterUpdated(callback: (playerIndex: PlayerIndex, appearance: CharacterAppearance | null) => void): () => void;\n\n /**\n * Register a callback for when an error occurs.\n * If no error callback is registered, errors are logged to console in debug mode.\n *\n * @param callback - Called with the error object\n * @returns Unsubscribe function to remove the callback\n */\n onError(callback: (error: SmoreError) => void): () => void;\n\n /**\n * Register a callback for when the connection status changes.\n * Called when the connection to the server is lost or restored.\n *\n * @param callback - Called with true (connected) or false (disconnected)\n * @returns Unsubscribe function to remove the callback\n */\n onConnectionChange(callback: (connected: boolean) => void): () => void;\n\n // === Communication Methods ===\n\n /**\n * Broadcast an event to all connected controllers.\n *\n * Use this to push the same view state to all controllers simultaneously.\n *\n * @param event - Event name (must match TEvents keys)\n * @param data - Event data (type-safe based on event name)\n * @note Data should be an object. Primitive values will be wrapped as `{ data: value }` by the relay server.\n * @note Maximum payload size is 64KB. Payloads exceeding this limit will be silently dropped by the server.\n * **Rate limit:** The server allows up to 60 events/sec per Screen socket\n * (shared across broadcast and sendToController calls).\n * Events exceeding this limit are silently dropped.\n * Messages from a single sender are delivered in order.\n *\n * @example\n * ```ts\n * screen.broadcast('phase-update', { phase: 'playing' });\n * ```\n */\n broadcast<K extends EventNames<TEvents>>(\n event: K,\n data: EventData<TEvents, K>,\n ): void;\n\n /**\n * Send an event to a specific controller.\n *\n * Screen -> Controller direction only. For Controller -> Screen, see `send()`.\n *\n * This is the primary method for the stateless controller pattern:\n * push complete view state to a specific controller.\n *\n * @param playerIndex - Target controller's player index\n * @param event - Event name (must match TEvents keys)\n * @param data - Event data (type-safe based on event name)\n * @note Data should be an object. Primitive values will be wrapped as `{ data: value }` by the relay server.\n * @note Maximum payload size is 64KB. Payloads exceeding this limit will be silently dropped by the server.\n * **Rate limit:** Shares the 60 events/sec limit with broadcast().\n *\n * @example\n * ```ts\n * screen.sendToController(0, 'your-turn', { timeLimit: 30 });\n * ```\n *\n * @example\n * ```ts\n * // Push current game view to a specific player\n * screen.sendToController(playerIndex, 'view-update', {\n * phase: 'voting',\n * candidates: [1, 3, 5],\n * timeRemaining: 30,\n * });\n * ```\n */\n sendToController<K extends EventNames<TEvents>>(\n playerIndex: PlayerIndex,\n event: K,\n data: EventData<TEvents, K>,\n ): void;\n\n // === Game Lifecycle ===\n\n /**\n * Signal that the game is over and send results.\n * This will broadcast a game-over event to all controllers.\n *\n * @param results - Game results (scores, rankings, etc.)\n *\n * @example\n * ```ts\n * screen.gameOver({\n * scores: { 0: 100, 1: 75, 2: 50 },\n * winner: 0,\n * rankings: [0, 1, 2],\n * });\n * ```\n */\n gameOver(results?: GameResults): void;\n\n /**\n * Signal that this screen has finished loading resources and is ready to start.\n *\n * Call this after all game resources (Phaser assets, images, sounds, etc.) are loaded.\n * The server will wait until all participants (screen + all connected controllers)\n * have signaled ready, then broadcast an all-ready event to everyone.\n *\n * @example\n * ```ts\n * // After Phaser scene loads all assets:\n * screen.signalReady();\n * ```\n */\n signalReady(): void;\n\n // === Event Subscription ===\n\n /**\n * Subscribe to a lifecycle event or a user-defined game event.\n *\n * Lifecycle events use `$`-prefixed names. Use `LifecycleEvent` constants\n * for type-safe subscription:\n * ```ts\n * screen.on(LifecycleEvent.CONTROLLER_JOIN, (pi, info) => { ... });\n * screen.on('tap', (pi, data) => { ... }); // user event\n * ```\n */\n on<K extends ScreenLifecycleEvent>(event: K, handler: ScreenLifecycleHandlers[K]): () => void;\n /**\n * Add a listener for a specific event after construction.\n * Can be called before the screen is ready -- handlers are queued\n * and activated when the transport becomes available.\n *\n * @param event - Event name\n * @param handler - Handler function (playerIndex, data) => void\n * @returns Cleanup function to remove the listener\n *\n * @example\n * ```ts\n * const unsubscribe = screen.on('tap', (playerIndex, data) => {\n * console.log(`Player ${playerIndex} tapped at`, data.x, data.y);\n * });\n *\n * // Later: remove listener\n * unsubscribe();\n * ```\n */\n on<K extends EventNames<TEvents>>(\n event: K,\n handler: ScreenEventHandler<EventData<TEvents, K>>,\n ): () => void;\n\n once<K extends ScreenLifecycleEvent>(event: K, handler: ScreenLifecycleHandlers[K]): () => void;\n /**\n * Add a one-time listener that auto-removes after first call.\n *\n * @note The handler is internally wrapped, so it cannot be removed via\n * `off(event, originalHandler)`. Use the returned unsubscribe function instead.\n */\n once<K extends EventNames<TEvents>>(\n event: K,\n handler: ScreenEventHandler<EventData<TEvents, K>>,\n ): () => void;\n\n off<K extends ScreenLifecycleEvent>(event: K, handler?: ScreenLifecycleHandlers[K]): void;\n /**\n * Remove a specific listener or all listeners for an event.\n */\n off<K extends EventNames<TEvents>>(\n event: K,\n handler?: ScreenEventHandler<EventData<TEvents, K>>,\n ): void;\n\n /**\n * Remove all event listeners, or all listeners for a specific event.\n * Only removes user event listeners registered via on()/once().\n * Lifecycle callbacks (onControllerJoin, onAllReady, etc.) are not affected.\n *\n * @param event - Optional event name. If omitted, removes ALL user event listeners.\n */\n removeAllListeners(event?: string): void;\n\n // === Utilities ===\n\n /**\n * Get a specific controller by player index.\n * Returns undefined if not found.\n */\n getController(playerIndex: PlayerIndex): ControllerInfo | undefined;\n\n /**\n * Get the number of connected controllers.\n */\n getControllerCount(): number;\n\n // === Cleanup ===\n\n /**\n * Clean up all resources and disconnect.\n * Call this when unmounting/destroying your game.\n */\n destroy(): void;\n}\n\n// =============================================================================\n// CONTROLLER TYPES - PLAYER/PHONE SIDE\n// =============================================================================\n\n/**\n * Handler for events received from the screen.\n * Receives only the event data (no player index needed).\n */\nexport type ControllerEventHandler<TData = unknown> = (data: TData) => void;\n\n/**\n * Configuration options for creating a Controller instance.\n *\n * In the event emitter pattern, only static options are passed via config.\n * All lifecycle callbacks and event listeners are registered via methods\n * on the returned Controller instance.\n *\n * @template TEvents - Event map type for type-safe events\n *\n * @example\n * ```ts\n * const controller = createController<MyEvents>({ debug: true });\n *\n * controller.on('phase-update', (data) => handlePhase(data.phase));\n * controller.onAllReady(() => console.log('Ready!'));\n *\n * await controller.ready;\n * controller.send('tap', { x: 100, y: 200 });\n * ```\n */\nexport interface ControllerConfig {\n // === Debug Options ===\n\n /**\n * Enable debug mode for verbose logging.\n * @default false\n */\n debug?: boolean | DebugOptions;\n\n // === Advanced Options ===\n\n /**\n * Parent window origin for postMessage validation (iframe games).\n * @default '*'\n */\n parentOrigin?: string;\n\n /**\n * Connection timeout in milliseconds.\n * @default 10000\n */\n timeout?: number;\n\n /**\n * Automatically signal ready after initialization.\n * When true (default), the SDK calls signalReady() automatically after init completes.\n * Set to false if your game needs to load resources before signaling ready.\n * @default true\n */\n autoReady?: boolean;\n\n /**\n * Custom transport implementation.\n * If provided, uses this instead of the default PostMessageTransport.\n * The bridge handshake (_bridge:init) still occurs via postMessage.\n */\n transport?: Transport;\n\n}\n\n/**\n * Controller instance - the main interface for the player/phone side.\n *\n * Uses an event emitter pattern: lifecycle callbacks and event listeners\n * are registered via methods on the instance, not via config.\n *\n * @template TEvents - Event map type for type-safe events\n *\n * @example\n * ```ts\n * const controller = createController<MyEvents>({ debug: true });\n *\n * controller.on('phase-update', (data) => setPhase(data.phase));\n * controller.onAllReady(() => console.log('Game starting!'));\n *\n * await controller.ready;\n * controller.send('tap', { x: 100, y: 200 });\n * ```\n *\n * ## Controller API Design Note:\n *\n * Controller only has `send()` (no `broadcast()` or `gameOver()`).\n * This is intentional: Controller-to-Controller (C2C) communication is not supported.\n * All coordination between controllers must go through the Screen.\n *\n * Flow: Controller.send() -> Screen receives -> Screen.broadcast() or Screen.sendToController()\n *\n * ## Stateless Controller Pattern (Recommended)\n *\n * Controllers should be stateless display + input devices:\n * - Render only what Screen sends via `on()` event handlers\n * - Send only user input to Screen via `send()`\n * - Do NOT store game state on the controller\n * - Screen is the single source of truth for all game state\n *\n * When a controller reconnects, Screen re-pushes current view state\n * via `sendToController()` in the `onControllerReconnect` callback.\n */\nexport interface Controller<TEvents extends EventMap = EventMap> {\n // === Properties (readonly) ===\n\n /** My player index (0, 1, 2, ...). */\n readonly myPlayerIndex: PlayerIndex;\n\n /** My own controller info. undefined before initialization. */\n readonly me: ControllerInfo | undefined;\n\n /** The room code for this game session. */\n readonly roomCode: RoomCode;\n\n /** Whether the controller is initialized and ready. */\n readonly isReady: boolean;\n\n /** Whether the controller has been destroyed. */\n readonly isDestroyed: boolean;\n\n /** Whether the connection to the server is active. */\n readonly isConnected: boolean;\n\n /** Protocol version negotiated with the parent frame. */\n readonly protocolVersion: number;\n\n /**\n * Read-only list of all known controllers (players) in the room.\n * Returns full ControllerInfo including playerIndex, nickname, connected status, and appearance.\n * Consistent with Screen's `controllers` property.\n *\n * **Performance note:** Each access creates a new shallow copy array.\n * Cache the result in a local variable if you need to access it repeatedly.\n */\n readonly controllers: readonly ControllerInfo[];\n\n /**\n * A Promise that resolves when the controller is initialized and ready.\n * Use this to await readiness after creating a controller synchronously.\n *\n * @example\n * ```ts\n * const controller = createController<MyEvents>();\n * controller.on('phase-update', handler);\n * await controller.ready;\n * controller.send('tap', { x: 0, y: 0 });\n * ```\n */\n readonly ready: Promise<void>;\n\n // === Lifecycle Methods ===\n\n /**\n * Register a callback for when all participants are ready (all-ready event).\n * If the all-ready event has already fired when called, the callback fires immediately.\n *\n * @param callback - Called when all participants signal ready\n * @returns Unsubscribe function to remove the callback\n */\n onAllReady(callback: () => void): () => void;\n\n /**\n * Register a callback for when another player joins the room.\n *\n * @param callback - Called with player index and controller info\n * @returns Unsubscribe function to remove the callback\n */\n onControllerJoin(callback: (playerIndex: PlayerIndex, info: ControllerInfo) => void): () => void;\n\n /**\n * Register a callback for when another player leaves the room.\n *\n * @param callback - Called with the leaving player's index\n * @returns Unsubscribe function to remove the callback\n */\n onControllerLeave(callback: (playerIndex: PlayerIndex) => void): () => void;\n\n /**\n * Register a callback for when another player temporarily disconnects.\n *\n * @param callback - Called with the disconnected player's index\n * @returns Unsubscribe function to remove the callback\n */\n onControllerDisconnect(callback: (playerIndex: PlayerIndex) => void): () => void;\n\n /**\n * Register a callback for when another player reconnects after a disconnect.\n *\n * @param callback - Called with player index and updated controller info\n * @returns Unsubscribe function to remove the callback\n */\n onControllerReconnect(callback: (playerIndex: PlayerIndex, info: ControllerInfo) => void): () => void;\n\n /**\n * Register a callback for when a player's character appearance is updated.\n *\n * @param callback - Called with player index and new appearance (or null if reset)\n * @returns Unsubscribe function to remove the callback\n */\n onCharacterUpdated(callback: (playerIndex: PlayerIndex, appearance: CharacterAppearance | null) => void): () => void;\n\n /**\n * Register a callback for when an error occurs.\n * If no error callback is registered, errors are logged to console in debug mode.\n *\n * @param callback - Called with the error object\n * @returns Unsubscribe function to remove the callback\n */\n onError(callback: (error: SmoreError) => void): () => void;\n\n /**\n * Register a callback for when the game ends.\n * Called when the Screen calls gameOver().\n *\n * @param callback - Called with optional game results\n * @returns Unsubscribe function to remove the callback\n */\n onGameOver(callback: (results?: GameResults) => void): () => void;\n\n /**\n * Register a callback for when the connection status changes.\n * Called when the connection to the server is lost or restored.\n *\n * @param callback - Called with true (connected) or false (disconnected)\n * @returns Unsubscribe function to remove the callback\n */\n onConnectionChange(callback: (connected: boolean) => void): () => void;\n\n /**\n * Returns the number of currently connected players.\n */\n getControllerCount(): number;\n\n /**\n * Get a specific controller by player index.\n * Returns undefined if not found.\n */\n getController(playerIndex: PlayerIndex): ControllerInfo | undefined;\n\n // === Communication Methods ===\n\n /**\n * Send an event to the screen.\n *\n * Controller -> Screen direction only. For Screen -> Controller, see `sendToController()`.\n *\n * @param event - Event name (must match TEvents keys)\n * @param data - Event data (type-safe based on event name)\n * @note Maximum payload size is 64KB. Payloads exceeding this limit will be silently dropped by the server.\n * **Rate limit:** The server allows up to 60 events/sec per Controller socket.\n * Messages are delivered to Screen in the order they are sent.\n *\n * @example\n * ```ts\n * controller.send('tap', { x: 100, y: 200 });\n * controller.send('answer', { choice: 2 });\n * ```\n */\n send<K extends EventNames<TEvents>>(\n event: K,\n data: EventData<TEvents, K>,\n ): void;\n\n /**\n * Signal that this controller has finished loading resources and is ready to start.\n *\n * Call this after all game resources are loaded.\n * The server will wait until all participants have signaled ready,\n * then broadcast an all-ready event to everyone.\n *\n * @example\n * ```ts\n * // After loading completes:\n * controller.signalReady();\n * ```\n */\n signalReady(): void;\n\n // === Event Subscription ===\n\n /**\n * Subscribe to a lifecycle event or a user-defined game event.\n *\n * Lifecycle events use `$`-prefixed names. Use `LifecycleEvent` constants\n * for type-safe subscription:\n * ```ts\n * controller.on(LifecycleEvent.CONTROLLER_JOIN, (pi, info) => { ... });\n * controller.on('phase-update', (data) => { ... }); // user event\n * ```\n */\n on<K extends ControllerLifecycleEvent>(event: K, handler: ControllerLifecycleHandlers[K]): () => void;\n /**\n * Add a listener for a specific event after construction.\n * Can be called before the controller is ready -- handlers are queued\n * and activated when the transport becomes available.\n *\n * @param event - Event name\n * @param handler - Handler function (data) => void\n * @returns Cleanup function to remove the listener\n *\n * @note Events from screen.broadcast() do not include playerIndex.\n * The handler signature is `(data: D)` without playerIndex context.\n * If you need to know which player triggered the broadcast, include\n * that information in the data object from the Screen side.\n *\n * @example\n * ```ts\n * const unsubscribe = controller.on('phase-update', (data) => {\n * console.log('New phase:', data.phase);\n * });\n *\n * // Later: remove listener\n * unsubscribe();\n * ```\n */\n on<K extends EventNames<TEvents>>(\n event: K,\n handler: ControllerEventHandler<EventData<TEvents, K>>,\n ): () => void;\n\n once<K extends ControllerLifecycleEvent>(event: K, handler: ControllerLifecycleHandlers[K]): () => void;\n /**\n * Add a one-time listener that auto-removes after first call.\n *\n * @note The handler is internally wrapped, so it cannot be removed via\n * `off(event, originalHandler)`. Use the returned unsubscribe function instead.\n */\n once<K extends EventNames<TEvents>>(\n event: K,\n handler: ControllerEventHandler<EventData<TEvents, K>>,\n ): () => void;\n\n off<K extends ControllerLifecycleEvent>(event: K, handler?: ControllerLifecycleHandlers[K]): void;\n /**\n * Remove a specific listener or all listeners for an event.\n */\n off<K extends EventNames<TEvents>>(\n event: K,\n handler?: ControllerEventHandler<EventData<TEvents, K>>,\n ): void;\n\n /**\n * Remove all event listeners, or all listeners for a specific event.\n * Only removes user event listeners registered via on()/once().\n * Lifecycle callbacks (onControllerJoin, onAllReady, etc.) are not affected.\n *\n * @param event - Optional event name. If omitted, removes ALL user event listeners.\n */\n removeAllListeners(event?: string): void;\n\n // === Cleanup ===\n\n /**\n * Clean up all resources and disconnect.\n * Call this when unmounting/destroying your game.\n */\n destroy(): void;\n}\n\n// =============================================================================\n// DEBUG OPTIONS\n// =============================================================================\n\n/**\n * Log levels for debug output.\n */\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\n/**\n * Debug configuration options.\n */\nexport interface DebugOptions {\n /** Enable debug logging */\n enabled?: boolean;\n\n /** Minimum log level to output */\n level?: LogLevel;\n\n /** Prefix for log messages */\n prefix?: string;\n\n /** Log events being sent */\n logSend?: boolean;\n\n /** Log events being received */\n logReceive?: boolean;\n\n /** Log lifecycle events (ready, destroy, etc.) */\n logLifecycle?: boolean;\n\n /** Custom logger function */\n logger?: (level: LogLevel, message: string, data?: unknown) => void;\n}\n"],"names":[],"mappings":";;AA+OO,MAAM,cAAA,GAAiB;AAAA,EAC5B,SAAA,EAAW,YAAA;AAAA,EACX,eAAA,EAAiB,kBAAA;AAAA,EACjB,gBAAA,EAAkB,mBAAA;AAAA,EAClB,qBAAA,EAAuB,wBAAA;AAAA,EACvB,oBAAA,EAAsB,uBAAA;AAAA,EACtB,iBAAA,EAAmB,oBAAA;AAAA,EACnB,KAAA,EAAO,QAAA;AAAA,EACP,SAAA,EAAW,YAAA;AAAA,EACX,iBAAA,EAAmB;AACrB;;;;"}
1
+ {"version":3,"file":"types.cjs","sources":["../../src/types.ts"],"sourcesContent":["/**\n * @smoregg/sdk - World-Class Party Game SDK\n *\n * Type definitions for building multiplayer party games with type-safe events,\n * factory pattern initialization, and comprehensive error handling.\n *\n * @packageDocumentation\n */\n\n// =============================================================================\n// GAME CONFIGURATION\n// =============================================================================\n\n/**\n * Valid game categories for the S'MORE platform.\n * Use these when setting categories in game.json.\n */\nexport type GameCategory =\n | 'bet' // 🎰 내기\n | 'coop' // 🤝 협동\n | 'versus' // ⚔️ 대결\n | 'time-attack' // ⏱️ 타임어택\n | 'survival' // 🏃 생존\n | 'reflex' // 🎯 반응속도\n | 'deception' // 🕵️ 추리/속임수\n | 'creative' // 🎨 창작\n | 'party' // 🎉 파티\n | 'puzzle' // 🧩 퍼즐\n | 'board' // 🎲 보드게임\n | 'strategy' // 🧠 전략\n | 'timing'; // 🎵 타이밍\n\n/**\n * Category metadata with emoji and localized labels.\n * Useful for displaying categories in UI.\n */\nexport const GAME_CATEGORIES: Record<GameCategory, { emoji: string; label: string; labelKo: string }> = {\n 'bet': { emoji: '🎰', label: 'Betting', labelKo: '내기' },\n 'coop': { emoji: '🤝', label: 'Co-op', labelKo: '협동' },\n 'versus': { emoji: '⚔️', label: 'Versus', labelKo: '대결' },\n 'time-attack': { emoji: '⏱️', label: 'Time Attack', labelKo: '타임어택' },\n 'survival': { emoji: '🏃', label: 'Survival', labelKo: '생존' },\n 'reflex': { emoji: '🎯', label: 'Reflex', labelKo: '반응속도' },\n 'deception': { emoji: '🕵️', label: 'Deception', labelKo: '추리/속임수' },\n 'creative': { emoji: '🎨', label: 'Creative', labelKo: '창작' },\n 'party': { emoji: '🎉', label: 'Party', labelKo: '파티' },\n 'puzzle': { emoji: '🧩', label: 'Puzzle', labelKo: '퍼즐' },\n 'board': { emoji: '🎲', label: 'Board Game', labelKo: '보드게임' },\n 'strategy': { emoji: '🧠', label: 'Strategy', labelKo: '전략' },\n 'timing': { emoji: '🎵', label: 'Timing', labelKo: '타이밍' },\n};\n\n/**\n * Game configuration from game.json.\n * This is the schema that game developers put in their game.json file.\n *\n * @example\n * ```json\n * {\n * \"id\": \"my-game\",\n * \"title\": \"My Game\",\n * \"description\": \"A fun party game\",\n * \"players\": [3, 4, 5, 6],\n * \"categories\": [\"party\", \"creative\"],\n * \"version\": \"1.0.0\"\n * }\n * ```\n */\nexport interface GameConfig {\n /** Unique game identifier (kebab-case) */\n id: string;\n /** Display name of the game */\n title: string;\n /** Short description (1-2 sentences) */\n description: string;\n /** Allowed player counts (e.g. [3,4,5,6,7,8] or [2,4,6]) */\n players: number[];\n /** Game categories from the fixed platform list */\n categories: GameCategory[];\n /** Semantic version (e.g. \"1.0.0\") */\n version: string;\n}\n\n// =============================================================================\n// CORE PRIMITIVES\n// =============================================================================\n\n/**\n * Unique identifier for a player (0-indexed integer).\n * Used consistently across all SDK methods.\n */\nexport type PlayerIndex = number;\n\n/**\n * Room code for joining a game session (e.g., \"ABCD\").\n */\nexport type RoomCode = string;\n\n// =============================================================================\n// EVENT SYSTEM - TYPE-SAFE EVENTS\n// =============================================================================\n\n/**\n * Base event map type. Extend this to define your game's events.\n *\n * **Important:** Event data values must be plain objects, not primitives.\n * Primitive values (string, number, boolean) will be automatically wrapped\n * as `{ data: <value> }` by the relay server, which breaks type safety.\n *\n * **Payload Size Limit:** Maximum payload size per event is 64KB. This limit\n * is enforced by the server's genericRelay handler. Payloads exceeding this\n * limit will be silently dropped by the server without error notification.\n *\n * **Reserved Fields:** The field names `playerIndex` and `targetPlayerIndex` are reserved\n * by the SDK for internal routing. Using these as custom data field names will cause\n * a compile-time error. The SDK automatically extracts `playerIndex` to identify the sender\n * and uses `targetPlayerIndex` for targeted message delivery.\n *\n * **Type Safety Note:** Without providing an explicit generic type parameter,\n * `createScreen()` and `createController()` default to the empty `EventMap`,\n * which means `send()`, `broadcast()`, and `on()` accept any string as an event\n * name and `unknown` as data -- effectively losing compile-time type checking.\n * Always define and pass your game's event map for full type safety.\n *\n * @example Defining events for type safety\n * ```ts\n * interface MyGameEvents {\n * // Screen receives from Controller\n * 'tap': { x: number; y: number };\n * 'answer': { choice: number };\n *\n * // Controller receives from Screen\n * 'phase-update': { phase: 'lobby' | 'playing' | 'results' };\n * 'your-turn': { timeLimit: number };\n * }\n *\n * // With explicit generic -- full type safety\n * const screen = createScreen<MyGameEvents>({ debug: true });\n * screen.on('tap', (playerIndex, data) => { ... });\n * await screen.ready;\n *\n * // Without generic -- no type safety (not recommended)\n * const screen = createScreen();\n * ```\n *\n * @example Event naming conventions\n * ```ts\n * // Define your game's event map for type safety:\n * type MyEvents = {\n * 'player-move': { x: number; y: number };\n * 'game-action': { action: string; value: number };\n * };\n * // Event names: use kebab-case, no colons (:), no 'smore:' prefix\n * ```\n */\nexport interface EventMap {\n [key: string]: Record<string, unknown> & { playerIndex?: never; targetPlayerIndex?: never };\n}\n\n/**\n * Extract event names from an event map.\n */\nexport type EventNames<TEvents extends EventMap> = keyof TEvents & string;\n\n/**\n * Extract event data type for a specific event.\n */\nexport type EventData<\n TEvents extends EventMap,\n TEvent extends EventNames<TEvents>,\n> = TEvents[TEvent];\n\n// =============================================================================\n// CONTROLLER INFO - PLAYER INFORMATION\n// =============================================================================\n\n/**\n * Character appearance data for player avatars.\n *\n * This type matches the server's CharacterDTO structure to ensure\n * type consistency across the platform.\n *\n * @property id - Unique character identifier\n * @property seed - Random seed for generating the character\n * @property style - Character style preset identifier\n * @property options - Additional character customization options\n */\nexport interface CharacterAppearance {\n /** Unique character identifier */\n id: string;\n /** Random seed for generating the character */\n seed: string;\n /** Character style preset identifier */\n style: string;\n /** Additional character customization options */\n options: Record<string, unknown>;\n}\n\n/**\n * Information about a connected controller (player).\n * Used by Screen to identify and manage players.\n */\nexport interface ControllerInfo {\n /** Player's unique index (0, 1, 2, ...) */\n readonly playerIndex: PlayerIndex;\n /**\n * Player's chosen display name.\n *\n * Maps to `PlayerDTO.name` on the server side. The SDK exposes it as\n * \"nickname\" for semantic clarity in game code.\n * The mapping (`name` -> `nickname`) is handled automatically during\n * player data deserialization in the transport layer.\n *\n * @see PlayerDTO.name (server) -- same value, different field name\n */\n readonly nickname: string;\n /** Whether the player is currently connected */\n readonly connected: boolean;\n /**\n * Optional character appearance data.\n *\n * Note: The server sends this as \"character\" in PlayerDTO.\n * The SDK maps it to \"appearance\" for semantic clarity.\n * The server may send `null` when no character is set.\n */\n readonly appearance?: CharacterAppearance | null;\n}\n\n// =============================================================================\n// TRANSPORT\n// =============================================================================\n\n/**\n * Transport interface for custom communication implementations.\n * Implement this to use a custom transport instead of the default PostMessageTransport.\n */\nexport interface Transport {\n emit(event: string, ...args: unknown[]): void;\n on(event: string, handler: (...args: unknown[]) => void): void;\n off(event: string, handler?: (...args: unknown[]) => void): void;\n destroy(): void;\n}\n\n// =============================================================================\n// ERROR HANDLING\n// =============================================================================\n\n/**\n * Error codes for SDK errors.\n */\nexport type SmoreErrorCode =\n | 'TIMEOUT' // Connection or operation timeout\n | 'NOT_READY' // Operation called before ready\n | 'DESTROYED' // Operation called after destroy\n | 'INVALID_EVENT' // Invalid event name\n | 'INVALID_PLAYER' // Invalid player index\n | 'CONNECTION_LOST' // Lost connection to server\n | 'INIT_FAILED' // Failed to initialize\n | 'RATE_LIMITED' // Server rate-limited an event\n | 'PAYLOAD_TOO_LARGE' // Payload exceeds 64KB limit\n | 'UNKNOWN'; // Unknown error\n\n/**\n * Structured error type for SDK errors.\n */\nexport interface SmoreError {\n /** Error code for programmatic handling */\n code: SmoreErrorCode;\n /** Human-readable error message */\n message: string;\n /** Original error if available */\n cause?: Error;\n /** Additional context */\n details?: Record<string, unknown>;\n}\n\n// =============================================================================\n// GAME RESULTS\n// =============================================================================\n\n/**\n * Game results structure for gameOver().\n * Flexible to accommodate different game types.\n */\nexport interface GameResults {\n /** Player scores indexed by player index */\n scores?: Record<PlayerIndex, number>;\n /** Winner's player index (or -1 for no winner/tie) */\n winner?: PlayerIndex;\n /** Ranked player indices from first to last */\n rankings?: PlayerIndex[];\n /** Additional custom game-specific data */\n custom?: Record<string, unknown>;\n}\n\n// =============================================================================\n// LIFECYCLE EVENTS — UNIFIED EVENT SYSTEM\n// =============================================================================\n\n/**\n * Lifecycle event names for subscribing via `on()`.\n *\n * These `$`-prefixed event names allow lifecycle events to be registered\n * through the same `on()` method used for game events. The `$` prefix is\n * reserved by the SDK and cannot be used for user-defined events.\n *\n * @example\n * ```ts\n * // These are equivalent:\n * screen.onControllerJoin((pi, info) => { ... });\n * screen.on(LifecycleEvent.CONTROLLER_JOIN, (pi, info) => { ... });\n * ```\n */\nexport const LifecycleEvent = {\n ALL_READY: '$all-ready',\n CONTROLLER_JOIN: '$controller-join',\n CONTROLLER_LEAVE: '$controller-leave',\n CONTROLLER_DISCONNECT: '$controller-disconnect',\n CONTROLLER_RECONNECT: '$controller-reconnect',\n CHARACTER_UPDATED: '$character-updated',\n ERROR: '$error',\n GAME_OVER: '$game-over',\n CONNECTION_CHANGE: '$connection-change',\n} as const;\n\n/** Union of all lifecycle event name strings. */\nexport type LifecycleEventName = typeof LifecycleEvent[keyof typeof LifecycleEvent];\n\n/**\n * Handler signatures for Screen lifecycle events.\n * Used by `on()` overloads to provide type-safe lifecycle event subscription.\n */\nexport interface ScreenLifecycleHandlers {\n '$all-ready': () => void;\n '$controller-join': (playerIndex: PlayerIndex, info: ControllerInfo) => void;\n '$controller-leave': (playerIndex: PlayerIndex) => void;\n '$controller-disconnect': (playerIndex: PlayerIndex) => void;\n '$controller-reconnect': (playerIndex: PlayerIndex, info: ControllerInfo) => void;\n '$character-updated': (playerIndex: PlayerIndex, appearance: CharacterAppearance | null) => void;\n '$error': (error: SmoreError) => void;\n '$connection-change': (connected: boolean) => void;\n}\n\n/** Screen lifecycle event name union. */\nexport type ScreenLifecycleEvent = keyof ScreenLifecycleHandlers;\n\n/**\n * Handler signatures for Controller lifecycle events.\n * Extends Screen lifecycle events with Controller-specific events.\n */\nexport interface ControllerLifecycleHandlers extends ScreenLifecycleHandlers {\n '$game-over': (results?: GameResults) => void;\n}\n\n/** Controller lifecycle event name union. */\nexport type ControllerLifecycleEvent = keyof ControllerLifecycleHandlers;\n\n// =============================================================================\n// SCREEN TYPES - HOST/TV SIDE\n// =============================================================================\n\n/**\n * Handler for events received from controllers.\n * Receives the player index and event data.\n */\nexport type ScreenEventHandler<TData = unknown> = (\n playerIndex: PlayerIndex,\n data: TData,\n) => void;\n\n/**\n * Configuration options for creating a Screen instance.\n *\n * In the event emitter pattern, only static options are passed via config.\n * All lifecycle callbacks and event listeners are registered via methods\n * on the returned Screen instance.\n *\n * @template TEvents - Event map type for type-safe events\n *\n * @example\n * ```ts\n * const screen = createScreen<MyEvents>({ debug: true });\n *\n * screen.on('tap', (playerIndex, data) => handleTap(playerIndex, data));\n * screen.onAllReady(() => startCountdown());\n * screen.onControllerJoin((playerIndex, info) => console.log('Joined:', playerIndex));\n *\n * await screen.ready;\n * ```\n */\nexport interface ScreenConfig {\n // === Debug Options ===\n\n /**\n * Enable debug mode for verbose logging.\n * @default false\n */\n debug?: boolean | DebugOptions;\n\n // === Advanced Options ===\n\n /**\n * Parent window origin for postMessage validation (iframe games).\n * Use '*' to accept messages from any origin (not recommended for production).\n * @default '*'\n */\n parentOrigin?: string;\n\n /**\n * Connection timeout in milliseconds.\n * @default 10000\n */\n timeout?: number;\n\n /**\n * Automatically signal ready after initialization.\n * When true (default), the SDK calls signalReady() automatically after init completes.\n * Set to false if your game needs to load resources before signaling ready.\n * @default true\n */\n autoReady?: boolean;\n\n /**\n * Custom transport implementation.\n * If provided, uses this instead of the default PostMessageTransport.\n * The bridge handshake (_bridge:init) still occurs via postMessage.\n */\n transport?: Transport;\n\n}\n\n/**\n * Screen instance - the main interface for the host/TV side of your game.\n *\n * Uses an event emitter pattern: lifecycle callbacks and event listeners\n * are registered via methods on the instance, not via config.\n *\n * @template TEvents - Event map type for type-safe events\n *\n * @example\n * ```ts\n * const screen = createScreen<MyEvents>({ debug: true });\n *\n * screen.on('tap', (playerIndex, data) => handleTap(playerIndex, data));\n * screen.onAllReady(() => startGame());\n * screen.onControllerJoin((playerIndex, info) => addPlayer(playerIndex, info));\n *\n * await screen.ready;\n * screen.broadcast('phase-update', { phase: 'playing' });\n * screen.gameOver({ scores: { 0: 100, 1: 75 } });\n * ```\n */\nexport interface Screen<TEvents extends EventMap = EventMap> {\n // === Properties (readonly) ===\n\n /**\n * All connected controllers. Returns a new shallow copy on every access.\n *\n * **Performance note:** Each access creates a new array via spread.\n * Avoid calling this in tight loops; cache the result in a local variable\n * if you need to access it repeatedly within the same frame/tick.\n */\n readonly controllers: readonly ControllerInfo[];\n\n /** The room code for this game session. */\n readonly roomCode: RoomCode;\n\n /** Whether the screen is initialized and ready. */\n readonly isReady: boolean;\n\n /** Whether the screen has been destroyed. */\n readonly isDestroyed: boolean;\n\n /** Whether the connection to the server is active. */\n readonly isConnected: boolean;\n\n /** Protocol version negotiated with the parent frame. */\n readonly protocolVersion: number;\n\n /**\n * A Promise that resolves when the screen is initialized and ready.\n * Use this to await readiness after creating a screen synchronously.\n *\n * @example\n * ```ts\n * const screen = createScreen<MyEvents>();\n * screen.on('tap', handler);\n * await screen.ready;\n * screen.broadcast('start', {});\n * ```\n */\n readonly ready: Promise<void>;\n\n // === Lifecycle Methods ===\n\n /**\n * Register a callback for when all participants are ready (all-ready event).\n * If the all-ready event has already fired when called, the callback fires immediately.\n *\n * @param callback - Called when all participants signal ready\n * @returns Unsubscribe function to remove the callback\n */\n onAllReady(callback: () => void): () => void;\n\n /**\n * Register a callback for when a controller (player) joins the room.\n *\n * @param callback - Called with player index and controller info\n * @returns Unsubscribe function to remove the callback\n */\n onControllerJoin(callback: (playerIndex: PlayerIndex, info: ControllerInfo) => void): () => void;\n\n /**\n * Register a callback for when a controller (player) leaves the room.\n *\n * @param callback - Called with the leaving player's index\n * @returns Unsubscribe function to remove the callback\n */\n onControllerLeave(callback: (playerIndex: PlayerIndex) => void): () => void;\n\n /**\n * Register a callback for when a controller temporarily disconnects.\n *\n * @param callback - Called with the disconnected player's index\n * @returns Unsubscribe function to remove the callback\n */\n onControllerDisconnect(callback: (playerIndex: PlayerIndex) => void): () => void;\n\n /**\n * Register a callback for when a controller reconnects after a disconnect.\n *\n * In the stateless controller pattern, use this callback to re-push\n * the current view state to the reconnecting controller.\n *\n * @example\n * ```ts\n * screen.onControllerReconnect((playerIndex) => {\n * screen.sendToController(playerIndex, 'view-update', getCurrentView(playerIndex));\n * });\n * ```\n *\n * @param callback - Called with player index and updated controller info\n * @returns Unsubscribe function to remove the callback\n */\n onControllerReconnect(callback: (playerIndex: PlayerIndex, info: ControllerInfo) => void): () => void;\n\n /**\n * Register a callback for when a player's character appearance is updated.\n *\n * @param callback - Called with player index and new appearance (or null if reset)\n * @returns Unsubscribe function to remove the callback\n */\n onCharacterUpdated(callback: (playerIndex: PlayerIndex, appearance: CharacterAppearance | null) => void): () => void;\n\n /**\n * Register a callback for when an error occurs.\n * If no error callback is registered, errors are logged to console in debug mode.\n *\n * @param callback - Called with the error object\n * @returns Unsubscribe function to remove the callback\n */\n onError(callback: (error: SmoreError) => void): () => void;\n\n /**\n * Register a callback for when the connection status changes.\n * Called when the connection to the server is lost or restored.\n *\n * @param callback - Called with true (connected) or false (disconnected)\n * @returns Unsubscribe function to remove the callback\n */\n onConnectionChange(callback: (connected: boolean) => void): () => void;\n\n // === Communication Methods ===\n\n /**\n * Broadcast an event to all connected controllers.\n *\n * Use this to push the same view state to all controllers simultaneously.\n *\n * @param event - Event name (must match TEvents keys)\n * @param data - Event data (type-safe based on event name)\n * @note Data should be an object. Primitive values will be wrapped as `{ data: value }` by the relay server.\n * @note Maximum payload size is 64KB. Payloads exceeding this limit will be silently dropped by the server.\n * **Rate limit:** The server allows up to 60 events/sec per Screen socket\n * (shared across broadcast and sendToController calls).\n * Events exceeding this limit are silently dropped.\n * Messages from a single sender are delivered in order.\n *\n * @example\n * ```ts\n * screen.broadcast('phase-update', { phase: 'playing' });\n * ```\n */\n broadcast<K extends EventNames<TEvents>>(\n event: K,\n data: EventData<TEvents, K>,\n ): void;\n\n /**\n * Send an event to a specific controller.\n *\n * Screen -> Controller direction only. For Controller -> Screen, see `send()`.\n *\n * This is the primary method for the stateless controller pattern:\n * push complete view state to a specific controller.\n *\n * @param playerIndex - Target controller's player index\n * @param event - Event name (must match TEvents keys)\n * @param data - Event data (type-safe based on event name)\n * @note Data should be an object. Primitive values will be wrapped as `{ data: value }` by the relay server.\n * @note Maximum payload size is 64KB. Payloads exceeding this limit will be silently dropped by the server.\n * **Rate limit:** Shares the 60 events/sec limit with broadcast().\n *\n * @example\n * ```ts\n * screen.sendToController(0, 'your-turn', { timeLimit: 30 });\n * ```\n *\n * @example\n * ```ts\n * // Push current game view to a specific player\n * screen.sendToController(playerIndex, 'view-update', {\n * phase: 'voting',\n * candidates: [1, 3, 5],\n * timeRemaining: 30,\n * });\n * ```\n */\n sendToController<K extends EventNames<TEvents>>(\n playerIndex: PlayerIndex,\n event: K,\n data: EventData<TEvents, K>,\n ): void;\n\n // === Game Lifecycle ===\n\n /**\n * Signal that the game is over and send results.\n * This will broadcast a game-over event to all controllers.\n *\n * @param results - Game results (scores, rankings, etc.)\n *\n * @example\n * ```ts\n * screen.gameOver({\n * scores: { 0: 100, 1: 75, 2: 50 },\n * winner: 0,\n * rankings: [0, 1, 2],\n * });\n * ```\n */\n gameOver(results?: GameResults): void;\n\n /**\n * Signal that this screen has finished loading resources and is ready to start.\n *\n * Call this after all game resources (Phaser assets, images, sounds, etc.) are loaded.\n * The server will wait until all participants (screen + all connected controllers)\n * have signaled ready, then broadcast an all-ready event to everyone.\n *\n * @example\n * ```ts\n * // After Phaser scene loads all assets:\n * screen.signalReady();\n * ```\n */\n signalReady(): void;\n\n // === Event Subscription ===\n\n /**\n * Subscribe to a lifecycle event or a user-defined game event.\n *\n * Lifecycle events use `$`-prefixed names. Use `LifecycleEvent` constants\n * for type-safe subscription:\n * ```ts\n * screen.on(LifecycleEvent.CONTROLLER_JOIN, (pi, info) => { ... });\n * screen.on('tap', (pi, data) => { ... }); // user event\n * ```\n */\n on<K extends ScreenLifecycleEvent>(event: K, handler: ScreenLifecycleHandlers[K]): () => void;\n /**\n * Add a listener for a specific event after construction.\n * Can be called before the screen is ready -- handlers are queued\n * and activated when the transport becomes available.\n *\n * @param event - Event name\n * @param handler - Handler function (playerIndex, data) => void\n * @returns Cleanup function to remove the listener\n *\n * @example\n * ```ts\n * const unsubscribe = screen.on('tap', (playerIndex, data) => {\n * console.log(`Player ${playerIndex} tapped at`, data.x, data.y);\n * });\n *\n * // Later: remove listener\n * unsubscribe();\n * ```\n */\n on<K extends EventNames<TEvents>>(\n event: K,\n handler: ScreenEventHandler<EventData<TEvents, K>>,\n ): () => void;\n\n once<K extends ScreenLifecycleEvent>(event: K, handler: ScreenLifecycleHandlers[K]): () => void;\n /**\n * Add a one-time listener that auto-removes after first call.\n *\n * @note The handler is internally wrapped, so it cannot be removed via\n * `off(event, originalHandler)`. Use the returned unsubscribe function instead.\n */\n once<K extends EventNames<TEvents>>(\n event: K,\n handler: ScreenEventHandler<EventData<TEvents, K>>,\n ): () => void;\n\n off<K extends ScreenLifecycleEvent>(event: K, handler?: ScreenLifecycleHandlers[K]): void;\n /**\n * Remove a specific listener or all listeners for an event.\n */\n off<K extends EventNames<TEvents>>(\n event: K,\n handler?: ScreenEventHandler<EventData<TEvents, K>>,\n ): void;\n\n /**\n * Remove all event listeners, or all listeners for a specific event.\n * Only removes user event listeners registered via on()/once().\n * Lifecycle callbacks (onControllerJoin, onAllReady, etc.) are not affected.\n *\n * @param event - Optional event name. If omitted, removes ALL user event listeners.\n */\n removeAllListeners(event?: string): void;\n\n // === Utilities ===\n\n /**\n * Get a specific controller by player index.\n * Returns undefined if not found.\n */\n getController(playerIndex: PlayerIndex): ControllerInfo | undefined;\n\n /**\n * Get the number of connected controllers.\n */\n getControllerCount(): number;\n\n // === Cleanup ===\n\n /**\n * Clean up all resources and disconnect.\n * Call this when unmounting/destroying your game.\n */\n destroy(): void;\n}\n\n// =============================================================================\n// CONTROLLER TYPES - PLAYER/PHONE SIDE\n// =============================================================================\n\n/**\n * Handler for events received from the screen.\n * Receives only the event data (no player index needed).\n */\nexport type ControllerEventHandler<TData = unknown> = (data: TData) => void;\n\n/**\n * Configuration options for creating a Controller instance.\n *\n * In the event emitter pattern, only static options are passed via config.\n * All lifecycle callbacks and event listeners are registered via methods\n * on the returned Controller instance.\n *\n * @template TEvents - Event map type for type-safe events\n *\n * @example\n * ```ts\n * const controller = createController<MyEvents>({ debug: true });\n *\n * controller.on('phase-update', (data) => handlePhase(data.phase));\n * controller.onAllReady(() => console.log('Ready!'));\n *\n * await controller.ready;\n * controller.send('tap', { x: 100, y: 200 });\n * ```\n */\nexport interface ControllerConfig {\n // === Debug Options ===\n\n /**\n * Enable debug mode for verbose logging.\n * @default false\n */\n debug?: boolean | DebugOptions;\n\n // === Advanced Options ===\n\n /**\n * Parent window origin for postMessage validation (iframe games).\n * @default '*'\n */\n parentOrigin?: string;\n\n /**\n * Connection timeout in milliseconds.\n * @default 10000\n */\n timeout?: number;\n\n /**\n * Automatically signal ready after initialization.\n * When true (default), the SDK calls signalReady() automatically after init completes.\n * Set to false if your game needs to load resources before signaling ready.\n * @default true\n */\n autoReady?: boolean;\n\n /**\n * Custom transport implementation.\n * If provided, uses this instead of the default PostMessageTransport.\n * The bridge handshake (_bridge:init) still occurs via postMessage.\n */\n transport?: Transport;\n\n}\n\n/**\n * Controller instance - the main interface for the player/phone side.\n *\n * Uses an event emitter pattern: lifecycle callbacks and event listeners\n * are registered via methods on the instance, not via config.\n *\n * @template TEvents - Event map type for type-safe events\n *\n * @example\n * ```ts\n * const controller = createController<MyEvents>({ debug: true });\n *\n * controller.on('phase-update', (data) => setPhase(data.phase));\n * controller.onAllReady(() => console.log('Game starting!'));\n *\n * await controller.ready;\n * controller.send('tap', { x: 100, y: 200 });\n * ```\n *\n * ## Controller API Design Note:\n *\n * Controller only has `send()` (no `broadcast()` or `gameOver()`).\n * This is intentional: Controller-to-Controller (C2C) communication is not supported.\n * All coordination between controllers must go through the Screen.\n *\n * Flow: Controller.send() -> Screen receives -> Screen.broadcast() or Screen.sendToController()\n *\n * ## Stateless Controller Pattern (Recommended)\n *\n * Controllers should be stateless display + input devices:\n * - Render only what Screen sends via `on()` event handlers\n * - Send only user input to Screen via `send()`\n * - Do NOT store game state on the controller\n * - Screen is the single source of truth for all game state\n *\n * When a controller reconnects, Screen re-pushes current view state\n * via `sendToController()` in the `onControllerReconnect` callback.\n */\nexport interface Controller<TEvents extends EventMap = EventMap> {\n // === Properties (readonly) ===\n\n /** My player index (0, 1, 2, ...). */\n readonly myPlayerIndex: PlayerIndex;\n\n /** My own controller info. undefined before initialization. */\n readonly me: ControllerInfo | undefined;\n\n /** The room code for this game session. */\n readonly roomCode: RoomCode;\n\n /** Whether the controller is initialized and ready. */\n readonly isReady: boolean;\n\n /** Whether the controller has been destroyed. */\n readonly isDestroyed: boolean;\n\n /** Whether the connection to the server is active. */\n readonly isConnected: boolean;\n\n /** Protocol version negotiated with the parent frame. */\n readonly protocolVersion: number;\n\n /**\n * Read-only list of all known controllers (players) in the room.\n * Returns full ControllerInfo including playerIndex, nickname, connected status, and appearance.\n * Consistent with Screen's `controllers` property.\n *\n * **Performance note:** Each access creates a new shallow copy array.\n * Cache the result in a local variable if you need to access it repeatedly.\n */\n readonly controllers: readonly ControllerInfo[];\n\n /**\n * A Promise that resolves when the controller is initialized and ready.\n * Use this to await readiness after creating a controller synchronously.\n *\n * @example\n * ```ts\n * const controller = createController<MyEvents>();\n * controller.on('phase-update', handler);\n * await controller.ready;\n * controller.send('tap', { x: 0, y: 0 });\n * ```\n */\n readonly ready: Promise<void>;\n\n // === Lifecycle Methods ===\n\n /**\n * Register a callback for when all participants are ready (all-ready event).\n * If the all-ready event has already fired when called, the callback fires immediately.\n *\n * @param callback - Called when all participants signal ready\n * @returns Unsubscribe function to remove the callback\n */\n onAllReady(callback: () => void): () => void;\n\n /**\n * Register a callback for when another player joins the room.\n *\n * @param callback - Called with player index and controller info\n * @returns Unsubscribe function to remove the callback\n */\n onControllerJoin(callback: (playerIndex: PlayerIndex, info: ControllerInfo) => void): () => void;\n\n /**\n * Register a callback for when another player leaves the room.\n *\n * @param callback - Called with the leaving player's index\n * @returns Unsubscribe function to remove the callback\n */\n onControllerLeave(callback: (playerIndex: PlayerIndex) => void): () => void;\n\n /**\n * Register a callback for when another player temporarily disconnects.\n *\n * @param callback - Called with the disconnected player's index\n * @returns Unsubscribe function to remove the callback\n */\n onControllerDisconnect(callback: (playerIndex: PlayerIndex) => void): () => void;\n\n /**\n * Register a callback for when another player reconnects after a disconnect.\n *\n * @param callback - Called with player index and updated controller info\n * @returns Unsubscribe function to remove the callback\n */\n onControllerReconnect(callback: (playerIndex: PlayerIndex, info: ControllerInfo) => void): () => void;\n\n /**\n * Register a callback for when a player's character appearance is updated.\n *\n * @param callback - Called with player index and new appearance (or null if reset)\n * @returns Unsubscribe function to remove the callback\n */\n onCharacterUpdated(callback: (playerIndex: PlayerIndex, appearance: CharacterAppearance | null) => void): () => void;\n\n /**\n * Register a callback for when an error occurs.\n * If no error callback is registered, errors are logged to console in debug mode.\n *\n * @param callback - Called with the error object\n * @returns Unsubscribe function to remove the callback\n */\n onError(callback: (error: SmoreError) => void): () => void;\n\n /**\n * Register a callback for when the game ends.\n * Called when the Screen calls gameOver().\n *\n * @param callback - Called with optional game results\n * @returns Unsubscribe function to remove the callback\n */\n onGameOver(callback: (results?: GameResults) => void): () => void;\n\n /**\n * Register a callback for when the connection status changes.\n * Called when the connection to the server is lost or restored.\n *\n * @param callback - Called with true (connected) or false (disconnected)\n * @returns Unsubscribe function to remove the callback\n */\n onConnectionChange(callback: (connected: boolean) => void): () => void;\n\n /**\n * Returns the number of currently connected players.\n */\n getControllerCount(): number;\n\n /**\n * Get a specific controller by player index.\n * Returns undefined if not found.\n */\n getController(playerIndex: PlayerIndex): ControllerInfo | undefined;\n\n // === Communication Methods ===\n\n /**\n * Send an event to the screen.\n *\n * Controller -> Screen direction only. For Screen -> Controller, see `sendToController()`.\n *\n * @param event - Event name (must match TEvents keys)\n * @param data - Event data (type-safe based on event name)\n * @note Maximum payload size is 64KB. Payloads exceeding this limit will be silently dropped by the server.\n * **Rate limit:** The server allows up to 60 events/sec per Controller socket.\n * Messages are delivered to Screen in the order they are sent.\n *\n * @example\n * ```ts\n * controller.send('tap', { x: 100, y: 200 });\n * controller.send('answer', { choice: 2 });\n * ```\n */\n send<K extends EventNames<TEvents>>(\n event: K,\n data: EventData<TEvents, K>,\n ): void;\n\n /**\n * Signal that this controller has finished loading resources and is ready to start.\n *\n * Call this after all game resources are loaded.\n * The server will wait until all participants have signaled ready,\n * then broadcast an all-ready event to everyone.\n *\n * @example\n * ```ts\n * // After loading completes:\n * controller.signalReady();\n * ```\n */\n signalReady(): void;\n\n // === Event Subscription ===\n\n /**\n * Subscribe to a lifecycle event or a user-defined game event.\n *\n * Lifecycle events use `$`-prefixed names. Use `LifecycleEvent` constants\n * for type-safe subscription:\n * ```ts\n * controller.on(LifecycleEvent.CONTROLLER_JOIN, (pi, info) => { ... });\n * controller.on('phase-update', (data) => { ... }); // user event\n * ```\n */\n on<K extends ControllerLifecycleEvent>(event: K, handler: ControllerLifecycleHandlers[K]): () => void;\n /**\n * Add a listener for a specific event after construction.\n * Can be called before the controller is ready -- handlers are queued\n * and activated when the transport becomes available.\n *\n * @param event - Event name\n * @param handler - Handler function (data) => void\n * @returns Cleanup function to remove the listener\n *\n * @note Events from screen.broadcast() do not include playerIndex.\n * The handler signature is `(data: D)` without playerIndex context.\n * If you need to know which player triggered the broadcast, include\n * that information in the data object from the Screen side.\n *\n * @example\n * ```ts\n * const unsubscribe = controller.on('phase-update', (data) => {\n * console.log('New phase:', data.phase);\n * });\n *\n * // Later: remove listener\n * unsubscribe();\n * ```\n */\n on<K extends EventNames<TEvents>>(\n event: K,\n handler: ControllerEventHandler<EventData<TEvents, K>>,\n ): () => void;\n\n once<K extends ControllerLifecycleEvent>(event: K, handler: ControllerLifecycleHandlers[K]): () => void;\n /**\n * Add a one-time listener that auto-removes after first call.\n *\n * @note The handler is internally wrapped, so it cannot be removed via\n * `off(event, originalHandler)`. Use the returned unsubscribe function instead.\n */\n once<K extends EventNames<TEvents>>(\n event: K,\n handler: ControllerEventHandler<EventData<TEvents, K>>,\n ): () => void;\n\n off<K extends ControllerLifecycleEvent>(event: K, handler?: ControllerLifecycleHandlers[K]): void;\n /**\n * Remove a specific listener or all listeners for an event.\n */\n off<K extends EventNames<TEvents>>(\n event: K,\n handler?: ControllerEventHandler<EventData<TEvents, K>>,\n ): void;\n\n /**\n * Remove all event listeners, or all listeners for a specific event.\n * Only removes user event listeners registered via on()/once().\n * Lifecycle callbacks (onControllerJoin, onAllReady, etc.) are not affected.\n *\n * @param event - Optional event name. If omitted, removes ALL user event listeners.\n */\n removeAllListeners(event?: string): void;\n\n // === Cleanup ===\n\n /**\n * Clean up all resources and disconnect.\n * Call this when unmounting/destroying your game.\n */\n destroy(): void;\n}\n\n// =============================================================================\n// DEBUG OPTIONS\n// =============================================================================\n\n/**\n * Log levels for debug output.\n */\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\n/**\n * Debug configuration options.\n */\nexport interface DebugOptions {\n /** Enable debug logging */\n enabled?: boolean;\n\n /** Minimum log level to output */\n level?: LogLevel;\n\n /** Prefix for log messages */\n prefix?: string;\n\n /** Log events being sent */\n logSend?: boolean;\n\n /** Log events being received */\n logReceive?: boolean;\n\n /** Log lifecycle events (ready, destroy, etc.) */\n logLifecycle?: boolean;\n\n /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EAC5B,SAAA,EAAW,YAAA;AAAA,EACX,eAAA,EAAiB,kBAAA;AAAA,EACjB,gBAAA,EAAkB,mBAAA;AAAA,EAClB,qBAAA,EAAuB,wBAAA;AAAA,EACvB,oBAAA,EAAsB,uBAAA;AAAA,EACtB,iBAAA,EAAmB,oBAAA;AAAA,EACnB,KAAA,EAAO,QAAA;AAAA,EACP,SAAA,EAAW,YAAA;AAAA,EACX,iBAAA,EAAmB;AACrB;;;;;"}
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { createScreen } from './screen.js';
2
2
  export { createController } from './controller.js';
3
3
  export { SmoreSDKError } from './errors.js';
4
- export { LifecycleEvent } from './types.js';
4
+ export { GAME_CATEGORIES, LifecycleEvent } from './types.js';
5
5
  //# sourceMappingURL=index.js.map
package/dist/esm/types.js CHANGED
@@ -1,3 +1,18 @@
1
+ const GAME_CATEGORIES = {
2
+ "bet": { emoji: "\u{1F3B0}", label: "Betting", labelKo: "\uB0B4\uAE30" },
3
+ "coop": { emoji: "\u{1F91D}", label: "Co-op", labelKo: "\uD611\uB3D9" },
4
+ "versus": { emoji: "\u2694\uFE0F", label: "Versus", labelKo: "\uB300\uACB0" },
5
+ "time-attack": { emoji: "\u23F1\uFE0F", label: "Time Attack", labelKo: "\uD0C0\uC784\uC5B4\uD0DD" },
6
+ "survival": { emoji: "\u{1F3C3}", label: "Survival", labelKo: "\uC0DD\uC874" },
7
+ "reflex": { emoji: "\u{1F3AF}", label: "Reflex", labelKo: "\uBC18\uC751\uC18D\uB3C4" },
8
+ "deception": { emoji: "\u{1F575}\uFE0F", label: "Deception", labelKo: "\uCD94\uB9AC/\uC18D\uC784\uC218" },
9
+ "creative": { emoji: "\u{1F3A8}", label: "Creative", labelKo: "\uCC3D\uC791" },
10
+ "party": { emoji: "\u{1F389}", label: "Party", labelKo: "\uD30C\uD2F0" },
11
+ "puzzle": { emoji: "\u{1F9E9}", label: "Puzzle", labelKo: "\uD37C\uC990" },
12
+ "board": { emoji: "\u{1F3B2}", label: "Board Game", labelKo: "\uBCF4\uB4DC\uAC8C\uC784" },
13
+ "strategy": { emoji: "\u{1F9E0}", label: "Strategy", labelKo: "\uC804\uB7B5" },
14
+ "timing": { emoji: "\u{1F3B5}", label: "Timing", labelKo: "\uD0C0\uC774\uBC0D" }
15
+ };
1
16
  const LifecycleEvent = {
2
17
  ALL_READY: "$all-ready",
3
18
  CONTROLLER_JOIN: "$controller-join",
@@ -10,5 +25,5 @@ const LifecycleEvent = {
10
25
  CONNECTION_CHANGE: "$connection-change"
11
26
  };
12
27
 
13
- export { LifecycleEvent };
28
+ export { GAME_CATEGORIES, LifecycleEvent };
14
29
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../src/types.ts"],"sourcesContent":["/**\n * @smoregg/sdk - World-Class Party Game SDK\n *\n * Type definitions for building multiplayer party games with type-safe events,\n * factory pattern initialization, and comprehensive error handling.\n *\n * @packageDocumentation\n */\n\n// =============================================================================\n// CORE PRIMITIVES\n// =============================================================================\n\n/**\n * Unique identifier for a player (0-indexed integer).\n * Used consistently across all SDK methods.\n */\nexport type PlayerIndex = number;\n\n/**\n * Room code for joining a game session (e.g., \"ABCD\").\n */\nexport type RoomCode = string;\n\n// =============================================================================\n// EVENT SYSTEM - TYPE-SAFE EVENTS\n// =============================================================================\n\n/**\n * Base event map type. Extend this to define your game's events.\n *\n * **Important:** Event data values must be plain objects, not primitives.\n * Primitive values (string, number, boolean) will be automatically wrapped\n * as `{ data: <value> }` by the relay server, which breaks type safety.\n *\n * **Payload Size Limit:** Maximum payload size per event is 64KB. This limit\n * is enforced by the server's genericRelay handler. Payloads exceeding this\n * limit will be silently dropped by the server without error notification.\n *\n * **Reserved Fields:** The field names `playerIndex` and `targetPlayerIndex` are reserved\n * by the SDK for internal routing. Using these as custom data field names will cause\n * a compile-time error. The SDK automatically extracts `playerIndex` to identify the sender\n * and uses `targetPlayerIndex` for targeted message delivery.\n *\n * **Type Safety Note:** Without providing an explicit generic type parameter,\n * `createScreen()` and `createController()` default to the empty `EventMap`,\n * which means `send()`, `broadcast()`, and `on()` accept any string as an event\n * name and `unknown` as data -- effectively losing compile-time type checking.\n * Always define and pass your game's event map for full type safety.\n *\n * @example Defining events for type safety\n * ```ts\n * interface MyGameEvents {\n * // Screen receives from Controller\n * 'tap': { x: number; y: number };\n * 'answer': { choice: number };\n *\n * // Controller receives from Screen\n * 'phase-update': { phase: 'lobby' | 'playing' | 'results' };\n * 'your-turn': { timeLimit: number };\n * }\n *\n * // With explicit generic -- full type safety\n * const screen = createScreen<MyGameEvents>({ debug: true });\n * screen.on('tap', (playerIndex, data) => { ... });\n * await screen.ready;\n *\n * // Without generic -- no type safety (not recommended)\n * const screen = createScreen();\n * ```\n *\n * @example Event naming conventions\n * ```ts\n * // Define your game's event map for type safety:\n * type MyEvents = {\n * 'player-move': { x: number; y: number };\n * 'game-action': { action: string; value: number };\n * };\n * // Event names: use kebab-case, no colons (:), no 'smore:' prefix\n * ```\n */\nexport interface EventMap {\n [key: string]: Record<string, unknown> & { playerIndex?: never; targetPlayerIndex?: never };\n}\n\n/**\n * Extract event names from an event map.\n */\nexport type EventNames<TEvents extends EventMap> = keyof TEvents & string;\n\n/**\n * Extract event data type for a specific event.\n */\nexport type EventData<\n TEvents extends EventMap,\n TEvent extends EventNames<TEvents>,\n> = TEvents[TEvent];\n\n// =============================================================================\n// CONTROLLER INFO - PLAYER INFORMATION\n// =============================================================================\n\n/**\n * Character appearance data for player avatars.\n *\n * This type matches the server's CharacterDTO structure to ensure\n * type consistency across the platform.\n *\n * @property id - Unique character identifier\n * @property seed - Random seed for generating the character\n * @property style - Character style preset identifier\n * @property options - Additional character customization options\n */\nexport interface CharacterAppearance {\n /** Unique character identifier */\n id: string;\n /** Random seed for generating the character */\n seed: string;\n /** Character style preset identifier */\n style: string;\n /** Additional character customization options */\n options: Record<string, unknown>;\n}\n\n/**\n * Information about a connected controller (player).\n * Used by Screen to identify and manage players.\n */\nexport interface ControllerInfo {\n /** Player's unique index (0, 1, 2, ...) */\n readonly playerIndex: PlayerIndex;\n /**\n * Player's chosen display name.\n *\n * Maps to `PlayerDTO.name` on the server side. The SDK exposes it as\n * \"nickname\" for semantic clarity in game code.\n * The mapping (`name` -> `nickname`) is handled automatically during\n * player data deserialization in the transport layer.\n *\n * @see PlayerDTO.name (server) -- same value, different field name\n */\n readonly nickname: string;\n /** Whether the player is currently connected */\n readonly connected: boolean;\n /**\n * Optional character appearance data.\n *\n * Note: The server sends this as \"character\" in PlayerDTO.\n * The SDK maps it to \"appearance\" for semantic clarity.\n * The server may send `null` when no character is set.\n */\n readonly appearance?: CharacterAppearance | null;\n}\n\n// =============================================================================\n// TRANSPORT\n// =============================================================================\n\n/**\n * Transport interface for custom communication implementations.\n * Implement this to use a custom transport instead of the default PostMessageTransport.\n */\nexport interface Transport {\n emit(event: string, ...args: unknown[]): void;\n on(event: string, handler: (...args: unknown[]) => void): void;\n off(event: string, handler?: (...args: unknown[]) => void): void;\n destroy(): void;\n}\n\n// =============================================================================\n// ERROR HANDLING\n// =============================================================================\n\n/**\n * Error codes for SDK errors.\n */\nexport type SmoreErrorCode =\n | 'TIMEOUT' // Connection or operation timeout\n | 'NOT_READY' // Operation called before ready\n | 'DESTROYED' // Operation called after destroy\n | 'INVALID_EVENT' // Invalid event name\n | 'INVALID_PLAYER' // Invalid player index\n | 'CONNECTION_LOST' // Lost connection to server\n | 'INIT_FAILED' // Failed to initialize\n | 'RATE_LIMITED' // Server rate-limited an event\n | 'PAYLOAD_TOO_LARGE' // Payload exceeds 64KB limit\n | 'UNKNOWN'; // Unknown error\n\n/**\n * Structured error type for SDK errors.\n */\nexport interface SmoreError {\n /** Error code for programmatic handling */\n code: SmoreErrorCode;\n /** Human-readable error message */\n message: string;\n /** Original error if available */\n cause?: Error;\n /** Additional context */\n details?: Record<string, unknown>;\n}\n\n// =============================================================================\n// GAME RESULTS\n// =============================================================================\n\n/**\n * Game results structure for gameOver().\n * Flexible to accommodate different game types.\n */\nexport interface GameResults {\n /** Player scores indexed by player index */\n scores?: Record<PlayerIndex, number>;\n /** Winner's player index (or -1 for no winner/tie) */\n winner?: PlayerIndex;\n /** Ranked player indices from first to last */\n rankings?: PlayerIndex[];\n /** Additional custom game-specific data */\n custom?: Record<string, unknown>;\n}\n\n// =============================================================================\n// LIFECYCLE EVENTS — UNIFIED EVENT SYSTEM\n// =============================================================================\n\n/**\n * Lifecycle event names for subscribing via `on()`.\n *\n * These `$`-prefixed event names allow lifecycle events to be registered\n * through the same `on()` method used for game events. The `$` prefix is\n * reserved by the SDK and cannot be used for user-defined events.\n *\n * @example\n * ```ts\n * // These are equivalent:\n * screen.onControllerJoin((pi, info) => { ... });\n * screen.on(LifecycleEvent.CONTROLLER_JOIN, (pi, info) => { ... });\n * ```\n */\nexport const LifecycleEvent = {\n ALL_READY: '$all-ready',\n CONTROLLER_JOIN: '$controller-join',\n CONTROLLER_LEAVE: '$controller-leave',\n CONTROLLER_DISCONNECT: '$controller-disconnect',\n CONTROLLER_RECONNECT: '$controller-reconnect',\n CHARACTER_UPDATED: '$character-updated',\n ERROR: '$error',\n GAME_OVER: '$game-over',\n CONNECTION_CHANGE: '$connection-change',\n} as const;\n\n/** Union of all lifecycle event name strings. */\nexport type LifecycleEventName = typeof LifecycleEvent[keyof typeof LifecycleEvent];\n\n/**\n * Handler signatures for Screen lifecycle events.\n * Used by `on()` overloads to provide type-safe lifecycle event subscription.\n */\nexport interface ScreenLifecycleHandlers {\n '$all-ready': () => void;\n '$controller-join': (playerIndex: PlayerIndex, info: ControllerInfo) => void;\n '$controller-leave': (playerIndex: PlayerIndex) => void;\n '$controller-disconnect': (playerIndex: PlayerIndex) => void;\n '$controller-reconnect': (playerIndex: PlayerIndex, info: ControllerInfo) => void;\n '$character-updated': (playerIndex: PlayerIndex, appearance: CharacterAppearance | null) => void;\n '$error': (error: SmoreError) => void;\n '$connection-change': (connected: boolean) => void;\n}\n\n/** Screen lifecycle event name union. */\nexport type ScreenLifecycleEvent = keyof ScreenLifecycleHandlers;\n\n/**\n * Handler signatures for Controller lifecycle events.\n * Extends Screen lifecycle events with Controller-specific events.\n */\nexport interface ControllerLifecycleHandlers extends ScreenLifecycleHandlers {\n '$game-over': (results?: GameResults) => void;\n}\n\n/** Controller lifecycle event name union. */\nexport type ControllerLifecycleEvent = keyof ControllerLifecycleHandlers;\n\n// =============================================================================\n// SCREEN TYPES - HOST/TV SIDE\n// =============================================================================\n\n/**\n * Handler for events received from controllers.\n * Receives the player index and event data.\n */\nexport type ScreenEventHandler<TData = unknown> = (\n playerIndex: PlayerIndex,\n data: TData,\n) => void;\n\n/**\n * Configuration options for creating a Screen instance.\n *\n * In the event emitter pattern, only static options are passed via config.\n * All lifecycle callbacks and event listeners are registered via methods\n * on the returned Screen instance.\n *\n * @template TEvents - Event map type for type-safe events\n *\n * @example\n * ```ts\n * const screen = createScreen<MyEvents>({ debug: true });\n *\n * screen.on('tap', (playerIndex, data) => handleTap(playerIndex, data));\n * screen.onAllReady(() => startCountdown());\n * screen.onControllerJoin((playerIndex, info) => console.log('Joined:', playerIndex));\n *\n * await screen.ready;\n * ```\n */\nexport interface ScreenConfig {\n // === Debug Options ===\n\n /**\n * Enable debug mode for verbose logging.\n * @default false\n */\n debug?: boolean | DebugOptions;\n\n // === Advanced Options ===\n\n /**\n * Parent window origin for postMessage validation (iframe games).\n * Use '*' to accept messages from any origin (not recommended for production).\n * @default '*'\n */\n parentOrigin?: string;\n\n /**\n * Connection timeout in milliseconds.\n * @default 10000\n */\n timeout?: number;\n\n /**\n * Automatically signal ready after initialization.\n * When true (default), the SDK calls signalReady() automatically after init completes.\n * Set to false if your game needs to load resources before signaling ready.\n * @default true\n */\n autoReady?: boolean;\n\n /**\n * Custom transport implementation.\n * If provided, uses this instead of the default PostMessageTransport.\n * The bridge handshake (_bridge:init) still occurs via postMessage.\n */\n transport?: Transport;\n\n}\n\n/**\n * Screen instance - the main interface for the host/TV side of your game.\n *\n * Uses an event emitter pattern: lifecycle callbacks and event listeners\n * are registered via methods on the instance, not via config.\n *\n * @template TEvents - Event map type for type-safe events\n *\n * @example\n * ```ts\n * const screen = createScreen<MyEvents>({ debug: true });\n *\n * screen.on('tap', (playerIndex, data) => handleTap(playerIndex, data));\n * screen.onAllReady(() => startGame());\n * screen.onControllerJoin((playerIndex, info) => addPlayer(playerIndex, info));\n *\n * await screen.ready;\n * screen.broadcast('phase-update', { phase: 'playing' });\n * screen.gameOver({ scores: { 0: 100, 1: 75 } });\n * ```\n */\nexport interface Screen<TEvents extends EventMap = EventMap> {\n // === Properties (readonly) ===\n\n /**\n * All connected controllers. Returns a new shallow copy on every access.\n *\n * **Performance note:** Each access creates a new array via spread.\n * Avoid calling this in tight loops; cache the result in a local variable\n * if you need to access it repeatedly within the same frame/tick.\n */\n readonly controllers: readonly ControllerInfo[];\n\n /** The room code for this game session. */\n readonly roomCode: RoomCode;\n\n /** Whether the screen is initialized and ready. */\n readonly isReady: boolean;\n\n /** Whether the screen has been destroyed. */\n readonly isDestroyed: boolean;\n\n /** Whether the connection to the server is active. */\n readonly isConnected: boolean;\n\n /** Protocol version negotiated with the parent frame. */\n readonly protocolVersion: number;\n\n /**\n * A Promise that resolves when the screen is initialized and ready.\n * Use this to await readiness after creating a screen synchronously.\n *\n * @example\n * ```ts\n * const screen = createScreen<MyEvents>();\n * screen.on('tap', handler);\n * await screen.ready;\n * screen.broadcast('start', {});\n * ```\n */\n readonly ready: Promise<void>;\n\n // === Lifecycle Methods ===\n\n /**\n * Register a callback for when all participants are ready (all-ready event).\n * If the all-ready event has already fired when called, the callback fires immediately.\n *\n * @param callback - Called when all participants signal ready\n * @returns Unsubscribe function to remove the callback\n */\n onAllReady(callback: () => void): () => void;\n\n /**\n * Register a callback for when a controller (player) joins the room.\n *\n * @param callback - Called with player index and controller info\n * @returns Unsubscribe function to remove the callback\n */\n onControllerJoin(callback: (playerIndex: PlayerIndex, info: ControllerInfo) => void): () => void;\n\n /**\n * Register a callback for when a controller (player) leaves the room.\n *\n * @param callback - Called with the leaving player's index\n * @returns Unsubscribe function to remove the callback\n */\n onControllerLeave(callback: (playerIndex: PlayerIndex) => void): () => void;\n\n /**\n * Register a callback for when a controller temporarily disconnects.\n *\n * @param callback - Called with the disconnected player's index\n * @returns Unsubscribe function to remove the callback\n */\n onControllerDisconnect(callback: (playerIndex: PlayerIndex) => void): () => void;\n\n /**\n * Register a callback for when a controller reconnects after a disconnect.\n *\n * In the stateless controller pattern, use this callback to re-push\n * the current view state to the reconnecting controller.\n *\n * @example\n * ```ts\n * screen.onControllerReconnect((playerIndex) => {\n * screen.sendToController(playerIndex, 'view-update', getCurrentView(playerIndex));\n * });\n * ```\n *\n * @param callback - Called with player index and updated controller info\n * @returns Unsubscribe function to remove the callback\n */\n onControllerReconnect(callback: (playerIndex: PlayerIndex, info: ControllerInfo) => void): () => void;\n\n /**\n * Register a callback for when a player's character appearance is updated.\n *\n * @param callback - Called with player index and new appearance (or null if reset)\n * @returns Unsubscribe function to remove the callback\n */\n onCharacterUpdated(callback: (playerIndex: PlayerIndex, appearance: CharacterAppearance | null) => void): () => void;\n\n /**\n * Register a callback for when an error occurs.\n * If no error callback is registered, errors are logged to console in debug mode.\n *\n * @param callback - Called with the error object\n * @returns Unsubscribe function to remove the callback\n */\n onError(callback: (error: SmoreError) => void): () => void;\n\n /**\n * Register a callback for when the connection status changes.\n * Called when the connection to the server is lost or restored.\n *\n * @param callback - Called with true (connected) or false (disconnected)\n * @returns Unsubscribe function to remove the callback\n */\n onConnectionChange(callback: (connected: boolean) => void): () => void;\n\n // === Communication Methods ===\n\n /**\n * Broadcast an event to all connected controllers.\n *\n * Use this to push the same view state to all controllers simultaneously.\n *\n * @param event - Event name (must match TEvents keys)\n * @param data - Event data (type-safe based on event name)\n * @note Data should be an object. Primitive values will be wrapped as `{ data: value }` by the relay server.\n * @note Maximum payload size is 64KB. Payloads exceeding this limit will be silently dropped by the server.\n * **Rate limit:** The server allows up to 60 events/sec per Screen socket\n * (shared across broadcast and sendToController calls).\n * Events exceeding this limit are silently dropped.\n * Messages from a single sender are delivered in order.\n *\n * @example\n * ```ts\n * screen.broadcast('phase-update', { phase: 'playing' });\n * ```\n */\n broadcast<K extends EventNames<TEvents>>(\n event: K,\n data: EventData<TEvents, K>,\n ): void;\n\n /**\n * Send an event to a specific controller.\n *\n * Screen -> Controller direction only. For Controller -> Screen, see `send()`.\n *\n * This is the primary method for the stateless controller pattern:\n * push complete view state to a specific controller.\n *\n * @param playerIndex - Target controller's player index\n * @param event - Event name (must match TEvents keys)\n * @param data - Event data (type-safe based on event name)\n * @note Data should be an object. Primitive values will be wrapped as `{ data: value }` by the relay server.\n * @note Maximum payload size is 64KB. Payloads exceeding this limit will be silently dropped by the server.\n * **Rate limit:** Shares the 60 events/sec limit with broadcast().\n *\n * @example\n * ```ts\n * screen.sendToController(0, 'your-turn', { timeLimit: 30 });\n * ```\n *\n * @example\n * ```ts\n * // Push current game view to a specific player\n * screen.sendToController(playerIndex, 'view-update', {\n * phase: 'voting',\n * candidates: [1, 3, 5],\n * timeRemaining: 30,\n * });\n * ```\n */\n sendToController<K extends EventNames<TEvents>>(\n playerIndex: PlayerIndex,\n event: K,\n data: EventData<TEvents, K>,\n ): void;\n\n // === Game Lifecycle ===\n\n /**\n * Signal that the game is over and send results.\n * This will broadcast a game-over event to all controllers.\n *\n * @param results - Game results (scores, rankings, etc.)\n *\n * @example\n * ```ts\n * screen.gameOver({\n * scores: { 0: 100, 1: 75, 2: 50 },\n * winner: 0,\n * rankings: [0, 1, 2],\n * });\n * ```\n */\n gameOver(results?: GameResults): void;\n\n /**\n * Signal that this screen has finished loading resources and is ready to start.\n *\n * Call this after all game resources (Phaser assets, images, sounds, etc.) are loaded.\n * The server will wait until all participants (screen + all connected controllers)\n * have signaled ready, then broadcast an all-ready event to everyone.\n *\n * @example\n * ```ts\n * // After Phaser scene loads all assets:\n * screen.signalReady();\n * ```\n */\n signalReady(): void;\n\n // === Event Subscription ===\n\n /**\n * Subscribe to a lifecycle event or a user-defined game event.\n *\n * Lifecycle events use `$`-prefixed names. Use `LifecycleEvent` constants\n * for type-safe subscription:\n * ```ts\n * screen.on(LifecycleEvent.CONTROLLER_JOIN, (pi, info) => { ... });\n * screen.on('tap', (pi, data) => { ... }); // user event\n * ```\n */\n on<K extends ScreenLifecycleEvent>(event: K, handler: ScreenLifecycleHandlers[K]): () => void;\n /**\n * Add a listener for a specific event after construction.\n * Can be called before the screen is ready -- handlers are queued\n * and activated when the transport becomes available.\n *\n * @param event - Event name\n * @param handler - Handler function (playerIndex, data) => void\n * @returns Cleanup function to remove the listener\n *\n * @example\n * ```ts\n * const unsubscribe = screen.on('tap', (playerIndex, data) => {\n * console.log(`Player ${playerIndex} tapped at`, data.x, data.y);\n * });\n *\n * // Later: remove listener\n * unsubscribe();\n * ```\n */\n on<K extends EventNames<TEvents>>(\n event: K,\n handler: ScreenEventHandler<EventData<TEvents, K>>,\n ): () => void;\n\n once<K extends ScreenLifecycleEvent>(event: K, handler: ScreenLifecycleHandlers[K]): () => void;\n /**\n * Add a one-time listener that auto-removes after first call.\n *\n * @note The handler is internally wrapped, so it cannot be removed via\n * `off(event, originalHandler)`. Use the returned unsubscribe function instead.\n */\n once<K extends EventNames<TEvents>>(\n event: K,\n handler: ScreenEventHandler<EventData<TEvents, K>>,\n ): () => void;\n\n off<K extends ScreenLifecycleEvent>(event: K, handler?: ScreenLifecycleHandlers[K]): void;\n /**\n * Remove a specific listener or all listeners for an event.\n */\n off<K extends EventNames<TEvents>>(\n event: K,\n handler?: ScreenEventHandler<EventData<TEvents, K>>,\n ): void;\n\n /**\n * Remove all event listeners, or all listeners for a specific event.\n * Only removes user event listeners registered via on()/once().\n * Lifecycle callbacks (onControllerJoin, onAllReady, etc.) are not affected.\n *\n * @param event - Optional event name. If omitted, removes ALL user event listeners.\n */\n removeAllListeners(event?: string): void;\n\n // === Utilities ===\n\n /**\n * Get a specific controller by player index.\n * Returns undefined if not found.\n */\n getController(playerIndex: PlayerIndex): ControllerInfo | undefined;\n\n /**\n * Get the number of connected controllers.\n */\n getControllerCount(): number;\n\n // === Cleanup ===\n\n /**\n * Clean up all resources and disconnect.\n * Call this when unmounting/destroying your game.\n */\n destroy(): void;\n}\n\n// =============================================================================\n// CONTROLLER TYPES - PLAYER/PHONE SIDE\n// =============================================================================\n\n/**\n * Handler for events received from the screen.\n * Receives only the event data (no player index needed).\n */\nexport type ControllerEventHandler<TData = unknown> = (data: TData) => void;\n\n/**\n * Configuration options for creating a Controller instance.\n *\n * In the event emitter pattern, only static options are passed via config.\n * All lifecycle callbacks and event listeners are registered via methods\n * on the returned Controller instance.\n *\n * @template TEvents - Event map type for type-safe events\n *\n * @example\n * ```ts\n * const controller = createController<MyEvents>({ debug: true });\n *\n * controller.on('phase-update', (data) => handlePhase(data.phase));\n * controller.onAllReady(() => console.log('Ready!'));\n *\n * await controller.ready;\n * controller.send('tap', { x: 100, y: 200 });\n * ```\n */\nexport interface ControllerConfig {\n // === Debug Options ===\n\n /**\n * Enable debug mode for verbose logging.\n * @default false\n */\n debug?: boolean | DebugOptions;\n\n // === Advanced Options ===\n\n /**\n * Parent window origin for postMessage validation (iframe games).\n * @default '*'\n */\n parentOrigin?: string;\n\n /**\n * Connection timeout in milliseconds.\n * @default 10000\n */\n timeout?: number;\n\n /**\n * Automatically signal ready after initialization.\n * When true (default), the SDK calls signalReady() automatically after init completes.\n * Set to false if your game needs to load resources before signaling ready.\n * @default true\n */\n autoReady?: boolean;\n\n /**\n * Custom transport implementation.\n * If provided, uses this instead of the default PostMessageTransport.\n * The bridge handshake (_bridge:init) still occurs via postMessage.\n */\n transport?: Transport;\n\n}\n\n/**\n * Controller instance - the main interface for the player/phone side.\n *\n * Uses an event emitter pattern: lifecycle callbacks and event listeners\n * are registered via methods on the instance, not via config.\n *\n * @template TEvents - Event map type for type-safe events\n *\n * @example\n * ```ts\n * const controller = createController<MyEvents>({ debug: true });\n *\n * controller.on('phase-update', (data) => setPhase(data.phase));\n * controller.onAllReady(() => console.log('Game starting!'));\n *\n * await controller.ready;\n * controller.send('tap', { x: 100, y: 200 });\n * ```\n *\n * ## Controller API Design Note:\n *\n * Controller only has `send()` (no `broadcast()` or `gameOver()`).\n * This is intentional: Controller-to-Controller (C2C) communication is not supported.\n * All coordination between controllers must go through the Screen.\n *\n * Flow: Controller.send() -> Screen receives -> Screen.broadcast() or Screen.sendToController()\n *\n * ## Stateless Controller Pattern (Recommended)\n *\n * Controllers should be stateless display + input devices:\n * - Render only what Screen sends via `on()` event handlers\n * - Send only user input to Screen via `send()`\n * - Do NOT store game state on the controller\n * - Screen is the single source of truth for all game state\n *\n * When a controller reconnects, Screen re-pushes current view state\n * via `sendToController()` in the `onControllerReconnect` callback.\n */\nexport interface Controller<TEvents extends EventMap = EventMap> {\n // === Properties (readonly) ===\n\n /** My player index (0, 1, 2, ...). */\n readonly myPlayerIndex: PlayerIndex;\n\n /** My own controller info. undefined before initialization. */\n readonly me: ControllerInfo | undefined;\n\n /** The room code for this game session. */\n readonly roomCode: RoomCode;\n\n /** Whether the controller is initialized and ready. */\n readonly isReady: boolean;\n\n /** Whether the controller has been destroyed. */\n readonly isDestroyed: boolean;\n\n /** Whether the connection to the server is active. */\n readonly isConnected: boolean;\n\n /** Protocol version negotiated with the parent frame. */\n readonly protocolVersion: number;\n\n /**\n * Read-only list of all known controllers (players) in the room.\n * Returns full ControllerInfo including playerIndex, nickname, connected status, and appearance.\n * Consistent with Screen's `controllers` property.\n *\n * **Performance note:** Each access creates a new shallow copy array.\n * Cache the result in a local variable if you need to access it repeatedly.\n */\n readonly controllers: readonly ControllerInfo[];\n\n /**\n * A Promise that resolves when the controller is initialized and ready.\n * Use this to await readiness after creating a controller synchronously.\n *\n * @example\n * ```ts\n * const controller = createController<MyEvents>();\n * controller.on('phase-update', handler);\n * await controller.ready;\n * controller.send('tap', { x: 0, y: 0 });\n * ```\n */\n readonly ready: Promise<void>;\n\n // === Lifecycle Methods ===\n\n /**\n * Register a callback for when all participants are ready (all-ready event).\n * If the all-ready event has already fired when called, the callback fires immediately.\n *\n * @param callback - Called when all participants signal ready\n * @returns Unsubscribe function to remove the callback\n */\n onAllReady(callback: () => void): () => void;\n\n /**\n * Register a callback for when another player joins the room.\n *\n * @param callback - Called with player index and controller info\n * @returns Unsubscribe function to remove the callback\n */\n onControllerJoin(callback: (playerIndex: PlayerIndex, info: ControllerInfo) => void): () => void;\n\n /**\n * Register a callback for when another player leaves the room.\n *\n * @param callback - Called with the leaving player's index\n * @returns Unsubscribe function to remove the callback\n */\n onControllerLeave(callback: (playerIndex: PlayerIndex) => void): () => void;\n\n /**\n * Register a callback for when another player temporarily disconnects.\n *\n * @param callback - Called with the disconnected player's index\n * @returns Unsubscribe function to remove the callback\n */\n onControllerDisconnect(callback: (playerIndex: PlayerIndex) => void): () => void;\n\n /**\n * Register a callback for when another player reconnects after a disconnect.\n *\n * @param callback - Called with player index and updated controller info\n * @returns Unsubscribe function to remove the callback\n */\n onControllerReconnect(callback: (playerIndex: PlayerIndex, info: ControllerInfo) => void): () => void;\n\n /**\n * Register a callback for when a player's character appearance is updated.\n *\n * @param callback - Called with player index and new appearance (or null if reset)\n * @returns Unsubscribe function to remove the callback\n */\n onCharacterUpdated(callback: (playerIndex: PlayerIndex, appearance: CharacterAppearance | null) => void): () => void;\n\n /**\n * Register a callback for when an error occurs.\n * If no error callback is registered, errors are logged to console in debug mode.\n *\n * @param callback - Called with the error object\n * @returns Unsubscribe function to remove the callback\n */\n onError(callback: (error: SmoreError) => void): () => void;\n\n /**\n * Register a callback for when the game ends.\n * Called when the Screen calls gameOver().\n *\n * @param callback - Called with optional game results\n * @returns Unsubscribe function to remove the callback\n */\n onGameOver(callback: (results?: GameResults) => void): () => void;\n\n /**\n * Register a callback for when the connection status changes.\n * Called when the connection to the server is lost or restored.\n *\n * @param callback - Called with true (connected) or false (disconnected)\n * @returns Unsubscribe function to remove the callback\n */\n onConnectionChange(callback: (connected: boolean) => void): () => void;\n\n /**\n * Returns the number of currently connected players.\n */\n getControllerCount(): number;\n\n /**\n * Get a specific controller by player index.\n * Returns undefined if not found.\n */\n getController(playerIndex: PlayerIndex): ControllerInfo | undefined;\n\n // === Communication Methods ===\n\n /**\n * Send an event to the screen.\n *\n * Controller -> Screen direction only. For Screen -> Controller, see `sendToController()`.\n *\n * @param event - Event name (must match TEvents keys)\n * @param data - Event data (type-safe based on event name)\n * @note Maximum payload size is 64KB. Payloads exceeding this limit will be silently dropped by the server.\n * **Rate limit:** The server allows up to 60 events/sec per Controller socket.\n * Messages are delivered to Screen in the order they are sent.\n *\n * @example\n * ```ts\n * controller.send('tap', { x: 100, y: 200 });\n * controller.send('answer', { choice: 2 });\n * ```\n */\n send<K extends EventNames<TEvents>>(\n event: K,\n data: EventData<TEvents, K>,\n ): void;\n\n /**\n * Signal that this controller has finished loading resources and is ready to start.\n *\n * Call this after all game resources are loaded.\n * The server will wait until all participants have signaled ready,\n * then broadcast an all-ready event to everyone.\n *\n * @example\n * ```ts\n * // After loading completes:\n * controller.signalReady();\n * ```\n */\n signalReady(): void;\n\n // === Event Subscription ===\n\n /**\n * Subscribe to a lifecycle event or a user-defined game event.\n *\n * Lifecycle events use `$`-prefixed names. Use `LifecycleEvent` constants\n * for type-safe subscription:\n * ```ts\n * controller.on(LifecycleEvent.CONTROLLER_JOIN, (pi, info) => { ... });\n * controller.on('phase-update', (data) => { ... }); // user event\n * ```\n */\n on<K extends ControllerLifecycleEvent>(event: K, handler: ControllerLifecycleHandlers[K]): () => void;\n /**\n * Add a listener for a specific event after construction.\n * Can be called before the controller is ready -- handlers are queued\n * and activated when the transport becomes available.\n *\n * @param event - Event name\n * @param handler - Handler function (data) => void\n * @returns Cleanup function to remove the listener\n *\n * @note Events from screen.broadcast() do not include playerIndex.\n * The handler signature is `(data: D)` without playerIndex context.\n * If you need to know which player triggered the broadcast, include\n * that information in the data object from the Screen side.\n *\n * @example\n * ```ts\n * const unsubscribe = controller.on('phase-update', (data) => {\n * console.log('New phase:', data.phase);\n * });\n *\n * // Later: remove listener\n * unsubscribe();\n * ```\n */\n on<K extends EventNames<TEvents>>(\n event: K,\n handler: ControllerEventHandler<EventData<TEvents, K>>,\n ): () => void;\n\n once<K extends ControllerLifecycleEvent>(event: K, handler: ControllerLifecycleHandlers[K]): () => void;\n /**\n * Add a one-time listener that auto-removes after first call.\n *\n * @note The handler is internally wrapped, so it cannot be removed via\n * `off(event, originalHandler)`. Use the returned unsubscribe function instead.\n */\n once<K extends EventNames<TEvents>>(\n event: K,\n handler: ControllerEventHandler<EventData<TEvents, K>>,\n ): () => void;\n\n off<K extends ControllerLifecycleEvent>(event: K, handler?: ControllerLifecycleHandlers[K]): void;\n /**\n * Remove a specific listener or all listeners for an event.\n */\n off<K extends EventNames<TEvents>>(\n event: K,\n handler?: ControllerEventHandler<EventData<TEvents, K>>,\n ): void;\n\n /**\n * Remove all event listeners, or all listeners for a specific event.\n * Only removes user event listeners registered via on()/once().\n * Lifecycle callbacks (onControllerJoin, onAllReady, etc.) are not affected.\n *\n * @param event - Optional event name. If omitted, removes ALL user event listeners.\n */\n removeAllListeners(event?: string): void;\n\n // === Cleanup ===\n\n /**\n * Clean up all resources and disconnect.\n * Call this when unmounting/destroying your game.\n */\n destroy(): void;\n}\n\n// =============================================================================\n// DEBUG OPTIONS\n// =============================================================================\n\n/**\n * Log levels for debug output.\n */\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\n/**\n * Debug configuration options.\n */\nexport interface DebugOptions {\n /** Enable debug logging */\n enabled?: boolean;\n\n /** Minimum log level to output */\n level?: LogLevel;\n\n /** Prefix for log messages */\n prefix?: string;\n\n /** Log events being sent */\n logSend?: boolean;\n\n /** Log events being received */\n logReceive?: boolean;\n\n /** Log lifecycle events (ready, destroy, etc.) */\n logLifecycle?: boolean;\n\n /** Custom logger function */\n logger?: (level: LogLevel, message: string, data?: unknown) => void;\n}\n"],"names":[],"mappings":"AA+OO,MAAM,cAAA,GAAiB;AAAA,EAC5B,SAAA,EAAW,YAAA;AAAA,EACX,eAAA,EAAiB,kBAAA;AAAA,EACjB,gBAAA,EAAkB,mBAAA;AAAA,EAClB,qBAAA,EAAuB,wBAAA;AAAA,EACvB,oBAAA,EAAsB,uBAAA;AAAA,EACtB,iBAAA,EAAmB,oBAAA;AAAA,EACnB,KAAA,EAAO,QAAA;AAAA,EACP,SAAA,EAAW,YAAA;AAAA,EACX,iBAAA,EAAmB;AACrB;;;;"}
1
+ {"version":3,"file":"types.js","sources":["../../src/types.ts"],"sourcesContent":["/**\n * @smoregg/sdk - World-Class Party Game SDK\n *\n * Type definitions for building multiplayer party games with type-safe events,\n * factory pattern initialization, and comprehensive error handling.\n *\n * @packageDocumentation\n */\n\n// =============================================================================\n// GAME CONFIGURATION\n// =============================================================================\n\n/**\n * Valid game categories for the S'MORE platform.\n * Use these when setting categories in game.json.\n */\nexport type GameCategory =\n | 'bet' // 🎰 내기\n | 'coop' // 🤝 협동\n | 'versus' // ⚔️ 대결\n | 'time-attack' // ⏱️ 타임어택\n | 'survival' // 🏃 생존\n | 'reflex' // 🎯 반응속도\n | 'deception' // 🕵️ 추리/속임수\n | 'creative' // 🎨 창작\n | 'party' // 🎉 파티\n | 'puzzle' // 🧩 퍼즐\n | 'board' // 🎲 보드게임\n | 'strategy' // 🧠 전략\n | 'timing'; // 🎵 타이밍\n\n/**\n * Category metadata with emoji and localized labels.\n * Useful for displaying categories in UI.\n */\nexport const GAME_CATEGORIES: Record<GameCategory, { emoji: string; label: string; labelKo: string }> = {\n 'bet': { emoji: '🎰', label: 'Betting', labelKo: '내기' },\n 'coop': { emoji: '🤝', label: 'Co-op', labelKo: '협동' },\n 'versus': { emoji: '⚔️', label: 'Versus', labelKo: '대결' },\n 'time-attack': { emoji: '⏱️', label: 'Time Attack', labelKo: '타임어택' },\n 'survival': { emoji: '🏃', label: 'Survival', labelKo: '생존' },\n 'reflex': { emoji: '🎯', label: 'Reflex', labelKo: '반응속도' },\n 'deception': { emoji: '🕵️', label: 'Deception', labelKo: '추리/속임수' },\n 'creative': { emoji: '🎨', label: 'Creative', labelKo: '창작' },\n 'party': { emoji: '🎉', label: 'Party', labelKo: '파티' },\n 'puzzle': { emoji: '🧩', label: 'Puzzle', labelKo: '퍼즐' },\n 'board': { emoji: '🎲', label: 'Board Game', labelKo: '보드게임' },\n 'strategy': { emoji: '🧠', label: 'Strategy', labelKo: '전략' },\n 'timing': { emoji: '🎵', label: 'Timing', labelKo: '타이밍' },\n};\n\n/**\n * Game configuration from game.json.\n * This is the schema that game developers put in their game.json file.\n *\n * @example\n * ```json\n * {\n * \"id\": \"my-game\",\n * \"title\": \"My Game\",\n * \"description\": \"A fun party game\",\n * \"players\": [3, 4, 5, 6],\n * \"categories\": [\"party\", \"creative\"],\n * \"version\": \"1.0.0\"\n * }\n * ```\n */\nexport interface GameConfig {\n /** Unique game identifier (kebab-case) */\n id: string;\n /** Display name of the game */\n title: string;\n /** Short description (1-2 sentences) */\n description: string;\n /** Allowed player counts (e.g. [3,4,5,6,7,8] or [2,4,6]) */\n players: number[];\n /** Game categories from the fixed platform list */\n categories: GameCategory[];\n /** Semantic version (e.g. \"1.0.0\") */\n version: string;\n}\n\n// =============================================================================\n// CORE PRIMITIVES\n// =============================================================================\n\n/**\n * Unique identifier for a player (0-indexed integer).\n * Used consistently across all SDK methods.\n */\nexport type PlayerIndex = number;\n\n/**\n * Room code for joining a game session (e.g., \"ABCD\").\n */\nexport type RoomCode = string;\n\n// =============================================================================\n// EVENT SYSTEM - TYPE-SAFE EVENTS\n// =============================================================================\n\n/**\n * Base event map type. Extend this to define your game's events.\n *\n * **Important:** Event data values must be plain objects, not primitives.\n * Primitive values (string, number, boolean) will be automatically wrapped\n * as `{ data: <value> }` by the relay server, which breaks type safety.\n *\n * **Payload Size Limit:** Maximum payload size per event is 64KB. This limit\n * is enforced by the server's genericRelay handler. Payloads exceeding this\n * limit will be silently dropped by the server without error notification.\n *\n * **Reserved Fields:** The field names `playerIndex` and `targetPlayerIndex` are reserved\n * by the SDK for internal routing. Using these as custom data field names will cause\n * a compile-time error. The SDK automatically extracts `playerIndex` to identify the sender\n * and uses `targetPlayerIndex` for targeted message delivery.\n *\n * **Type Safety Note:** Without providing an explicit generic type parameter,\n * `createScreen()` and `createController()` default to the empty `EventMap`,\n * which means `send()`, `broadcast()`, and `on()` accept any string as an event\n * name and `unknown` as data -- effectively losing compile-time type checking.\n * Always define and pass your game's event map for full type safety.\n *\n * @example Defining events for type safety\n * ```ts\n * interface MyGameEvents {\n * // Screen receives from Controller\n * 'tap': { x: number; y: number };\n * 'answer': { choice: number };\n *\n * // Controller receives from Screen\n * 'phase-update': { phase: 'lobby' | 'playing' | 'results' };\n * 'your-turn': { timeLimit: number };\n * }\n *\n * // With explicit generic -- full type safety\n * const screen = createScreen<MyGameEvents>({ debug: true });\n * screen.on('tap', (playerIndex, data) => { ... });\n * await screen.ready;\n *\n * // Without generic -- no type safety (not recommended)\n * const screen = createScreen();\n * ```\n *\n * @example Event naming conventions\n * ```ts\n * // Define your game's event map for type safety:\n * type MyEvents = {\n * 'player-move': { x: number; y: number };\n * 'game-action': { action: string; value: number };\n * };\n * // Event names: use kebab-case, no colons (:), no 'smore:' prefix\n * ```\n */\nexport interface EventMap {\n [key: string]: Record<string, unknown> & { playerIndex?: never; targetPlayerIndex?: never };\n}\n\n/**\n * Extract event names from an event map.\n */\nexport type EventNames<TEvents extends EventMap> = keyof TEvents & string;\n\n/**\n * Extract event data type for a specific event.\n */\nexport type EventData<\n TEvents extends EventMap,\n TEvent extends EventNames<TEvents>,\n> = TEvents[TEvent];\n\n// =============================================================================\n// CONTROLLER INFO - PLAYER INFORMATION\n// =============================================================================\n\n/**\n * Character appearance data for player avatars.\n *\n * This type matches the server's CharacterDTO structure to ensure\n * type consistency across the platform.\n *\n * @property id - Unique character identifier\n * @property seed - Random seed for generating the character\n * @property style - Character style preset identifier\n * @property options - Additional character customization options\n */\nexport interface CharacterAppearance {\n /** Unique character identifier */\n id: string;\n /** Random seed for generating the character */\n seed: string;\n /** Character style preset identifier */\n style: string;\n /** Additional character customization options */\n options: Record<string, unknown>;\n}\n\n/**\n * Information about a connected controller (player).\n * Used by Screen to identify and manage players.\n */\nexport interface ControllerInfo {\n /** Player's unique index (0, 1, 2, ...) */\n readonly playerIndex: PlayerIndex;\n /**\n * Player's chosen display name.\n *\n * Maps to `PlayerDTO.name` on the server side. The SDK exposes it as\n * \"nickname\" for semantic clarity in game code.\n * The mapping (`name` -> `nickname`) is handled automatically during\n * player data deserialization in the transport layer.\n *\n * @see PlayerDTO.name (server) -- same value, different field name\n */\n readonly nickname: string;\n /** Whether the player is currently connected */\n readonly connected: boolean;\n /**\n * Optional character appearance data.\n *\n * Note: The server sends this as \"character\" in PlayerDTO.\n * The SDK maps it to \"appearance\" for semantic clarity.\n * The server may send `null` when no character is set.\n */\n readonly appearance?: CharacterAppearance | null;\n}\n\n// =============================================================================\n// TRANSPORT\n// =============================================================================\n\n/**\n * Transport interface for custom communication implementations.\n * Implement this to use a custom transport instead of the default PostMessageTransport.\n */\nexport interface Transport {\n emit(event: string, ...args: unknown[]): void;\n on(event: string, handler: (...args: unknown[]) => void): void;\n off(event: string, handler?: (...args: unknown[]) => void): void;\n destroy(): void;\n}\n\n// =============================================================================\n// ERROR HANDLING\n// =============================================================================\n\n/**\n * Error codes for SDK errors.\n */\nexport type SmoreErrorCode =\n | 'TIMEOUT' // Connection or operation timeout\n | 'NOT_READY' // Operation called before ready\n | 'DESTROYED' // Operation called after destroy\n | 'INVALID_EVENT' // Invalid event name\n | 'INVALID_PLAYER' // Invalid player index\n | 'CONNECTION_LOST' // Lost connection to server\n | 'INIT_FAILED' // Failed to initialize\n | 'RATE_LIMITED' // Server rate-limited an event\n | 'PAYLOAD_TOO_LARGE' // Payload exceeds 64KB limit\n | 'UNKNOWN'; // Unknown error\n\n/**\n * Structured error type for SDK errors.\n */\nexport interface SmoreError {\n /** Error code for programmatic handling */\n code: SmoreErrorCode;\n /** Human-readable error message */\n message: string;\n /** Original error if available */\n cause?: Error;\n /** Additional context */\n details?: Record<string, unknown>;\n}\n\n// =============================================================================\n// GAME RESULTS\n// =============================================================================\n\n/**\n * Game results structure for gameOver().\n * Flexible to accommodate different game types.\n */\nexport interface GameResults {\n /** Player scores indexed by player index */\n scores?: Record<PlayerIndex, number>;\n /** Winner's player index (or -1 for no winner/tie) */\n winner?: PlayerIndex;\n /** Ranked player indices from first to last */\n rankings?: PlayerIndex[];\n /** Additional custom game-specific data */\n custom?: Record<string, unknown>;\n}\n\n// =============================================================================\n// LIFECYCLE EVENTS — UNIFIED EVENT SYSTEM\n// =============================================================================\n\n/**\n * Lifecycle event names for subscribing via `on()`.\n *\n * These `$`-prefixed event names allow lifecycle events to be registered\n * through the same `on()` method used for game events. The `$` prefix is\n * reserved by the SDK and cannot be used for user-defined events.\n *\n * @example\n * ```ts\n * // These are equivalent:\n * screen.onControllerJoin((pi, info) => { ... });\n * screen.on(LifecycleEvent.CONTROLLER_JOIN, (pi, info) => { ... });\n * ```\n */\nexport const LifecycleEvent = {\n ALL_READY: '$all-ready',\n CONTROLLER_JOIN: '$controller-join',\n CONTROLLER_LEAVE: '$controller-leave',\n CONTROLLER_DISCONNECT: '$controller-disconnect',\n CONTROLLER_RECONNECT: '$controller-reconnect',\n CHARACTER_UPDATED: '$character-updated',\n ERROR: '$error',\n GAME_OVER: '$game-over',\n CONNECTION_CHANGE: '$connection-change',\n} as const;\n\n/** Union of all lifecycle event name strings. */\nexport type LifecycleEventName = typeof LifecycleEvent[keyof typeof LifecycleEvent];\n\n/**\n * Handler signatures for Screen lifecycle events.\n * Used by `on()` overloads to provide type-safe lifecycle event subscription.\n */\nexport interface ScreenLifecycleHandlers {\n '$all-ready': () => void;\n '$controller-join': (playerIndex: PlayerIndex, info: ControllerInfo) => void;\n '$controller-leave': (playerIndex: PlayerIndex) => void;\n '$controller-disconnect': (playerIndex: PlayerIndex) => void;\n '$controller-reconnect': (playerIndex: PlayerIndex, info: ControllerInfo) => void;\n '$character-updated': (playerIndex: PlayerIndex, appearance: CharacterAppearance | null) => void;\n '$error': (error: SmoreError) => void;\n '$connection-change': (connected: boolean) => void;\n}\n\n/** Screen lifecycle event name union. */\nexport type ScreenLifecycleEvent = keyof ScreenLifecycleHandlers;\n\n/**\n * Handler signatures for Controller lifecycle events.\n * Extends Screen lifecycle events with Controller-specific events.\n */\nexport interface ControllerLifecycleHandlers extends ScreenLifecycleHandlers {\n '$game-over': (results?: GameResults) => void;\n}\n\n/** Controller lifecycle event name union. */\nexport type ControllerLifecycleEvent = keyof ControllerLifecycleHandlers;\n\n// =============================================================================\n// SCREEN TYPES - HOST/TV SIDE\n// =============================================================================\n\n/**\n * Handler for events received from controllers.\n * Receives the player index and event data.\n */\nexport type ScreenEventHandler<TData = unknown> = (\n playerIndex: PlayerIndex,\n data: TData,\n) => void;\n\n/**\n * Configuration options for creating a Screen instance.\n *\n * In the event emitter pattern, only static options are passed via config.\n * All lifecycle callbacks and event listeners are registered via methods\n * on the returned Screen instance.\n *\n * @template TEvents - Event map type for type-safe events\n *\n * @example\n * ```ts\n * const screen = createScreen<MyEvents>({ debug: true });\n *\n * screen.on('tap', (playerIndex, data) => handleTap(playerIndex, data));\n * screen.onAllReady(() => startCountdown());\n * screen.onControllerJoin((playerIndex, info) => console.log('Joined:', playerIndex));\n *\n * await screen.ready;\n * ```\n */\nexport interface ScreenConfig {\n // === Debug Options ===\n\n /**\n * Enable debug mode for verbose logging.\n * @default false\n */\n debug?: boolean | DebugOptions;\n\n // === Advanced Options ===\n\n /**\n * Parent window origin for postMessage validation (iframe games).\n * Use '*' to accept messages from any origin (not recommended for production).\n * @default '*'\n */\n parentOrigin?: string;\n\n /**\n * Connection timeout in milliseconds.\n * @default 10000\n */\n timeout?: number;\n\n /**\n * Automatically signal ready after initialization.\n * When true (default), the SDK calls signalReady() automatically after init completes.\n * Set to false if your game needs to load resources before signaling ready.\n * @default true\n */\n autoReady?: boolean;\n\n /**\n * Custom transport implementation.\n * If provided, uses this instead of the default PostMessageTransport.\n * The bridge handshake (_bridge:init) still occurs via postMessage.\n */\n transport?: Transport;\n\n}\n\n/**\n * Screen instance - the main interface for the host/TV side of your game.\n *\n * Uses an event emitter pattern: lifecycle callbacks and event listeners\n * are registered via methods on the instance, not via config.\n *\n * @template TEvents - Event map type for type-safe events\n *\n * @example\n * ```ts\n * const screen = createScreen<MyEvents>({ debug: true });\n *\n * screen.on('tap', (playerIndex, data) => handleTap(playerIndex, data));\n * screen.onAllReady(() => startGame());\n * screen.onControllerJoin((playerIndex, info) => addPlayer(playerIndex, info));\n *\n * await screen.ready;\n * screen.broadcast('phase-update', { phase: 'playing' });\n * screen.gameOver({ scores: { 0: 100, 1: 75 } });\n * ```\n */\nexport interface Screen<TEvents extends EventMap = EventMap> {\n // === Properties (readonly) ===\n\n /**\n * All connected controllers. Returns a new shallow copy on every access.\n *\n * **Performance note:** Each access creates a new array via spread.\n * Avoid calling this in tight loops; cache the result in a local variable\n * if you need to access it repeatedly within the same frame/tick.\n */\n readonly controllers: readonly ControllerInfo[];\n\n /** The room code for this game session. */\n readonly roomCode: RoomCode;\n\n /** Whether the screen is initialized and ready. */\n readonly isReady: boolean;\n\n /** Whether the screen has been destroyed. */\n readonly isDestroyed: boolean;\n\n /** Whether the connection to the server is active. */\n readonly isConnected: boolean;\n\n /** Protocol version negotiated with the parent frame. */\n readonly protocolVersion: number;\n\n /**\n * A Promise that resolves when the screen is initialized and ready.\n * Use this to await readiness after creating a screen synchronously.\n *\n * @example\n * ```ts\n * const screen = createScreen<MyEvents>();\n * screen.on('tap', handler);\n * await screen.ready;\n * screen.broadcast('start', {});\n * ```\n */\n readonly ready: Promise<void>;\n\n // === Lifecycle Methods ===\n\n /**\n * Register a callback for when all participants are ready (all-ready event).\n * If the all-ready event has already fired when called, the callback fires immediately.\n *\n * @param callback - Called when all participants signal ready\n * @returns Unsubscribe function to remove the callback\n */\n onAllReady(callback: () => void): () => void;\n\n /**\n * Register a callback for when a controller (player) joins the room.\n *\n * @param callback - Called with player index and controller info\n * @returns Unsubscribe function to remove the callback\n */\n onControllerJoin(callback: (playerIndex: PlayerIndex, info: ControllerInfo) => void): () => void;\n\n /**\n * Register a callback for when a controller (player) leaves the room.\n *\n * @param callback - Called with the leaving player's index\n * @returns Unsubscribe function to remove the callback\n */\n onControllerLeave(callback: (playerIndex: PlayerIndex) => void): () => void;\n\n /**\n * Register a callback for when a controller temporarily disconnects.\n *\n * @param callback - Called with the disconnected player's index\n * @returns Unsubscribe function to remove the callback\n */\n onControllerDisconnect(callback: (playerIndex: PlayerIndex) => void): () => void;\n\n /**\n * Register a callback for when a controller reconnects after a disconnect.\n *\n * In the stateless controller pattern, use this callback to re-push\n * the current view state to the reconnecting controller.\n *\n * @example\n * ```ts\n * screen.onControllerReconnect((playerIndex) => {\n * screen.sendToController(playerIndex, 'view-update', getCurrentView(playerIndex));\n * });\n * ```\n *\n * @param callback - Called with player index and updated controller info\n * @returns Unsubscribe function to remove the callback\n */\n onControllerReconnect(callback: (playerIndex: PlayerIndex, info: ControllerInfo) => void): () => void;\n\n /**\n * Register a callback for when a player's character appearance is updated.\n *\n * @param callback - Called with player index and new appearance (or null if reset)\n * @returns Unsubscribe function to remove the callback\n */\n onCharacterUpdated(callback: (playerIndex: PlayerIndex, appearance: CharacterAppearance | null) => void): () => void;\n\n /**\n * Register a callback for when an error occurs.\n * If no error callback is registered, errors are logged to console in debug mode.\n *\n * @param callback - Called with the error object\n * @returns Unsubscribe function to remove the callback\n */\n onError(callback: (error: SmoreError) => void): () => void;\n\n /**\n * Register a callback for when the connection status changes.\n * Called when the connection to the server is lost or restored.\n *\n * @param callback - Called with true (connected) or false (disconnected)\n * @returns Unsubscribe function to remove the callback\n */\n onConnectionChange(callback: (connected: boolean) => void): () => void;\n\n // === Communication Methods ===\n\n /**\n * Broadcast an event to all connected controllers.\n *\n * Use this to push the same view state to all controllers simultaneously.\n *\n * @param event - Event name (must match TEvents keys)\n * @param data - Event data (type-safe based on event name)\n * @note Data should be an object. Primitive values will be wrapped as `{ data: value }` by the relay server.\n * @note Maximum payload size is 64KB. Payloads exceeding this limit will be silently dropped by the server.\n * **Rate limit:** The server allows up to 60 events/sec per Screen socket\n * (shared across broadcast and sendToController calls).\n * Events exceeding this limit are silently dropped.\n * Messages from a single sender are delivered in order.\n *\n * @example\n * ```ts\n * screen.broadcast('phase-update', { phase: 'playing' });\n * ```\n */\n broadcast<K extends EventNames<TEvents>>(\n event: K,\n data: EventData<TEvents, K>,\n ): void;\n\n /**\n * Send an event to a specific controller.\n *\n * Screen -> Controller direction only. For Controller -> Screen, see `send()`.\n *\n * This is the primary method for the stateless controller pattern:\n * push complete view state to a specific controller.\n *\n * @param playerIndex - Target controller's player index\n * @param event - Event name (must match TEvents keys)\n * @param data - Event data (type-safe based on event name)\n * @note Data should be an object. Primitive values will be wrapped as `{ data: value }` by the relay server.\n * @note Maximum payload size is 64KB. Payloads exceeding this limit will be silently dropped by the server.\n * **Rate limit:** Shares the 60 events/sec limit with broadcast().\n *\n * @example\n * ```ts\n * screen.sendToController(0, 'your-turn', { timeLimit: 30 });\n * ```\n *\n * @example\n * ```ts\n * // Push current game view to a specific player\n * screen.sendToController(playerIndex, 'view-update', {\n * phase: 'voting',\n * candidates: [1, 3, 5],\n * timeRemaining: 30,\n * });\n * ```\n */\n sendToController<K extends EventNames<TEvents>>(\n playerIndex: PlayerIndex,\n event: K,\n data: EventData<TEvents, K>,\n ): void;\n\n // === Game Lifecycle ===\n\n /**\n * Signal that the game is over and send results.\n * This will broadcast a game-over event to all controllers.\n *\n * @param results - Game results (scores, rankings, etc.)\n *\n * @example\n * ```ts\n * screen.gameOver({\n * scores: { 0: 100, 1: 75, 2: 50 },\n * winner: 0,\n * rankings: [0, 1, 2],\n * });\n * ```\n */\n gameOver(results?: GameResults): void;\n\n /**\n * Signal that this screen has finished loading resources and is ready to start.\n *\n * Call this after all game resources (Phaser assets, images, sounds, etc.) are loaded.\n * The server will wait until all participants (screen + all connected controllers)\n * have signaled ready, then broadcast an all-ready event to everyone.\n *\n * @example\n * ```ts\n * // After Phaser scene loads all assets:\n * screen.signalReady();\n * ```\n */\n signalReady(): void;\n\n // === Event Subscription ===\n\n /**\n * Subscribe to a lifecycle event or a user-defined game event.\n *\n * Lifecycle events use `$`-prefixed names. Use `LifecycleEvent` constants\n * for type-safe subscription:\n * ```ts\n * screen.on(LifecycleEvent.CONTROLLER_JOIN, (pi, info) => { ... });\n * screen.on('tap', (pi, data) => { ... }); // user event\n * ```\n */\n on<K extends ScreenLifecycleEvent>(event: K, handler: ScreenLifecycleHandlers[K]): () => void;\n /**\n * Add a listener for a specific event after construction.\n * Can be called before the screen is ready -- handlers are queued\n * and activated when the transport becomes available.\n *\n * @param event - Event name\n * @param handler - Handler function (playerIndex, data) => void\n * @returns Cleanup function to remove the listener\n *\n * @example\n * ```ts\n * const unsubscribe = screen.on('tap', (playerIndex, data) => {\n * console.log(`Player ${playerIndex} tapped at`, data.x, data.y);\n * });\n *\n * // Later: remove listener\n * unsubscribe();\n * ```\n */\n on<K extends EventNames<TEvents>>(\n event: K,\n handler: ScreenEventHandler<EventData<TEvents, K>>,\n ): () => void;\n\n once<K extends ScreenLifecycleEvent>(event: K, handler: ScreenLifecycleHandlers[K]): () => void;\n /**\n * Add a one-time listener that auto-removes after first call.\n *\n * @note The handler is internally wrapped, so it cannot be removed via\n * `off(event, originalHandler)`. Use the returned unsubscribe function instead.\n */\n once<K extends EventNames<TEvents>>(\n event: K,\n handler: ScreenEventHandler<EventData<TEvents, K>>,\n ): () => void;\n\n off<K extends ScreenLifecycleEvent>(event: K, handler?: ScreenLifecycleHandlers[K]): void;\n /**\n * Remove a specific listener or all listeners for an event.\n */\n off<K extends EventNames<TEvents>>(\n event: K,\n handler?: ScreenEventHandler<EventData<TEvents, K>>,\n ): void;\n\n /**\n * Remove all event listeners, or all listeners for a specific event.\n * Only removes user event listeners registered via on()/once().\n * Lifecycle callbacks (onControllerJoin, onAllReady, etc.) are not affected.\n *\n * @param event - Optional event name. If omitted, removes ALL user event listeners.\n */\n removeAllListeners(event?: string): void;\n\n // === Utilities ===\n\n /**\n * Get a specific controller by player index.\n * Returns undefined if not found.\n */\n getController(playerIndex: PlayerIndex): ControllerInfo | undefined;\n\n /**\n * Get the number of connected controllers.\n */\n getControllerCount(): number;\n\n // === Cleanup ===\n\n /**\n * Clean up all resources and disconnect.\n * Call this when unmounting/destroying your game.\n */\n destroy(): void;\n}\n\n// =============================================================================\n// CONTROLLER TYPES - PLAYER/PHONE SIDE\n// =============================================================================\n\n/**\n * Handler for events received from the screen.\n * Receives only the event data (no player index needed).\n */\nexport type ControllerEventHandler<TData = unknown> = (data: TData) => void;\n\n/**\n * Configuration options for creating a Controller instance.\n *\n * In the event emitter pattern, only static options are passed via config.\n * All lifecycle callbacks and event listeners are registered via methods\n * on the returned Controller instance.\n *\n * @template TEvents - Event map type for type-safe events\n *\n * @example\n * ```ts\n * const controller = createController<MyEvents>({ debug: true });\n *\n * controller.on('phase-update', (data) => handlePhase(data.phase));\n * controller.onAllReady(() => console.log('Ready!'));\n *\n * await controller.ready;\n * controller.send('tap', { x: 100, y: 200 });\n * ```\n */\nexport interface ControllerConfig {\n // === Debug Options ===\n\n /**\n * Enable debug mode for verbose logging.\n * @default false\n */\n debug?: boolean | DebugOptions;\n\n // === Advanced Options ===\n\n /**\n * Parent window origin for postMessage validation (iframe games).\n * @default '*'\n */\n parentOrigin?: string;\n\n /**\n * Connection timeout in milliseconds.\n * @default 10000\n */\n timeout?: number;\n\n /**\n * Automatically signal ready after initialization.\n * When true (default), the SDK calls signalReady() automatically after init completes.\n * Set to false if your game needs to load resources before signaling ready.\n * @default true\n */\n autoReady?: boolean;\n\n /**\n * Custom transport implementation.\n * If provided, uses this instead of the default PostMessageTransport.\n * The bridge handshake (_bridge:init) still occurs via postMessage.\n */\n transport?: Transport;\n\n}\n\n/**\n * Controller instance - the main interface for the player/phone side.\n *\n * Uses an event emitter pattern: lifecycle callbacks and event listeners\n * are registered via methods on the instance, not via config.\n *\n * @template TEvents - Event map type for type-safe events\n *\n * @example\n * ```ts\n * const controller = createController<MyEvents>({ debug: true });\n *\n * controller.on('phase-update', (data) => setPhase(data.phase));\n * controller.onAllReady(() => console.log('Game starting!'));\n *\n * await controller.ready;\n * controller.send('tap', { x: 100, y: 200 });\n * ```\n *\n * ## Controller API Design Note:\n *\n * Controller only has `send()` (no `broadcast()` or `gameOver()`).\n * This is intentional: Controller-to-Controller (C2C) communication is not supported.\n * All coordination between controllers must go through the Screen.\n *\n * Flow: Controller.send() -> Screen receives -> Screen.broadcast() or Screen.sendToController()\n *\n * ## Stateless Controller Pattern (Recommended)\n *\n * Controllers should be stateless display + input devices:\n * - Render only what Screen sends via `on()` event handlers\n * - Send only user input to Screen via `send()`\n * - Do NOT store game state on the controller\n * - Screen is the single source of truth for all game state\n *\n * When a controller reconnects, Screen re-pushes current view state\n * via `sendToController()` in the `onControllerReconnect` callback.\n */\nexport interface Controller<TEvents extends EventMap = EventMap> {\n // === Properties (readonly) ===\n\n /** My player index (0, 1, 2, ...). */\n readonly myPlayerIndex: PlayerIndex;\n\n /** My own controller info. undefined before initialization. */\n readonly me: ControllerInfo | undefined;\n\n /** The room code for this game session. */\n readonly roomCode: RoomCode;\n\n /** Whether the controller is initialized and ready. */\n readonly isReady: boolean;\n\n /** Whether the controller has been destroyed. */\n readonly isDestroyed: boolean;\n\n /** Whether the connection to the server is active. */\n readonly isConnected: boolean;\n\n /** Protocol version negotiated with the parent frame. */\n readonly protocolVersion: number;\n\n /**\n * Read-only list of all known controllers (players) in the room.\n * Returns full ControllerInfo including playerIndex, nickname, connected status, and appearance.\n * Consistent with Screen's `controllers` property.\n *\n * **Performance note:** Each access creates a new shallow copy array.\n * Cache the result in a local variable if you need to access it repeatedly.\n */\n readonly controllers: readonly ControllerInfo[];\n\n /**\n * A Promise that resolves when the controller is initialized and ready.\n * Use this to await readiness after creating a controller synchronously.\n *\n * @example\n * ```ts\n * const controller = createController<MyEvents>();\n * controller.on('phase-update', handler);\n * await controller.ready;\n * controller.send('tap', { x: 0, y: 0 });\n * ```\n */\n readonly ready: Promise<void>;\n\n // === Lifecycle Methods ===\n\n /**\n * Register a callback for when all participants are ready (all-ready event).\n * If the all-ready event has already fired when called, the callback fires immediately.\n *\n * @param callback - Called when all participants signal ready\n * @returns Unsubscribe function to remove the callback\n */\n onAllReady(callback: () => void): () => void;\n\n /**\n * Register a callback for when another player joins the room.\n *\n * @param callback - Called with player index and controller info\n * @returns Unsubscribe function to remove the callback\n */\n onControllerJoin(callback: (playerIndex: PlayerIndex, info: ControllerInfo) => void): () => void;\n\n /**\n * Register a callback for when another player leaves the room.\n *\n * @param callback - Called with the leaving player's index\n * @returns Unsubscribe function to remove the callback\n */\n onControllerLeave(callback: (playerIndex: PlayerIndex) => void): () => void;\n\n /**\n * Register a callback for when another player temporarily disconnects.\n *\n * @param callback - Called with the disconnected player's index\n * @returns Unsubscribe function to remove the callback\n */\n onControllerDisconnect(callback: (playerIndex: PlayerIndex) => void): () => void;\n\n /**\n * Register a callback for when another player reconnects after a disconnect.\n *\n * @param callback - Called with player index and updated controller info\n * @returns Unsubscribe function to remove the callback\n */\n onControllerReconnect(callback: (playerIndex: PlayerIndex, info: ControllerInfo) => void): () => void;\n\n /**\n * Register a callback for when a player's character appearance is updated.\n *\n * @param callback - Called with player index and new appearance (or null if reset)\n * @returns Unsubscribe function to remove the callback\n */\n onCharacterUpdated(callback: (playerIndex: PlayerIndex, appearance: CharacterAppearance | null) => void): () => void;\n\n /**\n * Register a callback for when an error occurs.\n * If no error callback is registered, errors are logged to console in debug mode.\n *\n * @param callback - Called with the error object\n * @returns Unsubscribe function to remove the callback\n */\n onError(callback: (error: SmoreError) => void): () => void;\n\n /**\n * Register a callback for when the game ends.\n * Called when the Screen calls gameOver().\n *\n * @param callback - Called with optional game results\n * @returns Unsubscribe function to remove the callback\n */\n onGameOver(callback: (results?: GameResults) => void): () => void;\n\n /**\n * Register a callback for when the connection status changes.\n * Called when the connection to the server is lost or restored.\n *\n * @param callback - Called with true (connected) or false (disconnected)\n * @returns Unsubscribe function to remove the callback\n */\n onConnectionChange(callback: (connected: boolean) => void): () => void;\n\n /**\n * Returns the number of currently connected players.\n */\n getControllerCount(): number;\n\n /**\n * Get a specific controller by player index.\n * Returns undefined if not found.\n */\n getController(playerIndex: PlayerIndex): ControllerInfo | undefined;\n\n // === Communication Methods ===\n\n /**\n * Send an event to the screen.\n *\n * Controller -> Screen direction only. For Screen -> Controller, see `sendToController()`.\n *\n * @param event - Event name (must match TEvents keys)\n * @param data - Event data (type-safe based on event name)\n * @note Maximum payload size is 64KB. Payloads exceeding this limit will be silently dropped by the server.\n * **Rate limit:** The server allows up to 60 events/sec per Controller socket.\n * Messages are delivered to Screen in the order they are sent.\n *\n * @example\n * ```ts\n * controller.send('tap', { x: 100, y: 200 });\n * controller.send('answer', { choice: 2 });\n * ```\n */\n send<K extends EventNames<TEvents>>(\n event: K,\n data: EventData<TEvents, K>,\n ): void;\n\n /**\n * Signal that this controller has finished loading resources and is ready to start.\n *\n * Call this after all game resources are loaded.\n * The server will wait until all participants have signaled ready,\n * then broadcast an all-ready event to everyone.\n *\n * @example\n * ```ts\n * // After loading completes:\n * controller.signalReady();\n * ```\n */\n signalReady(): void;\n\n // === Event Subscription ===\n\n /**\n * Subscribe to a lifecycle event or a user-defined game event.\n *\n * Lifecycle events use `$`-prefixed names. Use `LifecycleEvent` constants\n * for type-safe subscription:\n * ```ts\n * controller.on(LifecycleEvent.CONTROLLER_JOIN, (pi, info) => { ... });\n * controller.on('phase-update', (data) => { ... }); // user event\n * ```\n */\n on<K extends ControllerLifecycleEvent>(event: K, handler: ControllerLifecycleHandlers[K]): () => void;\n /**\n * Add a listener for a specific event after construction.\n * Can be called before the controller is ready -- handlers are queued\n * and activated when the transport becomes available.\n *\n * @param event - Event name\n * @param handler - Handler function (data) => void\n * @returns Cleanup function to remove the listener\n *\n * @note Events from screen.broadcast() do not include playerIndex.\n * The handler signature is `(data: D)` without playerIndex context.\n * If you need to know which player triggered the broadcast, include\n * that information in the data object from the Screen side.\n *\n * @example\n * ```ts\n * const unsubscribe = controller.on('phase-update', (data) => {\n * console.log('New phase:', data.phase);\n * });\n *\n * // Later: remove listener\n * unsubscribe();\n * ```\n */\n on<K extends EventNames<TEvents>>(\n event: K,\n handler: ControllerEventHandler<EventData<TEvents, K>>,\n ): () => void;\n\n once<K extends ControllerLifecycleEvent>(event: K, handler: ControllerLifecycleHandlers[K]): () => void;\n /**\n * Add a one-time listener that auto-removes after first call.\n *\n * @note The handler is internally wrapped, so it cannot be removed via\n * `off(event, originalHandler)`. Use the returned unsubscribe function instead.\n */\n once<K extends EventNames<TEvents>>(\n event: K,\n handler: ControllerEventHandler<EventData<TEvents, K>>,\n ): () => void;\n\n off<K extends ControllerLifecycleEvent>(event: K, handler?: ControllerLifecycleHandlers[K]): void;\n /**\n * Remove a specific listener or all listeners for an event.\n */\n off<K extends EventNames<TEvents>>(\n event: K,\n handler?: ControllerEventHandler<EventData<TEvents, K>>,\n ): void;\n\n /**\n * Remove all event listeners, or all listeners for a specific event.\n * Only removes user event listeners registered via on()/once().\n * Lifecycle callbacks (onControllerJoin, onAllReady, etc.) are not affected.\n *\n * @param event - Optional event name. If omitted, removes ALL user event listeners.\n */\n removeAllListeners(event?: string): void;\n\n // === Cleanup ===\n\n /**\n * Clean up all resources and disconnect.\n * Call this when unmounting/destroying your game.\n */\n destroy(): void;\n}\n\n// =============================================================================\n// DEBUG OPTIONS\n// =============================================================================\n\n/**\n * Log levels for debug output.\n */\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\n/**\n * Debug configuration options.\n */\nexport interface DebugOptions {\n /** Enable debug logging */\n enabled?: boolean;\n\n /** Minimum log level to output */\n level?: LogLevel;\n\n /** Prefix for log messages */\n prefix?: string;\n\n /** Log events being sent */\n logSend?: boolean;\n\n /** Log events being received */\n logReceive?: boolean;\n\n /** Log lifecycle events (ready, destroy, etc.) */\n logLifecycle?: boolean;\n\n /** Custom logger function */\n logger?: (level: LogLev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AAA,EACX,eAAA,EAAiB,kBAAA;AAAA,EACjB,gBAAA,EAAkB,mBAAA;AAAA,EAClB,qBAAA,EAAuB,wBAAA;AAAA,EACvB,oBAAA,EAAsB,uBAAA;AAAA,EACtB,iBAAA,EAAmB,oBAAA;AAAA,EACnB,KAAA,EAAO,QAAA;AAAA,EACP,SAAA,EAAW,YAAA;AAAA,EACX,iBAAA,EAAmB;AACrB;;;;"}
@@ -39,5 +39,6 @@ export { createScreen } from './screen';
39
39
  export { createController } from './controller';
40
40
  export { SmoreSDKError } from './errors';
41
41
  export { LifecycleEvent } from './types';
42
- export type { PlayerIndex, RoomCode, EventMap, EventNames, EventData, LifecycleEventName, ScreenLifecycleEvent, ScreenLifecycleHandlers, ControllerLifecycleEvent, ControllerLifecycleHandlers, Controller, ControllerConfig, ControllerEventHandler, ControllerInfo, CharacterAppearance, Screen, ScreenConfig, ScreenEventHandler, Transport, GameResults, SmoreError, SmoreErrorCode, DebugOptions, LogLevel, } from './types';
42
+ export { GAME_CATEGORIES } from './types';
43
+ export type { PlayerIndex, RoomCode, EventMap, EventNames, EventData, LifecycleEventName, ScreenLifecycleEvent, ScreenLifecycleHandlers, ControllerLifecycleEvent, ControllerLifecycleHandlers, Controller, ControllerConfig, ControllerEventHandler, ControllerInfo, CharacterAppearance, Screen, ScreenConfig, ScreenEventHandler, Transport, GameResults, SmoreError, SmoreErrorCode, DebugOptions, LogLevel, GameCategory, GameConfig, } from './types';
43
44
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAMH,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAMzC,YAAY,EAEV,WAAW,EACX,QAAQ,EAER,QAAQ,EACR,UAAU,EACV,SAAS,EAET,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,2BAA2B,EAE3B,UAAU,EACV,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,mBAAmB,EAEnB,MAAM,EACN,YAAY,EACZ,kBAAkB,EAElB,SAAS,EAET,WAAW,EAEX,UAAU,EACV,cAAc,EAEd,YAAY,EACZ,QAAQ,GACT,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAMH,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAM1C,YAAY,EAEV,WAAW,EACX,QAAQ,EAER,QAAQ,EACR,UAAU,EACV,SAAS,EAET,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,2BAA2B,EAE3B,UAAU,EACV,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,mBAAmB,EAEnB,MAAM,EACN,YAAY,EACZ,kBAAkB,EAElB,SAAS,EAET,WAAW,EAEX,UAAU,EACV,cAAc,EAEd,YAAY,EACZ,QAAQ,EAER,YAAY,EACZ,UAAU,GACX,MAAM,SAAS,CAAC"}
@@ -6,6 +6,50 @@
6
6
  *
7
7
  * @packageDocumentation
8
8
  */
9
+ /**
10
+ * Valid game categories for the S'MORE platform.
11
+ * Use these when setting categories in game.json.
12
+ */
13
+ export type GameCategory = 'bet' | 'coop' | 'versus' | 'time-attack' | 'survival' | 'reflex' | 'deception' | 'creative' | 'party' | 'puzzle' | 'board' | 'strategy' | 'timing';
14
+ /**
15
+ * Category metadata with emoji and localized labels.
16
+ * Useful for displaying categories in UI.
17
+ */
18
+ export declare const GAME_CATEGORIES: Record<GameCategory, {
19
+ emoji: string;
20
+ label: string;
21
+ labelKo: string;
22
+ }>;
23
+ /**
24
+ * Game configuration from game.json.
25
+ * This is the schema that game developers put in their game.json file.
26
+ *
27
+ * @example
28
+ * ```json
29
+ * {
30
+ * "id": "my-game",
31
+ * "title": "My Game",
32
+ * "description": "A fun party game",
33
+ * "players": [3, 4, 5, 6],
34
+ * "categories": ["party", "creative"],
35
+ * "version": "1.0.0"
36
+ * }
37
+ * ```
38
+ */
39
+ export interface GameConfig {
40
+ /** Unique game identifier (kebab-case) */
41
+ id: string;
42
+ /** Display name of the game */
43
+ title: string;
44
+ /** Short description (1-2 sentences) */
45
+ description: string;
46
+ /** Allowed player counts (e.g. [3,4,5,6,7,8] or [2,4,6]) */
47
+ players: number[];
48
+ /** Game categories from the fixed platform list */
49
+ categories: GameCategory[];
50
+ /** Semantic version (e.g. "1.0.0") */
51
+ version: string;
52
+ }
9
53
  /**
10
54
  * Unique identifier for a player (0-indexed integer).
11
55
  * Used consistently across all SDK methods.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAM9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,MAAM,WAAW,QAAQ;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;QAAE,WAAW,CAAC,EAAE,K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