feat(tui): export Ink's colorize so callers can match its color depth
Anything writing raw SGR past the renderer has to resolve a tone the same way Ink does — chalk downgrades to the terminal's real depth, and Apple Terminal takes a bespoke rich-8-bit path on top of that. Sharing the renderer's own function is the only way a bypass can't drift from it.
This commit is contained in:
committed by
brooklyn!
parent
8a754104ad
commit
43f395a4f8
+1
@@ -6,6 +6,7 @@ export type { StdoutHandle } from './src/hooks/use-stdout.ts'
|
||||
export { Ansi } from './src/ink/Ansi.tsx'
|
||||
export { evictInkCaches } from './src/ink/cache-eviction.ts'
|
||||
export type { EvictLevel, InkCacheSizes } from './src/ink/cache-eviction.ts'
|
||||
export { colorize } from './src/ink/colorize.ts'
|
||||
export { AlternateScreen } from './src/ink/components/AlternateScreen.tsx'
|
||||
export { default as Box } from './src/ink/components/Box.tsx'
|
||||
export type { Props as BoxProps } from './src/ink/components/Box.tsx'
|
||||
|
||||
@@ -2,6 +2,7 @@ export { default as useStderr } from './hooks/use-stderr.js'
|
||||
export { default as useStdout } from './hooks/use-stdout.js'
|
||||
export { Ansi } from './ink/Ansi.js'
|
||||
export { evictInkCaches, type EvictLevel, type InkCacheSizes } from './ink/cache-eviction.js'
|
||||
export { colorize } from './ink/colorize.js'
|
||||
export { AlternateScreen } from './ink/components/AlternateScreen.js'
|
||||
export { default as Box } from './ink/components/Box.js'
|
||||
export { default as Link } from './ink/components/Link.js'
|
||||
|
||||
Vendored
+1
@@ -107,6 +107,7 @@ declare module '@hermes/ink' {
|
||||
export const Text: React.ComponentType<any>
|
||||
export function setDimFallbackColor(color: string | undefined): void
|
||||
export const TextInput: React.ComponentType<any>
|
||||
export const colorize: (str: string, color: string | undefined, type: 'foreground' | 'background') => string
|
||||
export const stringWidth: (s: string) => number
|
||||
export function isXtermJs(): boolean
|
||||
export function onTerminalBackground(listener: (hex: string) => void): void
|
||||
|
||||
Reference in New Issue
Block a user