import { Writable } from 'stream'; /** A $LESSOPEN replacement: its lines, byte size and alt file name. */ interface AltFile { lines: string[]; size: number; /** `-` for pipe preprocessors, the temp file name otherwise. */ alt: string; /** The preprocessor's output as it arrived, for the byte copy a * non-terminal session makes (less's cat_file reads the altpipe * through ch_forw_get, doing no line processing at all). */ raw: string; /** The pipe preprocessor's failure message, reported when the * file is LEFT (less's close_altfile, edit.c:288), not at open. */ preprocError?: string; } /** What a cat session gets back: the alt name for $LESSCLOSE, plus a * file to copy when the replacement is one. Nothing to copy means * the bytes already went out (or the "||" form found it empty). */ interface AltStream { alt: string; path?: string; empty?: boolean; preprocError?: string; } export declare function openAltFile(filename: string, input?: string): AltFile | null; /** * The $LESSOPEN pipe forms for a session that CATS its input. * * less keeps the popen stream open and reads through it as it copies * (open_altfile's returnfd branch hands edit_ifile the live FILE), * so the preprocessor is still running while its output is written - * which is why its own stderr lands interleaved rather than all in * front. Collecting the output first, as the display path must, gets * the bytes right and the order wrong, so this streams instead. * * The one-byte peek is less's: an empty pipe means no replacement, and * only then does the exit status decide between an EMPTY file (the * "||" form) and no alt file at all. * * @param filename - The file being opened. * @param out - Where the preprocessor's bytes go, verbatim. * @returns The replacement, or null to open the file itself. */ export declare function streamAltFile(filename: string, out: Writable): Promise; /** * Runs $LESSCLOSE when a preprocessed file is left, like filename.c's * close_altfile: the first %s is the original name, the second the * replacement. * * @param altName - The replacement name (`-` for pipes). * @param filename - The original file name. */ export declare function closeAltFile(altName: string, filename: string, preprocError?: string): void; export {};