File size: 681 Bytes
7e3630c f73174f 7e3630c f73174f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | import { createContext, useContext } from 'react'
export type Props = {
readonly stdout: NodeJS.WriteStream & { readonly rows: number; readonly columns: number }
/**
* Write any string to stdout while preserving Ink's output.
* Useful for emitting raw escape sequences (e.g. image protocols)
* outside of Ink's normal render loop.
*/
readonly write: (data: string) => void
}
const StdoutContext = createContext<Props>({
stdout: process.stdout as NodeJS.WriteStream & { rows: number; columns: number },
write() {},
})
StdoutContext.displayName = 'StdoutContext'
export default StdoutContext
export function useStdout(): Props {
return useContext(StdoutContext)
}
|