How vadimdemedes/ink works
Ink is a React renderer for terminal interfaces. A CLI supplies a React tree to the public render API; Ink reconciles components into a terminal-oriented tree, computes layout and output, then updates the terminal. The documented surface also includes input, focus, stream, accessibility, animation, and sizing hooks, plus static and transformed output. Edges are limited to README statements and source references or calls visible in the supplied excerpts; some unsampled runtime connections are therefore left out.
Main entry points: App.tsx App Contexts · index.ts Ink API · dom.ts Terminal Tree · ink.tsx Ink Instance
Components 22
Public API
- Ink API
src/index.ts - Render API
src/render.ts - String Rendering
src/render-to-string.ts - UI Components
src/components - React Hooks
src/hooks - Stdin Hook
src/hooks/use-stdin.ts
App Runtime
- App Contexts
src/components/App.tsx - Input Parsing
src/input-parser.ts - Key Parsing
src/parse-keypress.ts - Focus Management
src/components/FocusContext.ts
Tree and Layout
- React Reconciler
src/reconciler.ts - Terminal Tree
src/dom.ts - Yoga Layout
src/dom.ts - Output Rendering
src/render-node-to-output.ts - Output Model
src/output.ts
Terminal I/O
- Ink Instance
src/ink.tsx - Renderer Adapter
src/renderer.ts - Screen Updates
src/log-update.ts - Output Stream Context
src/components/StdoutContext.ts - Input Stream Context
src/components/StdinContext.ts - Raw Mode Stream
src/stream.ts
Other components
- CLI Application
Connections 21
- CLI Application → Ink API: uses
- Ink API → Render API: exports
src/index.ts - Ink API → String Rendering: exports
src/index.ts - Ink API → UI Components: exports
src/index.ts - Ink API → React Hooks: exports
src/index.ts - App Contexts → Input Parsing: parses input
src/components/App.tsx - App Contexts → Key Parsing: parses keys
src/components/App.tsx - Input Parsing → Key Parsing: delegates to
src/input-parser.ts - App Contexts → Input Stream Context: provides context
src/components/App.tsx - App Contexts → Output Stream Context: provides context
src/components/App.tsx - App Contexts → Focus Management: provides context
src/components/App.tsx - Stdin Hook → Input Stream Context: reads context
src/hooks/use-stdin.ts - React Hooks → Focus Management: manages focus
src/hooks/use-focus-manager.ts - React Reconciler → Terminal Tree: mutates tree
src/reconciler.ts - Terminal Tree → Yoga Layout: measures layout
src/dom.ts - Terminal Tree → Output Rendering: renders nodes
src/dom.ts - Output Rendering → Output Model: builds output
src/render-node-to-output.ts - Ink Instance → Renderer Adapter: invokes
src/ink.tsx - Ink Instance → Screen Updates: writes frames
src/ink.tsx - Screen Updates → Raw Mode Stream: writes to
src/log-update.ts - App Contexts → Raw Mode Stream: reads raw input
src/components/App.tsx