source dump of claude code
at main 85 lines 3.9 kB view raw
1import { createElement, type ReactNode } from 'react' 2import { ThemeProvider } from './components/design-system/ThemeProvider.js' 3import inkRender, { 4 type Instance, 5 createRoot as inkCreateRoot, 6 type RenderOptions, 7 type Root, 8} from './ink/root.js' 9 10export type { RenderOptions, Instance, Root } 11 12// Wrap all CC render calls with ThemeProvider so ThemedBox/ThemedText work 13// without every call site having to mount it. Ink itself is theme-agnostic. 14function withTheme(node: ReactNode): ReactNode { 15 return createElement(ThemeProvider, null, node) 16} 17 18export async function render( 19 node: ReactNode, 20 options?: NodeJS.WriteStream | RenderOptions, 21): Promise<Instance> { 22 return inkRender(withTheme(node), options) 23} 24 25export async function createRoot(options?: RenderOptions): Promise<Root> { 26 const root = await inkCreateRoot(options) 27 return { 28 ...root, 29 render: node => root.render(withTheme(node)), 30 } 31} 32 33export { color } from './components/design-system/color.js' 34export type { Props as BoxProps } from './components/design-system/ThemedBox.js' 35export { default as Box } from './components/design-system/ThemedBox.js' 36export type { Props as TextProps } from './components/design-system/ThemedText.js' 37export { default as Text } from './components/design-system/ThemedText.js' 38export { 39 ThemeProvider, 40 usePreviewTheme, 41 useTheme, 42 useThemeSetting, 43} from './components/design-system/ThemeProvider.js' 44export { Ansi } from './ink/Ansi.js' 45export type { Props as AppProps } from './ink/components/AppContext.js' 46export type { Props as BaseBoxProps } from './ink/components/Box.js' 47export { default as BaseBox } from './ink/components/Box.js' 48export type { 49 ButtonState, 50 Props as ButtonProps, 51} from './ink/components/Button.js' 52export { default as Button } from './ink/components/Button.js' 53export type { Props as LinkProps } from './ink/components/Link.js' 54export { default as Link } from './ink/components/Link.js' 55export type { Props as NewlineProps } from './ink/components/Newline.js' 56export { default as Newline } from './ink/components/Newline.js' 57export { NoSelect } from './ink/components/NoSelect.js' 58export { RawAnsi } from './ink/components/RawAnsi.js' 59export { default as Spacer } from './ink/components/Spacer.js' 60export type { Props as StdinProps } from './ink/components/StdinContext.js' 61export type { Props as BaseTextProps } from './ink/components/Text.js' 62export { default as BaseText } from './ink/components/Text.js' 63export type { DOMElement } from './ink/dom.js' 64export { ClickEvent } from './ink/events/click-event.js' 65export { EventEmitter } from './ink/events/emitter.js' 66export { Event } from './ink/events/event.js' 67export type { Key } from './ink/events/input-event.js' 68export { InputEvent } from './ink/events/input-event.js' 69export type { TerminalFocusEventType } from './ink/events/terminal-focus-event.js' 70export { TerminalFocusEvent } from './ink/events/terminal-focus-event.js' 71export { FocusManager } from './ink/focus.js' 72export type { FlickerReason } from './ink/frame.js' 73export { useAnimationFrame } from './ink/hooks/use-animation-frame.js' 74export { default as useApp } from './ink/hooks/use-app.js' 75export { default as useInput } from './ink/hooks/use-input.js' 76export { useAnimationTimer, useInterval } from './ink/hooks/use-interval.js' 77export { useSelection } from './ink/hooks/use-selection.js' 78export { default as useStdin } from './ink/hooks/use-stdin.js' 79export { useTabStatus } from './ink/hooks/use-tab-status.js' 80export { useTerminalFocus } from './ink/hooks/use-terminal-focus.js' 81export { useTerminalTitle } from './ink/hooks/use-terminal-title.js' 82export { useTerminalViewport } from './ink/hooks/use-terminal-viewport.js' 83export { default as measureElement } from './ink/measure-element.js' 84export { supportsTabStatus } from './ink/termio/osc.js' 85export { default as wrapText } from './ink/wrap-text.js'