ink

  • Version 8.0.0
  • Published
  • 620 kB
  • 23 dependencies
  • MIT license

Install

npm i ink
yarn add ink
pnpm add ink

Overview

React for CLI

Index

Variables

variable homeAndEraseDown

const homeAndEraseDown: string;

    Classes

    class Ink

    class Ink {}

      constructor

      constructor(options: Options);

        property calculateLayout

        calculateLayout: () => void;

          property handleAppExit

          handleAppExit: (errorOrResult?: unknown) => void;

            property handleKittyQueryResponse

            handleKittyQueryResponse: () => void;

              property handleStaticChange

              handleStaticChange: () => void;

                property isConcurrent

                readonly isConcurrent: boolean;
                • Whether this instance is using concurrent rendering mode.

                property onRender

                onRender: () => void;

                  property rejectExitPromise

                  rejectExitPromise: (reason?: Error) => void;

                    property resized

                    resized: () => void;

                      property resolveExitPromise

                      resolveExitPromise: (result?: unknown) => void;

                        property restoreLastOutput

                        restoreLastOutput: () => void;

                          property setCursorPosition

                          setCursorPosition: (position: CursorPosition | undefined) => void;

                            property unsubscribeExit

                            unsubscribeExit: () => void;

                              method clear

                              clear: () => void;

                                method patchConsole

                                patchConsole: () => void;

                                  method registerInputControl

                                  registerInputControl: (pauseInput: () => void, resumeInput: () => void) => void;

                                    method render

                                    render: (node: ReactNode) => void;

                                      method suspendTerminal

                                      suspendTerminal: {
                                      (callback: () => void | Promise<void>): Promise<void>;
                                      (): Promise<TerminalSuspension>;
                                      };

                                        method unmount

                                        unmount: (error?: Error | number | null) => void;

                                          method waitUntilExit

                                          waitUntilExit: () => Promise<unknown>;

                                            method waitUntilRenderFlush

                                            waitUntilRenderFlush: () => Promise<void>;

                                              method writeToStderr

                                              writeToStderr: (data: string) => void;

                                                method writeToStdout

                                                writeToStdout: (data: string) => void;

                                                  Type Aliases

                                                  type Options

                                                  type Options = {
                                                  stdout: OutputStream;
                                                  stdin: NodeJS.ReadableStream;
                                                  stderr: OutputStream;
                                                  debug: boolean;
                                                  exitOnCtrlC: boolean;
                                                  patchConsole: boolean;
                                                  onRender?: (metrics: RenderMetrics) => void;
                                                  isScreenReaderEnabled?: boolean;
                                                  waitUntilExit?: () => Promise<unknown>;
                                                  maxFps?: number;
                                                  incrementalRendering?: boolean;
                                                  /**
                                                  Enable React Concurrent Rendering mode.
                                                  When enabled:
                                                  - Suspense boundaries work correctly with async data
                                                  - `useTransition` and `useDeferredValue` are fully functional
                                                  - Updates can be interrupted for higher priority work
                                                  Note: Concurrent mode changes the timing of renders. Some tests may need to use `act()` to properly await updates. Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change the rendering mode or create a fresh instance.
                                                  @default false
                                                  @experimental
                                                  */
                                                  concurrent?: boolean;
                                                  kittyKeyboard?: KittyKeyboardOptions;
                                                  /**
                                                  Override automatic interactive mode detection.
                                                  By default, Ink detects whether the environment is interactive based on CI detection (via [`is-in-ci`](https://github.com/sindresorhus/is-in-ci)) and `stdout.isTTY`. Most users should not need to set this.
                                                  When non-interactive, Ink disables ANSI erase sequences, cursor manipulation, synchronized output, resize handling, and kitty keyboard auto-detection, writing only the final frame at unmount.
                                                  Set to `false` to force non-interactive mode or `true` to force interactive mode when the automatic detection doesn't suit your use case.
                                                  Note: Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change this option or create a fresh instance.
                                                  @default true (false if in CI or `stdout.isTTY` is falsy)
                                                  @see {@link RenderOptions.interactive}
                                                  */
                                                  interactive?: boolean;
                                                  /**
                                                  Render the app in the terminal's alternate screen buffer. When enabled, the app renders on a separate screen, and the original terminal content is restored when the app exits. This is the same mechanism used by programs like vim, htop, and less.
                                                  Note: The terminal's scrollback buffer is not available while in the alternate screen. This is standard terminal behavior; programs like vim use the alternate screen specifically to avoid polluting the user's scrollback history.
                                                  Note: Ink intentionally treats alternate-screen teardown output as disposable. It does not preserve or replay teardown-time frames, hook writes, or `console.*` output after restoring the primary screen.
                                                  Only works in interactive mode. Ignored when `interactive` is `false` or in a non-interactive environment (CI, piped stdout).
                                                  Note: Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change this option or create a fresh instance.
                                                  @default false
                                                  @see {@link RenderOptions.alternateScreen}
                                                  */
                                                  alternateScreen?: boolean;
                                                  };

                                                    type RenderMetrics

                                                    type RenderMetrics = {
                                                    /**
                                                    Time spent rendering in milliseconds.
                                                    */
                                                    renderTime: number;
                                                    };
                                                    • Performance metrics for a render operation.

                                                    Package Files (1)

                                                    Dependencies (23)

                                                    Dev Dependencies (30)

                                                    Peer Dependencies (3)

                                                    Badge

                                                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/ink.

                                                    • Markdown
                                                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/ink)
                                                    • HTML
                                                      <a href="https://www.jsdocs.io/package/ink"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>