import { WriteStream } from "tty" ; import { Token , TokenDict } from "../token" ; import { ProgressBarState } from "../ProgressBar" ; import { MultiProgressBarRenderer , ProgressBarRenderer } from "./ProgressBarRenderer" ; export class TTYProgressBarRenderer extends ProgressBarRenderer { constructor ( template , tokens , public readonly stream ) { super ( template , tokens ) ; } public render ( bar ) { if ( ! this . stream . isTTY ) return ; this . stream . cursorTo ( 0 ) ; this . stream . write ( this . makeString ( bar ) ) ; this . stream . clearLine ( 1 ) ; } } export class TTYMultiProgressBarRenderer extends MultiProgressBarRenderer { constructor ( template , tokens , bars , public readonly stream ) { super ( template , tokens , bars ) ; } public render ( bar ) { if ( ! this . stream . isTTY ) return ; const index = this . indexOfBar ( bar ) ; if ( index === - 1 ) return ; this . stream . cursorTo ( 0 , index ) ; this . stream . write ( this . makeString ( bar ) ) ; this . stream . clearLine ( 1 ) ; } }