@travisennis/acai 0.0.6 → 0.0.8
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/README.md +225 -39
- package/dist/agent/index.d.ts +30 -21
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +237 -198
- package/dist/cli.d.ts +4 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +56 -18
- package/dist/commands/add-directory/index.d.ts +3 -0
- package/dist/commands/add-directory/index.d.ts.map +1 -0
- package/dist/commands/add-directory/index.js +50 -0
- package/dist/commands/add-directory/types.d.ts +6 -0
- package/dist/commands/add-directory/types.d.ts.map +1 -0
- package/dist/commands/add-directory/utils.d.ts +3 -0
- package/dist/commands/add-directory/utils.d.ts.map +1 -0
- package/dist/commands/add-directory/utils.js +15 -0
- package/dist/commands/clear/index.d.ts +3 -0
- package/dist/commands/clear/index.d.ts.map +1 -0
- package/dist/commands/{clear-command.js → clear/index.js} +1 -7
- package/dist/commands/copy/index.d.ts +3 -0
- package/dist/commands/copy/index.d.ts.map +1 -0
- package/dist/commands/copy/index.js +39 -0
- package/dist/commands/copy/types.d.ts +3 -0
- package/dist/commands/copy/types.d.ts.map +1 -0
- package/dist/commands/copy/types.js +1 -0
- package/dist/commands/copy/utils.d.ts +3 -0
- package/dist/commands/copy/utils.d.ts.map +1 -0
- package/dist/commands/copy/utils.js +22 -0
- package/dist/commands/exit/index.d.ts +10 -0
- package/dist/commands/exit/index.d.ts.map +1 -0
- package/dist/commands/exit/index.js +21 -0
- package/dist/commands/exit/types.d.ts +8 -0
- package/dist/commands/exit/types.d.ts.map +1 -0
- package/dist/commands/exit/types.js +1 -0
- package/dist/commands/exit/utils.d.ts +2 -0
- package/dist/commands/exit/utils.d.ts.map +1 -0
- package/dist/commands/exit/utils.js +13 -0
- package/dist/commands/generate-rules/index.d.ts +3 -0
- package/dist/commands/generate-rules/index.d.ts.map +1 -0
- package/dist/commands/{generate-rules-command.js → generate-rules/index.js} +65 -147
- package/dist/commands/generate-rules/utils.d.ts +5 -0
- package/dist/commands/generate-rules/utils.d.ts.map +1 -0
- package/dist/commands/generate-rules/utils.js +25 -0
- package/dist/commands/handoff/index.d.ts +3 -0
- package/dist/commands/handoff/index.d.ts.map +1 -0
- package/dist/commands/handoff/index.js +97 -0
- package/dist/commands/handoff/utils.d.ts +4 -0
- package/dist/commands/handoff/utils.d.ts.map +1 -0
- package/dist/commands/handoff/utils.js +123 -0
- package/dist/commands/health/index.d.ts +3 -0
- package/dist/commands/health/index.d.ts.map +1 -0
- package/dist/commands/health/index.js +56 -0
- package/dist/commands/health/utils.d.ts +15 -0
- package/dist/commands/health/utils.d.ts.map +1 -0
- package/dist/commands/health/utils.js +52 -0
- package/dist/commands/help/index.d.ts +3 -0
- package/dist/commands/help/index.d.ts.map +1 -0
- package/dist/commands/{help-command.js → help/index.js} +6 -14
- package/dist/commands/history/index.d.ts +3 -0
- package/dist/commands/history/index.d.ts.map +1 -0
- package/dist/commands/{history-command.js → history/index.js} +40 -200
- package/dist/commands/history/types.d.ts +11 -0
- package/dist/commands/history/types.d.ts.map +1 -0
- package/dist/commands/history/types.js +1 -0
- package/dist/commands/history/utils.d.ts +4 -0
- package/dist/commands/history/utils.d.ts.map +1 -0
- package/dist/commands/history/utils.js +86 -0
- package/dist/commands/init/index.d.ts +3 -0
- package/dist/commands/init/index.d.ts.map +1 -0
- package/dist/commands/{init-command.js → init/index.js} +17 -27
- package/dist/commands/init-project/index.d.ts +3 -0
- package/dist/commands/init-project/index.d.ts.map +1 -0
- package/dist/commands/init-project/index.js +51 -0
- package/dist/commands/init-project/utils.d.ts +9 -0
- package/dist/commands/init-project/utils.d.ts.map +1 -0
- package/dist/commands/init-project/utils.js +43 -0
- package/dist/commands/list-directories/index.d.ts +3 -0
- package/dist/commands/list-directories/index.d.ts.map +1 -0
- package/dist/commands/{list-directories-command.js → list-directories/index.js} +2 -15
- package/dist/commands/list-tools/index.d.ts +3 -0
- package/dist/commands/list-tools/index.d.ts.map +1 -0
- package/dist/commands/list-tools/index.js +89 -0
- package/dist/commands/manager.d.ts +2 -9
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +38 -83
- package/dist/commands/model/index.d.ts +3 -0
- package/dist/commands/model/index.d.ts.map +1 -0
- package/dist/commands/model/index.js +182 -0
- package/dist/commands/model/utils.d.ts +3 -0
- package/dist/commands/model/utils.d.ts.map +1 -0
- package/dist/commands/model/utils.js +5 -0
- package/dist/commands/paste/index.d.ts +3 -0
- package/dist/commands/paste/index.d.ts.map +1 -0
- package/dist/commands/paste/index.js +94 -0
- package/dist/commands/paste/utils.d.ts +5 -0
- package/dist/commands/paste/utils.d.ts.map +1 -0
- package/dist/commands/paste/utils.js +86 -0
- package/dist/commands/pickup/index.d.ts +3 -0
- package/dist/commands/pickup/index.d.ts.map +1 -0
- package/dist/commands/pickup/index.js +138 -0
- package/dist/commands/pickup/types.d.ts +6 -0
- package/dist/commands/pickup/types.d.ts.map +1 -0
- package/dist/commands/pickup/types.js +1 -0
- package/dist/commands/pickup/utils.d.ts +7 -0
- package/dist/commands/pickup/utils.d.ts.map +1 -0
- package/dist/commands/pickup/utils.js +56 -0
- package/dist/commands/prompt/index.d.ts +5 -0
- package/dist/commands/prompt/index.d.ts.map +1 -0
- package/dist/commands/prompt/index.js +126 -0
- package/dist/commands/prompt/types.d.ts +15 -0
- package/dist/commands/prompt/types.d.ts.map +1 -0
- package/dist/commands/prompt/types.js +1 -0
- package/dist/commands/prompt/utils.d.ts +12 -0
- package/dist/commands/prompt/utils.d.ts.map +1 -0
- package/dist/commands/prompt/utils.js +107 -0
- package/dist/commands/remove-directory/index.d.ts +3 -0
- package/dist/commands/remove-directory/index.d.ts.map +1 -0
- package/dist/commands/{remove-directory-command.js → remove-directory/index.js} +3 -35
- package/dist/commands/reset/index.d.ts +3 -0
- package/dist/commands/reset/index.d.ts.map +1 -0
- package/dist/commands/{reset-command.js → reset/index.js} +8 -11
- package/dist/commands/reset/types.d.ts +1 -0
- package/dist/commands/reset/types.d.ts.map +1 -0
- package/dist/commands/reset/types.js +3 -0
- package/dist/commands/resources/index.d.ts +3 -0
- package/dist/commands/resources/index.d.ts.map +1 -0
- package/dist/commands/resources/index.js +84 -0
- package/dist/commands/review/index.d.ts +3 -0
- package/dist/commands/review/index.d.ts.map +1 -0
- package/dist/commands/review/index.js +126 -0
- package/dist/commands/review/types.d.ts +12 -0
- package/dist/commands/review/types.d.ts.map +1 -0
- package/dist/commands/review/types.js +1 -0
- package/dist/commands/review/utils.d.ts +4 -0
- package/dist/commands/review/utils.d.ts.map +1 -0
- package/dist/commands/review/utils.js +87 -0
- package/dist/commands/save/index.d.ts +3 -0
- package/dist/commands/save/index.d.ts.map +1 -0
- package/dist/commands/{save-command.js → save/index.js} +3 -10
- package/dist/commands/session/index.d.ts +3 -0
- package/dist/commands/session/index.d.ts.map +1 -0
- package/dist/commands/session/index.js +197 -0
- package/dist/commands/session/types.d.ts +13 -0
- package/dist/commands/session/types.d.ts.map +1 -0
- package/dist/commands/session/types.js +7 -0
- package/dist/commands/shell/index.d.ts +3 -0
- package/dist/commands/shell/index.d.ts.map +1 -0
- package/dist/commands/{shell-command.js → shell/index.js} +4 -51
- package/dist/commands/types.d.ts +2 -5
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/config.d.ts +36 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +118 -60
- package/dist/dedent.d.ts.map +1 -1
- package/dist/dedent.js +7 -7
- package/dist/execution/index.d.ts +18 -2
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +119 -81
- package/dist/formatting.d.ts +46 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +94 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +299 -177
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +4 -11
- package/dist/mentions.d.ts.map +1 -1
- package/dist/mentions.js +3 -53
- package/dist/middleware/audit-message.d.ts +2 -2
- package/dist/middleware/audit-message.d.ts.map +1 -1
- package/dist/middleware/audit-message.js +40 -2
- package/dist/middleware/cache.d.ts +2 -2
- package/dist/middleware/cache.d.ts.map +1 -1
- package/dist/middleware/cache.js +111 -27
- package/dist/middleware/rate-limit.d.ts +2 -2
- package/dist/middleware/rate-limit.d.ts.map +1 -1
- package/dist/middleware/rate-limit.js +1 -0
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +46 -29
- package/dist/models/anthropic-provider.d.ts +14 -13
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/anthropic-provider.js +0 -7
- package/dist/models/deepseek-provider.d.ts +9 -8
- package/dist/models/deepseek-provider.d.ts.map +1 -1
- package/dist/models/deepseek-provider.js +0 -2
- package/dist/models/google-provider.d.ts +10 -9
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/google-provider.js +0 -3
- package/dist/models/groq-provider.d.ts +8 -7
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.js +0 -1
- package/dist/models/manager.d.ts +7 -4
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +5 -25
- package/dist/models/openai-provider.d.ts +11 -10
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +0 -4
- package/dist/models/opencode-zen-provider.d.ts +23 -0
- package/dist/models/opencode-zen-provider.d.ts.map +1 -0
- package/dist/models/opencode-zen-provider.js +76 -0
- package/dist/models/openrouter-provider.d.ts +34 -28
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +148 -139
- package/dist/models/providers.d.ts +6 -16
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +8 -58
- package/dist/models/xai-provider.d.ts +9 -8
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/models/xai-provider.js +0 -2
- package/dist/prompts/manager.d.ts +1 -1
- package/dist/prompts/manager.d.ts.map +1 -1
- package/dist/prompts/manager.js +1 -1
- package/dist/prompts.d.ts +8 -4
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +155 -177
- package/dist/repl/project-status.d.ts +19 -0
- package/dist/repl/project-status.d.ts.map +1 -0
- package/dist/repl/project-status.js +78 -0
- package/dist/repl-new.d.ts +15 -6
- package/dist/repl-new.d.ts.map +1 -1
- package/dist/repl-new.js +266 -83
- package/dist/{messages.d.ts → sessions/manager.d.ts} +13 -4
- package/dist/sessions/manager.d.ts.map +1 -0
- package/dist/{messages.js → sessions/manager.js} +126 -16
- package/dist/skills.d.ts +16 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +233 -0
- package/dist/terminal/control.d.ts +56 -0
- package/dist/terminal/control.d.ts.map +1 -0
- package/dist/terminal/control.js +111 -0
- package/dist/terminal/default-theme.d.ts +1 -1
- package/dist/terminal/default-theme.d.ts.map +1 -1
- package/dist/terminal/default-theme.js +24 -28
- package/dist/terminal/formatting.d.ts +23 -26
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +35 -53
- package/dist/terminal/highlight/index.d.ts.map +1 -1
- package/dist/terminal/highlight/index.js +3 -6
- package/dist/terminal/highlight/theme.d.ts.map +1 -1
- package/dist/terminal/highlight/theme.js +2 -6
- package/dist/terminal/index.d.ts +2 -101
- package/dist/terminal/index.d.ts.map +1 -1
- package/dist/terminal/index.js +2 -464
- package/dist/terminal/keys.d.ts +211 -0
- package/dist/terminal/keys.d.ts.map +1 -0
- package/dist/terminal/keys.js +546 -0
- package/dist/terminal/segmenter.d.ts +6 -0
- package/dist/terminal/segmenter.d.ts.map +1 -0
- package/dist/terminal/segmenter.js +11 -0
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +9 -21
- package/dist/terminal/string-width.d.ts.map +1 -1
- package/dist/terminal/string-width.js +40 -21
- package/dist/terminal/strip-ansi.d.ts.map +1 -1
- package/dist/terminal/strip-ansi.js +9 -15
- package/dist/terminal/table/cell.d.ts +114 -0
- package/dist/terminal/table/cell.d.ts.map +1 -0
- package/dist/terminal/table/cell.js +407 -0
- package/dist/terminal/table/debug.d.ts +15 -0
- package/dist/terminal/table/debug.d.ts.map +1 -0
- package/dist/terminal/table/debug.js +32 -0
- package/dist/terminal/table/index.d.ts +3 -0
- package/dist/terminal/table/index.d.ts.map +1 -0
- package/dist/terminal/table/index.js +2 -0
- package/dist/terminal/table/layout-manager.d.ts +27 -0
- package/dist/terminal/table/layout-manager.d.ts.map +1 -0
- package/dist/terminal/table/layout-manager.js +257 -0
- package/dist/terminal/table/table.d.ts +9 -0
- package/dist/terminal/table/table.d.ts.map +1 -0
- package/dist/terminal/table/table.js +97 -0
- package/dist/terminal/table/utils.d.ts +63 -0
- package/dist/terminal/table/utils.d.ts.map +1 -0
- package/dist/terminal/table/utils.js +326 -0
- package/dist/tokens/tracker.d.ts.map +1 -1
- package/dist/tokens/tracker.js +58 -16
- package/dist/tools/bash.d.ts +11 -11
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +189 -81
- package/dist/tools/directory-tree.d.ts +9 -13
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +90 -60
- package/dist/tools/dynamic-tool-loader.d.ts +22 -8
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +41 -46
- package/dist/tools/edit-file.d.ts +6 -16
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +22 -66
- package/dist/tools/glob.d.ts +15 -16
- package/dist/tools/glob.d.ts.map +1 -1
- package/dist/tools/glob.js +78 -109
- package/dist/tools/grep.d.ts +19 -22
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +61 -93
- package/dist/tools/index.d.ts +202 -167
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +17 -273
- package/dist/tools/ls.d.ts +26 -0
- package/dist/tools/ls.d.ts.map +1 -0
- package/dist/tools/ls.js +80 -0
- package/dist/tools/read-file.d.ts +15 -15
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +52 -76
- package/dist/tools/save-file.d.ts +8 -8
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +42 -53
- package/dist/tools/think.d.ts +4 -4
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +9 -32
- package/dist/tools/types.d.ts +5 -21
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +0 -9
- package/dist/tui/autocomplete/attachment-provider.d.ts +18 -0
- package/dist/tui/autocomplete/attachment-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/attachment-provider.js +159 -0
- package/dist/tui/autocomplete/base-provider.d.ts +17 -0
- package/dist/tui/autocomplete/base-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/base-provider.js +1 -0
- package/dist/tui/autocomplete/combined-provider.d.ts +20 -0
- package/dist/tui/autocomplete/combined-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/combined-provider.js +61 -0
- package/dist/tui/autocomplete/command-provider.d.ts +20 -0
- package/dist/tui/autocomplete/command-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/command-provider.js +90 -0
- package/dist/tui/autocomplete/file-search-provider.d.ts +16 -0
- package/dist/tui/autocomplete/file-search-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/file-search-provider.js +123 -0
- package/dist/tui/autocomplete/path-provider.d.ts +21 -0
- package/dist/tui/autocomplete/path-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/path-provider.js +164 -0
- package/dist/tui/autocomplete/utils.d.ts +16 -0
- package/dist/tui/autocomplete/utils.d.ts.map +1 -0
- package/dist/tui/autocomplete/utils.js +137 -0
- package/dist/tui/autocomplete.d.ts +12 -43
- package/dist/tui/autocomplete.d.ts.map +1 -1
- package/dist/tui/autocomplete.js +20 -465
- package/dist/tui/components/assistant-message.js +1 -1
- package/dist/tui/components/box.d.ts +20 -0
- package/dist/tui/components/box.d.ts.map +1 -0
- package/dist/tui/components/box.js +87 -0
- package/dist/tui/components/editor.d.ts +61 -7
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +630 -127
- package/dist/tui/components/footer.d.ts +19 -18
- package/dist/tui/components/footer.d.ts.map +1 -1
- package/dist/tui/components/footer.js +90 -185
- package/dist/tui/components/header.d.ts +21 -0
- package/dist/tui/components/header.d.ts.map +1 -0
- package/dist/tui/components/header.js +63 -0
- package/dist/tui/components/input.d.ts.map +1 -1
- package/dist/tui/components/input.js +8 -7
- package/dist/tui/components/loader.d.ts +6 -1
- package/dist/tui/components/loader.d.ts.map +1 -1
- package/dist/tui/components/loader.js +8 -3
- package/dist/tui/components/markdown.d.ts +31 -27
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/markdown.js +131 -67
- package/dist/tui/components/modal.d.ts +0 -11
- package/dist/tui/components/modal.d.ts.map +1 -1
- package/dist/tui/components/modal.js +9 -37
- package/dist/tui/components/notification.d.ts +28 -0
- package/dist/tui/components/notification.d.ts.map +1 -0
- package/dist/tui/components/notification.js +63 -0
- package/dist/tui/components/progress-bar.d.ts +19 -0
- package/dist/tui/components/progress-bar.d.ts.map +1 -0
- package/dist/tui/components/progress-bar.js +66 -0
- package/dist/tui/components/select-list.d.ts +12 -1
- package/dist/tui/components/select-list.d.ts.map +1 -1
- package/dist/tui/components/select-list.js +73 -32
- package/dist/tui/components/spacer.d.ts +1 -1
- package/dist/tui/components/spacer.d.ts.map +1 -1
- package/dist/tui/components/spacer.js +2 -2
- package/dist/tui/components/table.d.ts +27 -0
- package/dist/tui/components/table.d.ts.map +1 -0
- package/dist/tui/components/table.js +125 -0
- package/dist/tui/components/thinking-block.d.ts.map +1 -1
- package/dist/tui/components/thinking-block.js +4 -1
- package/dist/tui/components/tool-execution.d.ts +7 -6
- package/dist/tui/components/tool-execution.d.ts.map +1 -1
- package/dist/tui/components/tool-execution.js +81 -85
- package/dist/tui/components/user-message.d.ts.map +1 -1
- package/dist/tui/components/user-message.js +6 -4
- package/dist/tui/components/welcome.d.ts +8 -1
- package/dist/tui/components/welcome.d.ts.map +1 -1
- package/dist/tui/components/welcome.js +45 -6
- package/dist/tui/index.d.ts +12 -6
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +7 -3
- package/dist/tui/terminal.d.ts +4 -3
- package/dist/tui/terminal.d.ts.map +1 -1
- package/dist/tui/terminal.js +43 -49
- package/dist/tui/tui.d.ts +3 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +58 -43
- package/dist/tui/utils.d.ts +5 -0
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +80 -1
- package/dist/{tools/bash-utils.d.ts → utils/bash.d.ts} +3 -3
- package/dist/utils/bash.d.ts.map +1 -0
- package/dist/{tools/bash-utils.js → utils/bash.js} +22 -11
- package/dist/utils/{filesystem.d.ts → filesystem/operations.d.ts} +1 -1
- package/dist/utils/filesystem/operations.d.ts.map +1 -0
- package/dist/{tools/filesystem-utils.d.ts → utils/filesystem/security.d.ts} +3 -2
- package/dist/utils/filesystem/security.d.ts.map +1 -0
- package/dist/{tools/filesystem-utils.js → utils/filesystem/security.js} +62 -4
- package/dist/utils/funcs.d.ts +6 -0
- package/dist/utils/funcs.d.ts.map +1 -0
- package/dist/utils/funcs.js +6 -0
- package/dist/{tools/git-utils.d.ts → utils/git.d.ts} +1 -1
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/{tools/git-utils.js → utils/git.js} +0 -6
- package/dist/utils/glob.js +1 -1
- package/dist/utils/yaml.d.ts +11 -0
- package/dist/utils/yaml.d.ts.map +1 -0
- package/dist/utils/yaml.js +207 -0
- package/dist/utils/{zod-utils.d.ts → zod.d.ts} +2 -1
- package/dist/utils/zod.d.ts.map +1 -0
- package/dist/utils/zod.js +24 -0
- package/package.json +31 -29
- package/dist/agent/manual-loop.d.ts +0 -41
- package/dist/agent/manual-loop.d.ts.map +0 -1
- package/dist/agent/manual-loop.js +0 -278
- package/dist/api/exa/index.d.ts +0 -177
- package/dist/api/exa/index.d.ts.map +0 -1
- package/dist/api/exa/index.js +0 -439
- package/dist/commands/add-directory-command.d.ts +0 -3
- package/dist/commands/add-directory-command.d.ts.map +0 -1
- package/dist/commands/add-directory-command.js +0 -85
- package/dist/commands/application-log-command.d.ts +0 -3
- package/dist/commands/application-log-command.d.ts.map +0 -1
- package/dist/commands/application-log-command.js +0 -79
- package/dist/commands/clear-command.d.ts +0 -3
- package/dist/commands/clear-command.d.ts.map +0 -1
- package/dist/commands/compact-command.d.ts +0 -3
- package/dist/commands/compact-command.d.ts.map +0 -1
- package/dist/commands/compact-command.js +0 -64
- package/dist/commands/context-command.d.ts +0 -3
- package/dist/commands/context-command.d.ts.map +0 -1
- package/dist/commands/context-command.js +0 -183
- package/dist/commands/copy-command.d.ts +0 -3
- package/dist/commands/copy-command.d.ts.map +0 -1
- package/dist/commands/copy-command.js +0 -80
- package/dist/commands/edit-command.d.ts +0 -3
- package/dist/commands/edit-command.d.ts.map +0 -1
- package/dist/commands/edit-command.js +0 -88
- package/dist/commands/edit-prompt-command.d.ts +0 -3
- package/dist/commands/edit-prompt-command.d.ts.map +0 -1
- package/dist/commands/edit-prompt-command.js +0 -61
- package/dist/commands/exit-command.d.ts +0 -13
- package/dist/commands/exit-command.d.ts.map +0 -1
- package/dist/commands/exit-command.js +0 -46
- package/dist/commands/files-command.d.ts +0 -3
- package/dist/commands/files-command.d.ts.map +0 -1
- package/dist/commands/files-command.js +0 -121
- package/dist/commands/generate-rules-command.d.ts +0 -3
- package/dist/commands/generate-rules-command.d.ts.map +0 -1
- package/dist/commands/handoff-command.d.ts +0 -3
- package/dist/commands/handoff-command.d.ts.map +0 -1
- package/dist/commands/handoff-command.js +0 -202
- package/dist/commands/health-command.d.ts +0 -4
- package/dist/commands/health-command.d.ts.map +0 -1
- package/dist/commands/health-command.js +0 -213
- package/dist/commands/help-command.d.ts +0 -3
- package/dist/commands/help-command.d.ts.map +0 -1
- package/dist/commands/history-command.d.ts +0 -3
- package/dist/commands/history-command.d.ts.map +0 -1
- package/dist/commands/init-command.d.ts +0 -3
- package/dist/commands/init-command.d.ts.map +0 -1
- package/dist/commands/last-log-command.d.ts +0 -3
- package/dist/commands/last-log-command.d.ts.map +0 -1
- package/dist/commands/last-log-command.js +0 -98
- package/dist/commands/list-directories-command.d.ts +0 -3
- package/dist/commands/list-directories-command.d.ts.map +0 -1
- package/dist/commands/list-tools-command.d.ts +0 -3
- package/dist/commands/list-tools-command.d.ts.map +0 -1
- package/dist/commands/list-tools-command.js +0 -124
- package/dist/commands/model-command.d.ts +0 -25
- package/dist/commands/model-command.d.ts.map +0 -1
- package/dist/commands/model-command.js +0 -340
- package/dist/commands/paste-command.d.ts +0 -3
- package/dist/commands/paste-command.d.ts.map +0 -1
- package/dist/commands/paste-command.js +0 -277
- package/dist/commands/pickup-command.d.ts +0 -3
- package/dist/commands/pickup-command.d.ts.map +0 -1
- package/dist/commands/pickup-command.js +0 -161
- package/dist/commands/prompt-command.d.ts +0 -3
- package/dist/commands/prompt-command.d.ts.map +0 -1
- package/dist/commands/prompt-command.js +0 -280
- package/dist/commands/remove-directory-command.d.ts +0 -3
- package/dist/commands/remove-directory-command.d.ts.map +0 -1
- package/dist/commands/reset-command.d.ts +0 -3
- package/dist/commands/reset-command.d.ts.map +0 -1
- package/dist/commands/rules-command.d.ts +0 -3
- package/dist/commands/rules-command.d.ts.map +0 -1
- package/dist/commands/rules-command.js +0 -135
- package/dist/commands/save-command.d.ts +0 -3
- package/dist/commands/save-command.d.ts.map +0 -1
- package/dist/commands/shell-command.d.ts +0 -3
- package/dist/commands/shell-command.d.ts.map +0 -1
- package/dist/commands/usage-command.d.ts +0 -3
- package/dist/commands/usage-command.d.ts.map +0 -1
- package/dist/commands/usage-command.js +0 -42
- package/dist/messages.d.ts.map +0 -1
- package/dist/repl/display-tool-messages.d.ts +0 -4
- package/dist/repl/display-tool-messages.d.ts.map +0 -1
- package/dist/repl/display-tool-messages.js +0 -58
- package/dist/repl/display-tool-use.d.ts +0 -14
- package/dist/repl/display-tool-use.d.ts.map +0 -1
- package/dist/repl/display-tool-use.js +0 -63
- package/dist/repl/get-prompt-header.d.ts +0 -8
- package/dist/repl/get-prompt-header.d.ts.map +0 -1
- package/dist/repl/get-prompt-header.js +0 -9
- package/dist/repl/project-status-line.d.ts +0 -2
- package/dist/repl/project-status-line.d.ts.map +0 -1
- package/dist/repl/project-status-line.js +0 -31
- package/dist/repl/prompt.d.ts +0 -21
- package/dist/repl/prompt.d.ts.map +0 -1
- package/dist/repl/prompt.js +0 -244
- package/dist/repl/tool-call-repair.d.ts +0 -4
- package/dist/repl/tool-call-repair.d.ts.map +0 -1
- package/dist/repl/tool-call-repair.js +0 -54
- package/dist/repl.d.ts +0 -29
- package/dist/repl.d.ts.map +0 -1
- package/dist/repl.js +0 -218
- package/dist/terminal/checkbox-prompt.d.ts +0 -36
- package/dist/terminal/checkbox-prompt.d.ts.map +0 -1
- package/dist/terminal/checkbox-prompt.js +0 -368
- package/dist/terminal/editor-prompt.d.ts +0 -10
- package/dist/terminal/editor-prompt.d.ts.map +0 -1
- package/dist/terminal/editor-prompt.js +0 -61
- package/dist/terminal/errors.d.ts +0 -19
- package/dist/terminal/errors.d.ts.map +0 -1
- package/dist/terminal/errors.js +0 -37
- package/dist/terminal/input-prompt.d.ts +0 -17
- package/dist/terminal/input-prompt.d.ts.map +0 -1
- package/dist/terminal/input-prompt.js +0 -181
- package/dist/terminal/markdown.d.ts +0 -2
- package/dist/terminal/markdown.d.ts.map +0 -1
- package/dist/terminal/markdown.js +0 -118
- package/dist/terminal/search-prompt.d.ts +0 -20
- package/dist/terminal/search-prompt.d.ts.map +0 -1
- package/dist/terminal/search-prompt.js +0 -280
- package/dist/terminal/types.d.ts +0 -35
- package/dist/terminal/types.d.ts.map +0 -1
- package/dist/tokens/threshold.d.ts +0 -35
- package/dist/tokens/threshold.d.ts.map +0 -1
- package/dist/tokens/threshold.js +0 -85
- package/dist/tools/advanced-edit-file.d.ts +0 -69
- package/dist/tools/advanced-edit-file.d.ts.map +0 -1
- package/dist/tools/advanced-edit-file.js +0 -281
- package/dist/tools/agent.d.ts +0 -29
- package/dist/tools/agent.d.ts.map +0 -1
- package/dist/tools/agent.js +0 -103
- package/dist/tools/bash-utils.d.ts.map +0 -1
- package/dist/tools/code-interpreter.d.ts +0 -25
- package/dist/tools/code-interpreter.d.ts.map +0 -1
- package/dist/tools/code-interpreter.js +0 -167
- package/dist/tools/delete-file.d.ts +0 -24
- package/dist/tools/delete-file.d.ts.map +0 -1
- package/dist/tools/delete-file.js +0 -70
- package/dist/tools/dynamic-tool-parser.d.ts +0 -21
- package/dist/tools/dynamic-tool-parser.d.ts.map +0 -1
- package/dist/tools/dynamic-tool-parser.js +0 -22
- package/dist/tools/filesystem-utils.d.ts.map +0 -1
- package/dist/tools/git-utils.d.ts.map +0 -1
- package/dist/tools/llm-edit-fixer.d.ts +0 -25
- package/dist/tools/llm-edit-fixer.d.ts.map +0 -1
- package/dist/tools/llm-edit-fixer.js +0 -150
- package/dist/tools/move-file.d.ts +0 -26
- package/dist/tools/move-file.d.ts.map +0 -1
- package/dist/tools/move-file.js +0 -58
- package/dist/tools/read-multiple-files.d.ts +0 -26
- package/dist/tools/read-multiple-files.d.ts.map +0 -1
- package/dist/tools/read-multiple-files.js +0 -139
- package/dist/tools/web-fetch.d.ts +0 -56
- package/dist/tools/web-fetch.d.ts.map +0 -1
- package/dist/tools/web-fetch.js +0 -247
- package/dist/tools/web-search.d.ts +0 -23
- package/dist/tools/web-search.d.ts.map +0 -1
- package/dist/tools/web-search.js +0 -133
- package/dist/tui/components/prompt-status.d.ts +0 -16
- package/dist/tui/components/prompt-status.d.ts.map +0 -1
- package/dist/tui/components/prompt-status.js +0 -21
- package/dist/utils/filesystem.d.ts.map +0 -1
- package/dist/utils/zod-utils.d.ts.map +0 -1
- package/dist/utils/zod-utils.js +0 -7
- /package/dist/{terminal → commands/add-directory}/types.js +0 -0
- /package/dist/utils/{filesystem.js → filesystem/operations.js} +0 -0
|
@@ -1,25 +1,32 @@
|
|
|
1
1
|
import { eastAsianWidth } from "./east-asian-width.js";
|
|
2
|
+
import { getSegmenter } from "./segmenter.js";
|
|
2
3
|
import stripAnsi from "./strip-ansi.js";
|
|
3
|
-
|
|
4
|
+
// Precompile regexes (these are already at module level, which is good)
|
|
4
5
|
// Whole-cluster zero-width
|
|
5
6
|
const zeroWidthClusterRegex = /^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Mark}|\p{Surrogate})+$/v;
|
|
6
7
|
// Pick the base scalar if the cluster starts with Prepend/Format/Marks
|
|
7
8
|
const leadingNonPrintingRegex = /^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Mark}\p{Surrogate}]+/v;
|
|
8
9
|
// RGI emoji sequences
|
|
9
10
|
const rgiEmojiRegex = /^\p{RGI_Emoji}$/v;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function isZeroWidthCluster(segment) {
|
|
14
|
-
return zeroWidthClusterRegex.test(segment);
|
|
15
|
-
}
|
|
11
|
+
// Halfwidth/Fullwidth range constants
|
|
12
|
+
const HALFWIDTH_START = 0xff00;
|
|
13
|
+
const HALFWIDTH_END = 0xffef;
|
|
16
14
|
function trailingHalfwidthWidth(segment, eastAsianWidthOptions) {
|
|
15
|
+
const len = segment.length;
|
|
16
|
+
if (len <= 1) {
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
17
19
|
let extra = 0;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
// Use for loop with index for better performance
|
|
21
|
+
for (let i = 1; i < len; i++) {
|
|
22
|
+
const codePoint = segment.codePointAt(i);
|
|
23
|
+
if (codePoint !== undefined &&
|
|
24
|
+
codePoint >= HALFWIDTH_START &&
|
|
25
|
+
codePoint <= HALFWIDTH_END) {
|
|
26
|
+
extra += eastAsianWidth(codePoint, eastAsianWidthOptions);
|
|
27
|
+
// Skip next char if this was a surrogate pair
|
|
28
|
+
if (codePoint > 0xffff) {
|
|
29
|
+
i++;
|
|
23
30
|
}
|
|
24
31
|
}
|
|
25
32
|
}
|
|
@@ -33,15 +40,17 @@ export default function stringWidth(input, options = {}) {
|
|
|
33
40
|
let string = input;
|
|
34
41
|
if (!countAnsiEscapeCodes) {
|
|
35
42
|
string = stripAnsi(string);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
if (string.length === 0) {
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
39
46
|
}
|
|
40
47
|
let width = 0;
|
|
41
48
|
const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
|
|
49
|
+
// Use lazy segmenter initialization
|
|
50
|
+
const segmenter = getSegmenter();
|
|
42
51
|
for (const { segment } of segmenter.segment(string)) {
|
|
43
|
-
// Zero-width
|
|
44
|
-
if (
|
|
52
|
+
// Zero-width clusters - inline test for hot path
|
|
53
|
+
if (zeroWidthClusterRegex.test(segment)) {
|
|
45
54
|
continue;
|
|
46
55
|
}
|
|
47
56
|
// Emoji width logic
|
|
@@ -49,12 +58,22 @@ export default function stringWidth(input, options = {}) {
|
|
|
49
58
|
width += 2;
|
|
50
59
|
continue;
|
|
51
60
|
}
|
|
52
|
-
//
|
|
53
|
-
const
|
|
61
|
+
// Get first code point directly, avoiding intermediate string
|
|
62
|
+
const firstCodePoint = segment.codePointAt(0);
|
|
63
|
+
if (firstCodePoint === undefined) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
// Check if we need to strip leading non-printing characters
|
|
67
|
+
const hasLeadingNonPrinting = leadingNonPrintingRegex.test(segment);
|
|
68
|
+
const codePoint = hasLeadingNonPrinting
|
|
69
|
+
? segment.replace(leadingNonPrintingRegex, "").codePointAt(0)
|
|
70
|
+
: firstCodePoint;
|
|
54
71
|
if (codePoint !== undefined) {
|
|
55
72
|
width += eastAsianWidth(codePoint, eastAsianWidthOptions);
|
|
56
|
-
//
|
|
57
|
-
|
|
73
|
+
// Only check trailing width if segment has multiple characters
|
|
74
|
+
if (segment.length > 1) {
|
|
75
|
+
width += trailingHalfwidthWidth(segment, eastAsianWidthOptions);
|
|
76
|
+
}
|
|
58
77
|
}
|
|
59
78
|
}
|
|
60
79
|
return width;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strip-ansi.d.ts","sourceRoot":"","sources":["../../source/terminal/strip-ansi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"strip-ansi.d.ts","sourceRoot":"","sources":["../../source/terminal/strip-ansi.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKxD"}
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
//
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const pattern = `${osc}|${csi}`;
|
|
10
|
-
return new RegExp(pattern, onlyFirst ? undefined : "g");
|
|
11
|
-
};
|
|
1
|
+
// Pre-compile the regex outside the function to avoid recreation on every call
|
|
2
|
+
const ANSI_REGEX = (() => {
|
|
3
|
+
const St = "(?:\u0007|\u001B\u005C|\u009C)";
|
|
4
|
+
// biome-ignore lint/suspicious/noUselessEscapeInString: later
|
|
5
|
+
const osc = `(?:\u001B\][\\s\\S]*?${St})`;
|
|
6
|
+
const csi = "[\u001B\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
|
|
7
|
+
return new RegExp(`${osc}|${csi}`, "g");
|
|
8
|
+
})();
|
|
12
9
|
export default function stripAnsi(string) {
|
|
13
10
|
if (typeof string !== "string") {
|
|
14
11
|
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
15
12
|
}
|
|
16
|
-
|
|
17
|
-
// because unlike `.exec()` and `.test()`, `.replace()` does it automatically
|
|
18
|
-
// and doing it manually has a performance penalty.
|
|
19
|
-
return string.replace(ansiRegex(), "");
|
|
13
|
+
return string.replace(ANSI_REGEX, "");
|
|
20
14
|
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { type CellOptions, type CharName, type HorizontalAlignment, type TableInstanceOptions, type VerticalAlignment } from "./utils.ts";
|
|
2
|
+
export declare class Cell {
|
|
3
|
+
options: CellOptions;
|
|
4
|
+
content: string;
|
|
5
|
+
colSpan: number;
|
|
6
|
+
rowSpan: number;
|
|
7
|
+
x: number | null;
|
|
8
|
+
y: number | null;
|
|
9
|
+
chars: Record<CharName, string>;
|
|
10
|
+
truncate: string;
|
|
11
|
+
paddingLeft: number;
|
|
12
|
+
paddingRight: number;
|
|
13
|
+
head: string[];
|
|
14
|
+
border: string[];
|
|
15
|
+
fixedWidth: number | null;
|
|
16
|
+
lines: string[];
|
|
17
|
+
desiredWidth: number;
|
|
18
|
+
desiredHeight: number;
|
|
19
|
+
widths: number[];
|
|
20
|
+
heights: number[];
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
hAlign: HorizontalAlignment;
|
|
24
|
+
vAlign: VerticalAlignment;
|
|
25
|
+
drawRight: boolean;
|
|
26
|
+
cells: Cell[][] | null;
|
|
27
|
+
/**
|
|
28
|
+
* A representation of a cell within the table.
|
|
29
|
+
* Implementations must have `init` and `draw` methods,
|
|
30
|
+
* as well as `colSpan`, `rowSpan`, `desiredHeight` and `desiredWidth` properties.
|
|
31
|
+
*/
|
|
32
|
+
constructor(options: CellOptions | string | number | boolean | bigint);
|
|
33
|
+
setOptions(options: CellOptions | string | number | boolean | bigint): void;
|
|
34
|
+
mergeTableOptions(tableOptions: TableInstanceOptions, cells: Cell[][]): void;
|
|
35
|
+
computeLines(tableOptions: TableInstanceOptions): string[];
|
|
36
|
+
wrapLines(computedLines: string[]): string[];
|
|
37
|
+
/**
|
|
38
|
+
* Initializes the Cells data structure.
|
|
39
|
+
*
|
|
40
|
+
* @param tableOptions - A fully populated set of tableOptions.
|
|
41
|
+
* In addition to the standard default values, tableOptions must have fully populated the
|
|
42
|
+
* `colWidths` and `rowWidths` arrays. Those arrays must have lengths equal to the number
|
|
43
|
+
* of columns or rows (respectively) in this table, and each array item must be a Number.
|
|
44
|
+
*/
|
|
45
|
+
init(tableOptions: TableInstanceOptions): void;
|
|
46
|
+
/**
|
|
47
|
+
* Draws the given line of the cell.
|
|
48
|
+
* This default implementation defers to methods `drawTop`, `drawBottom`, `drawLine` and `drawEmpty`.
|
|
49
|
+
* @param lineNum - can be `top`, `bottom` or a numerical line number.
|
|
50
|
+
* @param spanningCell - will be a number if being called from a RowSpanCell, and will represent how
|
|
51
|
+
* many rows below it's being called from. Otherwise it's undefined.
|
|
52
|
+
* @returns {String} The representation of this line.
|
|
53
|
+
*/
|
|
54
|
+
draw(lineNum: "top" | "bottom" | number, spanningCell?: number): string;
|
|
55
|
+
/**
|
|
56
|
+
* Renders the top line of the cell.
|
|
57
|
+
* @param drawRight - true if this method should render the right edge of the cell.
|
|
58
|
+
* @returns {String}
|
|
59
|
+
*/
|
|
60
|
+
drawTop(drawRight: boolean): string;
|
|
61
|
+
_topLeftChar(offset: number): string;
|
|
62
|
+
wrapWithStyleColors(styleProperty: "head" | "border", content: string): string;
|
|
63
|
+
/**
|
|
64
|
+
* Renders a line of text.
|
|
65
|
+
* @param lineNum - Which line of text to render. This is not necessarily the line within the cell.
|
|
66
|
+
* There may be top-padding above the first line of text.
|
|
67
|
+
* @param drawRight - true if this method should render the right edge of the cell.
|
|
68
|
+
* @param forceTruncationSymbol - `true` if the rendered text should end with the truncation symbol even
|
|
69
|
+
* if the text fits. This is used when the cell is vertically truncated. If `false` the text should
|
|
70
|
+
* only include the truncation symbol if the text will not fit horizontally within the cell width.
|
|
71
|
+
* @param spanningCell - a number of if being called from a RowSpanCell. (how many rows below). otherwise undefined.
|
|
72
|
+
* @returns {String}
|
|
73
|
+
*/
|
|
74
|
+
drawLine(lineNum: number, drawRight: boolean, forceTruncationSymbol: boolean, spanningCell?: number): string;
|
|
75
|
+
stylizeLine(left: string, content: string, right: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* Renders the bottom line of the cell.
|
|
78
|
+
* @param drawRight - true if this method should render the right edge of the cell.
|
|
79
|
+
* @returns {String}
|
|
80
|
+
*/
|
|
81
|
+
drawBottom(drawRight: boolean): string;
|
|
82
|
+
/**
|
|
83
|
+
* Renders a blank line of text within the cell. Used for top and/or bottom padding.
|
|
84
|
+
* @param drawRight - true if this method should render the right edge of the cell.
|
|
85
|
+
* @param spanningCell - a number of if being called from a RowSpanCell. (how many rows below). otherwise undefined.
|
|
86
|
+
* @returns {String}
|
|
87
|
+
*/
|
|
88
|
+
drawEmpty(drawRight: boolean, spanningCell?: number): string;
|
|
89
|
+
}
|
|
90
|
+
export declare class ColSpanCell {
|
|
91
|
+
x: number | null;
|
|
92
|
+
y: number | null;
|
|
93
|
+
colSpan: number;
|
|
94
|
+
draw(lineNum: "top" | "bottom" | number): string;
|
|
95
|
+
init(): void;
|
|
96
|
+
mergeTableOptions(): void;
|
|
97
|
+
}
|
|
98
|
+
export declare class RowSpanCell {
|
|
99
|
+
originalCell: Cell;
|
|
100
|
+
x: number | null;
|
|
101
|
+
y: number | null;
|
|
102
|
+
colSpan: number;
|
|
103
|
+
cellOffset: number;
|
|
104
|
+
offset: number;
|
|
105
|
+
/**
|
|
106
|
+
* A placeholder Cell for a Cell that spans multiple rows.
|
|
107
|
+
* It delegates rendering to the original cell, but adds the appropriate offset.
|
|
108
|
+
*/
|
|
109
|
+
constructor(originalCell: Cell);
|
|
110
|
+
init(tableOptions: TableInstanceOptions): void;
|
|
111
|
+
draw(lineNum: "top" | "bottom" | number): string;
|
|
112
|
+
mergeTableOptions(): void;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=cell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cell.d.ts","sourceRoot":"","sources":["../../../source/terminal/table/cell.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,QAAQ,EAEb,KAAK,mBAAmB,EAMxB,KAAK,oBAAoB,EAEzB,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAC;AAoBpB,qBAAa,IAAI;IACf,OAAO,EAAG,WAAW,CAAC;IACtB,OAAO,EAAG,MAAM,CAAC;IACjB,OAAO,EAAG,MAAM,CAAC;IACjB,OAAO,EAAG,MAAM,CAAC;IACjB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAQ;IACxB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAQ;IACxB,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAkC;IACjE,QAAQ,SAAO;IACf,WAAW,SAAK;IAChB,YAAY,SAAK;IACjB,IAAI,EAAE,MAAM,EAAE,CAAM;IACpB,MAAM,EAAE,MAAM,EAAE,CAAM;IACtB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAQ;IACjC,KAAK,EAAE,MAAM,EAAE,CAAM;IACrB,YAAY,SAAK;IACjB,aAAa,SAAK;IAClB,MAAM,EAAE,MAAM,EAAE,CAAM;IACtB,OAAO,EAAE,MAAM,EAAE,CAAM;IACvB,KAAK,SAAK;IACV,MAAM,SAAK;IACX,MAAM,EAAE,mBAAmB,CAAU;IACrC,MAAM,EAAE,iBAAiB,CAAS;IAClC,SAAS,UAAS;IAClB,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI,CAAQ;IAE9B;;;;OAIG;gBACS,OAAO,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM;IAIrE,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI;IA2B3E,iBAAiB,CAAC,YAAY,EAAE,oBAAoB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI;IAqC5E,YAAY,CAAC,YAAY,EAAE,oBAAoB,GAAG,MAAM,EAAE;IAsB1D,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;IAS5C;;;;;;;OAOG;IACH,IAAI,CAAC,YAAY,EAAE,oBAAoB,GAAG,IAAI;IAqB9C;;;;;;;OAOG;IACH,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM;IAoCvE;;;;OAIG;IACH,OAAO,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM;IAoBnC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAkCpC,mBAAmB,CACjB,aAAa,EAAE,MAAM,GAAG,QAAQ,EAChC,OAAO,EAAE,MAAM,GACd,MAAM;IAwBT;;;;;;;;;;OAUG;IACH,QAAQ,CACN,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,OAAO,EAClB,qBAAqB,EAAE,OAAO,EAC9B,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM;IA2BT,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAUjE;;;;OAIG;IACH,UAAU,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM;IAOtC;;;;;OAKG;IACH,SAAS,CAAC,SAAS,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM;CAmB7D;AAED,qBAAa,WAAW;IACtB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAQ;IACxB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAQ;IACxB,OAAO,SAAK;IAEZ,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM;IAOhD,IAAI,IAAI,IAAI;IAEZ,iBAAiB,IAAI,IAAI;CAC1B;AAED,qBAAa,WAAW;IACtB,YAAY,EAAE,IAAI,CAAC;IACnB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAQ;IACxB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAQ;IACxB,OAAO,SAAK;IACZ,UAAU,SAAK;IACf,MAAM,SAAK;IAEX;;;OAGG;gBACS,YAAY,EAAE,IAAI;IAI9B,IAAI,CAAC,YAAY,EAAE,oBAAoB,GAAG,IAAI;IAgB9C,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM;IAahD,iBAAiB,IAAI,IAAI;CAC1B"}
|
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import debug from "./debug.js";
|
|
2
|
+
import { colorizeLines, hyperlink, multiLineWordWrap, pad, repeat, strlen, truncate, } from "./utils.js";
|
|
3
|
+
const CHAR_NAMES = [
|
|
4
|
+
"top",
|
|
5
|
+
"topMid",
|
|
6
|
+
"topLeft",
|
|
7
|
+
"topRight",
|
|
8
|
+
"bottom",
|
|
9
|
+
"bottomMid",
|
|
10
|
+
"bottomLeft",
|
|
11
|
+
"bottomRight",
|
|
12
|
+
"left",
|
|
13
|
+
"leftMid",
|
|
14
|
+
"mid",
|
|
15
|
+
"midMid",
|
|
16
|
+
"right",
|
|
17
|
+
"rightMid",
|
|
18
|
+
"middle",
|
|
19
|
+
];
|
|
20
|
+
export class Cell {
|
|
21
|
+
options;
|
|
22
|
+
content;
|
|
23
|
+
colSpan;
|
|
24
|
+
rowSpan;
|
|
25
|
+
x = null;
|
|
26
|
+
y = null;
|
|
27
|
+
chars = {};
|
|
28
|
+
truncate = "…";
|
|
29
|
+
paddingLeft = 1;
|
|
30
|
+
paddingRight = 1;
|
|
31
|
+
head = [];
|
|
32
|
+
border = [];
|
|
33
|
+
fixedWidth = null;
|
|
34
|
+
lines = [];
|
|
35
|
+
desiredWidth = 0;
|
|
36
|
+
desiredHeight = 0;
|
|
37
|
+
widths = [];
|
|
38
|
+
heights = [];
|
|
39
|
+
width = 0;
|
|
40
|
+
height = 0;
|
|
41
|
+
hAlign = "left";
|
|
42
|
+
vAlign = "top";
|
|
43
|
+
drawRight = false;
|
|
44
|
+
cells = null;
|
|
45
|
+
/**
|
|
46
|
+
* A representation of a cell within the table.
|
|
47
|
+
* Implementations must have `init` and `draw` methods,
|
|
48
|
+
* as well as `colSpan`, `rowSpan`, `desiredHeight` and `desiredWidth` properties.
|
|
49
|
+
*/
|
|
50
|
+
constructor(options) {
|
|
51
|
+
this.setOptions(options);
|
|
52
|
+
}
|
|
53
|
+
setOptions(options) {
|
|
54
|
+
let processedOptions = options;
|
|
55
|
+
if (["boolean", "number", "bigint", "string"].indexOf(typeof processedOptions) !== -1) {
|
|
56
|
+
processedOptions = { content: `${processedOptions}` };
|
|
57
|
+
}
|
|
58
|
+
const opts = (processedOptions || {});
|
|
59
|
+
this.options = opts;
|
|
60
|
+
const content = opts.content;
|
|
61
|
+
if (["boolean", "number", "bigint", "string"].indexOf(typeof content) !== -1) {
|
|
62
|
+
this.content = String(content);
|
|
63
|
+
}
|
|
64
|
+
else if (!content) {
|
|
65
|
+
this.content = this.options.href || "";
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
throw new Error(`Content needs to be a primitive, got: ${typeof content}`);
|
|
69
|
+
}
|
|
70
|
+
this.colSpan = opts.colSpan || 1;
|
|
71
|
+
this.rowSpan = opts.rowSpan || 1;
|
|
72
|
+
}
|
|
73
|
+
mergeTableOptions(tableOptions, cells) {
|
|
74
|
+
this.cells = cells;
|
|
75
|
+
const optionsChars = this.options.chars || {};
|
|
76
|
+
const tableChars = tableOptions.chars;
|
|
77
|
+
const chars = this.chars;
|
|
78
|
+
CHAR_NAMES.forEach((name) => {
|
|
79
|
+
setOption(optionsChars, tableChars, name, chars);
|
|
80
|
+
});
|
|
81
|
+
this.truncate = this.options.truncate || tableOptions.truncate;
|
|
82
|
+
const style = this.options.style || {};
|
|
83
|
+
const tableStyle = tableOptions.style;
|
|
84
|
+
setOption(style, tableStyle, "padding-left", this);
|
|
85
|
+
setOption(style, tableStyle, "padding-right", this);
|
|
86
|
+
this.head = style.head || tableStyle.head;
|
|
87
|
+
this.border = style.border || tableStyle.border;
|
|
88
|
+
this.fixedWidth = this.x !== null ? tableOptions.colWidths[this.x] : null;
|
|
89
|
+
this.lines = this.computeLines(tableOptions);
|
|
90
|
+
this.desiredWidth =
|
|
91
|
+
strlen(this.content) + this.paddingLeft + this.paddingRight;
|
|
92
|
+
this.desiredHeight = this.lines.length;
|
|
93
|
+
}
|
|
94
|
+
computeLines(tableOptions) {
|
|
95
|
+
const tableWordWrap = tableOptions.wordWrap || tableOptions.textWrap;
|
|
96
|
+
const { wordWrap = tableWordWrap } = this.options;
|
|
97
|
+
if (this.fixedWidth && wordWrap) {
|
|
98
|
+
let fixedWidth = this.fixedWidth - this.paddingLeft - this.paddingRight;
|
|
99
|
+
if (this.colSpan && this.x !== null) {
|
|
100
|
+
let i = 1;
|
|
101
|
+
while (i < this.colSpan) {
|
|
102
|
+
fixedWidth += tableOptions.colWidths[this.x + i] || 0;
|
|
103
|
+
i++;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const { wrapOnWordBoundary: tableWrapOnWordBoundary = true } = tableOptions;
|
|
107
|
+
const { wrapOnWordBoundary = tableWrapOnWordBoundary } = this.options;
|
|
108
|
+
return this.wrapLines(multiLineWordWrap(fixedWidth, this.content, wrapOnWordBoundary));
|
|
109
|
+
}
|
|
110
|
+
return this.wrapLines(this.content.split("\n"));
|
|
111
|
+
}
|
|
112
|
+
wrapLines(computedLines) {
|
|
113
|
+
const lines = colorizeLines(computedLines);
|
|
114
|
+
const href = this.options.href;
|
|
115
|
+
if (href) {
|
|
116
|
+
return lines.map((line) => hyperlink(href, line));
|
|
117
|
+
}
|
|
118
|
+
return lines;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Initializes the Cells data structure.
|
|
122
|
+
*
|
|
123
|
+
* @param tableOptions - A fully populated set of tableOptions.
|
|
124
|
+
* In addition to the standard default values, tableOptions must have fully populated the
|
|
125
|
+
* `colWidths` and `rowWidths` arrays. Those arrays must have lengths equal to the number
|
|
126
|
+
* of columns or rows (respectively) in this table, and each array item must be a Number.
|
|
127
|
+
*/
|
|
128
|
+
init(tableOptions) {
|
|
129
|
+
if (this.x === null || this.y === null) {
|
|
130
|
+
throw new Error("Cell x and y must be initialized before calling init");
|
|
131
|
+
}
|
|
132
|
+
const x = this.x;
|
|
133
|
+
const y = this.y;
|
|
134
|
+
this.widths = tableOptions.colWidths.slice(x, x + this.colSpan).filter((w) => w !== null);
|
|
135
|
+
this.heights = tableOptions.rowHeights.slice(y, y + this.rowSpan).filter((h) => h !== null);
|
|
136
|
+
this.width = this.widths.reduce(sumPlusOne, -1);
|
|
137
|
+
this.height = this.heights.reduce(sumPlusOne, -1);
|
|
138
|
+
this.hAlign = this.options.hAlign || tableOptions.colAligns[x];
|
|
139
|
+
this.vAlign = this.options.vAlign || tableOptions.rowAligns[y];
|
|
140
|
+
this.drawRight = x + this.colSpan === tableOptions.colWidths.length;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Draws the given line of the cell.
|
|
144
|
+
* This default implementation defers to methods `drawTop`, `drawBottom`, `drawLine` and `drawEmpty`.
|
|
145
|
+
* @param lineNum - can be `top`, `bottom` or a numerical line number.
|
|
146
|
+
* @param spanningCell - will be a number if being called from a RowSpanCell, and will represent how
|
|
147
|
+
* many rows below it's being called from. Otherwise it's undefined.
|
|
148
|
+
* @returns {String} The representation of this line.
|
|
149
|
+
*/
|
|
150
|
+
draw(lineNum, spanningCell) {
|
|
151
|
+
if (lineNum === "top")
|
|
152
|
+
return this.drawTop(this.drawRight);
|
|
153
|
+
if (lineNum === "bottom")
|
|
154
|
+
return this.drawBottom(this.drawRight);
|
|
155
|
+
const content = truncate(this.content, 10, this.truncate);
|
|
156
|
+
if (!lineNum) {
|
|
157
|
+
debug.info(`${this.y}-${this.x}: ${this.rowSpan - lineNum}x${this.colSpan} Cell ${content}`);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
// debug.debug(`${lineNum}-${this.x}: 1x${this.colSpan} RowSpanCell ${content}`);
|
|
161
|
+
}
|
|
162
|
+
const padLen = Math.max(this.height - this.lines.length, 0);
|
|
163
|
+
let padTop;
|
|
164
|
+
switch (this.vAlign) {
|
|
165
|
+
case "center":
|
|
166
|
+
padTop = Math.ceil(padLen / 2);
|
|
167
|
+
break;
|
|
168
|
+
case "bottom":
|
|
169
|
+
padTop = padLen;
|
|
170
|
+
break;
|
|
171
|
+
default:
|
|
172
|
+
padTop = 0;
|
|
173
|
+
}
|
|
174
|
+
if (lineNum < padTop || lineNum >= padTop + this.lines.length) {
|
|
175
|
+
return this.drawEmpty(this.drawRight, spanningCell);
|
|
176
|
+
}
|
|
177
|
+
const forceTruncation = this.lines.length > this.height && lineNum + 1 >= this.height;
|
|
178
|
+
return this.drawLine(lineNum - padTop, this.drawRight, forceTruncation, spanningCell);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Renders the top line of the cell.
|
|
182
|
+
* @param drawRight - true if this method should render the right edge of the cell.
|
|
183
|
+
* @returns {String}
|
|
184
|
+
*/
|
|
185
|
+
drawTop(drawRight) {
|
|
186
|
+
const content = [];
|
|
187
|
+
if (this.cells) {
|
|
188
|
+
// TODO: cells should always exist - some tests don't fill it in though
|
|
189
|
+
this.widths.forEach((width, index) => {
|
|
190
|
+
content.push(this._topLeftChar(index));
|
|
191
|
+
content.push(repeat(this.chars[this.y === 0 ? "top" : "mid"], width));
|
|
192
|
+
}, this);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
content.push(this._topLeftChar(0));
|
|
196
|
+
content.push(repeat(this.chars[this.y === 0 ? "top" : "mid"], this.width));
|
|
197
|
+
}
|
|
198
|
+
if (drawRight) {
|
|
199
|
+
content.push(this.chars[this.y === 0 ? "topRight" : "rightMid"]);
|
|
200
|
+
}
|
|
201
|
+
return this.wrapWithStyleColors("border", content.join(""));
|
|
202
|
+
}
|
|
203
|
+
_topLeftChar(offset) {
|
|
204
|
+
if (this.x === null) {
|
|
205
|
+
throw new Error("Cell x must be initialized before calling _topLeftChar");
|
|
206
|
+
}
|
|
207
|
+
const x = this.x + offset;
|
|
208
|
+
let leftChar;
|
|
209
|
+
if (this.y === 0) {
|
|
210
|
+
leftChar = x === 0 ? "topLeft" : offset === 0 ? "topMid" : "top";
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
if (x === 0) {
|
|
214
|
+
leftChar = "leftMid";
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
leftChar = offset === 0 ? "midMid" : "bottomMid";
|
|
218
|
+
if (this.cells && this.y !== null) {
|
|
219
|
+
// TODO: cells should always exist - some tests don't fill it in though
|
|
220
|
+
const spanAbove = this.cells[this.y - 1]?.[x] instanceof ColSpanCell;
|
|
221
|
+
if (spanAbove) {
|
|
222
|
+
leftChar = offset === 0 ? "topMid" : "mid";
|
|
223
|
+
}
|
|
224
|
+
if (offset === 0) {
|
|
225
|
+
let i = 1;
|
|
226
|
+
while (this.cells[this.y]?.[x - i] instanceof ColSpanCell) {
|
|
227
|
+
i++;
|
|
228
|
+
}
|
|
229
|
+
if (this.cells[this.y]?.[x - i] instanceof RowSpanCell) {
|
|
230
|
+
leftChar = "leftMid";
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return this.chars[leftChar];
|
|
237
|
+
}
|
|
238
|
+
wrapWithStyleColors(styleProperty, content) {
|
|
239
|
+
if (this[styleProperty]?.length) {
|
|
240
|
+
try {
|
|
241
|
+
// Use basic ANSI color codes
|
|
242
|
+
const colorMap = {
|
|
243
|
+
red: "\x1b[31m",
|
|
244
|
+
grey: "\x1b[90m",
|
|
245
|
+
gray: "\x1b[90m",
|
|
246
|
+
};
|
|
247
|
+
let styledContent = content;
|
|
248
|
+
for (const colorName of this[styleProperty]) {
|
|
249
|
+
if (colorName in colorMap) {
|
|
250
|
+
styledContent = `${colorMap[colorName] + styledContent}\x1b[0m`;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return styledContent;
|
|
254
|
+
}
|
|
255
|
+
catch (_e) {
|
|
256
|
+
return content;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
return content;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Renders a line of text.
|
|
265
|
+
* @param lineNum - Which line of text to render. This is not necessarily the line within the cell.
|
|
266
|
+
* There may be top-padding above the first line of text.
|
|
267
|
+
* @param drawRight - true if this method should render the right edge of the cell.
|
|
268
|
+
* @param forceTruncationSymbol - `true` if the rendered text should end with the truncation symbol even
|
|
269
|
+
* if the text fits. This is used when the cell is vertically truncated. If `false` the text should
|
|
270
|
+
* only include the truncation symbol if the text will not fit horizontally within the cell width.
|
|
271
|
+
* @param spanningCell - a number of if being called from a RowSpanCell. (how many rows below). otherwise undefined.
|
|
272
|
+
* @returns {String}
|
|
273
|
+
*/
|
|
274
|
+
drawLine(lineNum, drawRight, forceTruncationSymbol, spanningCell) {
|
|
275
|
+
let left = this.chars[this.x === 0 ? "left" : "middle"];
|
|
276
|
+
if (this.x && this.x > 0 && spanningCell && this.cells && this.y !== null) {
|
|
277
|
+
let cellLeft = this.cells[this.y + spanningCell]?.[this.x - 1];
|
|
278
|
+
while (cellLeft instanceof ColSpanCell &&
|
|
279
|
+
cellLeft.y !== null &&
|
|
280
|
+
cellLeft.x !== null) {
|
|
281
|
+
cellLeft = this.cells[cellLeft.y]?.[cellLeft.x - 1];
|
|
282
|
+
}
|
|
283
|
+
if (!(cellLeft instanceof RowSpanCell)) {
|
|
284
|
+
left = this.chars["rightMid"];
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
const leftPadding = repeat(" ", this.paddingLeft);
|
|
288
|
+
const right = drawRight ? this.chars["right"] : "";
|
|
289
|
+
const rightPadding = repeat(" ", this.paddingRight);
|
|
290
|
+
let line = this.lines[lineNum];
|
|
291
|
+
const len = this.width - (this.paddingLeft + this.paddingRight);
|
|
292
|
+
if (forceTruncationSymbol)
|
|
293
|
+
line += this.truncate || "…";
|
|
294
|
+
let content = truncate(line, len, this.truncate);
|
|
295
|
+
content = pad(content, len, " ", this.hAlign);
|
|
296
|
+
content = leftPadding + content + rightPadding;
|
|
297
|
+
return this.stylizeLine(left, content, right);
|
|
298
|
+
}
|
|
299
|
+
stylizeLine(left, content, right) {
|
|
300
|
+
const processedLeft = this.wrapWithStyleColors("border", left);
|
|
301
|
+
const processedRight = this.wrapWithStyleColors("border", right);
|
|
302
|
+
let processedContent = content;
|
|
303
|
+
if (this.y === 0) {
|
|
304
|
+
processedContent = this.wrapWithStyleColors("head", processedContent);
|
|
305
|
+
}
|
|
306
|
+
return processedLeft + processedContent + processedRight;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Renders the bottom line of the cell.
|
|
310
|
+
* @param drawRight - true if this method should render the right edge of the cell.
|
|
311
|
+
* @returns {String}
|
|
312
|
+
*/
|
|
313
|
+
drawBottom(drawRight) {
|
|
314
|
+
const left = this.chars[this.x === 0 ? "bottomLeft" : "bottomMid"];
|
|
315
|
+
const content = repeat(this.chars.bottom, this.width);
|
|
316
|
+
const right = drawRight ? this.chars["bottomRight"] : "";
|
|
317
|
+
return this.wrapWithStyleColors("border", left + content + right);
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Renders a blank line of text within the cell. Used for top and/or bottom padding.
|
|
321
|
+
* @param drawRight - true if this method should render the right edge of the cell.
|
|
322
|
+
* @param spanningCell - a number of if being called from a RowSpanCell. (how many rows below). otherwise undefined.
|
|
323
|
+
* @returns {String}
|
|
324
|
+
*/
|
|
325
|
+
drawEmpty(drawRight, spanningCell) {
|
|
326
|
+
let left = this.chars[this.x === 0 ? "left" : "middle"];
|
|
327
|
+
if (this.x && this.x > 0 && spanningCell && this.cells && this.y !== null) {
|
|
328
|
+
let cellLeft = this.cells[this.y + spanningCell]?.[this.x - 1];
|
|
329
|
+
while (cellLeft instanceof ColSpanCell &&
|
|
330
|
+
cellLeft.y !== null &&
|
|
331
|
+
cellLeft.x !== null) {
|
|
332
|
+
cellLeft = this.cells[cellLeft.y]?.[cellLeft.x - 1];
|
|
333
|
+
}
|
|
334
|
+
if (!(cellLeft instanceof RowSpanCell)) {
|
|
335
|
+
left = this.chars["rightMid"];
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
const right = drawRight ? this.chars["right"] : "";
|
|
339
|
+
const content = repeat(" ", this.width);
|
|
340
|
+
return this.stylizeLine(left, content, right);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
export class ColSpanCell {
|
|
344
|
+
x = null;
|
|
345
|
+
y = null;
|
|
346
|
+
colSpan = 1;
|
|
347
|
+
draw(lineNum) {
|
|
348
|
+
if (typeof lineNum === "number") {
|
|
349
|
+
debug.debug(`${this.y}-${this.x}: 1x1 ColSpanCell`);
|
|
350
|
+
}
|
|
351
|
+
return "";
|
|
352
|
+
}
|
|
353
|
+
init() { }
|
|
354
|
+
mergeTableOptions() { }
|
|
355
|
+
}
|
|
356
|
+
export class RowSpanCell {
|
|
357
|
+
originalCell;
|
|
358
|
+
x = null;
|
|
359
|
+
y = null;
|
|
360
|
+
colSpan = 1;
|
|
361
|
+
cellOffset = 0;
|
|
362
|
+
offset = 0;
|
|
363
|
+
/**
|
|
364
|
+
* A placeholder Cell for a Cell that spans multiple rows.
|
|
365
|
+
* It delegates rendering to the original cell, but adds the appropriate offset.
|
|
366
|
+
*/
|
|
367
|
+
constructor(originalCell) {
|
|
368
|
+
this.originalCell = originalCell;
|
|
369
|
+
}
|
|
370
|
+
init(tableOptions) {
|
|
371
|
+
if (this.y === null || this.originalCell.y === null) {
|
|
372
|
+
throw new Error("RowSpanCell y and originalCell.y must be initialized before calling init");
|
|
373
|
+
}
|
|
374
|
+
const y = this.y;
|
|
375
|
+
const originalY = this.originalCell.y;
|
|
376
|
+
this.cellOffset = y - originalY;
|
|
377
|
+
this.offset = findDimension(tableOptions.rowHeights, originalY, this.cellOffset);
|
|
378
|
+
}
|
|
379
|
+
draw(lineNum) {
|
|
380
|
+
if (lineNum === "top") {
|
|
381
|
+
return this.originalCell.draw(this.offset, this.cellOffset);
|
|
382
|
+
}
|
|
383
|
+
if (lineNum === "bottom") {
|
|
384
|
+
return this.originalCell.draw("bottom");
|
|
385
|
+
}
|
|
386
|
+
debug.debug(`${this.y}-${this.x}: 1x${this.colSpan} RowSpanCell for ${this.originalCell.content}`);
|
|
387
|
+
return this.originalCell.draw(this.offset + 1 + lineNum);
|
|
388
|
+
}
|
|
389
|
+
mergeTableOptions() { }
|
|
390
|
+
}
|
|
391
|
+
function firstDefined(...args) {
|
|
392
|
+
return args.filter((v) => v !== undefined && v !== null).shift();
|
|
393
|
+
}
|
|
394
|
+
// HELPER FUNCTIONS
|
|
395
|
+
function setOption(objA, objB, nameB, targetObj) {
|
|
396
|
+
targetObj[nameB] = firstDefined(objA[nameB], objB[nameB]);
|
|
397
|
+
}
|
|
398
|
+
function findDimension(dimensionTable, startingIndex, span) {
|
|
399
|
+
let ret = dimensionTable[startingIndex];
|
|
400
|
+
for (let i = 1; i < span; i++) {
|
|
401
|
+
ret += 1 + dimensionTable[startingIndex + i];
|
|
402
|
+
}
|
|
403
|
+
return ret;
|
|
404
|
+
}
|
|
405
|
+
function sumPlusOne(a, b) {
|
|
406
|
+
return a + b + 1;
|
|
407
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type DebugLevel = 0 | 1 | 2 | 3;
|
|
2
|
+
declare const debug: {
|
|
3
|
+
(msg: string, min: DebugLevel): void;
|
|
4
|
+
WARN: 1;
|
|
5
|
+
INFO: 2;
|
|
6
|
+
DEBUG: 3;
|
|
7
|
+
reset(): void;
|
|
8
|
+
setDebugLevel(v: number | string | boolean): void;
|
|
9
|
+
warn(msg: string): void;
|
|
10
|
+
info(msg: string): void;
|
|
11
|
+
debug(msg: string): void;
|
|
12
|
+
debugMessages(): string[];
|
|
13
|
+
};
|
|
14
|
+
export default debug;
|
|
15
|
+
//# sourceMappingURL=debug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../source/terminal/table/debug.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAKhC,QAAA,MAAM,KAAK;UAAS,MAAM,OAAO,UAAU,GAAG,IAAI;;;;aAUhC,IAAI;qBAII,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI;cAYvC,MAAM,GAAG,IAAI;cACb,MAAM,GAAG,IAAI;eACZ,MAAM,GAAG,IAAI;qBAEP,MAAM,EAAE;CA1BjC,CAAC;AA4BF,eAAe,KAAK,CAAC"}
|