@deepseek-harness-tui/dsh-tui 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +235 -0
- package/bin/dsh-tui.js +95 -0
- package/cordis.patch.yml +218 -0
- package/cordis.yml +185 -0
- package/lib/invariant.js +28 -0
- package/lib/types/activityPrefs.d.ts +29 -0
- package/lib/types/activityPrefs.d.ts.map +1 -0
- package/lib/types/activityPrefs.js +60 -0
- package/lib/types/bootstrap/state.d.ts +13 -0
- package/lib/types/bootstrap/state.d.ts.map +1 -0
- package/lib/types/bootstrap/state.js +12 -0
- package/lib/types/cc/cliHighlight.d.ts +20 -0
- package/lib/types/cc/cliHighlight.d.ts.map +1 -0
- package/lib/types/cc/cliHighlight.js +53 -0
- package/lib/types/cc/figures.d.ts +59 -0
- package/lib/types/cc/figures.d.ts.map +1 -0
- package/lib/types/cc/figures.js +69 -0
- package/lib/types/cc/format.d.ts +26 -0
- package/lib/types/cc/format.d.ts.map +1 -0
- package/lib/types/cc/format.js +55 -0
- package/lib/types/cc/hash.d.ts +25 -0
- package/lib/types/cc/hash.d.ts.map +1 -0
- package/lib/types/cc/hash.js +41 -0
- package/lib/types/cc/hyperlink.d.ts +21 -0
- package/lib/types/cc/hyperlink.d.ts.map +1 -0
- package/lib/types/cc/hyperlink.js +31 -0
- package/lib/types/cc/markdown.d.ts +43 -0
- package/lib/types/cc/markdown.d.ts.map +1 -0
- package/lib/types/cc/markdown.js +345 -0
- package/lib/types/cc/spinnerVerbs.d.ts +3 -0
- package/lib/types/cc/spinnerVerbs.d.ts.map +1 -0
- package/lib/types/cc/spinnerVerbs.js +190 -0
- package/lib/types/cc/terminal.d.ts +15 -0
- package/lib/types/cc/terminal.d.ts.map +1 -0
- package/lib/types/cc/terminal.js +84 -0
- package/lib/types/channel.d.ts +672 -0
- package/lib/types/channel.d.ts.map +1 -0
- package/lib/types/channel.js +2427 -0
- package/lib/types/childStderr.d.ts +63 -0
- package/lib/types/childStderr.d.ts.map +1 -0
- package/lib/types/childStderr.js +161 -0
- package/lib/types/commands.d.ts +55 -0
- package/lib/types/commands.d.ts.map +1 -0
- package/lib/types/commands.js +101 -0
- package/lib/types/components/ActivityLine.d.ts +29 -0
- package/lib/types/components/ActivityLine.d.ts.map +1 -0
- package/lib/types/components/ActivityLine.js +47 -0
- package/lib/types/components/ActivityPicker.d.ts +13 -0
- package/lib/types/components/ActivityPicker.d.ts.map +1 -0
- package/lib/types/components/ActivityPicker.js +24 -0
- package/lib/types/components/CommandSuggestions.d.ts +14 -0
- package/lib/types/components/CommandSuggestions.d.ts.map +1 -0
- package/lib/types/components/CommandSuggestions.js +33 -0
- package/lib/types/components/FileSuggestions.d.ts +12 -0
- package/lib/types/components/FileSuggestions.d.ts.map +1 -0
- package/lib/types/components/FileSuggestions.js +26 -0
- package/lib/types/components/GoalTodoPanel.d.ts +13 -0
- package/lib/types/components/GoalTodoPanel.d.ts.map +1 -0
- package/lib/types/components/GoalTodoPanel.js +57 -0
- package/lib/types/components/HelpMenu.d.ts +12 -0
- package/lib/types/components/HelpMenu.d.ts.map +1 -0
- package/lib/types/components/HelpMenu.js +12 -0
- package/lib/types/components/HistorySearchDialog.d.ts +16 -0
- package/lib/types/components/HistorySearchDialog.d.ts.map +1 -0
- package/lib/types/components/HistorySearchDialog.js +31 -0
- package/lib/types/components/InterruptedByUser.d.ts +7 -0
- package/lib/types/components/InterruptedByUser.d.ts.map +1 -0
- package/lib/types/components/InterruptedByUser.js +9 -0
- package/lib/types/components/LoadedContextPanel.d.ts +20 -0
- package/lib/types/components/LoadedContextPanel.d.ts.map +1 -0
- package/lib/types/components/LoadedContextPanel.js +30 -0
- package/lib/types/components/LogoV2.d.ts +23 -0
- package/lib/types/components/LogoV2.d.ts.map +1 -0
- package/lib/types/components/LogoV2.js +95 -0
- package/lib/types/components/Markdown.d.ts +24 -0
- package/lib/types/components/Markdown.d.ts.map +1 -0
- package/lib/types/components/Markdown.js +106 -0
- package/lib/types/components/MarkdownTable.d.ts +17 -0
- package/lib/types/components/MarkdownTable.d.ts.map +1 -0
- package/lib/types/components/MarkdownTable.js +272 -0
- package/lib/types/components/MessageList.d.ts +41 -0
- package/lib/types/components/MessageList.d.ts.map +1 -0
- package/lib/types/components/MessageList.js +303 -0
- package/lib/types/components/ModelPicker.d.ts +14 -0
- package/lib/types/components/ModelPicker.d.ts.map +1 -0
- package/lib/types/components/ModelPicker.js +15 -0
- package/lib/types/components/PresetPicker.d.ts +17 -0
- package/lib/types/components/PresetPicker.d.ts.map +1 -0
- package/lib/types/components/PresetPicker.js +25 -0
- package/lib/types/components/PromptInput.d.ts +67 -0
- package/lib/types/components/PromptInput.d.ts.map +1 -0
- package/lib/types/components/PromptInput.js +778 -0
- package/lib/types/components/ResumePicker.d.ts +15 -0
- package/lib/types/components/ResumePicker.d.ts.map +1 -0
- package/lib/types/components/ResumePicker.js +34 -0
- package/lib/types/components/RewindPicker.d.ts +14 -0
- package/lib/types/components/RewindPicker.d.ts.map +1 -0
- package/lib/types/components/RewindPicker.js +23 -0
- package/lib/types/components/SearchBox.d.ts +20 -0
- package/lib/types/components/SearchBox.d.ts.map +1 -0
- package/lib/types/components/SearchBox.js +33 -0
- package/lib/types/components/Select.d.ts +22 -0
- package/lib/types/components/Select.d.ts.map +1 -0
- package/lib/types/components/Select.js +19 -0
- package/lib/types/components/Spinner/GlimmerMessage.d.ts +19 -0
- package/lib/types/components/Spinner/GlimmerMessage.d.ts.map +1 -0
- package/lib/types/components/Spinner/GlimmerMessage.js +78 -0
- package/lib/types/components/Spinner/SpinnerAnimationRow.d.ts +31 -0
- package/lib/types/components/Spinner/SpinnerAnimationRow.d.ts.map +1 -0
- package/lib/types/components/Spinner/SpinnerAnimationRow.js +162 -0
- package/lib/types/components/Spinner/SpinnerGlyph.d.ts +16 -0
- package/lib/types/components/Spinner/SpinnerGlyph.d.ts.map +1 -0
- package/lib/types/components/Spinner/SpinnerGlyph.js +36 -0
- package/lib/types/components/Spinner/spinnerMode.d.ts +6 -0
- package/lib/types/components/Spinner/spinnerMode.d.ts.map +1 -0
- package/lib/types/components/Spinner/spinnerMode.js +1 -0
- package/lib/types/components/Spinner/spinnerUtils.d.ts +41 -0
- package/lib/types/components/Spinner/spinnerUtils.d.ts.map +1 -0
- package/lib/types/components/Spinner/spinnerUtils.js +104 -0
- package/lib/types/components/Spinner/useStalledAnimation.d.ts +16 -0
- package/lib/types/components/Spinner/useStalledAnimation.d.ts.map +1 -0
- package/lib/types/components/Spinner/useStalledAnimation.js +71 -0
- package/lib/types/components/StreamingMarkdown.d.ts +12 -0
- package/lib/types/components/StreamingMarkdown.d.ts.map +1 -0
- package/lib/types/components/StreamingMarkdown.js +39 -0
- package/lib/types/components/ThemePicker.d.ts +22 -0
- package/lib/types/components/ThemePicker.d.ts.map +1 -0
- package/lib/types/components/ThemePicker.js +51 -0
- package/lib/types/components/ThinkingToggle.d.ts +17 -0
- package/lib/types/components/ThinkingToggle.d.ts.map +1 -0
- package/lib/types/components/ThinkingToggle.js +30 -0
- package/lib/types/components/ToolUseLoader.d.ts +13 -0
- package/lib/types/components/ToolUseLoader.d.ts.map +1 -0
- package/lib/types/components/ToolUseLoader.js +17 -0
- package/lib/types/components/Whale.d.ts +22 -0
- package/lib/types/components/Whale.d.ts.map +1 -0
- package/lib/types/components/Whale.js +78 -0
- package/lib/types/components/WorkingSpinner.d.ts +26 -0
- package/lib/types/components/WorkingSpinner.d.ts.map +1 -0
- package/lib/types/components/WorkingSpinner.js +68 -0
- package/lib/types/components/activityFrames.d.ts +31 -0
- package/lib/types/components/activityFrames.d.ts.map +1 -0
- package/lib/types/components/activityFrames.js +83 -0
- package/lib/types/components/bigfont.d.ts +28 -0
- package/lib/types/components/bigfont.d.ts.map +1 -0
- package/lib/types/components/bigfont.js +91 -0
- package/lib/types/components/design-system/Byline.d.ts +14 -0
- package/lib/types/components/design-system/Byline.d.ts.map +1 -0
- package/lib/types/components/design-system/Byline.js +17 -0
- package/lib/types/components/design-system/Divider.d.ts +40 -0
- package/lib/types/components/design-system/Divider.d.ts.map +1 -0
- package/lib/types/components/design-system/Divider.js +24 -0
- package/lib/types/components/design-system/KeyboardShortcutHint.d.ts +19 -0
- package/lib/types/components/design-system/KeyboardShortcutHint.d.ts.map +1 -0
- package/lib/types/components/design-system/KeyboardShortcutHint.js +14 -0
- package/lib/types/components/design-system/ListItem.d.ts +36 -0
- package/lib/types/components/design-system/ListItem.d.ts.map +1 -0
- package/lib/types/components/design-system/ListItem.js +48 -0
- package/lib/types/components/design-system/LoadingState.d.ts +19 -0
- package/lib/types/components/design-system/LoadingState.d.ts.map +1 -0
- package/lib/types/components/design-system/LoadingState.js +22 -0
- package/lib/types/components/design-system/Pane.d.ts +17 -0
- package/lib/types/components/design-system/Pane.d.ts.map +1 -0
- package/lib/types/components/design-system/Pane.js +15 -0
- package/lib/types/components/design-system/ProgressBar.d.ts +22 -0
- package/lib/types/components/design-system/ProgressBar.d.ts.map +1 -0
- package/lib/types/components/design-system/ProgressBar.js +27 -0
- package/lib/types/components/design-system/StatusIcon.d.ts +15 -0
- package/lib/types/components/design-system/StatusIcon.d.ts.map +1 -0
- package/lib/types/components/design-system/StatusIcon.js +20 -0
- package/lib/types/components/design-system/ThemeProvider.d.ts +11 -0
- package/lib/types/components/design-system/ThemeProvider.d.ts.map +1 -0
- package/lib/types/components/design-system/ThemeProvider.js +135 -0
- package/lib/types/components/design-system/ThemedBox.d.ts +37 -0
- package/lib/types/components/design-system/ThemedBox.d.ts.map +1 -0
- package/lib/types/components/design-system/ThemedBox.js +26 -0
- package/lib/types/components/design-system/ThemedText.d.ts +56 -0
- package/lib/types/components/design-system/ThemedText.d.ts.map +1 -0
- package/lib/types/components/design-system/ThemedText.js +45 -0
- package/lib/types/components/messages/AssistantTextMessage.d.ts +18 -0
- package/lib/types/components/messages/AssistantTextMessage.d.ts.map +1 -0
- package/lib/types/components/messages/AssistantTextMessage.js +15 -0
- package/lib/types/components/messages/AssistantThinkingMessage.d.ts +23 -0
- package/lib/types/components/messages/AssistantThinkingMessage.d.ts.map +1 -0
- package/lib/types/components/messages/AssistantThinkingMessage.js +23 -0
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts +23 -0
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -0
- package/lib/types/components/messages/AssistantToolUseMessage.js +220 -0
- package/lib/types/components/messages/MessageMetadata.d.ts +15 -0
- package/lib/types/components/messages/MessageMetadata.d.ts.map +1 -0
- package/lib/types/components/messages/MessageMetadata.js +20 -0
- package/lib/types/components/messages/UserPromptMessage.d.ts +19 -0
- package/lib/types/components/messages/UserPromptMessage.d.ts.map +1 -0
- package/lib/types/components/messages/UserPromptMessage.js +15 -0
- package/lib/types/components/questions/AskUserQuestionPanel.d.ts +39 -0
- package/lib/types/components/questions/AskUserQuestionPanel.d.ts.map +1 -0
- package/lib/types/components/questions/AskUserQuestionPanel.js +228 -0
- package/lib/types/components/shimmer.d.ts +35 -0
- package/lib/types/components/shimmer.d.ts.map +1 -0
- package/lib/types/components/shimmer.js +43 -0
- package/lib/types/components/whaleFrames.d.ts +25 -0
- package/lib/types/components/whaleFrames.d.ts.map +1 -0
- package/lib/types/components/whaleFrames.js +419 -0
- package/lib/types/customTheme.d.ts +104 -0
- package/lib/types/customTheme.d.ts.map +1 -0
- package/lib/types/customTheme.js +268 -0
- package/lib/types/effortPrefs.d.ts +22 -0
- package/lib/types/effortPrefs.d.ts.map +1 -0
- package/lib/types/effortPrefs.js +45 -0
- package/lib/types/history.d.ts +24 -0
- package/lib/types/history.d.ts.map +1 -0
- package/lib/types/history.js +75 -0
- package/lib/types/hooks/useBlink.d.ts +11 -0
- package/lib/types/hooks/useBlink.d.ts.map +1 -0
- package/lib/types/hooks/useBlink.js +20 -0
- package/lib/types/i18n.d.ts +926 -0
- package/lib/types/i18n.d.ts.map +1 -0
- package/lib/types/i18n.js +356 -0
- package/lib/types/index.d.ts +70 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +31 -0
- package/lib/types/ink/Ansi.d.ts +11 -0
- package/lib/types/ink/Ansi.d.ts.map +1 -0
- package/lib/types/ink/Ansi.js +269 -0
- package/lib/types/ink/bidi.d.ts +18 -0
- package/lib/types/ink/bidi.d.ts.map +1 -0
- package/lib/types/ink/bidi.js +119 -0
- package/lib/types/ink/clearTerminal.d.ts +22 -0
- package/lib/types/ink/clearTerminal.d.ts.map +1 -0
- package/lib/types/ink/clearTerminal.js +72 -0
- package/lib/types/ink/colorize.d.ts +33 -0
- package/lib/types/ink/colorize.d.ts.map +1 -0
- package/lib/types/ink/colorize.js +213 -0
- package/lib/types/ink/components/AlternateScreen.d.ts +22 -0
- package/lib/types/ink/components/AlternateScreen.d.ts.map +1 -0
- package/lib/types/ink/components/AlternateScreen.js +74 -0
- package/lib/types/ink/components/App.d.ts +73 -0
- package/lib/types/ink/components/App.d.ts.map +1 -0
- package/lib/types/ink/components/App.js +597 -0
- package/lib/types/ink/components/AppContext.d.ts +15 -0
- package/lib/types/ink/components/AppContext.d.ts.map +1 -0
- package/lib/types/ink/components/AppContext.js +11 -0
- package/lib/types/ink/components/Box.d.ts +49 -0
- package/lib/types/ink/components/Box.d.ts.map +1 -0
- package/lib/types/ink/components/Box.js +153 -0
- package/lib/types/ink/components/Button.d.ts +37 -0
- package/lib/types/ink/components/Button.d.ts.map +1 -0
- package/lib/types/ink/components/Button.js +166 -0
- package/lib/types/ink/components/ClockContext.d.ts +10 -0
- package/lib/types/ink/components/ClockContext.d.ts.map +1 -0
- package/lib/types/ink/components/ClockContext.js +108 -0
- package/lib/types/ink/components/CursorDeclarationContext.d.ts +30 -0
- package/lib/types/ink/components/CursorDeclarationContext.d.ts.map +1 -0
- package/lib/types/ink/components/CursorDeclarationContext.js +6 -0
- package/lib/types/ink/components/ErrorOverview.d.ts +7 -0
- package/lib/types/ink/components/ErrorOverview.d.ts.map +1 -0
- package/lib/types/ink/components/ErrorOverview.js +49 -0
- package/lib/types/ink/components/Link.d.ts +8 -0
- package/lib/types/ink/components/Link.d.ts.map +1 -0
- package/lib/types/ink/components/Link.js +33 -0
- package/lib/types/ink/components/Newline.d.ts +13 -0
- package/lib/types/ink/components/Newline.d.ts.map +1 -0
- package/lib/types/ink/components/Newline.js +29 -0
- package/lib/types/ink/components/NoSelect.d.ts +20 -0
- package/lib/types/ink/components/NoSelect.d.ts.map +1 -0
- package/lib/types/ink/components/NoSelect.js +56 -0
- package/lib/types/ink/components/RawAnsi.d.ts +17 -0
- package/lib/types/ink/components/RawAnsi.d.ts.map +1 -0
- package/lib/types/ink/components/RawAnsi.js +45 -0
- package/lib/types/ink/components/ScrollBox.d.ts +78 -0
- package/lib/types/ink/components/ScrollBox.d.ts.map +1 -0
- package/lib/types/ink/components/ScrollBox.js +174 -0
- package/lib/types/ink/components/Spacer.d.ts +6 -0
- package/lib/types/ink/components/Spacer.d.ts.map +1 -0
- package/lib/types/ink/components/Spacer.js +19 -0
- package/lib/types/ink/components/StdinContext.d.ts +32 -0
- package/lib/types/ink/components/StdinContext.d.ts.map +1 -0
- package/lib/types/ink/components/StdinContext.js +16 -0
- package/lib/types/ink/components/TerminalFocusContext.d.ts +11 -0
- package/lib/types/ink/components/TerminalFocusContext.d.ts.map +1 -0
- package/lib/types/ink/components/TerminalFocusContext.js +45 -0
- package/lib/types/ink/components/TerminalSizeContext.d.ts +6 -0
- package/lib/types/ink/components/TerminalSizeContext.d.ts.map +1 -0
- package/lib/types/ink/components/TerminalSizeContext.js +3 -0
- package/lib/types/ink/components/Text.d.ts +56 -0
- package/lib/types/ink/components/Text.d.ts.map +1 -0
- package/lib/types/ink/components/Text.js +194 -0
- package/lib/types/ink/constants.d.ts +3 -0
- package/lib/types/ink/constants.d.ts.map +1 -0
- package/lib/types/ink/constants.js +2 -0
- package/lib/types/ink/cursor.d.ts +11 -0
- package/lib/types/ink/cursor.d.ts.map +1 -0
- package/lib/types/ink/cursor.js +1 -0
- package/lib/types/ink/devtools.d.ts +7 -0
- package/lib/types/ink/devtools.d.ts.map +1 -0
- package/lib/types/ink/devtools.js +1 -0
- package/lib/types/ink/dom.d.ts +178 -0
- package/lib/types/ink/dom.d.ts.map +1 -0
- package/lib/types/ink/dom.js +424 -0
- package/lib/types/ink/events/click-event.d.ts +32 -0
- package/lib/types/ink/events/click-event.d.ts.map +1 -0
- package/lib/types/ink/events/click-event.js +36 -0
- package/lib/types/ink/events/dispatcher.d.ts +63 -0
- package/lib/types/ink/events/dispatcher.d.ts.map +1 -0
- package/lib/types/ink/events/dispatcher.js +194 -0
- package/lib/types/ink/events/emitter.d.ts +20 -0
- package/lib/types/ink/events/emitter.d.ts.map +1 -0
- package/lib/types/ink/events/emitter.js +43 -0
- package/lib/types/ink/events/event-handlers.d.ts +47 -0
- package/lib/types/ink/events/event-handlers.d.ts.map +1 -0
- package/lib/types/ink/events/event-handlers.js +30 -0
- package/lib/types/ink/events/event.d.ts +19 -0
- package/lib/types/ink/events/event.d.ts.map +1 -0
- package/lib/types/ink/events/event.js +22 -0
- package/lib/types/ink/events/focus-event.d.ts +19 -0
- package/lib/types/ink/events/focus-event.d.ts.map +1 -0
- package/lib/types/ink/events/focus-event.js +21 -0
- package/lib/types/ink/events/input-event.d.ts +53 -0
- package/lib/types/ink/events/input-event.d.ts.map +1 -0
- package/lib/types/ink/events/input-event.js +180 -0
- package/lib/types/ink/events/keyboard-event.d.ts +40 -0
- package/lib/types/ink/events/keyboard-event.d.ts.map +1 -0
- package/lib/types/ink/events/keyboard-event.js +65 -0
- package/lib/types/ink/events/paste-event.d.ts +11 -0
- package/lib/types/ink/events/paste-event.d.ts.map +1 -0
- package/lib/types/ink/events/paste-event.js +13 -0
- package/lib/types/ink/events/resize-event.d.ts +13 -0
- package/lib/types/ink/events/resize-event.d.ts.map +1 -0
- package/lib/types/ink/events/resize-event.js +16 -0
- package/lib/types/ink/events/terminal-event.d.ts +112 -0
- package/lib/types/ink/events/terminal-event.d.ts.map +1 -0
- package/lib/types/ink/events/terminal-event.js +131 -0
- package/lib/types/ink/events/terminal-focus-event.d.ts +21 -0
- package/lib/types/ink/events/terminal-focus-event.d.ts.map +1 -0
- package/lib/types/ink/events/terminal-focus-event.js +18 -0
- package/lib/types/ink/focus.d.ts +74 -0
- package/lib/types/ink/focus.d.ts.map +1 -0
- package/lib/types/ink/focus.js +188 -0
- package/lib/types/ink/frame.d.ts +119 -0
- package/lib/types/ink/frame.d.ts.map +1 -0
- package/lib/types/ink/frame.js +43 -0
- package/lib/types/ink/get-max-width.d.ts +20 -0
- package/lib/types/ink/get-max-width.d.ts.map +1 -0
- package/lib/types/ink/get-max-width.js +25 -0
- package/lib/types/ink/hit-test.d.ts +47 -0
- package/lib/types/ink/hit-test.d.ts.map +1 -0
- package/lib/types/ink/hit-test.js +126 -0
- package/lib/types/ink/hooks/use-animation-frame.d.ts +27 -0
- package/lib/types/ink/hooks/use-animation-frame.d.ts.map +1 -0
- package/lib/types/ink/hooks/use-animation-frame.js +48 -0
- package/lib/types/ink/hooks/use-app.d.ts +8 -0
- package/lib/types/ink/hooks/use-app.d.ts.map +1 -0
- package/lib/types/ink/hooks/use-app.js +8 -0
- package/lib/types/ink/hooks/use-copy-on-select.d.ts +22 -0
- package/lib/types/ink/hooks/use-copy-on-select.d.ts.map +1 -0
- package/lib/types/ink/hooks/use-copy-on-select.js +40 -0
- package/lib/types/ink/hooks/use-declared-cursor.d.ts +31 -0
- package/lib/types/ink/hooks/use-declared-cursor.d.ts.map +1 -0
- package/lib/types/ink/hooks/use-declared-cursor.js +65 -0
- package/lib/types/ink/hooks/use-input.d.ts +41 -0
- package/lib/types/ink/hooks/use-input.d.ts.map +1 -0
- package/lib/types/ink/hooks/use-input.js +73 -0
- package/lib/types/ink/hooks/use-interval.d.ts +23 -0
- package/lib/types/ink/hooks/use-interval.d.ts.map +1 -0
- package/lib/types/ink/hooks/use-interval.js +58 -0
- package/lib/types/ink/hooks/use-search-highlight.d.ts +34 -0
- package/lib/types/ink/hooks/use-search-highlight.d.ts.map +1 -0
- package/lib/types/ink/hooks/use-search-highlight.js +35 -0
- package/lib/types/ink/hooks/use-selection.d.ts +44 -0
- package/lib/types/ink/hooks/use-selection.d.ts.map +1 -0
- package/lib/types/ink/hooks/use-selection.js +64 -0
- package/lib/types/ink/hooks/use-stdin.d.ts +8 -0
- package/lib/types/ink/hooks/use-stdin.d.ts.map +1 -0
- package/lib/types/ink/hooks/use-stdin.js +8 -0
- package/lib/types/ink/hooks/use-tab-status.d.ts +18 -0
- package/lib/types/ink/hooks/use-tab-status.d.ts.map +1 -0
- package/lib/types/ink/hooks/use-tab-status.js +58 -0
- package/lib/types/ink/hooks/use-terminal-focus.d.ts +11 -0
- package/lib/types/ink/hooks/use-terminal-focus.d.ts.map +1 -0
- package/lib/types/ink/hooks/use-terminal-focus.js +15 -0
- package/lib/types/ink/hooks/use-terminal-size.d.ts +6 -0
- package/lib/types/ink/hooks/use-terminal-size.d.ts.map +1 -0
- package/lib/types/ink/hooks/use-terminal-size.js +12 -0
- package/lib/types/ink/hooks/use-terminal-title.d.ts +14 -0
- package/lib/types/ink/hooks/use-terminal-title.d.ts.map +1 -0
- package/lib/types/ink/hooks/use-terminal-title.js +30 -0
- package/lib/types/ink/hooks/use-terminal-viewport.d.ts +32 -0
- package/lib/types/ink/hooks/use-terminal-viewport.d.ts.map +1 -0
- package/lib/types/ink/hooks/use-terminal-viewport.js +79 -0
- package/lib/types/ink/ink.d.ts +370 -0
- package/lib/types/ink/ink.d.ts.map +1 -0
- package/lib/types/ink/ink.js +1665 -0
- package/lib/types/ink/instances.d.ts +10 -0
- package/lib/types/ink/instances.d.ts.map +1 -0
- package/lib/types/ink/instances.js +13 -0
- package/lib/types/ink/layout/engine.d.ts +7 -0
- package/lib/types/ink/layout/engine.d.ts.map +1 -0
- package/lib/types/ink/layout/engine.js +8 -0
- package/lib/types/ink/layout/geometry.d.ts +86 -0
- package/lib/types/ink/layout/geometry.d.ts.map +1 -0
- package/lib/types/ink/layout/geometry.js +95 -0
- package/lib/types/ink/layout/node.d.ts +151 -0
- package/lib/types/ink/layout/node.d.ts.map +1 -0
- package/lib/types/ink/layout/node.js +72 -0
- package/lib/types/ink/layout/yoga.d.ts +69 -0
- package/lib/types/ink/layout/yoga.d.ts.map +1 -0
- package/lib/types/ink/layout/yoga.js +249 -0
- package/lib/types/ink/line-width-cache.d.ts +9 -0
- package/lib/types/ink/line-width-cache.d.ts.map +1 -0
- package/lib/types/ink/line-width-cache.js +45 -0
- package/lib/types/ink/log-update.d.ts +57 -0
- package/lib/types/ink/log-update.d.ts.map +1 -0
- package/lib/types/ink/log-update.js +710 -0
- package/lib/types/ink/measure-element.d.ts +19 -0
- package/lib/types/ink/measure-element.d.ts.map +1 -0
- package/lib/types/ink/measure-element.js +10 -0
- package/lib/types/ink/measure-text.d.ts +13 -0
- package/lib/types/ink/measure-text.d.ts.map +1 -0
- package/lib/types/ink/measure-text.js +38 -0
- package/lib/types/ink/node-cache.d.ts +33 -0
- package/lib/types/ink/node-cache.d.ts.map +1 -0
- package/lib/types/ink/node-cache.js +42 -0
- package/lib/types/ink/optimizer.d.ts +18 -0
- package/lib/types/ink/optimizer.d.ts.map +1 -0
- package/lib/types/ink/optimizer.js +83 -0
- package/lib/types/ink/output.d.ts +200 -0
- package/lib/types/ink/output.d.ts.map +1 -0
- package/lib/types/ink/output.js +663 -0
- package/lib/types/ink/parse-keypress.d.ts +132 -0
- package/lib/types/ink/parse-keypress.d.ts.map +1 -0
- package/lib/types/ink/parse-keypress.js +707 -0
- package/lib/types/ink/reconciler.d.ts +43 -0
- package/lib/types/ink/reconciler.d.ts.map +1 -0
- package/lib/types/ink/reconciler.js +413 -0
- package/lib/types/ink/render-border.d.ts +36 -0
- package/lib/types/ink/render-border.d.ts.map +1 -0
- package/lib/types/ink/render-border.js +143 -0
- package/lib/types/ink/render-node-to-output.d.ts +93 -0
- package/lib/types/ink/render-node-to-output.d.ts.map +1 -0
- package/lib/types/ink/render-node-to-output.js +1290 -0
- package/lib/types/ink/render-to-screen.d.ts +65 -0
- package/lib/types/ink/render-to-screen.d.ts.map +1 -0
- package/lib/types/ink/render-to-screen.js +189 -0
- package/lib/types/ink/renderer.d.ts +24 -0
- package/lib/types/ink/renderer.d.ts.map +1 -0
- package/lib/types/ink/renderer.js +136 -0
- package/lib/types/ink/root.d.ts +91 -0
- package/lib/types/ink/root.d.ts.map +1 -0
- package/lib/types/ink/root.js +93 -0
- package/lib/types/ink/screen.d.ts +443 -0
- package/lib/types/ink/screen.d.ts.map +1 -0
- package/lib/types/ink/screen.js +1295 -0
- package/lib/types/ink/searchHighlight.d.ts +25 -0
- package/lib/types/ink/searchHighlight.d.ts.map +1 -0
- package/lib/types/ink/searchHighlight.js +82 -0
- package/lib/types/ink/selection.d.ts +323 -0
- package/lib/types/ink/selection.d.ts.map +1 -0
- package/lib/types/ink/selection.js +881 -0
- package/lib/types/ink/squash-text-nodes.d.ts +30 -0
- package/lib/types/ink/squash-text-nodes.d.ts.map +1 -0
- package/lib/types/ink/squash-text-nodes.js +63 -0
- package/lib/types/ink/stringWidth.d.ts +11 -0
- package/lib/types/ink/stringWidth.d.ts.map +1 -0
- package/lib/types/ink/stringWidth.js +209 -0
- package/lib/types/ink/styles.d.ts +324 -0
- package/lib/types/ink/styles.d.ts.map +1 -0
- package/lib/types/ink/styles.js +307 -0
- package/lib/types/ink/supports-hyperlinks.d.ts +20 -0
- package/lib/types/ink/supports-hyperlinks.d.ts.map +1 -0
- package/lib/types/ink/supports-hyperlinks.js +44 -0
- package/lib/types/ink/tabstops.d.ts +9 -0
- package/lib/types/ink/tabstops.d.ts.map +1 -0
- package/lib/types/ink/tabstops.js +46 -0
- package/lib/types/ink/terminal-focus-state.d.ts +35 -0
- package/lib/types/ink/terminal-focus-state.d.ts.map +1 -0
- package/lib/types/ink/terminal-focus-state.js +57 -0
- package/lib/types/ink/terminal-querier.d.ts +161 -0
- package/lib/types/ink/terminal-querier.d.ts.map +1 -0
- package/lib/types/ink/terminal-querier.js +204 -0
- package/lib/types/ink/terminal.d.ts +80 -0
- package/lib/types/ink/terminal.d.ts.map +1 -0
- package/lib/types/ink/terminal.js +268 -0
- package/lib/types/ink/termio/ansi.d.ts +75 -0
- package/lib/types/ink/termio/ansi.d.ts.map +1 -0
- package/lib/types/ink/termio/ansi.js +79 -0
- package/lib/types/ink/termio/csi.d.ts +253 -0
- package/lib/types/ink/termio/csi.d.ts.map +1 -0
- package/lib/types/ink/termio/csi.js +347 -0
- package/lib/types/ink/termio/dec.d.ts +61 -0
- package/lib/types/ink/termio/dec.d.ts.map +1 -0
- package/lib/types/ink/termio/dec.js +76 -0
- package/lib/types/ink/termio/esc.d.ts +15 -0
- package/lib/types/ink/termio/esc.d.ts.map +1 -0
- package/lib/types/ink/termio/esc.js +57 -0
- package/lib/types/ink/termio/osc.d.ts +208 -0
- package/lib/types/ink/termio/osc.d.ts.map +1 -0
- package/lib/types/ink/termio/osc.js +466 -0
- package/lib/types/ink/termio/parser.d.ts +46 -0
- package/lib/types/ink/termio/parser.d.ts.map +1 -0
- package/lib/types/ink/termio/parser.js +366 -0
- package/lib/types/ink/termio/sgr.d.ts +17 -0
- package/lib/types/ink/termio/sgr.d.ts.map +1 -0
- package/lib/types/ink/termio/sgr.js +300 -0
- package/lib/types/ink/termio/tokenize.d.ts +50 -0
- package/lib/types/ink/termio/tokenize.d.ts.map +1 -0
- package/lib/types/ink/termio/tokenize.js +266 -0
- package/lib/types/ink/termio/types.d.ts +211 -0
- package/lib/types/ink/termio/types.d.ts.map +1 -0
- package/lib/types/ink/termio/types.js +68 -0
- package/lib/types/ink/termio.d.ts +25 -0
- package/lib/types/ink/termio.d.ts.map +1 -0
- package/lib/types/ink/termio.js +24 -0
- package/lib/types/ink/truncateToWidth.d.ts +7 -0
- package/lib/types/ink/truncateToWidth.d.ts.map +1 -0
- package/lib/types/ink/truncateToWidth.js +18 -0
- package/lib/types/ink/useTerminalNotification.d.ts +45 -0
- package/lib/types/ink/useTerminalNotification.d.ts.map +1 -0
- package/lib/types/ink/useTerminalNotification.js +70 -0
- package/lib/types/ink/warn.d.ts +7 -0
- package/lib/types/ink/warn.d.ts.map +1 -0
- package/lib/types/ink/warn.js +15 -0
- package/lib/types/ink/widest-line.d.ts +7 -0
- package/lib/types/ink/widest-line.d.ts.map +1 -0
- package/lib/types/ink/widest-line.js +19 -0
- package/lib/types/ink/wrap-text.d.ts +10 -0
- package/lib/types/ink/wrap-text.d.ts.map +1 -0
- package/lib/types/ink/wrap-text.js +61 -0
- package/lib/types/ink/wrapAnsi.d.ts +18 -0
- package/lib/types/ink/wrapAnsi.d.ts.map +1 -0
- package/lib/types/ink/wrapAnsi.js +16 -0
- package/lib/types/invariant.d.ts +20 -0
- package/lib/types/invariant.d.ts.map +1 -0
- package/lib/types/invariant.js +26 -0
- package/lib/types/modelPrefs.d.ts +37 -0
- package/lib/types/modelPrefs.d.ts.map +1 -0
- package/lib/types/modelPrefs.js +66 -0
- package/lib/types/modelRoute.d.ts +79 -0
- package/lib/types/modelRoute.d.ts.map +1 -0
- package/lib/types/modelRoute.js +96 -0
- package/lib/types/native-ts/yoga-layout/enums.d.ts +183 -0
- package/lib/types/native-ts/yoga-layout/enums.d.ts.map +1 -0
- package/lib/types/native-ts/yoga-layout/enums.js +150 -0
- package/lib/types/native-ts/yoga-layout/index.d.ts +788 -0
- package/lib/types/native-ts/yoga-layout/index.d.ts.map +1 -0
- package/lib/types/native-ts/yoga-layout/index.js +2571 -0
- package/lib/types/packaged-skills.d.ts +10 -0
- package/lib/types/packaged-skills.d.ts.map +1 -0
- package/lib/types/packaged-skills.js +63 -0
- package/lib/types/plugin.d.ts +33 -0
- package/lib/types/plugin.d.ts.map +1 -0
- package/lib/types/plugin.js +454 -0
- package/lib/types/presetPrefs.d.ts +29 -0
- package/lib/types/presetPrefs.d.ts.map +1 -0
- package/lib/types/presetPrefs.js +61 -0
- package/lib/types/presets.d.ts +110 -0
- package/lib/types/presets.d.ts.map +1 -0
- package/lib/types/presets.js +114 -0
- package/lib/types/questions.d.ts +97 -0
- package/lib/types/questions.d.ts.map +1 -0
- package/lib/types/questions.js +201 -0
- package/lib/types/screens/Chat.d.ts +23 -0
- package/lib/types/screens/Chat.d.ts.map +1 -0
- package/lib/types/screens/Chat.js +1263 -0
- package/lib/types/screens/StatusLine.d.ts +16 -0
- package/lib/types/screens/StatusLine.d.ts.map +1 -0
- package/lib/types/screens/StatusLine.js +105 -0
- package/lib/types/screens/StatusMetrics.d.ts +87 -0
- package/lib/types/screens/StatusMetrics.d.ts.map +1 -0
- package/lib/types/screens/StatusMetrics.js +252 -0
- package/lib/types/sessionHistory.d.ts +32 -0
- package/lib/types/sessionHistory.d.ts.map +1 -0
- package/lib/types/sessionHistory.js +87 -0
- package/lib/types/theme.d.ts +115 -0
- package/lib/types/theme.d.ts.map +1 -0
- package/lib/types/theme.js +300 -0
- package/lib/types/themePrefs.d.ts +28 -0
- package/lib/types/themePrefs.d.ts.map +1 -0
- package/lib/types/themePrefs.js +59 -0
- package/lib/types/ui.d.ts +28 -0
- package/lib/types/ui.d.ts.map +1 -0
- package/lib/types/ui.js +25 -0
- package/lib/types/update.d.ts +76 -0
- package/lib/types/update.d.ts.map +1 -0
- package/lib/types/update.js +203 -0
- package/lib/types/utils/clipboard.d.ts +43 -0
- package/lib/types/utils/clipboard.d.ts.map +1 -0
- package/lib/types/utils/clipboard.js +82 -0
- package/lib/types/utils/debug.d.ts +8 -0
- package/lib/types/utils/debug.d.ts.map +1 -0
- package/lib/types/utils/debug.js +12 -0
- package/lib/types/utils/earlyInput.d.ts +7 -0
- package/lib/types/utils/earlyInput.d.ts.map +1 -0
- package/lib/types/utils/earlyInput.js +6 -0
- package/lib/types/utils/env.d.ts +10 -0
- package/lib/types/utils/env.d.ts.map +1 -0
- package/lib/types/utils/env.js +9 -0
- package/lib/types/utils/envUtils.d.ts +8 -0
- package/lib/types/utils/envUtils.d.ts.map +1 -0
- package/lib/types/utils/envUtils.js +13 -0
- package/lib/types/utils/execFileNoThrow.d.ts +34 -0
- package/lib/types/utils/execFileNoThrow.d.ts.map +1 -0
- package/lib/types/utils/execFileNoThrow.js +31 -0
- package/lib/types/utils/fullscreen.d.ts +8 -0
- package/lib/types/utils/fullscreen.d.ts.map +1 -0
- package/lib/types/utils/fullscreen.js +10 -0
- package/lib/types/utils/intl.d.ts +7 -0
- package/lib/types/utils/intl.d.ts.map +1 -0
- package/lib/types/utils/intl.js +9 -0
- package/lib/types/utils/loaded-context.d.ts +20 -0
- package/lib/types/utils/loaded-context.d.ts.map +1 -0
- package/lib/types/utils/loaded-context.js +36 -0
- package/lib/types/utils/log.d.ts +7 -0
- package/lib/types/utils/log.d.ts.map +1 -0
- package/lib/types/utils/log.js +9 -0
- package/lib/types/utils/mentions.d.ts +30 -0
- package/lib/types/utils/mentions.d.ts.map +1 -0
- package/lib/types/utils/mentions.js +72 -0
- package/lib/types/utils/narration.d.ts +11 -0
- package/lib/types/utils/narration.d.ts.map +1 -0
- package/lib/types/utils/narration.js +16 -0
- package/lib/types/utils/semver.d.ts +9 -0
- package/lib/types/utils/semver.d.ts.map +1 -0
- package/lib/types/utils/semver.js +24 -0
- package/lib/types/utils/sliceAnsi.d.ts +12 -0
- package/lib/types/utils/sliceAnsi.d.ts.map +1 -0
- package/lib/types/utils/sliceAnsi.js +79 -0
- package/lib/types/working-activity.d.ts +19 -0
- package/lib/types/working-activity.d.ts.map +1 -0
- package/lib/types/working-activity.js +18 -0
- package/package.json +141 -0
- package/skills/audit/SKILL.md +24 -0
- package/skills/bug/SKILL.md +27 -0
- package/skills/pr-comments/SKILL.md +20 -0
- package/skills/practice/SKILL.md +22 -0
- package/skills/release-notes/SKILL.md +25 -0
- package/skills/review/SKILL.md +25 -0
- package/skills/vuln-check/SKILL.md +25 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import createReconciler from 'react-reconciler';
|
|
2
|
+
import { type DOMElement, type TextNode } from './dom.js';
|
|
3
|
+
import { Dispatcher } from './events/dispatcher.js';
|
|
4
|
+
/**
|
|
5
|
+
* Walk a fiber's owner chain and return the names of the components that
|
|
6
|
+
* rendered it, skipping host elements.
|
|
7
|
+
* @param fiber - the fiber whose owner chain to walk.
|
|
8
|
+
* @returns the component display names, outermost first.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getOwnerChain(fiber: unknown): string[];
|
|
11
|
+
/**
|
|
12
|
+
* Read the CLAUDE_CODE_DEBUG_REPAINTS flag once and cache it.
|
|
13
|
+
* @returns whether repaint debugging is enabled.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isDebugRepaintsEnabled(): boolean;
|
|
16
|
+
/** The terminal event dispatcher that routes input events to registered handlers. */
|
|
17
|
+
export declare const dispatcher: Dispatcher;
|
|
18
|
+
/**
|
|
19
|
+
* Record the yoga layout duration of the current commit.
|
|
20
|
+
* @param ms - the layout duration in milliseconds.
|
|
21
|
+
*/
|
|
22
|
+
export declare function recordYogaMs(ms: number): void;
|
|
23
|
+
/**
|
|
24
|
+
* The yoga layout duration recorded by recordYogaMs.
|
|
25
|
+
* @returns the layout duration in milliseconds.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getLastYogaMs(): number;
|
|
28
|
+
/** Mark the start of the current commit for commit-duration profiling. */
|
|
29
|
+
export declare function markCommitStart(): void;
|
|
30
|
+
/**
|
|
31
|
+
* The duration of the last commit, from markCommitStart to resetAfterCommit.
|
|
32
|
+
* @returns the commit duration in milliseconds.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getLastCommitMs(): number;
|
|
35
|
+
/** Reset all commit and layout profiling counters to zero. */
|
|
36
|
+
export declare function resetProfileCounters(): void;
|
|
37
|
+
/**
|
|
38
|
+
* The react-reconciler instance that renders React elements into the Ink
|
|
39
|
+
* DOM tree, wired to the event dispatcher for update priorities.
|
|
40
|
+
*/
|
|
41
|
+
declare const reconciler: createReconciler.Reconciler<DOMElement, DOMElement, TextNode, DOMElement, unknown, DOMElement>;
|
|
42
|
+
export default reconciler;
|
|
43
|
+
//# sourceMappingURL=reconciler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconciler.d.ts","sourceRoot":"","sources":["../../../src/ink/reconciler.ts"],"names":[],"mappings":"AAGA,OAAO,gBAAgB,MAAM,kBAAkB,CAAA;AAG/C,OAAO,EAKL,KAAK,UAAU,EAUf,KAAK,QAAQ,EACd,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAsInD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAmBtD;AAGD;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAKhD;AAED,qFAAqF;AACrF,eAAO,MAAM,UAAU,YAAmB,CAAA;AAkB1C;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAE7C;AACD;;;GAGG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AACD,0EAA0E;AAC1E,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AACD;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AACD,8DAA8D;AAC9D,wBAAgB,oBAAoB,IAAI,IAAI,CAI3C;AAGD;;;GAGG;AACH,QAAA,MAAM,UAAU,gGA0Rd,CAAA;AAMF,eAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
/* eslint-disable custom-rules/no-top-level-side-effects */
|
|
2
|
+
import { appendFileSync } from 'fs';
|
|
3
|
+
import createReconciler from 'react-reconciler';
|
|
4
|
+
import { getYogaCounters } from '../native-ts/yoga-layout/index.js';
|
|
5
|
+
import { isEnvTruthy } from '../utils/envUtils.js';
|
|
6
|
+
import { appendChildNode, clearYogaNodeReferences, createNode, createTextNode, insertBeforeNode, markDirty, removeChildNode, setAttribute, setStyle, setTextNodeValue, setTextStyles, } from './dom.js';
|
|
7
|
+
import { Dispatcher } from './events/dispatcher.js';
|
|
8
|
+
import { EVENT_HANDLER_PROPS } from './events/event-handlers.js';
|
|
9
|
+
import { getFocusManager, getRootNode } from './focus.js';
|
|
10
|
+
import { LayoutDisplay } from './layout/node.js';
|
|
11
|
+
import applyStyles from './styles.js';
|
|
12
|
+
// We need to conditionally perform devtools connection to avoid
|
|
13
|
+
// accidentally breaking other third-party code.
|
|
14
|
+
// See https://github.com/vadimdemedes/ink/issues/384
|
|
15
|
+
if (process.env.NODE_ENV === 'development') {
|
|
16
|
+
try {
|
|
17
|
+
// eslint-disable-next-line custom-rules/no-top-level-dynamic-import -- dev-only; NODE_ENV check is DCE'd in production
|
|
18
|
+
void import('./devtools.js');
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
if (error.code === 'ERR_MODULE_NOT_FOUND') {
|
|
23
|
+
// biome-ignore lint/suspicious/noConsole: intentional warning
|
|
24
|
+
console.warn(`
|
|
25
|
+
The environment variable DEV is set to true, so Ink tried to import \`react-devtools-core\`,
|
|
26
|
+
but this failed as it was not installed. Debugging with React Devtools requires it.
|
|
27
|
+
|
|
28
|
+
To install use this command:
|
|
29
|
+
|
|
30
|
+
$ npm install --save-dev react-devtools-core
|
|
31
|
+
`.trim() + '\n');
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/only-throw-error
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const diff = (before, after) => {
|
|
40
|
+
if (before === after) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (!before) {
|
|
44
|
+
return after;
|
|
45
|
+
}
|
|
46
|
+
const changed = {};
|
|
47
|
+
let isChanged = false;
|
|
48
|
+
for (const key of Object.keys(before)) {
|
|
49
|
+
const isDeleted = after ? !Object.hasOwn(after, key) : true;
|
|
50
|
+
if (isDeleted) {
|
|
51
|
+
changed[key] = undefined;
|
|
52
|
+
isChanged = true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (after) {
|
|
56
|
+
for (const key of Object.keys(after)) {
|
|
57
|
+
if (after[key] !== before[key]) {
|
|
58
|
+
changed[key] = after[key];
|
|
59
|
+
isChanged = true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return isChanged ? changed : undefined;
|
|
64
|
+
};
|
|
65
|
+
const cleanupYogaNode = (node) => {
|
|
66
|
+
const yogaNode = node.yogaNode;
|
|
67
|
+
if (yogaNode) {
|
|
68
|
+
yogaNode.unsetMeasureFunc();
|
|
69
|
+
// Clear all references BEFORE freeing to prevent other code from
|
|
70
|
+
// accessing freed WASM memory during concurrent operations
|
|
71
|
+
clearYogaNodeReferences(node);
|
|
72
|
+
yogaNode.freeRecursive();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
function setEventHandler(node, key, value) {
|
|
76
|
+
if (!node._eventHandlers) {
|
|
77
|
+
node._eventHandlers = {};
|
|
78
|
+
}
|
|
79
|
+
node._eventHandlers[key] = value;
|
|
80
|
+
}
|
|
81
|
+
function applyProp(node, key, value) {
|
|
82
|
+
if (key === 'children')
|
|
83
|
+
return;
|
|
84
|
+
if (key === 'style') {
|
|
85
|
+
setStyle(node, value);
|
|
86
|
+
if (node.yogaNode) {
|
|
87
|
+
applyStyles(node.yogaNode, value);
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (key === 'textStyles') {
|
|
92
|
+
node.textStyles = value;
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (EVENT_HANDLER_PROPS.has(key)) {
|
|
96
|
+
setEventHandler(node, key, value);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
setAttribute(node, key, value);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Walk a fiber's owner chain and return the names of the components that
|
|
103
|
+
* rendered it, skipping host elements.
|
|
104
|
+
* @param fiber - the fiber whose owner chain to walk.
|
|
105
|
+
* @returns the component display names, outermost first.
|
|
106
|
+
*/
|
|
107
|
+
export function getOwnerChain(fiber) {
|
|
108
|
+
const chain = [];
|
|
109
|
+
const seen = new Set();
|
|
110
|
+
let cur = fiber;
|
|
111
|
+
for (let i = 0; cur && i < 50; i++) {
|
|
112
|
+
if (seen.has(cur))
|
|
113
|
+
break;
|
|
114
|
+
seen.add(cur);
|
|
115
|
+
const t = cur.elementType;
|
|
116
|
+
const name = typeof t === 'function'
|
|
117
|
+
? t.displayName ||
|
|
118
|
+
t.name
|
|
119
|
+
: typeof t === 'string'
|
|
120
|
+
? undefined // host element (ink-box etc) — skip
|
|
121
|
+
: t?.displayName || t?.name;
|
|
122
|
+
if (name && name !== chain[chain.length - 1])
|
|
123
|
+
chain.push(name);
|
|
124
|
+
cur = cur._debugOwner ?? cur.return;
|
|
125
|
+
}
|
|
126
|
+
return chain;
|
|
127
|
+
}
|
|
128
|
+
let debugRepaints;
|
|
129
|
+
/**
|
|
130
|
+
* Read the CLAUDE_CODE_DEBUG_REPAINTS flag once and cache it.
|
|
131
|
+
* @returns whether repaint debugging is enabled.
|
|
132
|
+
*/
|
|
133
|
+
export function isDebugRepaintsEnabled() {
|
|
134
|
+
if (debugRepaints === undefined) {
|
|
135
|
+
debugRepaints = isEnvTruthy(process.env.CLAUDE_CODE_DEBUG_REPAINTS);
|
|
136
|
+
}
|
|
137
|
+
return debugRepaints;
|
|
138
|
+
}
|
|
139
|
+
/** The terminal event dispatcher that routes input events to registered handlers. */
|
|
140
|
+
export const dispatcher = new Dispatcher();
|
|
141
|
+
// --- COMMIT INSTRUMENTATION (temp debugging) ---
|
|
142
|
+
// eslint-disable-next-line custom-rules/no-process-env-top-level -- debug instrumentation, read-once is fine
|
|
143
|
+
const COMMIT_LOG = process.env.CLAUDE_CODE_COMMIT_LOG;
|
|
144
|
+
let _commits = 0;
|
|
145
|
+
let _lastLog = 0;
|
|
146
|
+
let _lastCommitAt = 0;
|
|
147
|
+
let _maxGapMs = 0;
|
|
148
|
+
let _createCount = 0;
|
|
149
|
+
let _prepareAt = 0;
|
|
150
|
+
// --- END ---
|
|
151
|
+
// --- SCROLL PROFILING (bench/scroll-e2e.sh reads via getLastYogaMs) ---
|
|
152
|
+
// Set by onComputeLayout wrapper in ink.tsx; read by onRender for phases.
|
|
153
|
+
let _lastYogaMs = 0;
|
|
154
|
+
let _lastCommitMs = 0;
|
|
155
|
+
let _commitStart = 0;
|
|
156
|
+
/**
|
|
157
|
+
* Record the yoga layout duration of the current commit.
|
|
158
|
+
* @param ms - the layout duration in milliseconds.
|
|
159
|
+
*/
|
|
160
|
+
export function recordYogaMs(ms) {
|
|
161
|
+
_lastYogaMs = ms;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* The yoga layout duration recorded by recordYogaMs.
|
|
165
|
+
* @returns the layout duration in milliseconds.
|
|
166
|
+
*/
|
|
167
|
+
export function getLastYogaMs() {
|
|
168
|
+
return _lastYogaMs;
|
|
169
|
+
}
|
|
170
|
+
/** Mark the start of the current commit for commit-duration profiling. */
|
|
171
|
+
export function markCommitStart() {
|
|
172
|
+
_commitStart = performance.now();
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The duration of the last commit, from markCommitStart to resetAfterCommit.
|
|
176
|
+
* @returns the commit duration in milliseconds.
|
|
177
|
+
*/
|
|
178
|
+
export function getLastCommitMs() {
|
|
179
|
+
return _lastCommitMs;
|
|
180
|
+
}
|
|
181
|
+
/** Reset all commit and layout profiling counters to zero. */
|
|
182
|
+
export function resetProfileCounters() {
|
|
183
|
+
_lastYogaMs = 0;
|
|
184
|
+
_lastCommitMs = 0;
|
|
185
|
+
_commitStart = 0;
|
|
186
|
+
}
|
|
187
|
+
// --- END ---
|
|
188
|
+
/**
|
|
189
|
+
* The react-reconciler instance that renders React elements into the Ink
|
|
190
|
+
* DOM tree, wired to the event dispatcher for update priorities.
|
|
191
|
+
*/
|
|
192
|
+
const reconciler = createReconciler({
|
|
193
|
+
getRootHostContext: () => ({ isInsideText: false }),
|
|
194
|
+
prepareForCommit: () => {
|
|
195
|
+
if (COMMIT_LOG)
|
|
196
|
+
_prepareAt = performance.now();
|
|
197
|
+
return null;
|
|
198
|
+
},
|
|
199
|
+
preparePortalMount: () => null,
|
|
200
|
+
clearContainer: () => false,
|
|
201
|
+
resetAfterCommit(rootNode) {
|
|
202
|
+
_lastCommitMs = _commitStart > 0 ? performance.now() - _commitStart : 0;
|
|
203
|
+
_commitStart = 0;
|
|
204
|
+
if (COMMIT_LOG) {
|
|
205
|
+
const now = performance.now();
|
|
206
|
+
_commits++;
|
|
207
|
+
const gap = _lastCommitAt > 0 ? now - _lastCommitAt : 0;
|
|
208
|
+
if (gap > _maxGapMs)
|
|
209
|
+
_maxGapMs = gap;
|
|
210
|
+
_lastCommitAt = now;
|
|
211
|
+
const reconcileMs = _prepareAt > 0 ? now - _prepareAt : 0;
|
|
212
|
+
if (gap > 30 || reconcileMs > 20 || _createCount > 50) {
|
|
213
|
+
// eslint-disable-next-line custom-rules/no-sync-fs -- debug instrumentation
|
|
214
|
+
appendFileSync(COMMIT_LOG, `${now.toFixed(1)} gap=${gap.toFixed(1)}ms reconcile=${reconcileMs.toFixed(1)}ms creates=${_createCount}\n`);
|
|
215
|
+
}
|
|
216
|
+
_createCount = 0;
|
|
217
|
+
if (now - _lastLog > 1000) {
|
|
218
|
+
// eslint-disable-next-line custom-rules/no-sync-fs -- debug instrumentation
|
|
219
|
+
appendFileSync(COMMIT_LOG, `${now.toFixed(1)} commits=${_commits}/s maxGap=${_maxGapMs.toFixed(1)}ms\n`);
|
|
220
|
+
_commits = 0;
|
|
221
|
+
_maxGapMs = 0;
|
|
222
|
+
_lastLog = now;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
const _t0 = COMMIT_LOG ? performance.now() : 0;
|
|
226
|
+
if (typeof rootNode.onComputeLayout === 'function') {
|
|
227
|
+
rootNode.onComputeLayout();
|
|
228
|
+
}
|
|
229
|
+
if (COMMIT_LOG) {
|
|
230
|
+
const layoutMs = performance.now() - _t0;
|
|
231
|
+
if (layoutMs > 20) {
|
|
232
|
+
const c = getYogaCounters();
|
|
233
|
+
// eslint-disable-next-line custom-rules/no-sync-fs -- debug instrumentation
|
|
234
|
+
appendFileSync(COMMIT_LOG, `${_t0.toFixed(1)} SLOW_YOGA ${layoutMs.toFixed(1)}ms visited=${c.visited} measured=${c.measured} hits=${c.cacheHits} live=${c.live}\n`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (process.env.NODE_ENV === 'test') {
|
|
238
|
+
if (rootNode.childNodes.length === 0 && rootNode.hasRenderedContent) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (rootNode.childNodes.length > 0) {
|
|
242
|
+
rootNode.hasRenderedContent = true;
|
|
243
|
+
}
|
|
244
|
+
rootNode.onImmediateRender?.();
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const _tr = COMMIT_LOG ? performance.now() : 0;
|
|
248
|
+
rootNode.onRender?.();
|
|
249
|
+
if (COMMIT_LOG) {
|
|
250
|
+
const renderMs = performance.now() - _tr;
|
|
251
|
+
if (renderMs > 10) {
|
|
252
|
+
// eslint-disable-next-line custom-rules/no-sync-fs -- debug instrumentation
|
|
253
|
+
appendFileSync(COMMIT_LOG, `${_tr.toFixed(1)} SLOW_PAINT ${renderMs.toFixed(1)}ms\n`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
getChildHostContext(parentHostContext, type) {
|
|
258
|
+
const previousIsInsideText = parentHostContext.isInsideText;
|
|
259
|
+
const isInsideText = type === 'ink-text' || type === 'ink-virtual-text' || type === 'ink-link';
|
|
260
|
+
if (previousIsInsideText === isInsideText) {
|
|
261
|
+
return parentHostContext;
|
|
262
|
+
}
|
|
263
|
+
return { isInsideText };
|
|
264
|
+
},
|
|
265
|
+
shouldSetTextContent: () => false,
|
|
266
|
+
createInstance(originalType, newProps, _root, hostContext, internalHandle) {
|
|
267
|
+
if (hostContext.isInsideText && originalType === 'ink-box') {
|
|
268
|
+
throw new Error(`<Box> can't be nested inside <Text> component`);
|
|
269
|
+
}
|
|
270
|
+
const type = originalType === 'ink-text' && hostContext.isInsideText
|
|
271
|
+
? 'ink-virtual-text'
|
|
272
|
+
: originalType;
|
|
273
|
+
const node = createNode(type);
|
|
274
|
+
if (COMMIT_LOG)
|
|
275
|
+
_createCount++;
|
|
276
|
+
for (const [key, value] of Object.entries(newProps)) {
|
|
277
|
+
applyProp(node, key, value);
|
|
278
|
+
}
|
|
279
|
+
if (isDebugRepaintsEnabled()) {
|
|
280
|
+
node.debugOwnerChain = getOwnerChain(internalHandle);
|
|
281
|
+
}
|
|
282
|
+
return node;
|
|
283
|
+
},
|
|
284
|
+
createTextInstance(text, _root, hostContext) {
|
|
285
|
+
if (!hostContext.isInsideText) {
|
|
286
|
+
throw new Error(`Text string "${text}" must be rendered inside <Text> component`);
|
|
287
|
+
}
|
|
288
|
+
return createTextNode(text);
|
|
289
|
+
},
|
|
290
|
+
resetTextContent() { },
|
|
291
|
+
hideTextInstance(node) {
|
|
292
|
+
setTextNodeValue(node, '');
|
|
293
|
+
},
|
|
294
|
+
unhideTextInstance(node, text) {
|
|
295
|
+
setTextNodeValue(node, text);
|
|
296
|
+
},
|
|
297
|
+
getPublicInstance: (instance) => instance,
|
|
298
|
+
hideInstance(node) {
|
|
299
|
+
node.isHidden = true;
|
|
300
|
+
node.yogaNode?.setDisplay(LayoutDisplay.None);
|
|
301
|
+
markDirty(node);
|
|
302
|
+
},
|
|
303
|
+
unhideInstance(node) {
|
|
304
|
+
node.isHidden = false;
|
|
305
|
+
node.yogaNode?.setDisplay(LayoutDisplay.Flex);
|
|
306
|
+
markDirty(node);
|
|
307
|
+
},
|
|
308
|
+
appendInitialChild: appendChildNode,
|
|
309
|
+
appendChild: appendChildNode,
|
|
310
|
+
insertBefore: insertBeforeNode,
|
|
311
|
+
finalizeInitialChildren(_node, _type, props) {
|
|
312
|
+
return props['autoFocus'] === true;
|
|
313
|
+
},
|
|
314
|
+
commitMount(node) {
|
|
315
|
+
getFocusManager(node).handleAutoFocus(node);
|
|
316
|
+
},
|
|
317
|
+
isPrimaryRenderer: true,
|
|
318
|
+
supportsMutation: true,
|
|
319
|
+
supportsPersistence: false,
|
|
320
|
+
supportsHydration: false,
|
|
321
|
+
scheduleTimeout: setTimeout,
|
|
322
|
+
cancelTimeout: clearTimeout,
|
|
323
|
+
noTimeout: -1,
|
|
324
|
+
getCurrentUpdatePriority: () => dispatcher.currentUpdatePriority,
|
|
325
|
+
beforeActiveInstanceBlur() { },
|
|
326
|
+
afterActiveInstanceBlur() { },
|
|
327
|
+
detachDeletedInstance() { },
|
|
328
|
+
getInstanceFromNode: () => null,
|
|
329
|
+
prepareScopeUpdate() { },
|
|
330
|
+
getInstanceFromScope: () => null,
|
|
331
|
+
appendChildToContainer: appendChildNode,
|
|
332
|
+
insertInContainerBefore: insertBeforeNode,
|
|
333
|
+
removeChildFromContainer(node, removeNode) {
|
|
334
|
+
removeChildNode(node, removeNode);
|
|
335
|
+
cleanupYogaNode(removeNode);
|
|
336
|
+
getFocusManager(node).handleNodeRemoved(removeNode, node);
|
|
337
|
+
},
|
|
338
|
+
// React 19 commitUpdate receives old and new props directly instead of an updatePayload
|
|
339
|
+
commitUpdate(node, _type, oldProps, newProps) {
|
|
340
|
+
const props = diff(oldProps, newProps);
|
|
341
|
+
const style = diff(oldProps['style'], newProps['style']);
|
|
342
|
+
if (props) {
|
|
343
|
+
for (const [key, value] of Object.entries(props)) {
|
|
344
|
+
if (key === 'style') {
|
|
345
|
+
setStyle(node, value);
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
if (key === 'textStyles') {
|
|
349
|
+
setTextStyles(node, value);
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
if (EVENT_HANDLER_PROPS.has(key)) {
|
|
353
|
+
setEventHandler(node, key, value);
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
setAttribute(node, key, value);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
if (style && node.yogaNode) {
|
|
360
|
+
applyStyles(node.yogaNode, style, newProps['style']);
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
commitTextUpdate(node, _oldText, newText) {
|
|
364
|
+
setTextNodeValue(node, newText);
|
|
365
|
+
},
|
|
366
|
+
removeChild(node, removeNode) {
|
|
367
|
+
removeChildNode(node, removeNode);
|
|
368
|
+
cleanupYogaNode(removeNode);
|
|
369
|
+
if (removeNode.nodeName !== '#text') {
|
|
370
|
+
const root = getRootNode(node);
|
|
371
|
+
root.focusManager.handleNodeRemoved(removeNode, root);
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
// React 19 required methods
|
|
375
|
+
maySuspendCommit() {
|
|
376
|
+
return false;
|
|
377
|
+
},
|
|
378
|
+
preloadInstance() {
|
|
379
|
+
return true;
|
|
380
|
+
},
|
|
381
|
+
startSuspendingCommit() { },
|
|
382
|
+
suspendInstance() { },
|
|
383
|
+
waitForCommitToBeReady() {
|
|
384
|
+
return null;
|
|
385
|
+
},
|
|
386
|
+
NotPendingTransition: null,
|
|
387
|
+
HostTransitionContext: {
|
|
388
|
+
$$typeof: Symbol.for('react.context'),
|
|
389
|
+
_currentValue: null,
|
|
390
|
+
},
|
|
391
|
+
setCurrentUpdatePriority(newPriority) {
|
|
392
|
+
dispatcher.currentUpdatePriority = newPriority;
|
|
393
|
+
},
|
|
394
|
+
resolveUpdatePriority() {
|
|
395
|
+
return dispatcher.resolveEventPriority();
|
|
396
|
+
},
|
|
397
|
+
resetFormInstance() { },
|
|
398
|
+
requestPostPaintCallback() { },
|
|
399
|
+
shouldAttemptEagerTransition() {
|
|
400
|
+
return false;
|
|
401
|
+
},
|
|
402
|
+
trackSchedulerEvent() { },
|
|
403
|
+
resolveEventType() {
|
|
404
|
+
return dispatcher.currentEvent?.type ?? null;
|
|
405
|
+
},
|
|
406
|
+
resolveEventTimeStamp() {
|
|
407
|
+
return dispatcher.currentEvent?.timeStamp ?? -1.1;
|
|
408
|
+
},
|
|
409
|
+
});
|
|
410
|
+
// Wire the reconciler's discreteUpdates into the dispatcher.
|
|
411
|
+
// This breaks the import cycle: dispatcher.ts doesn't import reconciler.ts.
|
|
412
|
+
dispatcher.discreteUpdates = reconciler.discreteUpdates.bind(reconciler);
|
|
413
|
+
export default reconciler;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type Boxes, type BoxStyle } from 'cli-boxes';
|
|
2
|
+
import type { DOMNode } from './dom.js';
|
|
3
|
+
import type Output from './output.js';
|
|
4
|
+
/** Options for embedding a text label into a border line. */
|
|
5
|
+
export type BorderTextOptions = {
|
|
6
|
+
content: string;
|
|
7
|
+
position: 'top' | 'bottom';
|
|
8
|
+
align: 'start' | 'end' | 'center';
|
|
9
|
+
offset?: number;
|
|
10
|
+
};
|
|
11
|
+
/** Built-in border styles beyond those provided by cli-boxes. */
|
|
12
|
+
export declare const CUSTOM_BORDER_STYLES: {
|
|
13
|
+
readonly dashed: {
|
|
14
|
+
readonly top: "╌";
|
|
15
|
+
readonly left: "╎";
|
|
16
|
+
readonly right: "╎";
|
|
17
|
+
readonly bottom: "╌";
|
|
18
|
+
readonly topLeft: " ";
|
|
19
|
+
readonly topRight: " ";
|
|
20
|
+
readonly bottomLeft: " ";
|
|
21
|
+
readonly bottomRight: " ";
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/** A border style: a cli-boxes key, a custom style key, or an explicit box style. */
|
|
25
|
+
export type BorderStyle = keyof Boxes | keyof typeof CUSTOM_BORDER_STYLES | BoxStyle;
|
|
26
|
+
/**
|
|
27
|
+
* Render the node's border, including any embedded border text, into the
|
|
28
|
+
* output buffer when a border style is set.
|
|
29
|
+
* @param x - the border's left column.
|
|
30
|
+
* @param y - the border's top row.
|
|
31
|
+
* @param node - the node whose border style to render.
|
|
32
|
+
* @param output - the output buffer receiving the border writes.
|
|
33
|
+
*/
|
|
34
|
+
declare const renderBorder: (x: number, y: number, node: DOMNode, output: Output) => void;
|
|
35
|
+
export default renderBorder;
|
|
36
|
+
//# sourceMappingURL=render-border.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-border.d.ts","sourceRoot":"","sources":["../../../src/ink/render-border.ts"],"names":[],"mappings":"AACA,OAAiB,EAAE,KAAK,KAAK,EAAE,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAA;AAE/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAIrC,6DAA6D;AAC7D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,KAAK,GAAG,QAAQ,CAAA;IAC1B,KAAK,EAAE,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAA;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,iEAAiE;AACjE,eAAO,MAAM,oBAAoB;;;;;;;;;;;CAYvB,CAAA;AAEV,qFAAqF;AACrF,MAAM,MAAM,WAAW,GACnB,MAAM,KAAK,GACX,MAAM,OAAO,oBAAoB,GACjC,QAAQ,CAAA;AAiDZ;;;;;;;GAOG;AACH,QAAA,MAAM,YAAY,GAChB,GAAG,MAAM,EACT,GAAG,MAAM,EACT,MAAM,OAAO,EACb,QAAQ,MAAM,KACb,IA8IF,CAAA;AAED,eAAe,YAAY,CAAA"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import cliBoxes from 'cli-boxes';
|
|
3
|
+
import { applyColor } from './colorize.js';
|
|
4
|
+
import { stringWidth } from './stringWidth.js';
|
|
5
|
+
/** Built-in border styles beyond those provided by cli-boxes. */
|
|
6
|
+
export const CUSTOM_BORDER_STYLES = {
|
|
7
|
+
dashed: {
|
|
8
|
+
top: '╌',
|
|
9
|
+
left: '╎',
|
|
10
|
+
right: '╎',
|
|
11
|
+
bottom: '╌',
|
|
12
|
+
// there aren't any line-drawing characters for dashes unfortunately
|
|
13
|
+
topLeft: ' ',
|
|
14
|
+
topRight: ' ',
|
|
15
|
+
bottomLeft: ' ',
|
|
16
|
+
bottomRight: ' ',
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
function embedTextInBorder(borderLine, text, align, offset = 0, borderChar) {
|
|
20
|
+
const textLength = stringWidth(text);
|
|
21
|
+
const borderLength = borderLine.length;
|
|
22
|
+
if (textLength >= borderLength - 2) {
|
|
23
|
+
return ['', text.substring(0, borderLength), ''];
|
|
24
|
+
}
|
|
25
|
+
let position;
|
|
26
|
+
if (align === 'center') {
|
|
27
|
+
position = Math.floor((borderLength - textLength) / 2);
|
|
28
|
+
}
|
|
29
|
+
else if (align === 'start') {
|
|
30
|
+
position = offset + 1; // +1 to account for corner character
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// align === 'end'
|
|
34
|
+
position = borderLength - textLength - offset - 1; // -1 for corner character
|
|
35
|
+
}
|
|
36
|
+
// Ensure position is valid
|
|
37
|
+
position = Math.max(1, Math.min(position, borderLength - textLength - 1));
|
|
38
|
+
const before = borderLine.substring(0, 1) + borderChar.repeat(position - 1);
|
|
39
|
+
const after = borderChar.repeat(borderLength - position - textLength - 1) +
|
|
40
|
+
borderLine.substring(borderLength - 1);
|
|
41
|
+
return [before, text, after];
|
|
42
|
+
}
|
|
43
|
+
function styleBorderLine(line, color, dim) {
|
|
44
|
+
let styled = applyColor(line, color);
|
|
45
|
+
if (dim) {
|
|
46
|
+
styled = chalk.dim(styled);
|
|
47
|
+
}
|
|
48
|
+
return styled;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Render the node's border, including any embedded border text, into the
|
|
52
|
+
* output buffer when a border style is set.
|
|
53
|
+
* @param x - the border's left column.
|
|
54
|
+
* @param y - the border's top row.
|
|
55
|
+
* @param node - the node whose border style to render.
|
|
56
|
+
* @param output - the output buffer receiving the border writes.
|
|
57
|
+
*/
|
|
58
|
+
const renderBorder = (x, y, node, output) => {
|
|
59
|
+
if (node.style.borderStyle) {
|
|
60
|
+
const width = Math.floor(node.yogaNode.getComputedWidth());
|
|
61
|
+
const height = Math.floor(node.yogaNode.getComputedHeight());
|
|
62
|
+
const box = typeof node.style.borderStyle === 'string'
|
|
63
|
+
? (CUSTOM_BORDER_STYLES[node.style.borderStyle] ?? cliBoxes[node.style.borderStyle])
|
|
64
|
+
: node.style.borderStyle;
|
|
65
|
+
const topBorderColor = node.style.borderTopColor ?? node.style.borderColor;
|
|
66
|
+
const bottomBorderColor = node.style.borderBottomColor ?? node.style.borderColor;
|
|
67
|
+
const leftBorderColor = node.style.borderLeftColor ?? node.style.borderColor;
|
|
68
|
+
const rightBorderColor = node.style.borderRightColor ?? node.style.borderColor;
|
|
69
|
+
const dimTopBorderColor = node.style.borderTopDimColor ?? node.style.borderDimColor;
|
|
70
|
+
const dimBottomBorderColor = node.style.borderBottomDimColor ?? node.style.borderDimColor;
|
|
71
|
+
const dimLeftBorderColor = node.style.borderLeftDimColor ?? node.style.borderDimColor;
|
|
72
|
+
const dimRightBorderColor = node.style.borderRightDimColor ?? node.style.borderDimColor;
|
|
73
|
+
const showTopBorder = node.style.borderTop !== false;
|
|
74
|
+
const showBottomBorder = node.style.borderBottom !== false;
|
|
75
|
+
const showLeftBorder = node.style.borderLeft !== false;
|
|
76
|
+
const showRightBorder = node.style.borderRight !== false;
|
|
77
|
+
const contentWidth = Math.max(0, width - (showLeftBorder ? 1 : 0) - (showRightBorder ? 1 : 0));
|
|
78
|
+
const topBorderLine = showTopBorder
|
|
79
|
+
? (showLeftBorder ? box.topLeft : '') +
|
|
80
|
+
box.top.repeat(contentWidth) +
|
|
81
|
+
(showRightBorder ? box.topRight : '')
|
|
82
|
+
: '';
|
|
83
|
+
// Handle text in top border
|
|
84
|
+
let topBorder;
|
|
85
|
+
if (showTopBorder && node.style.borderText?.position === 'top') {
|
|
86
|
+
const [before, text, after] = embedTextInBorder(topBorderLine, node.style.borderText.content, node.style.borderText.align, node.style.borderText.offset, box.top);
|
|
87
|
+
topBorder =
|
|
88
|
+
styleBorderLine(before, topBorderColor, dimTopBorderColor) +
|
|
89
|
+
text +
|
|
90
|
+
styleBorderLine(after, topBorderColor, dimTopBorderColor);
|
|
91
|
+
}
|
|
92
|
+
else if (showTopBorder) {
|
|
93
|
+
topBorder = styleBorderLine(topBorderLine, topBorderColor, dimTopBorderColor);
|
|
94
|
+
}
|
|
95
|
+
let verticalBorderHeight = height;
|
|
96
|
+
if (showTopBorder) {
|
|
97
|
+
verticalBorderHeight -= 1;
|
|
98
|
+
}
|
|
99
|
+
if (showBottomBorder) {
|
|
100
|
+
verticalBorderHeight -= 1;
|
|
101
|
+
}
|
|
102
|
+
verticalBorderHeight = Math.max(0, verticalBorderHeight);
|
|
103
|
+
let leftBorder = (applyColor(box.left, leftBorderColor) + '\n').repeat(verticalBorderHeight);
|
|
104
|
+
if (dimLeftBorderColor) {
|
|
105
|
+
leftBorder = chalk.dim(leftBorder);
|
|
106
|
+
}
|
|
107
|
+
let rightBorder = (applyColor(box.right, rightBorderColor) + '\n').repeat(verticalBorderHeight);
|
|
108
|
+
if (dimRightBorderColor) {
|
|
109
|
+
rightBorder = chalk.dim(rightBorder);
|
|
110
|
+
}
|
|
111
|
+
const bottomBorderLine = showBottomBorder
|
|
112
|
+
? (showLeftBorder ? box.bottomLeft : '') +
|
|
113
|
+
box.bottom.repeat(contentWidth) +
|
|
114
|
+
(showRightBorder ? box.bottomRight : '')
|
|
115
|
+
: '';
|
|
116
|
+
// Handle text in bottom border
|
|
117
|
+
let bottomBorder;
|
|
118
|
+
if (showBottomBorder && node.style.borderText?.position === 'bottom') {
|
|
119
|
+
const [before, text, after] = embedTextInBorder(bottomBorderLine, node.style.borderText.content, node.style.borderText.align, node.style.borderText.offset, box.bottom);
|
|
120
|
+
bottomBorder =
|
|
121
|
+
styleBorderLine(before, bottomBorderColor, dimBottomBorderColor) +
|
|
122
|
+
text +
|
|
123
|
+
styleBorderLine(after, bottomBorderColor, dimBottomBorderColor);
|
|
124
|
+
}
|
|
125
|
+
else if (showBottomBorder) {
|
|
126
|
+
bottomBorder = styleBorderLine(bottomBorderLine, bottomBorderColor, dimBottomBorderColor);
|
|
127
|
+
}
|
|
128
|
+
const offsetY = showTopBorder ? 1 : 0;
|
|
129
|
+
if (topBorder) {
|
|
130
|
+
output.write(x, y, topBorder);
|
|
131
|
+
}
|
|
132
|
+
if (showLeftBorder) {
|
|
133
|
+
output.write(x, y + offsetY, leftBorder);
|
|
134
|
+
}
|
|
135
|
+
if (showRightBorder) {
|
|
136
|
+
output.write(x + width - 1, y + offsetY, rightBorder);
|
|
137
|
+
}
|
|
138
|
+
if (bottomBorder) {
|
|
139
|
+
output.write(x, y + height - 1, bottomBorder);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
export default renderBorder;
|