colyseus
Version:
Multiplayer Framework for Node.js
49 lines (48 loc) • 1.8 kB
TypeScript
import { type RoomDefinitions, type ServerOptions, type Transport, type Router } from '@colyseus/core';
import type { Plugin } from 'vite';
export interface ColyseusViteOptions {
serverEntry: string;
port?: number;
quiet?: boolean;
/**
* Serve the built client files via express.static() in the production
* server entry. Adds a SPA fallback that serves index.html for
* unmatched GET requests.
*
* Has no effect in dev mode (Vite serves the frontend).
*/
serveClient?: boolean;
loadWsTransport?: () => Promise<{
WebSocketTransport: new (options?: any) => Transport & {
attachToServer(server: any, options?: {
filter?: (req: any) => boolean;
}): any;
};
}>;
/**
* HTTP server to attach the WebSocket transport to.
*
* Required when running Vite in middleware mode (`server.middlewareMode`),
* where the HTTP server is owned by the parent process (e.g. Express).
* In standalone Vite dev mode this is ignored — the plugin uses Vite's
* own HTTP server.
*/
httpServer?: import('http').Server;
}
type ServerConfig = {
options?: ServerOptions;
router?: Router;
'~rooms'?: RoomDefinitions;
};
/**
* Production build entry — standalone server that imports the user's
* server entry and calls `server.listen()`.
*/
export declare function createColyseusViteServerEntry(options: ColyseusViteOptions): string;
export declare function reloadColyseusViteRooms(importModule: (specifier: string) => Promise<any>, serverEntry: string, currentRoomNames?: string[]): Promise<{
roomNames: string[];
hasRooms: boolean;
server: ServerConfig;
}>;
export declare function colyseus(options: ColyseusViteOptions): Plugin[];
export {};