/** * ContainerMirror — the client half of the platform's **notify-to-pull** * pattern for game-model state: keep typed snapshots of the containers you * care about, re-pull them on demand or whenever a bound channel pings * ("state changed"), and render straight from the cache. * * Model changes are pull-based on this platform (there is no model * subscription); functions declare channel/spatial notifications and clients * re-read. The Game Kit's match layer pings a per-match channel — bind the * mirror to that channel and every watched container refreshes itself. */ import type { WorldSessionContext } from './session.js'; /** A typed snapshot of one watched container. */ export interface MirroredContainer> { readonly containerId: string; typeName: string; displayName: string; ownerUserId: string | null; /** The parsed, caller-visible properties. */ value: T; /** Bumped on every refresh that changed the snapshot. */ revision: number; /** Local time of the last refresh. */ refreshedAt: number; } /** Options for {@link attachContainerMirror}. */ export interface ContainerMirrorConfig { /** Clock override for tests. Defaults to `Date.now`. */ now?: () => number; } /** * The SDK-managed **model mirror**: typed, cached snapshots of watched * game-model containers with coalesced refresh and channel-ping binding. * Reads are synchronous ({@link get}); {@link onChange} fires only when a * refresh actually changed the visible state. */ export declare class ContainerMirror { private readonly ctx; private readonly watches; private readonly listeners; private readonly boundChannels; private readonly now; private refreshing; private refreshQueued; constructor(ctx: WorldSessionContext, config?: ContainerMirrorConfig); /** * Watch a container: fetches the initial snapshot and keeps it refreshable. * `parse` maps the visible properties object to your type (defaults to the * raw object). */ watch>(containerId: string, parse?: (properties: Record) => T): Promise>; /** Stop watching a container (its snapshot is dropped). */ unwatch(containerId: string): void; /** The current snapshot of a watched container (undefined before watch resolves). */ get>(containerId: string): MirroredContainer | undefined; /** Every watched snapshot. */ list(): Array>; /** * Subscribe to snapshot changes — every watched container, or one * `containerId`. Fires only when a refresh changed the visible state. * @returns off. */ onChange(handler: (container: MirroredContainer) => void, containerId?: string): () => void; /** * Bind a channel: any message on it triggers a coalesced {@link refreshAll} * — pair with model functions that declare channel notifications (e.g. the * Game Kit's `match_changed` pings). */ bindToChannel(channelId: string): () => void; /** Re-pull one watched container now. */ refresh(containerId: string): Promise; /** * Re-pull every watched container. Concurrent calls coalesce: a refresh * requested while one is running queues exactly one follow-up pass (pings * can burst; state converges without stampeding the API). */ refreshAll(): Promise; } /** Attach a {@link ContainerMirror}. Prefer the `model` config key. */ export declare function attachContainerMirror(ctx: WorldSessionContext, config?: ContainerMirrorConfig): ContainerMirror; //# sourceMappingURL=model.d.ts.map