import type { Vec3 } from './multiplayer-contract/index.js'; /** A guarded view over one declared vars bag. Safe before the first patch (fallbacks, never throws). */ export interface VarsView { /** A declared number var; `fallback` (default 0) before the first patch or when absent. */ num(name: string, fallback?: number): number; /** A declared string var; `fallback` (default '') when absent. Refs read as the referenced session/entity id. */ str(name: string, fallback?: string): string; /** A declared boolean var; `fallback` (default false) when absent. */ bool(name: string, fallback?: boolean): boolean; /** A declared vec3 var (e.g. a saved checkpoint), or null when absent. */ vec3(name: string): Vec3 | null; /** * A declared list var, materialized to a real Array each call (an ArraySchema is iterable but NOT an * Array). Elements are the LIVE synced values — index/read them fresh, don't cache across frames. */ list(name: string): T[]; /** The raw declared value, unconverted (escape hatch for declared names — transport keys stay hidden). */ raw(name: string): unknown; /** Whether the declared var currently has a synced value (false before the first patch). */ has(name: string): boolean; /** The logical declared var names currently synced on the bag (transport chunk containers excluded). */ names(): string[]; } type VarsBag = Record | null | undefined; /** Build a VarsView over a live bag getter — `source()` is re-read on every access (live semantics). */ export declare function createVarsView(source: () => VarsBag): VarsView; type PlayerBag = { vars?: Record; } | undefined; type EntityBag = { vars?: Record; } | undefined; type KeyedBag = { get(id: string): T | undefined; forEach?: (cb: (value: T, key: string) => void) => void; } | Record; export interface AccessorModuleState { roomVars?: Record; players?: KeyedBag; entities?: KeyedBag; phase?: string; timerDeadlines?: KeyedBag; } /** Fixed reflected wire for modules installed after room creation. Only public scalar room vars cross it. */ export interface AccessorDynamicModuleState { booleans?: KeyedBag; numbers?: KeyedBag; strings?: KeyedBag; phase?: string; externalRevision?: number; } /** The room-level state slice the accessors read (structural — the live RoomState satisfies it). * Live state holds `players` as a MapSchema (Map-like, `.get()`); plain Records are admitted for fixtures. */ export interface AccessorRoomState { roomVars?: Record; players?: { get(id: string): PlayerBag; } | Record; phase?: string; modules?: Record; /** Overflow modules follow the first 64 slots in consecutive c0, c1, ... wire chunks. */ moduleChunks?: Record | undefined>; dynamicModules?: KeyedBag; } export interface ModuleAccessors { readonly moduleId: string; /** Module-local room vars. */ vars: VarsView; /** This client's module-local player vars. */ me: VarsView; /** Another player's module-local vars. */ player(id: string): VarsView; /** One module-local entity's declared vars. */ entity(id: string): VarsView; /** Module-local state-machine phase. */ phase(): string; /** Absolute module-local timer deadline, or 0 while absent/sleeping. */ timerDeadline(name: string, key?: string): number; } export interface RoomAccessors { /** Declared room-level vars (`multiplayer.state.roomVars`). */ vars: VarsView; /** MY declared player vars — a live view over `players[sessionId].vars`. */ me: VarsView; /** Any player's declared vars by session id (safe for ids not yet/no longer present). */ player(id: string): VarsView; /** The room state machine's current phase ('' when the world declares no `states`). */ phase(): string; /** The session id whose turn it is, off the `turnOrder`/`turnIndex` roomVars convention ('' when unused). */ currentTurn(): string; /** Whether it's THIS client's turn (the turn-order convention; always false when unused). */ isMyTurn(): boolean; /** Live, guarded access to one module instance. Local ids never escape this provenance boundary. */ module(moduleId: string): ModuleAccessors; } /** Build a guarded module-instance view over the flat and overflow module wire fields. */ export declare function createModuleAccessors(sessionId: string, moduleId: string, state: () => AccessorRoomState | null | undefined): ModuleAccessors; /** Build the room-level accessor set over a live state getter + this client's session id. */ export declare function createRoomAccessors(sessionId: string, state: () => AccessorRoomState | null | undefined): RoomAccessors; export {};