import { MapStreamDefinition } from '@rpgjs/common'; import { RpgServer } from './RpgServer'; import { RpgPlayer } from './Player/Player'; import { RpgMap } from './rooms/map'; export interface ServerMapStreamingOptions { /** Chunks sent around the authoritative player position. Defaults to 2. */ loadRadius?: number; /** Chunks retained client-side to avoid churn at grid boundaries. Defaults to 3. */ retainRadius?: number; } /** Adapter that compiles a private source map into serializable public chunks. */ export interface ServerMapStreamingAdapter { /** Compile private authoritative map data into client-safe public chunks. */ compile(mapData: TMapData, map: RpgMap): MapStreamDefinition | undefined | Promise | undefined>; } export type MapStreamingVisibleEntityIds = { players: Set; events: Set; }; export declare function installMapStreaming(map: RpgMap, definition: MapStreamDefinition, options?: ServerMapStreamingOptions): void; export declare function clearMapStreaming(map: RpgMap): void; export declare function refreshMapStreaming(map: RpgMap): void; export declare function removeMapStreamingPlayer(map: RpgMap, player: RpgPlayer): void; /** Send a fresh manifest and initial chunks after the room attaches a connection. */ export declare function sendInitialMapStreaming(map: RpgMap, player: RpgPlayer): void; /** Whether this concrete room instance has compiled authoritative chunks. */ export declare function hasMapStreamingRuntime(map: RpgMap): boolean; export declare function isMapStreamingPositionVisible(map: RpgMap, player: RpgPlayer, x: number, y: number): boolean; /** Resolve nearby synchronized entities through the map physics spatial index. */ export declare function getMapStreamingVisibleEntityIds(map: RpgMap, player: RpgPlayer): MapStreamingVisibleEntityIds | undefined; export declare function filterMapStreamingProjectilePacket(map: RpgMap, player: RpgPlayer, packet: any): any; /** * Install a format adapter that streams map render and prediction data from the * authoritative room. It is transport-neutral and therefore behaves the same on * the Node.js room adapter and on a Cloudflare Durable Object. * * @param adapter - Server compiler for the installed map format. * @param options - Interest and retention radii expressed in chunks. * @returns A composable server module installed with `createServer()`. * * @example * ```ts * provideServerMapStreaming({ * compile(mapData) { * return compileMyPrivateMap(mapData) * }, * }, { loadRadius: 2, retainRadius: 3 }) * ``` */ export declare function provideServerMapStreaming(adapter: ServerMapStreamingAdapter, options?: ServerMapStreamingOptions): RpgServer;