@builder.io/dev-tools
Version:
Builder.io Visual CMS Devtools
106 lines (105 loc) • 2.77 kB
TypeScript
import { EventEmitter } from "node:events";
/**
* VS Code Tunnel status
*/
export type TunnelStatus = "stopped" | "starting" | "running" | "error";
/**
* VS Code Tunnel information
*/
export interface TunnelInfo {
status: TunnelStatus;
name: string | null;
url: string | null;
vscodeUri: string | null;
cursorUri: string | null;
webUrl: string | null;
error: string | null;
workspacePath: string;
}
/**
* Options for starting a VS Code tunnel
*/
export interface TunnelOptions {
name: string;
workspacePath?: string;
acceptLicense?: boolean;
autoRestart?: boolean;
}
/**
* VS Code Tunnel Manager
*
* Manages the lifecycle of a VS Code tunnel process, providing:
* - Start/stop functionality
* - URL parsing from CLI output
* - Health monitoring
* - Automatic restart on failure
* - Cleanup on shutdown
*/
export declare class VSCodeTunnelManager extends EventEmitter {
private process;
private status;
private tunnelName;
private tunnelUrl;
private error;
private workspacePath;
private autoRestart;
private restartAttempts;
private maxRestartAttempts;
private restartDelay;
private isShuttingDown;
constructor();
/**
* Start the VS Code tunnel
*/
start(options: TunnelOptions): Promise<TunnelInfo>;
private spawnTunnel;
/**
* Parse tunnel output to extract URL
*/
private parseOutput;
/**
* Stop the VS Code tunnel
*/
stop(): Promise<void>;
/**
* Get current tunnel information
*/
getInfo(): TunnelInfo;
/**
* Get tunnel status
*/
getStatus(): TunnelStatus;
/**
* Check if tunnel is enabled
* Enabled by default for cloud environments, can be disabled with VSCODE_TUNNEL_ENABLED=false
*/
static isEnabled(): boolean;
/**
* Check if auto-start is enabled
*/
static isAutoStartEnabled(): boolean;
/**
* Get the configured tunnel name from environment or generate one
*/
static getTunnelName(projectId?: string, branchName?: string): string;
/**
* Get the configured workspace path
*/
static getWorkspacePath(): string;
}
/**
* Get the singleton tunnel manager instance
*/
export declare function getTunnelManager(): VSCodeTunnelManager;
/**
* Generate VS Code deep link for a tunnel
*/
export declare function generateVSCodeDeepLink(tunnelName: string, workspacePath?: string): string;
/**
* Generate Cursor deep link for a tunnel
*/
export declare function generateCursorDeepLink(tunnelName: string, workspacePath?: string): string;
/**
* Generate web editor link for a tunnel
*/
export declare function generateWebEditorLink(tunnelName: string, workspacePath?: string): string;