/* Copyright (c) 2024 Rune AI Inc. All rights reserved. This code is proprietary to Rune AI Inc. The code may be used solely for accessing the Service provided by Rune AI Inc. following the Rune AI Inc. Terms of Service ("Terms") accessible at rune.ai/eula. You may not use this code for any use or purpose other than as expressly permitted by the Terms. Restrictions set forth in the Terms include, but is not limited to, that you may not copy, adapt, modify, prepare derivative works based upon, distribute, license, sell, transfer, publicly display, publicly perform, transmit, stream, broadcast, attempt to discover any source code, reverse engineer, decompile, dissemble, or otherwise exploit the code as a whole or any portion of the code. */ type PersistedPlayers = Record; type GameStateWithPersisted = GameState & { persisted: PersistedPlayers; }; type UntypedPersistedData = {}; type UntypedGameState = Record; type UntypedGameStateWithPersisted = GameStateWithPersisted; type UntypedInitLogicAction = (params?: any) => void; type UntypedInitLogicActions = Record; type SessionId = string; type GameId = number; type PlayerId = string; type RandomSeed = number; type Player = { playerId: PlayerId; displayName: string; avatarUrl: string; }; type Players = Record; type Base64Png = string; type AIPromptResponse = { requestId: string; response: string; }; type LogFn = { (obj: object, msg: string): void; (msg: string): void; }; type MsgLogger = { error: LogFn; warn: LogFn; info: LogFn; }; type LogInfo = { devDash: null; } | { devDash: { type: "CLIENT" | "LOGIC"; userType?: "UNKNOWN" | "PLAYER" | "SPECTATOR"; }; }; type ServerErrorMessage = keyof typeof errorMap; declare const errorMap: { SERVER_UPDATE_LOOP_FASTER_THAN_GAME_TIME: { devUIUnexpected: true; logInfo: { devDash: null; }; }; GET_GAME_STATE_FAILED: { devUIUnexpected: true; logInfo: { devDash: null; }; }; SERVER_RECEIVED_MESSAGE_TOO_BIG: { devUIUnexpected: true; logInfo: { devDash: null; }; }; SERVER_MESSAGE_TO_CLIENTS_TOO_BIG: { devUIUnexpected: true; logInfo: { devDash: null; }; }; SERVER_FULL: { devUIUnexpected: true; logInfo: { devDash: null; }; }; ON_PLAYER_JOINED_CALLBACK_MISSING: { devUIUnexpected: true; logInfo: { devDash: null; }; }; ROOM_GAME_STATE_MISSING: { devUIUnexpected: true; logInfo: { devDash: null; }; }; PERSIST_DATA_AFTER_ERROR_NOT_AVAILABLE: { devUIUnexpected: true; logInfo: { devDash: null; }; }; GET_PERSISTED_STATE_FAILED: { devUIUnexpected: true; logInfo: { devDash: null; }; }; GAME_END_PERSIST_USER_NOT_FOUND: { devUIUnexpected: true; logInfo: { devDash: null; }; }; PLAYER_LEFT_NO_USERS_INCORRECT_PERSISTED_PLAYERS: { devUIUnexpected: true; logInfo: { devDash: null; }; }; PERSISTED_STATE_NOT_ENABLED: { devUIUnexpected: true; logInfo: { devDash: null; }; }; UPDATE_LOOP_BEHIND_GAME_TIME: { devUIMessage: string; logInfo: { devDash: null; }; }; AI_PROMPT_REQUEST_FAILED: { devUIUnexpected: true; logInfo: { devDash: null; }; }; ACTION_PARAMS_SIZE_OVER_LIMIT: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); PLAYER_JOINED_FAILED: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); PLAYER_LEFT_FAILED: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); AI_PROMPT_RESPONSE_FAILED: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); ACTION_TRIGGERED_IN_LOGIC: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); STATE_SYNC_TOO_BIG: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); GAME_OVER_INVALID_OPTIONS: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); SERVER_UPDATE_LOOP_FAILED: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); ACTION_FAILED: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); SETUP_GAME_OVER_NOT_ALLOWED: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); SETUP_FAILED: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); PERSISTED_STATE_USED_WITHOUT_FLAG: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); SETUP_PERSISTED_KEY_NOT_ALLOWED: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); PERSISTED_NOT_AN_OBJECT: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); PERSISTED_KEY_MISSING: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); PERSISTED_EXTRA_KEY_DETECTED: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); PERSISTED_PLAYER_MISSING: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); PERSISTED_PLAYER_NOT_AN_OBJECT: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); PERSISTED_PLAYER_OVER_LIMIT: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); AI_PROMPT_RESPONSE_NOT_DEFINED: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); AI_PROMPT_REQUEST_PARAM_WRONG_FORMAT: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); NON_ERROR_THROWN_FROM_GAME_LOGIC: { logInfo: LogInfo; } & ({ devUIMessage?: string | ((data: any) => string) | undefined; consoleMessage?: string | ((data: any) => string) | undefined; printExtraDataInDevUI?: boolean | undefined; devUIErrorTitle?: string | undefined; } | { devUIUnexpected: true; }); }; type GameOverResult = "WON" | "LOST" | "TIE" | number; type GameOverOptions = { delayPopUp?: boolean; minimizePopUp?: boolean; } & ({ players: { [playerId: PlayerId]: GameOverResult; }; everyone?: never; } | { players?: never; everyone: GameOverResult; }); type GameOverGameEnded = { reason: "gameEnded"; options: GameOverOptions; }; type GameOverPlayerLeft = { reason: "playerLeft"; }; type GameOverMinPlayers = { reason: "minPlayers"; }; type GameOverError = { reason: "err"; err?: { message: ServerErrorMessage; data?: object; }; }; type GameOverContext = (GameOverMinPlayers | GameOverPlayerLeft | GameOverGameEnded | GameOverError) & { players: Players; }; type ClientToGame = { type: "setForceMuteStatus"; muted: boolean; } | { type: "setDebugOverlayStatus"; enabled: boolean; } | { type: "DISCONNECTED"; } | { type: "READY_TO_REQUEST_STATE_SYNC"; } | { type: "CLIPBOARD_WRITE_RES"; reqId: string; success: boolean; } | { type: "CLIPBOARD_READ_RES"; reqId: string; text: string | null; } | { type: "STORAGE_WRITE_RES"; reqId: string; success: boolean; } | { type: "STORAGE_READ_RES"; reqId: string; value: string | null; }; type GameToClient = { type: "INIT"; version: string; } | { type: "ERR"; msg: string; err?: string; errInfo: object; stack?: string; } | { type: "WARNING"; msg: string; data?: unknown; } | { type: "INFO"; msg: string; data?: unknown; } | { type: "WINDOW_ERR"; err: { msg: string; filename: string; lineno: number; colno: number; stack?: string; }; } | { type: "UNHANDLED_PROMISE_REJECTION"; reason: string; } | { type: "WINDOW_ALERT"; message: string; } | { type: "BROWSER_INITIAL_OVERLAY_CLICKED"; } | { type: "BROWSER_IFRAME_LOADED"; } | { type: "GAME_OVER"; context: GameOverContext; } | { type: "OPEN_EXTERNAL_APP"; url: string; } | { type: "CLIPBOARD_WRITE_REQ"; reqId: string; text: string; } | { type: "CLIPBOARD_READ_REQ"; reqId: string; } | { type: "STORAGE_WRITE_REQ"; reqId: string; key: string; value: string; } | { type: "STORAGE_READ_REQ"; reqId: string; key: string; } | { type: "SHOW_GAME_OVER_POP_UP"; } | { type: "SHOW_INVITE_SHEET"; } | { type: "SHOW_SHARE_IMAGE"; img: Base64Png | null; } | { type: "ON_STATE_SYNC"; } | { type: "ON_CHANGE"; } | { type: "FPS_STATS"; min: number; max: number; avg: number; } | { type: "FPS_WARNING"; fps: number; isLowFps: boolean; }; type StaticLogInfo = { gameId: GameId; gameVersionId: number; isGameMsg: true; }; type GameToClientWithGameInfo = GameToClient & { gameId: GameId; logInfo: LogInfo & StaticLogInfo; }; type SdkMessageDecodingLogger = { onSessionMismatch(sessionId: SessionId | null, expectedSessionId: SessionId | null, logger: MsgLogger | null): void; }; type SdkMessageCodec = { encodeGameToServer(msg: GameToServer, compress: boolean): string; encodeServerToGame(msg: ServerToGame, compress: boolean): string; decodeGameToServer(msg: string, logger: MsgLogger | null): GameToServer | undefined; decodeServerToGame(msg: string, logger: MsgLogger | null): ServerToGame | undefined; }; type ClientMessageCodec = { encodeClientToGame(msg: ClientToGame): string; encodeGameToClient(msg: GameToClientWithGameInfo): string; decodeClientToGame(msg: string): ClientToGame | undefined; decodeGameToClient(msg: string): GameToClientWithGameInfo | undefined; }; type GameContext = { readonly gameOver: GameOverContext | null; orderNumber: number; sessionId: SessionId; gameId: GameId; serverStartedAt: number; }; type ServerToGameBase = { orderNumber: number; serverGameTime: number; logicTick: number; }; type OnChangeMsgAction = { [Key in keyof GameActions]: { action: Key; playerId: PlayerId; params: Parameters[0]; }; }[keyof GameActions]; type ActionBase = { uuid: string; actionCount: number; sessionId: SessionId; randomSeed: RandomSeed; measureLatencyStart: number; }; type GameToServerAction = OnChangeMsgAction & ActionBase & { clientGameTime: number; expectedLogicTick: number; }; type ServerToGameAction = ServerToGameBase & OnChangeMsgAction & ActionBase & { stateHash: number | undefined; }; type ServerToGameGameTimeUpdate = ServerToGameBase & { event: "gameTimeUpdate"; params: { gameContext: GameContext; }; }; type ServerToGameLatencyEstimate = { event: "latencyEstimate"; measureLatencyStart: number; serverGameTime: number; }; type ServerToGameStopGameEvent = { event: "debugStopGame"; }; type ServerToGameStateSyncEvent = ServerToGameBase & { event: "stateSync"; params: { game: GameStateWithPersisted; gameContext: GameContext; players: Players; pastPlayerIds: PlayerId[]; yourPlayerSeed: RandomSeed | undefined; yourPlayerActionCount: number | undefined; yourPlayerId: PlayerId | undefined; serverSeed: RandomSeed; triggeredByUpdateLoop: boolean; measureLatencyStart?: number; latencyRttEstimate?: number; }; dictionary?: string[]; }; type OnChangePlayerJoinedEvent = { event: "playerJoined"; params: { playerId: PlayerId; }; }; type ServerToGamePlayerJoinedEvent = ServerToGameBase & OnChangePlayerJoinedEvent & { params: { playerId: PlayerId; gameContext: GameContext; players: Players; randomSeed: RandomSeed; stateHash: number | undefined; persistedPlayerState?: UntypedPersistedData; }; }; type ServerToGameAIPromptResponseEvent = ServerToGameBase & { event: "aiPromptResponse"; params: { aiPromptResponse: AIPromptResponse; gameContext: GameContext; players: Players; randomSeed: RandomSeed; stateHash: number | undefined; }; }; type OnChangePlayerLeftEvent = { event: "playerLeft"; params: { playerId: PlayerId; }; }; type ServerToGamePlayerLeftEvent = ServerToGameBase & OnChangePlayerLeftEvent & { params: { playerId: PlayerId; gameContext: GameContext; players: Players; randomSeed: RandomSeed; stateHash: number | undefined; }; }; type ServerToGameOnChangeTriggeringEvent = ServerToGameStateSyncEvent | ServerToGamePlayerJoinedEvent | ServerToGamePlayerLeftEvent | ServerToGameAIPromptResponseEvent; type ServerToGameEvent = ServerToGameOnChangeTriggeringEvent | ServerToGameGameTimeUpdate | ServerToGameLatencyEstimate | ServerToGameStopGameEvent; type ServerToGame = ServerToGameAction | ServerToGameEvent; type GameToServer = GameToServerAction | GameToServerStateSyncRequest | { type: "MEASURE_LATENCY"; measureLatencyStart: number; } | { type: "DEBUG_TIMELINE"; data: any; }; type GameToServerStateSyncRequest = { type: "REQUEST_STATE_SYNC"; measureLatencyStart: number; gameId: number | null; }; type ClientProtocolVersion = number; type SdkProtocolVersion = number; declare const CLIENT_PROTOCOL_VERSION_RUNE_MSG: ClientProtocolVersion; declare const CLIENT_PROTOCOL_VERSION_SIMPLE_JSON: ClientProtocolVersion; declare const SDK_PROTOCOL_VERSION_RUNE_MSG: SdkProtocolVersion; declare const SDK_PROTOCOL_VERSION_NEW_HEADER: SdkProtocolVersion; declare const SDK_PROTOCOL_VERSION_WITH_COMPRESSION: SdkProtocolVersion; declare const SDK_PROTOCOL_VERSION_LATEST: SdkProtocolVersion; declare const CLIENT_PROTOCOL_VERSION_LATEST: ClientProtocolVersion; declare function createSdkMessageCodecForVersion({ sdkProtocolVersion, gameId, sessionId, dictionary, logger, }: { sdkProtocolVersion: SdkProtocolVersion; gameId: GameId; sessionId: SessionId | null; dictionary: string[]; logger: SdkMessageDecodingLogger; }): SdkMessageCodec; declare function createClientMessageCodecForVersion(clientProtocolVersion: ClientProtocolVersion): ClientMessageCodec; export { CLIENT_PROTOCOL_VERSION_LATEST, CLIENT_PROTOCOL_VERSION_RUNE_MSG, CLIENT_PROTOCOL_VERSION_SIMPLE_JSON, ClientProtocolVersion, SDK_PROTOCOL_VERSION_LATEST, SDK_PROTOCOL_VERSION_NEW_HEADER, SDK_PROTOCOL_VERSION_RUNE_MSG, SDK_PROTOCOL_VERSION_WITH_COMPRESSION, SdkProtocolVersion, createClientMessageCodecForVersion, createSdkMessageCodecForVersion };