/** * Sweetlink WebSocket Server * * Main server module that handles WebSocket connections and message routing. */ import { type Server as HttpServer } from 'http'; import type { Server as HttpsServer } from 'https'; import { WebSocketServer } from 'ws'; import type { ConsoleLog, HmrScreenshotData, RecordStartCommand, SweetlinkCommand, SweetlinkResponse } from '../types.js'; export type { ConsoleLog, HmrScreenshotData, SweetlinkCommand, SweetlinkResponse }; /** * Get the project root directory (where the server was started) * This is captured at server initialization time for consistency */ export declare function getProjectRoot(): string; export interface InitSweetlinkOptions { port: number; /** Number of alternative ports to try if the primary port is in use (default: 10) */ maxPortRetries?: number; /** Called when server starts successfully with the actual port */ onReady?: (port: number) => void; /** The port of the associated dev server (e.g., Next.js port). Used to validate browser connections. */ appPort?: number; /** Override the app name (default: auto-detected from package.json) */ appName?: string; /** Existing app server to expose a same-origin WebSocket endpoint on. */ appServer?: HttpServer | HttpsServer; /** Path for the same-origin WebSocket endpoint. Default: /__sweetlink */ wsPath?: string; } /** * Initialize Sweetlink WebSocket server * Automatically tries alternative ports if the specified port is in use */ export declare function initSweetlink(options: InitSweetlinkOptions): Promise; /** Get the port the server is running on */ export declare function getSweetlinkPort(): number | null; /** Get the associated app port */ export declare function getAssociatedAppPort(): number | null; /** Get the detected git branch */ export declare function getGitBranch(): string | undefined; /** Get the app name */ export declare function getAppName(): string | undefined; /** * Allow-list the record-start params that may cross the browser→daemon WS * boundary. The daemon HTTP API also honors `storageState` (a daemon-side * auth-replay file path) and `trace`, but those must stay CLI/HTTP-only and * never be reachable from a browser origin — so only `label`/`viewport` are * forwarded, even if a caller sends more. Returns `undefined` when there's * nothing forwardable (so the daemon sees an empty params object). */ export declare function pickForwardableRecordParams(command: RecordStartCommand): Record | undefined; export declare function closeSweetlink(): Promise; //# sourceMappingURL=index.d.ts.map