import LazilyLoadedRoute from './LazilyLoadedRoute.ts'; import type { NextHandler } from 'polka'; import type { KittenRequest, KittenResponse, WebSocket } from '../types/index.ts'; type WebSocketWithIsAlive = WebSocket & { isAlive: boolean; id?: string; }; type RequestWithWebSocket = KittenRequest & { ws?: () => Promise; }; export default class PageSocketRoute extends LazilyLoadedRoute { sockets: WebSocketWithIsAlive[]; eventHandlers: Record any>; initialised: boolean; /** Create a lazily-loaded PageSocket route instance with the provided file path. (A PageSocket route is a specialised WebSocket route that simplifies streaming updates ot the page it is connected to.) */ constructor(filePath: string, basePath: string); /** Lazily load the handler. Unlike in other route types, we’re not loading in the default export here (our _handler() function is already defined, below) but the exported `onConnect()` function from a page route. */ lazilyLoadedHandler(request: RequestWithWebSocket, response: KittenResponse, next?: NextHandler): Promise; /** This is a specialised WebSocket route handler specifically for routing to an `onConnect()` handler exported from a page. TODO: Remove redundancy with routes/WebSocketRoute.js */ _handler({ request, next }: { request: RequestWithWebSocket; next?: NextHandler; [key: string]: any; }): Promise; } export {};