export interface Listener { pid: number; port: number; } export interface ProcessDetails { cwd?: string; command?: string; } /** Runs a program and returns its stdout, also when it exits non-zero with output. */ export type RunCommand = (file: string, args: string[]) => Promise; export type Probe = "html" | "slow" | "http" | "none"; /** `lsof -nP -iTCP -sTCP:LISTEN -Fpn`: a `p` line, then `n` lines. */ export declare function parseLsofListeners(out: string): Listener[]; /** `ss -ltnpH`: `LISTEN 0 511 127.0.0.1:5173 0.0.0.0:* users:(("node",pid=42,fd=20))`. */ export declare function parseSsListeners(out: string): Listener[]; /** `netstat -ano`: `TCP 0.0.0.0:3000 0.0.0.0:0 LISTENING 1234`. The state word is translated, so a * listener is told by its foreign port 0. */ export declare function parseNetstatListeners(out: string): Listener[]; /** * Whether a process runs from inside `project`: its working directory is in it, * or its command line names a path in it (`node /work/app/node_modules/.bin/vite`). * A home folder or drive root is too broad to tell projects apart. */ export declare function belongsToProject(project: string, details: ProcessDetails, platform?: NodeJS.Platform, home?: string): boolean; export declare const runCommand: RunCommand; export interface FindServersOptions { platform?: NodeJS.Platform; run?: RunCommand; /** This process (the sidecar and its own previews) is never a dev server. */ selfPid?: number; } /** Ports of local servers running from inside `project`, lowest first. Never throws. */ export declare function findProjectServers(project: string, opts?: FindServersOptions): Promise; /** What answers on a local port: a web page, something slow to answer (a first compile), another * HTTP server (an API, or an error page), or nothing. */ export declare function probePort(port: number, timeoutMs?: number): Promise;