diff --git a/.changeset/color-encoding-tiers.md b/.changeset/color-encoding-tiers.md deleted file mode 100644 index 97b1ed8..0000000 --- a/.changeset/color-encoding-tiers.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -'@bomb.sh/tty': minor ---- - -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 }); -``` diff --git a/.changeset/cooper-pr-84.md b/.changeset/cooper-pr-84.md deleted file mode 100644 index 4f25fc3..0000000 --- a/.changeset/cooper-pr-84.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@bomb.sh/tty': patch ---- - -Fixes width measurement and rendering of emoji with variation selector-16 (`U+FE0F`) diff --git a/.changeset/cooper-pr-86.md b/.changeset/cooper-pr-86.md deleted file mode 100644 index 216faae..0000000 --- a/.changeset/cooper-pr-86.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@bomb.sh/tty': patch ---- - -Fixes rendering when `floating` elements overlap the trailing column of wide characters diff --git a/.changeset/currentcolor.md b/.changeset/currentcolor.md deleted file mode 100644 index 56447c9..0000000 --- a/.changeset/currentcolor.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -"@bomb.sh/tty": minor ---- - -`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. diff --git a/.changeset/element-info-allocations.md b/.changeset/element-info-allocations.md deleted file mode 100644 index 7290af7..0000000 --- a/.changeset/element-info-allocations.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@bomb.sh/tty": patch ---- - -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 diff --git a/.changeset/large-geese-fix.md b/.changeset/large-geese-fix.md deleted file mode 100644 index 6d56bea..0000000 --- a/.changeset/large-geese-fix.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@bomb.sh/tty": patch ---- - -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. diff --git a/.changeset/system-colors-ansi16.md b/.changeset/system-colors-ansi16.md deleted file mode 100644 index f3a89fb..0000000 --- a/.changeset/system-colors-ansi16.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -"@bomb.sh/tty": minor ---- - -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. diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b3d404..8ec2631 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package.json b/package.json index 06ac324..86fd448 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bomb.sh/tty", - "version": "0.11.0", + "version": "0.12.0", "type": "module", "private": true, "scripts": {