Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions .changeset/color-encoding-tiers.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/cooper-pr-84.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/cooper-pr-86.md

This file was deleted.

21 changes: 0 additions & 21 deletions .changeset/currentcolor.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/element-info-allocations.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/large-geese-fix.md

This file was deleted.

24 changes: 0 additions & 24 deletions .changeset/system-colors-ansi16.md

This file was deleted.

70 changes: 70 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,75 @@
# @bomb.sh/tty

## 0.12.0

### Minor Changes

- [#148](https://github.com/bombshell-dev/tty/pull/148) [`6cbbaf4`](https://github.com/bombshell-dev/tty/commit/6cbbaf44423c818caddb8755f522096c2250faa0) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Adds capability-aware SGR color encoding to the renderer.

The renderer now derives its color encoding from terminal capability evidence instead of always emitting 24-bit truecolor. Terminals with truecolor evidence (`RGB`/`Tc`, `COLORTERM`, direct-color `max_colors`, or a `colordepth` probe folded through `term.update()`) continue to receive byte-identical truecolor output. Without truecolor evidence, cells emit 256-color SGR (`\x1b[38;5;Nm`) when `colors > 16`, or 4-bit SGR (`\x1b[31m`) at or below 16. Colors are downmapped deterministically. In 256-color output, RGB colors map onto the 6×6×6 cube and grayscale ramp (`rgba(255, 0, 0)` → `\x1b[38;5;196m`), never onto indices 0–15, which follow the terminal's theme. In 16-color output, they map to the nearest standard palette entry. Use the `-ansi-*` keywords when you want the terminal's own palette colors. A tier change between frames forces a complete redraw.

The baseline — no capability evidence — now resolves to 256-color rather than truecolor. Pass `detectTerminal()` output to `createTerm` to restore truecolor output on terminals that support it.

#### Migration

```diff
import { createTerm } from "@bomb.sh/tty";
+ import { detectTerminal } from "@bomb.sh/tty";

- const term = await createTerm({ width, height });
+ const terminfo = await detectTerminal();
+ const term = await createTerm({ width, height, terminfo });
```

- [#158](https://github.com/bombshell-dev/tty/pull/158) [`836f8e0`](https://github.com/bombshell-dev/tty/commit/836f8e0bfd99be253a35a9543ecdcfd1e233f4b3) Thanks [@natemoo-re](https://github.com/natemoo-re)! - `open()` accepts a `color` field: the element's own foreground color, inherited
by every descendant that doesn't set its own. `currentcolor` is now a valid
color string everywhere, including `color` itself, where it means "inherit"
(the same as omitting the field). Used in any other color field —
`open({ bg })`, `text({ bg })`, `border.color`, `border.bg`, or a structured
border side's `color`/`bg` — it resolves to the directive's own resolved
color (its explicit `color`, or the color it inherits), then follows the same
field resolution as any other color, so it probes the terminal theme and
transitions normally when that resolved color is an sRGB value. `border.color`
is now optional and defaults to `currentcolor`, matching CSS; a border with no
`color` set anywhere picks up the element's own foreground, same as before
this feature existed.

Inheritance, `currentcolor`, and system colors resolve where the element sits
in the frame being rendered, so a replayed element inherits from wherever its
replay appears, and system colors in it pick up a theme report on the next
render.

- [#157](https://github.com/bombshell-dev/tty/pull/157) [`d9b19c2`](https://github.com/bombshell-dev/tty/commit/d9b19c21f8f49c549046071c30ddaced70748d9c) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Color fields accept colors that follow the user's terminal theme instead of a
fixed RGB value, so output matches their light or dark theme.

The sixteen ANSI palette entries are named with `-ansi-` keywords:
`-ansi-black`, `-ansi-red`, `-ansi-green`, `-ansi-yellow`, `-ansi-blue`,
`-ansi-magenta`, `-ansi-cyan`, and `-ansi-white` for entries 0–7, and
`-ansi-bright-black` through `-ansi-bright-white` for entries 8–15. They render
as SGR 30–37/90–97 (or 40–47/100–107 as a background) and match
case-insensitively. CSS named colors are unchanged: `red` is still `#ff0000`,
while `-ansi-red` is whatever red the terminal's theme uses.

The CSS system colors `Canvas` and `CanvasText` name the terminal's default
background and foreground. `text({ bg: "Canvas" })` paints the terminal default
background over any enclosing element background, while an omitted `bg` still
keeps it. Named in the other field, they paint the terminal's actual default
color once it's known: `text({ bg: "CanvasText" })` renders the terminal's real
default foreground color as an opaque truecolor background, learned from the
terminal's OSC 10/11 theme report, falling back to the default background until
that report arrives. Other CSS system colors are not supported. Packed `rgba()`
colors and other color strings render exactly as before.

### Patch Changes

- [#84](https://github.com/bombshell-dev/tty/pull/84) [`9c2354f`](https://github.com/bombshell-dev/tty/commit/9c2354fa7c591f0a718f01b0f1a2a9b8e5e486f1) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Fixes width measurement and rendering of emoji with variation selector-16 (`U+FE0F`)

- [#86](https://github.com/bombshell-dev/tty/pull/86) [`43c8915`](https://github.com/bombshell-dev/tty/commit/43c89157f2577d09883ddc14283269263b724127) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Fixes rendering when `floating` elements overlap the trailing column of wide characters

- [#179](https://github.com/bombshell-dev/tty/pull/179) [`1585d55`](https://github.com/bombshell-dev/tty/commit/1585d55250a521b50104302fa2866d18979b6f88) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Improves `term.render()` and `result.info.get()` memory use by encoding element ids and text directly into the transfer buffer instead of allocating per string

- [#168](https://github.com/bombshell-dev/tty/pull/168) [`0813fa4`](https://github.com/bombshell-dev/tty/commit/0813fa480c864dc1a08366342e25c61fef9bca03) Thanks [@dreyfus92](https://github.com/dreyfus92)! - Fixes how elements at fractional positions map to cells. An element now draws on, and receives the pointer for, exactly the cells whose centers its bounding box covers. Elements sliding in past the top edge no longer pile onto row 0, and two elements that meet halfway through a cell no longer both receive the pointer there.

## 0.11.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bomb.sh/tty",
"version": "0.11.0",
"version": "0.12.0",
"type": "module",
"private": true,
"scripts": {
Expand Down
Loading