({
stdout = process.stdout,
stdin = process.stdin,
stderr = process.stderr,
exitOnCtrlC = true,
patchConsole = true,
onFrame,
}: RenderOptions = {})
| 127 | * Like react-dom's createRoot — call root.render() to mount a tree. |
| 128 | */ |
| 129 | export async function createRoot({ |
| 130 | stdout = process.stdout, |
| 131 | stdin = process.stdin, |
| 132 | stderr = process.stderr, |
| 133 | exitOnCtrlC = true, |
| 134 | patchConsole = true, |
| 135 | onFrame, |
| 136 | }: RenderOptions = {}): Promise<Root> { |
| 137 | // See wrappedRender — preserve microtask boundary from the old WASM await. |
| 138 | await Promise.resolve() |
| 139 | const instance = new Ink({ |
| 140 | stdout, |
| 141 | stdin, |
| 142 | stderr, |
| 143 | exitOnCtrlC, |
| 144 | patchConsole, |
| 145 | onFrame, |
| 146 | }) |
| 147 | |
| 148 | // Register in the instances map so that code that looks up the Ink |
| 149 | // instance by stdout (e.g. external editor pause/resume) can find it. |
| 150 | instances.set(stdout, instance) |
| 151 | |
| 152 | return { |
| 153 | render: node => instance.render(node), |
| 154 | unmount: () => instance.unmount(), |
| 155 | waitUntilExit: () => instance.waitUntilExit(), |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | const getOptions = ( |
| 160 | stdout: NodeJS.WriteStream | RenderOptions | undefined = {}, |
nothing calls this directly
no test coverage detected