/** * This library enables a tool to display live console output from multiple concurrent processes, * while ensuring that their output does not get jumbled together. * * @remarks * * For more info, please see the package {@link https://www.npmjs.com/package/@rushstack/stream-collator * | README}. * * @packageDocumentation */ import { ITerminalChunk } from '@rushstack/terminal'; import { TerminalWritable } from '@rushstack/terminal'; /** * This API was introduced as a temporary measure. * @deprecated Very soon we plan to replace this with the `Terminal` API from `@rushstack/node-core-library`. * @beta */ export declare class CollatedTerminal { private readonly _destination; constructor(destination: TerminalWritable); writeChunk(chunk: ITerminalChunk): void; writeStdoutLine(message: string): void; writeStderrLine(message: string): void; } /** * An writable interface for managing output of simultaneous processes. * * @beta */ export declare class CollatedWriter extends TerminalWritable { private readonly _collator; private readonly _bufferedChunks; readonly taskName: string; readonly terminal: CollatedTerminal; constructor(taskName: string, collator: StreamCollator); /** * Returns true if this is the active writer for its associated {@link StreamCollator}. */ get isActive(): boolean; /** * For diagnostic purposes, if the writer is buffering chunks because it has * not become active yet, they can be inspected via this property. */ get bufferedChunks(): ReadonlyArray; /** {@inheritDoc @rushstack/terminal#TerminalWritable.onWriteChunk} */ onWriteChunk(chunk: ITerminalChunk): void; /** {@inheritDoc @rushstack/terminal#TerminalWritable.onClose} */ onClose(): void; /** @internal */ _flushBufferedChunks(): void; } /** * Constructor options for {@link StreamCollator}. * * @beta */ export declare interface IStreamCollatorOptions { /** * The target {@link @rushstack/terminal#TerminalWritable} object that the * {@link StreamCollator} will write its output to. */ destination: TerminalWritable; /** * An event handler that is called when a {@link CollatedWriter} becomes output, * before any of its chunks have been written to the destination. * * @remarks * * Each `CollatedWriter` object will become active exactly once * before the `StreamCollator` completes. */ onWriterActive?: (writer: CollatedWriter) => void; } /** * A static class which manages the output of multiple threads. * * @beta */ export declare class StreamCollator { private _taskNames; private _writers; private _activeWriter; private _openInactiveWriters; private _closedInactiveWriters; private _onWriterActive; private _preventReentrantCall; readonly destination: TerminalWritable; readonly terminal: CollatedTerminal; constructor(options: IStreamCollatorOptions); /** * Returns the currently active `CollatedWriter`, or `undefined` if no writer * is active yet. */ get activeWriter(): CollatedWriter | undefined; /** * For diagnostic purposes, returns the {@link CollatedWriter.taskName} for the * currently active writer, or an empty string if no writer is active. */ get activeTaskName(): string; /** * The list of writers that have been registered by calling {@link StreamCollator.registerTask}, * in the order that they were registered. */ get writers(): ReadonlySet; /** * Registers a new task to be collated, and constructs a {@link CollatedWriter} object * to receive its input. */ registerTask(taskName: string): CollatedWriter; /** @internal */ _writerWriteChunk(writer: CollatedWriter, chunk: ITerminalChunk, bufferedChunks: ITerminalChunk[]): void; /** @internal */ _writerClose(writer: CollatedWriter, bufferedChunks: ITerminalChunk[]): void; private _assignActiveWriter; private _checkForReentrantCall; } export { }