UNPKG

1.84 kBTypeScriptView Raw
1/// <reference types="node" />
2import { ReactElement } from 'react';
3import Ink from './ink';
4export interface RenderOptions {
5 /**
6 * Output stream where app will be rendered.
7 *
8 * @default process.stdout
9 */
10 stdout?: NodeJS.WriteStream;
11 /**
12 * Input stream where app will listen for input.
13 *
14 * @default process.stdin
15 */
16 stdin?: NodeJS.ReadStream;
17 /**
18 * Error stream.
19 * @default process.stderr
20 */
21 stderr?: NodeJS.WriteStream;
22 /**
23 * If true, each update will be rendered as a separate output, without replacing the previous one.
24 *
25 * @default false
26 */
27 debug?: boolean;
28 /**
29 * Configure whether Ink should listen to Ctrl+C keyboard input and exit the app. This is needed in case `process.stdin` is in raw mode, because then Ctrl+C is ignored by default and process is expected to handle it manually.
30 *
31 * @default true
32 */
33 exitOnCtrlC?: boolean;
34 /**
35 * Patch console methods to ensure console output doesn't mix with Ink output.
36 *
37 * @default true
38 */
39 patchConsole?: boolean;
40}
41export interface Instance {
42 /**
43 * Replace previous root node with a new one or update props of the current root node.
44 */
45 rerender: Ink['render'];
46 /**
47 * Manually unmount the whole Ink app.
48 */
49 unmount: Ink['unmount'];
50 /**
51 * Returns a promise, which resolves when app is unmounted.
52 */
53 waitUntilExit: Ink['waitUntilExit'];
54 cleanup: () => void;
55 /**
56 * Clear output.
57 */
58 clear: () => void;
59}
60declare type RenderFunction = <Props, K extends NodeJS.WriteStream | RenderOptions>(tree: ReactElement<Props>, options?: K) => Instance;
61/**
62 * Mount a component and render the output.
63 */
64declare const render: RenderFunction;
65export default render;