/** * Runtime detection and capability checking primitive. * This is the foundation for all environment-specific behavior. * * All utilities should use this module instead of directly checking * for process, window, Deno, etc. */ /** * Thrown by `runtime.exit(code)` in environments without process exit * (i.e. browsers). Carries the requested exit code on `.exitCode` so * outer error handlers can still report it. */ export declare class ProcessExitError extends Error { readonly exitCode: number; constructor(code: number); } interface RuntimeCapabilities { readonly isBrowser: boolean; readonly isWorkerd: boolean; readonly isNode: boolean; readonly isDeno: boolean; readonly isBun: boolean; canExit(): boolean; canReadEnv(): boolean; canWriteEnv(): boolean; canFileSystem(): boolean; canNetwork(): boolean; canCrypto(): boolean; exit(code: number): never; env(key: string): string | undefined; setEnv(key: string, value: string): void; deleteEnv(key: string): void; hasEnv(key: string): boolean; allEnv(): Record; cwd(): string; entry(): string | undefined; stdout: { write(message: string): void; isTTY: boolean; }; stderr: { write(message: string): void; isTTY: boolean; }; } declare class RuntimeOps implements RuntimeCapabilities { readonly isBrowser: boolean; readonly isWorkerd: boolean; readonly isNode: boolean; readonly isDeno: boolean; readonly isBun: boolean; /** `process.env`: Node and Bun, and a Worker whose `nodejs_compat` puts its vars there. */ private get processEnv(); canExit(): boolean; canReadEnv(): boolean; canWriteEnv(): boolean; canFileSystem(): boolean; canNetwork(): boolean; canCrypto(): boolean; exit(code: number): never; env(key: string): string | undefined; setEnv(key: string, value: string): void; deleteEnv(key: string): void; hasEnv(key: string): boolean; allEnv(): Record; cwd(): string; /** * The program's entry: the script's path or URL, else the executable * (a REPL, `node -e`). undefined in browsers and Workers, which have none. */ entry(): string | undefined; get stdout(): { write: (message: string) => void; isTTY: boolean; }; get stderr(): { write: (message: string) => void; isTTY: boolean; }; } export declare const runtime: RuntimeOps; export type { RuntimeCapabilities }; //# sourceMappingURL=runtime.d.ts.map