# @mwillbanks/tuil-cell

Source: /tuil/docs/reference/packages/cell
Locale: en

Pure Bun cell renderer with an explicit native diff profiling boundary.



## Overview [#overview]

Pure Bun cell renderer with an explicit native diff profiling boundary.

`@mwillbanks/tuil-cell` is independently installable and also participates in the
umbrella `@mwillbanks/tuil` runtime where applicable.

## Installation [#installation]

<CodeBlockTabs defaultValue="npm">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="npm">
      npm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="pnpm">
      pnpm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="yarn">
      yarn
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="bun">
      bun
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="npm">
    ```bash
    npm install @mwillbanks/tuil-cell
    ```
  </CodeBlockTab>

  <CodeBlockTab value="pnpm">
    ```bash
    pnpm add @mwillbanks/tuil-cell
    ```
  </CodeBlockTab>

  <CodeBlockTab value="yarn">
    ```bash
    yarn add @mwillbanks/tuil-cell
    ```
  </CodeBlockTab>

  <CodeBlockTab value="bun">
    ```bash
    bun add @mwillbanks/tuil-cell
    ```
  </CodeBlockTab>
</CodeBlockTabs>

## How it operates [#how-it-operates]

The cell backend composes grapheme-aware buffers, preserves wide-character continuation cells, diffs frames, and emits minimal ANSI output. The TypeScript path is the default. Zig prebuilds expose an explicit conformance and profiling prototype, and applications must opt in because the prototype does not replace the complete diff and encoding workload.

<Mermaid
  chart="flowchart LR
  S0[&#x22;compose buffer&#x22;]
  S1[&#x22;snapshot frame&#x22;]
  S2[&#x22;diff&#x22;]
  S3[&#x22;emit&#x22;]
  S4[&#x22;restore session&#x22;]
  S0 --> S1
  S1 --> S2
  S2 --> S3
  S3 --> S4"
/>

## API [#api]

| API                                                                                                 | Signature                                | Description                                    |
| --------------------------------------------------------------------------------------------------- | ---------------------------------------- | ---------------------------------------------- |
| [`Cell`](/tuil/docs/reference/packages/cell/api/cell)                                                    | `interface Cell`                         | Public interface Cell.                         |
| [`CellAccelerator`](/tuil/docs/reference/packages/cell/api/cell-accelerator)                             | `interface CellAccelerator`              | Public interface CellAccelerator.              |
| [`CellAttributes`](/tuil/docs/reference/packages/cell/api/cell-attributes)                               | `interface CellAttributes`               | Public interface CellAttributes.               |
| [`CellBuffer`](/tuil/docs/reference/packages/cell/api/cell-buffer)                                       | `class CellBuffer`                       | Public class CellBuffer.                       |
| [`CellFrame`](/tuil/docs/reference/packages/cell/api/cell-frame)                                         | `interface CellFrame`                    | Public interface CellFrame.                    |
| [`CellOutputMode`](/tuil/docs/reference/packages/cell/api/cell-output-mode)                              | `type CellOutputMode`                    | Public type CellOutputMode.                    |
| [`CellRendererBackend`](/tuil/docs/reference/packages/cell/api/cell-renderer-backend)                    | `class CellRendererBackend`              | Public class CellRendererBackend.              |
| [`CellRendererBackendOptions`](/tuil/docs/reference/packages/cell/api/cell-renderer-backend-options)     | `interface CellRendererBackendOptions`   | Public interface CellRendererBackendOptions.   |
| [`CellSceneNode`](/tuil/docs/reference/packages/cell/api/cell-scene-node)                                | `interface CellSceneNode`                | Public interface CellSceneNode.                |
| [`CellTree`](/tuil/docs/reference/packages/cell/api/cell-tree)                                           | `type CellTree`                          | Public type CellTree.                          |
| [`Color`](/tuil/docs/reference/packages/cell/api/color)                                                  | `type Color`                             | Public type Color.                             |
| [`composeCellScene`](/tuil/docs/reference/packages/cell/api/compose-cell-scene)                          | `function composeCellScene`              | Public function composeCellScene.              |
| [`CursorState`](/tuil/docs/reference/packages/cell/api/cursor-state)                                     | `interface CursorState`                  | Public interface CursorState.                  |
| [`defaultColor`](/tuil/docs/reference/packages/cell/api/default-color)                                   | `constant defaultColor`                  | Public constant defaultColor.                  |
| [`diffCellFrames`](/tuil/docs/reference/packages/cell/api/diff-cell-frames)                              | `function diffCellFrames`                | Public function diffCellFrames.                |
| [`emptyCell`](/tuil/docs/reference/packages/cell/api/empty-cell)                                         | `constant emptyCell`                     | Public constant emptyCell.                     |
| [`encodeCellOutput`](/tuil/docs/reference/packages/cell/api/encode-cell-output)                          | `function encodeCellOutput`              | Public function encodeCellOutput.              |
| [`loadNativeCellAccelerator`](/tuil/docs/reference/packages/cell/api/load-native-cell-accelerator)       | `function loadNativeCellAccelerator`     | Public function loadNativeCellAccelerator.     |
| [`loadOptionalCellAccelerator`](/tuil/docs/reference/packages/cell/api/load-optional-cell-accelerator)   | `function loadOptionalCellAccelerator`   | Public function loadOptionalCellAccelerator.   |
| [`NativeCellAcceleratorOptions`](/tuil/docs/reference/packages/cell/api/native-cell-accelerator-options) | `interface NativeCellAcceleratorOptions` | Public interface NativeCellAcceleratorOptions. |
| [`typescriptCellAccelerator`](/tuil/docs/reference/packages/cell/api/typescript-cell-accelerator)        | `constant typescriptCellAccelerator`     | Public constant typescriptCellAccelerator.     |

## Events and lifecycle [#events-and-lifecycle]

The backend consumes renderer lifecycle and input contracts; it does not introduce an application event bus.

All subscriptions and registrations return a disposer or belong to an owning
runtime that disposes them in reverse order.

## Example [#example]

```tsx
import { CellBuffer } from "@mwillbanks/tuil-cell";

const buffer = new CellBuffer(80, 24);
buffer.write(0, 0, "Ready");
```

## Related [#related]

* [Package architecture](/tuil/docs/concepts/packages)
* [Events](/tuil/docs/concepts/events)
* [Testing](/tuil/docs/guides/testing)
