import { RuntimeAdapter } from "./adapter.mjs"; //#region src/runtime/deno.d.ts /** * Minimal subset of the Deno namespace needed by the adapter. * * We avoid `@types/deno` to keep the core runtime-agnostic at the type level. * This interface declares only what `createDenoAdapter` actually reads. * * The `env` property is optional because it requires `--allow-env` permission. * When permission is denied, the adapter catches the error and falls back to * an empty env object. */ interface DenoNamespace { /** Build target metadata (OS detection). */ readonly build: { readonly os: 'darwin' | 'linux' | 'android' | 'windows' | 'freebsd' | 'netbsd' | 'aix' | 'solaris' | 'illumos'; }; /** Deno version info — used for minimum-version guard. */ readonly version?: { readonly deno?: string; }; /** Raw command-line args (excludes the binary/script — Deno pre-strips them). */ readonly args: readonly string[]; /** Environment variable access (requires `--allow-env`). */ readonly env: { /** Get a single env var. Returns `undefined` if unset or permission denied. */ get(key: string): string | undefined; /** Get all env vars as a plain object. Throws on permission denied. */ toObject(): Record; }; /** Current working directory (may throw if `--allow-read` is denied for cwd). */ cwd(): string; /** Standard output — synchronous byte writer with TTY detection. */ readonly stdout: { /** Write raw bytes to stdout synchronously. */ writeSync(p: Uint8Array): number; /** Whether stdout is connected to a TTY. */ isTerminal(): boolean; }; /** Current console dimensions. */ consoleSize?(): { readonly columns: number; readonly rows: number; }; /** Register a native signal listener. */ addSignalListener?(signal: 'SIGWINCH', listener: () => void): void; /** Remove a native signal listener. */ removeSignalListener?(signal: 'SIGWINCH', listener: () => void): void; /** Standard error — synchronous byte writer. */ readonly stderr: { /** Write raw bytes to stderr synchronously. */ writeSync(p: Uint8Array): number; }; /** Standard input — TTY detection and readable byte stream. */ readonly stdin: { /** Whether stdin is connected to a TTY. */ isTerminal(): boolean; /** Readable stream for stdin bytes. */ readonly readable: ReadableStream; }; /** Exit the process with the given code. */ exit(code: number): never; /** Read a file as UTF-8 text (requires `--allow-read`). */ readTextFile(path: string): Promise; /** Probe a filesystem path (requires `--allow-read`). */ stat(path: string): Promise<{ readonly isDirectory: boolean; }>; /** Create a directory (requires `--allow-write`). */ mkdir(path: string, options?: { readonly recursive?: boolean; }): Promise; } /** * Create a runtime adapter backed by the Deno namespace. * * Reads `Deno.args`, `Deno.env`, `Deno.cwd()`, and wraps Deno's stream-based * I/O into the {@linkcode WriteFn}/{@linkcode ReadFn} functions expected by the framework. * * Unlike Node/Bun, Deno strips the binary and script path from `Deno.args`. * The adapter prepends synthetic entries (`['deno', 'run']`) so the argv * shape matches the {@linkcode RuntimeAdapter} contract (binary + script + user args). * * @param ns - Override the Deno namespace (useful for testing the adapter itself). * @returns A {@linkcode RuntimeAdapter} backed by Deno's namespace APIs. * * @example * ```ts * import { cli } from '@kjanat/dreamcli'; * import { createDenoAdapter } from '@kjanat/dreamcli/runtime'; * * cli('mycli') * .command(deploy) * .run({ adapter: createDenoAdapter() }); * ``` */ declare function createDenoAdapter(ns?: DenoNamespace): RuntimeAdapter; //#endregion export { type DenoNamespace, createDenoAdapter };