import type { Readable, Writable } from 'node:stream'; import { type TZurk, type TZurkPromise, type TZurkOptions, type TZurkCtx } from './zurk.ts'; import { type Promisified, type TVoidCallback, type TQuote } from './util.ts'; /** * @module * * Zurk $ API * * @example * ```ts * import {$} from 'zurk/x' * * const p = await $`echo foo`' * ``` */ export interface TShellCtxExtra { } export interface TShellExtra { } export interface TShellOptionsExtra { timeout?: number; timeoutSignal?: NodeJS.Signals; } export interface TShellResponseExtra { pipe(shell: T): T; pipe(stream: Writable): Writable; pipe(pieces: TemplateStringsArray, ...args: any[]): T; kill(signal?: NodeJS.Signals | null): Promise; abort(): void; timeout?: number; timeoutSignal?: NodeJS.Signals; } export interface TShellCtx extends TZurkCtx, TShellCtxExtra { timer?: number | NodeJS.Timeout; timeout?: number; timeoutSignal?: NodeJS.Signals; } export type TShellOptions = Omit & { quote?: TQuote; input?: TShellCtx['input'] | TShellResponse | TShellResponseSync | null; } & TShellOptionsExtra; export interface TShellResponse extends Omit, 'stdio' | 'ctx' | 'child'>, Promise>, TShellResponseExtra { child: TZurk['child']; stdio: [Readable | Writable, Writable, Writable]; ctx: TShellCtx; on: (event: string | symbol, listener: TVoidCallback) => TShellResponse; } export interface TShellResponseSync extends TZurk, TShellResponseExtra { } export type TMixin = (($: TShell, target: TShellOptions) => TShellOptions | TZurk | TZurkPromise) | (($: TShell, target: TZurk, ctx: TShellCtx) => TZurk) | (($: TShell, target: Promise | TZurkPromise, ctx: TShellCtx) => TZurkPromise); export interface TShell extends TShellExtra { mixins: TMixin[]; (this: O, pieces?: TemplateStringsArray, ...args: any[]): TShellResponse; (this: O, pieces?: TemplateStringsArray, ...args: any[]): R; (opts: O): R; } export interface TShellSync { (this: O, pieces?: TemplateStringsArray, ...args: any[]): TShellResponseSync; (opts: TShellOptions): TShellSync; } /** * Zurk $ template API * * @param pieces * @param args */ export declare const $: TShell; /** * Applies mixins to the result. * @param $ * @param result * @param parent * @returns TZurk | TZurkPromise | TShellOptions */ export declare const applyMixins: ($: TShell, result: TZurk | TZurkPromise | TShellOptions, parent?: TZurk | TZurkPromise) => TZurk | TZurkPromise | TShellOptions;