@simon_he/vue-tui 0.0.8 → 1.0.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/README.md +142 -30
- package/dist/TSelect-BwJJbuTt.js +6089 -0
- package/dist/TTree-DK_DQBYm.js +6480 -0
- package/dist/agent.cjs +39416 -0
- package/dist/agent.d.cts +44 -0
- package/dist/agent.d.ts +44 -0
- package/dist/agent.js +828 -0
- package/dist/ansi-palette-CNXqFciC.js +57 -0
- package/dist/ansi-styles.d.ts +200 -0
- package/dist/block-source-CKUOnkgT.js +1663 -0
- package/dist/cli/headless-renderer.d.ts +29 -0
- package/dist/cli/input.d.ts +49 -0
- package/dist/cli/node-file-writers.d.ts +13 -0
- package/dist/cli/node-module.d.ts +2 -0
- package/dist/cli/parse-kitty.d.ts +2 -0
- package/dist/cli/parse-mouse.d.ts +2 -0
- package/dist/cli/parse-utils.d.ts +14 -0
- package/dist/cli/parse-xterm.d.ts +2 -0
- package/dist/cli/path-provider-types.d.ts +1 -0
- package/dist/cli/path-provider.d.ts +4 -0
- package/dist/cli/path-suggest-core.d.ts +1 -0
- package/dist/cli/path-suggest.d.ts +15 -0
- package/dist/cli/recording.d.ts +4 -0
- package/dist/cli/stdin-buffer.d.ts +33 -0
- package/dist/cli.cjs +11061 -0
- package/dist/cli.d.cts +23 -0
- package/dist/cli.d.ts +23 -0
- package/dist/cli.js +9875 -0
- package/dist/core/ansi/capability.d.ts +20 -0
- package/dist/core/ansi/colors.d.ts +41 -0
- package/dist/core/ansi/sgr.d.ts +7 -0
- package/dist/core/ansi/theme.d.ts +6 -0
- package/dist/core/ansi-palette.d.ts +14 -0
- package/dist/core/buffer/buffer.d.ts +54 -0
- package/dist/core/buffer/width.d.ts +4 -0
- package/dist/core/debug-logger.d.ts +18 -0
- package/dist/core/hyperlink.d.ts +9 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/path-provider-types.d.ts +24 -0
- package/dist/core/path-suggest.d.ts +35 -0
- package/dist/core/render-plane.d.ts +3 -0
- package/dist/core/terminal/create-terminal.d.ts +8 -0
- package/dist/core/terminal/emitter.d.ts +7 -0
- package/dist/core/types.d.ts +107 -0
- package/dist/core.cjs +3153 -0
- package/dist/core.d.cts +14 -0
- package/dist/core.d.ts +14 -0
- package/dist/core.js +424 -0
- package/dist/create-terminal-C2oiWFJU.js +1434 -0
- package/dist/create-terminal-app.d.ts +36 -0
- package/dist/dom-renderer-BqGijQID.js +1173 -0
- package/dist/env-Cl8qmNFN.js +19 -0
- package/dist/events/index.d.ts +6 -0
- package/dist/events/manager/cli-event-manager.d.ts +22 -0
- package/dist/events/manager/event-manager.d.ts +30 -0
- package/dist/events/manager/selection-suppression.d.ts +3 -0
- package/dist/events/manager/types.d.ts +108 -0
- package/dist/events/recording.d.ts +44 -0
- package/dist/experimental.cjs +4412 -1641
- package/dist/experimental.d.cts +42 -0
- package/dist/experimental.d.ts +42 -825
- package/dist/experimental.js +31 -7392
- package/dist/frame-perf-C6Xfg85O.js +24 -0
- package/dist/hyperlink-Bn02UXJb.js +419 -0
- package/dist/index.cjs +14765 -17582
- package/dist/index.d.cts +35 -0
- package/dist/index.d.ts +35 -1528
- package/dist/index.js +17 -20026
- package/dist/linkify-D_gzn9Xq.js +562 -0
- package/dist/markdown.cjs +9321 -7623
- package/dist/markdown.d.cts +11 -0
- package/dist/markdown.d.ts +11 -112
- package/dist/markdown.js +36 -1427
- package/dist/observability/cli-latency-node.d.ts +3 -0
- package/dist/observability/cli-latency-types.d.ts +41 -0
- package/dist/observability/cli-latency.d.ts +3 -0
- package/dist/observability/frame-perf-store.d.ts +18 -0
- package/dist/observability/frame-perf.d.ts +40 -0
- package/dist/observability/perf-sink.d.ts +56 -0
- package/dist/observability/trace.d.ts +40 -0
- package/dist/observability/tui-profiler.d.ts +33 -0
- package/dist/observability.cjs +221 -0
- package/dist/observability.d.cts +8 -0
- package/dist/observability.d.ts +8 -0
- package/dist/observability.js +4 -0
- package/dist/path-mnSgEpCm.js +81 -0
- package/dist/path-suggest-BNqcuE3-.js +274 -0
- package/dist/path-suggest-Dk9TRLh5.js +3 -0
- package/dist/{path-suggest-DmrmeueH.js → path-suggest-bvR9SY6Q.js} +86 -18
- package/dist/renderer/capabilities.d.ts +13 -0
- package/dist/renderer/cli/index.d.ts +2 -0
- package/dist/renderer/cli/stdout-metrics.d.ts +18 -0
- package/dist/renderer/cli/stdout-renderer.d.ts +48 -0
- package/dist/renderer/dom/dom-renderer.d.ts +157 -0
- package/dist/renderer/dom/index.d.ts +2 -0
- package/dist/renderer/index.d.ts +2 -0
- package/dist/renderer-dom.cjs +1505 -0
- package/dist/renderer-dom.d.cts +4 -0
- package/dist/renderer-dom.d.ts +4 -0
- package/dist/renderer-dom.js +7 -0
- package/dist/runtime/index.d.ts +36 -0
- package/dist/runtime/osc52.d.ts +9 -0
- package/dist/runtime-rfcZCyJq.js +1197 -0
- package/dist/runtime.cjs +1698 -0
- package/dist/runtime.d.cts +9 -0
- package/dist/runtime.d.ts +9 -0
- package/dist/runtime.js +4 -0
- package/dist/selection/terminal-selection.d.ts +123 -0
- package/dist/sgr-BmzxEjAO.js +304 -0
- package/dist/terminal-selection-DBinO6p5.js +330 -0
- package/dist/tlog-theme-qPBt5rge.js +9254 -0
- package/dist/trace-CjzYeIxN.js +182 -0
- package/dist/utils/env.d.ts +3 -0
- package/dist/utils/grapheme.d.ts +5 -0
- package/dist/utils/newlines.d.ts +1 -0
- package/dist/utils/path.d.ts +7 -0
- package/dist/utils/url-safety.d.ts +2 -0
- package/dist/vue/agent/view-models.d.ts +98 -0
- package/dist/vue/components/TAnchor.d.ts +108 -0
- package/dist/vue/components/TBox.d.ts +144 -0
- package/dist/vue/components/TCommandPalette.d.ts +587 -0
- package/dist/vue/components/TDataTable.d.ts +367 -0
- package/dist/vue/components/TDebugOverlay.d.ts +43 -0
- package/dist/vue/components/TDialog.d.ts +255 -0
- package/dist/vue/components/TFeedback.d.ts +635 -0
- package/dist/vue/components/TFlow.d.ts +85 -0
- package/dist/vue/components/TForm.d.ts +1230 -0
- package/dist/vue/components/TInput.d.ts +545 -0
- package/dist/vue/components/TInputBox.d.ts +158 -0
- package/dist/vue/components/TJsonEditor.d.ts +165 -0
- package/dist/vue/components/TLink.d.ts +239 -0
- package/dist/vue/components/TLinkifyText.d.ts +141 -0
- package/dist/vue/components/TList.d.ts +119 -0
- package/dist/vue/components/TLogLinksPanel.d.ts +238 -0
- package/dist/vue/components/TLogMinimap.d.ts +263 -0
- package/dist/vue/components/TLogScrollbar.d.ts +236 -0
- package/dist/vue/components/TLogSearchBar.d.ts +267 -0
- package/dist/vue/components/TLogSearchPager.d.ts +162 -0
- package/dist/vue/components/TLogSearchResults.d.ts +200 -0
- package/dist/vue/components/TLogView.d.ts +536 -0
- package/dist/vue/components/TLogVirtualLinksPanel.d.ts +141 -0
- package/dist/vue/components/TLogVirtualSearchResults.d.ts +146 -0
- package/dist/vue/components/TMarkdownText.d.ts +134 -0
- package/dist/vue/components/TMultilineModal.d.ts +62 -0
- package/dist/vue/components/TNavigation.d.ts +324 -0
- package/dist/vue/components/TOverlay.d.ts +366 -0
- package/dist/vue/components/TPanels.d.ts +244 -0
- package/dist/vue/components/TPathPicker.d.ts +213 -0
- package/dist/vue/components/TRenderLayer.d.ts +16 -0
- package/dist/vue/components/TRenderPlane.d.ts +17 -0
- package/dist/vue/components/TSelect.d.ts +335 -0
- package/dist/vue/components/TTable.d.ts +317 -0
- package/dist/vue/components/TText.d.ts +116 -0
- package/dist/vue/components/TThinkingView.d.ts +233 -0
- package/dist/vue/components/TToolCallView.d.ts +384 -0
- package/dist/vue/components/TTranscriptView.d.ts +221 -0
- package/dist/vue/components/TTransition.d.ts +83 -0
- package/dist/vue/components/TTree.d.ts +200 -0
- package/dist/vue/components/TUserMessageView.d.ts +344 -0
- package/dist/vue/components/TView.d.ts +127 -0
- package/dist/vue/components/TVirtualList.d.ts +182 -0
- package/dist/vue/components/TVirtualMarkdown.d.ts +168 -0
- package/dist/vue/components/TVirtualRows.d.ts +247 -0
- package/dist/vue/components/TerminalProvider.d.ts +218 -0
- package/dist/vue/components/input/host.d.ts +17 -0
- package/dist/vue/components/input/plugins/hostPlugin.d.ts +7 -0
- package/dist/vue/components/input/plugins/hostPlugin.node.d.ts +15 -0
- package/dist/vue/components/input/plugins/mentionUtils.d.ts +17 -0
- package/dist/vue/components/input/plugins/nodeMentionPathProvider.d.ts +2 -0
- package/dist/vue/components/input/plugins/promptMentionPlugin.d.ts +8 -0
- package/dist/vue/components/input/plugins/promptMentionState.d.ts +98 -0
- package/dist/vue/components/input/plugins/restrictText.d.ts +27 -0
- package/dist/vue/components/input/plugins/types.d.ts +90 -0
- package/dist/vue/components/input/utils/inlineText.d.ts +57 -0
- package/dist/vue/components/input/utils/inlineTextTokens.d.ts +34 -0
- package/dist/vue/components/input/utils/primitives.d.ts +3 -0
- package/dist/vue/components/input/utils/wordNavigation.d.ts +6 -0
- package/dist/vue/components/link/host.d.ts +15 -0
- package/dist/vue/components/list/list-geometry.d.ts +16 -0
- package/dist/vue/components/list/list-paint.d.ts +1 -0
- package/dist/vue/components/list/scroll-state.d.ts +25 -0
- package/dist/vue/components/list/selection-state.d.ts +6 -0
- package/dist/vue/components/simple-utils.d.ts +5 -0
- package/dist/vue/components/terminal-provider/copy-toast.d.ts +6 -0
- package/dist/vue/components/terminal-provider/portals.d.ts +17 -0
- package/dist/vue/components/terminal-provider/scheduler.d.ts +29 -0
- package/dist/vue/components/terminal-provider/selection-config.d.ts +15 -0
- package/dist/vue/components/terminal-provider/utils.d.ts +5 -0
- package/dist/vue/composables/use-layout.d.ts +2 -0
- package/dist/vue/composables/use-render-node.d.ts +19 -0
- package/dist/vue/composables/use-render-stack.d.ts +3 -0
- package/dist/vue/composables/use-runtime.d.ts +5 -0
- package/dist/vue/composables/use-terminal-node.d.ts +14 -0
- package/dist/vue/composables/use-terminal.d.ts +2 -0
- package/dist/vue/composables/use-visibility.d.ts +12 -0
- package/dist/vue/context.d.ts +153 -0
- package/dist/vue/index.d.ts +69 -0
- package/dist/vue/injection-key.d.ts +2 -0
- package/dist/vue/linkify.d.ts +11 -0
- package/dist/vue/log/append-only-log-store.d.ts +2 -0
- package/dist/vue/log/tlog-keymap.d.ts +28 -0
- package/dist/vue/log/tlog-plugins.d.ts +144 -0
- package/dist/vue/log/tlog-session.d.ts +81 -0
- package/dist/vue/log/tlog-theme.d.ts +68 -0
- package/dist/vue/log/types.d.ts +43 -0
- package/dist/vue/log/use-tlog-link-controller.d.ts +31 -0
- package/dist/vue/log/use-tlog-retained-index.d.ts +26 -0
- package/dist/vue/log/use-tlog-search-controller.d.ts +51 -0
- package/dist/vue/log/use-tlog-search-results-page.d.ts +31 -0
- package/dist/vue/log/use-tlog-virtual-search-results.d.ts +22 -0
- package/dist/vue/markdown/ast.d.ts +3 -0
- package/dist/vue/markdown/block-source.d.ts +22 -0
- package/dist/vue/markdown/document.d.ts +20 -0
- package/dist/vue/markdown/layout.d.ts +21 -0
- package/dist/vue/markdown/parser.d.ts +11 -0
- package/dist/vue/markdown/render.d.ts +10 -0
- package/dist/vue/markdown/theme.d.ts +186 -0
- package/dist/vue/markdown/types.d.ts +59 -0
- package/dist/vue/overlay.d.ts +27 -0
- package/dist/vue/render/context.d.ts +3 -0
- package/dist/vue/render/render-manager.d.ts +94 -0
- package/dist/vue/router/RouterView.d.ts +25 -0
- package/dist/vue/router/composables.d.ts +4 -0
- package/dist/vue/router/context.d.ts +4 -0
- package/dist/vue/router/router.d.ts +7 -0
- package/dist/vue/router/types.d.ts +29 -0
- package/dist/vue/scheduler/frame-mailbox.d.ts +55 -0
- package/dist/vue/scheduler/frame-scheduler.d.ts +51 -0
- package/dist/vue/theme.d.ts +48 -0
- package/dist/vue/transcript/hit-regions.d.ts +2 -0
- package/dist/vue/transcript/layout.d.ts +20 -0
- package/dist/vue/transcript/plain-text.d.ts +2 -0
- package/dist/vue/transcript/types.d.ts +122 -0
- package/dist/vue/utils/frame-task.d.ts +6 -0
- package/dist/vue/utils/rect.d.ts +4 -0
- package/dist/vue/utils/row-scroll.d.ts +25 -0
- package/dist/vue/utils/style-cache.d.ts +3 -0
- package/dist/vue/utils/text.d.ts +27 -0
- package/dist/vue/utils/wheel-scroll.d.ts +18 -0
- package/dist/vue.cjs +23668 -0
- package/dist/vue.d.cts +1 -0
- package/dist/vue.d.ts +1 -0
- package/dist/vue.js +3957 -0
- package/dist/{wheel-scroll-CiNsasLf.js → wheel-scroll-vBRaQ7p-.js} +404 -405
- package/package.json +185 -35
- package/dist/path-suggest-BeV6n7m-.js +0 -3
- package/dist/sgr-Tko2EQ0U.js +0 -484
- package/dist/theme-Bsm65g8k.d.ts +0 -32
- package/dist/types-ClIV2h1o.d.ts +0 -103
package/dist/core.d.cts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { ansiStyles } from "./ansi-styles.js";
|
|
2
|
+
export { ANSI8_COLORS, ANSI16_COLORS, ANSI256_COLORS, ansiColors, rgbToAnsi256, SGR_RESET, type TerminalColorLevel, type TerminalColorMode, truecolorBgOpen, truecolorFgOpen, } from "./ansi-styles.js";
|
|
3
|
+
export { detectTerminalColorCapability, type TerminalColorCapability, } from "./core/ansi/capability.js";
|
|
4
|
+
export type { ThemePalette } from "./core/ansi-palette.js";
|
|
5
|
+
export { parseAnsiSgr } from "./core/ansi/sgr.js";
|
|
6
|
+
export { charCellWidth } from "./core/buffer/width.js";
|
|
7
|
+
export type { BuiltinWidthProvider, CellWidth, WidthProvider } from "./core/buffer/width.js";
|
|
8
|
+
export { isSafeRelativeHref, sanitizeDomHref, sanitizeTerminalHref, type SanitizeDomHrefOptions, type SanitizeTerminalHrefOptions, } from "./core/hyperlink.js";
|
|
9
|
+
export { TERMINAL_RENDER_PLANES, type TerminalRenderPlane, type TerminalRenderPlanes, } from "./core/render-plane.js";
|
|
10
|
+
export type { AnsiColorName, BufferSnapshot, Cell, Style, Terminal, TerminalCommitEvent, TerminalEventMap, TerminalOptions, TerminalResizeEvent, TerminalScrollOperation, ThemeModeId, } from "./core/index.js";
|
|
11
|
+
export { createTerminal } from "./core/index.js";
|
|
12
|
+
export type { FsDirEntry, FsEntryKind, FsStat, PathPickerProvider, } from "./core/path-provider-types.js";
|
|
13
|
+
export { type PathPickMode, type PathSuggestion, parsePathQuery, resolveUserPath, suggestParentHint, suggestPaths, type SuggestPathsResult, } from "./core/path-suggest.js";
|
|
14
|
+
export { normalizeNewlines } from "./utils/newlines.js";
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { ansiStyles } from "./ansi-styles.js";
|
|
2
|
+
export { ANSI8_COLORS, ANSI16_COLORS, ANSI256_COLORS, ansiColors, rgbToAnsi256, SGR_RESET, type TerminalColorLevel, type TerminalColorMode, truecolorBgOpen, truecolorFgOpen, } from "./ansi-styles.js";
|
|
3
|
+
export { detectTerminalColorCapability, type TerminalColorCapability, } from "./core/ansi/capability.js";
|
|
4
|
+
export type { ThemePalette } from "./core/ansi-palette.js";
|
|
5
|
+
export { parseAnsiSgr } from "./core/ansi/sgr.js";
|
|
6
|
+
export { charCellWidth } from "./core/buffer/width.js";
|
|
7
|
+
export type { BuiltinWidthProvider, CellWidth, WidthProvider } from "./core/buffer/width.js";
|
|
8
|
+
export { isSafeRelativeHref, sanitizeDomHref, sanitizeTerminalHref, type SanitizeDomHrefOptions, type SanitizeTerminalHrefOptions, } from "./core/hyperlink.js";
|
|
9
|
+
export { TERMINAL_RENDER_PLANES, type TerminalRenderPlane, type TerminalRenderPlanes, } from "./core/render-plane.js";
|
|
10
|
+
export type { AnsiColorName, BufferSnapshot, Cell, Style, Terminal, TerminalCommitEvent, TerminalEventMap, TerminalOptions, TerminalResizeEvent, TerminalScrollOperation, ThemeModeId, } from "./core/index.js";
|
|
11
|
+
export { createTerminal } from "./core/index.js";
|
|
12
|
+
export type { FsDirEntry, FsEntryKind, FsStat, PathPickerProvider, } from "./core/path-provider-types.js";
|
|
13
|
+
export { type PathPickMode, type PathSuggestion, parsePathQuery, resolveUserPath, suggestParentHint, suggestPaths, type SuggestPathsResult, } from "./core/path-suggest.js";
|
|
14
|
+
export { normalizeNewlines } from "./utils/newlines.js";
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import { TERMINAL_RENDER_PLANES, createTerminal } from "./create-terminal-C2oiWFJU.js";
|
|
2
|
+
import { charCellWidth, isSafeRelativeHref, sanitizeDomHref, sanitizeTerminalHref } from "./hyperlink-Bn02UXJb.js";
|
|
3
|
+
import { parseAnsiSgr } from "./sgr-BmzxEjAO.js";
|
|
4
|
+
import { ansiColorRgb } from "./ansi-palette-CNXqFciC.js";
|
|
5
|
+
import { firstNonEmptyEnv } from "./env-Cl8qmNFN.js";
|
|
6
|
+
import { normalizeNewlines } from "./path-mnSgEpCm.js";
|
|
7
|
+
import { parsePathQuery, resolveUserPath, suggestParentHint, suggestPaths } from "./path-suggest-BNqcuE3-.js";
|
|
8
|
+
|
|
9
|
+
//#region src/core/ansi/colors.ts
|
|
10
|
+
const ANSI8_COLOR_NAMES = Object.freeze([
|
|
11
|
+
"black",
|
|
12
|
+
"red",
|
|
13
|
+
"green",
|
|
14
|
+
"yellow",
|
|
15
|
+
"blue",
|
|
16
|
+
"magenta",
|
|
17
|
+
"cyan",
|
|
18
|
+
"white"
|
|
19
|
+
]);
|
|
20
|
+
const ANSI16_COLOR_NAMES = Object.freeze([
|
|
21
|
+
"black",
|
|
22
|
+
"red",
|
|
23
|
+
"green",
|
|
24
|
+
"yellow",
|
|
25
|
+
"blue",
|
|
26
|
+
"magenta",
|
|
27
|
+
"cyan",
|
|
28
|
+
"white",
|
|
29
|
+
"blackBright",
|
|
30
|
+
"redBright",
|
|
31
|
+
"greenBright",
|
|
32
|
+
"yellowBright",
|
|
33
|
+
"blueBright",
|
|
34
|
+
"magentaBright",
|
|
35
|
+
"cyanBright",
|
|
36
|
+
"whiteBright"
|
|
37
|
+
]);
|
|
38
|
+
const ESC$1 = "\x1B[";
|
|
39
|
+
const SGR_RESET = `${ESC$1}0m`;
|
|
40
|
+
const SGR_BOLD = `${ESC$1}1m`;
|
|
41
|
+
const SGR_DIM = `${ESC$1}2m`;
|
|
42
|
+
const SGR_ITALIC = `${ESC$1}3m`;
|
|
43
|
+
const SGR_UNDERLINE = `${ESC$1}4m`;
|
|
44
|
+
const SGR_INVERSE = `${ESC$1}7m`;
|
|
45
|
+
function toAnsi8ColorName(name) {
|
|
46
|
+
switch (name) {
|
|
47
|
+
case "black":
|
|
48
|
+
case "red":
|
|
49
|
+
case "green":
|
|
50
|
+
case "yellow":
|
|
51
|
+
case "blue":
|
|
52
|
+
case "magenta":
|
|
53
|
+
case "cyan":
|
|
54
|
+
case "white": return name;
|
|
55
|
+
case "blackBright": return "black";
|
|
56
|
+
case "redBright": return "red";
|
|
57
|
+
case "greenBright": return "green";
|
|
58
|
+
case "yellowBright": return "yellow";
|
|
59
|
+
case "blueBright": return "blue";
|
|
60
|
+
case "magentaBright": return "magenta";
|
|
61
|
+
case "cyanBright": return "cyan";
|
|
62
|
+
case "whiteBright": return "white";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const ANSI16_FG_CODE = Object.freeze({
|
|
66
|
+
black: 30,
|
|
67
|
+
red: 31,
|
|
68
|
+
green: 32,
|
|
69
|
+
yellow: 33,
|
|
70
|
+
blue: 34,
|
|
71
|
+
magenta: 35,
|
|
72
|
+
cyan: 36,
|
|
73
|
+
white: 37,
|
|
74
|
+
blackBright: 90,
|
|
75
|
+
redBright: 91,
|
|
76
|
+
greenBright: 92,
|
|
77
|
+
yellowBright: 93,
|
|
78
|
+
blueBright: 94,
|
|
79
|
+
magentaBright: 95,
|
|
80
|
+
cyanBright: 96,
|
|
81
|
+
whiteBright: 97
|
|
82
|
+
});
|
|
83
|
+
const ANSI16_BG_CODE = Object.freeze({
|
|
84
|
+
black: 40,
|
|
85
|
+
red: 41,
|
|
86
|
+
green: 42,
|
|
87
|
+
yellow: 43,
|
|
88
|
+
blue: 44,
|
|
89
|
+
magenta: 45,
|
|
90
|
+
cyan: 46,
|
|
91
|
+
white: 47,
|
|
92
|
+
blackBright: 100,
|
|
93
|
+
redBright: 101,
|
|
94
|
+
greenBright: 102,
|
|
95
|
+
yellowBright: 103,
|
|
96
|
+
blueBright: 104,
|
|
97
|
+
magentaBright: 105,
|
|
98
|
+
cyanBright: 106,
|
|
99
|
+
whiteBright: 107
|
|
100
|
+
});
|
|
101
|
+
function ansi8FgOpen(name) {
|
|
102
|
+
const base = toAnsi8ColorName(name);
|
|
103
|
+
const idx = ANSI8_COLOR_NAMES.indexOf(base);
|
|
104
|
+
return `${ESC$1}${30 + (idx < 0 ? 7 : idx)}m`;
|
|
105
|
+
}
|
|
106
|
+
function ansi8BgOpen(name) {
|
|
107
|
+
const base = toAnsi8ColorName(name);
|
|
108
|
+
const idx = ANSI8_COLOR_NAMES.indexOf(base);
|
|
109
|
+
return `${ESC$1}${40 + (idx < 0 ? 0 : idx)}m`;
|
|
110
|
+
}
|
|
111
|
+
function ansi16FgOpen(name) {
|
|
112
|
+
return `${ESC$1}${ANSI16_FG_CODE[name]}m`;
|
|
113
|
+
}
|
|
114
|
+
function ansi16BgOpen(name) {
|
|
115
|
+
return `${ESC$1}${ANSI16_BG_CODE[name]}m`;
|
|
116
|
+
}
|
|
117
|
+
function ansi256FgOpen(index) {
|
|
118
|
+
const n = clampAnsiIndex(index);
|
|
119
|
+
return `${ESC$1}38;5;${n}m`;
|
|
120
|
+
}
|
|
121
|
+
function ansi256BgOpen(index) {
|
|
122
|
+
const n = clampAnsiIndex(index);
|
|
123
|
+
return `${ESC$1}48;5;${n}m`;
|
|
124
|
+
}
|
|
125
|
+
function truecolorFgOpen(rgb) {
|
|
126
|
+
return `${ESC$1}38;2;${clampByte(rgb.r)};${clampByte(rgb.g)};${clampByte(rgb.b)}m`;
|
|
127
|
+
}
|
|
128
|
+
function truecolorBgOpen(rgb) {
|
|
129
|
+
return `${ESC$1}48;2;${clampByte(rgb.r)};${clampByte(rgb.g)};${clampByte(rgb.b)}m`;
|
|
130
|
+
}
|
|
131
|
+
function ansi256ToRgb(index) {
|
|
132
|
+
const n = clampAnsiIndex(index);
|
|
133
|
+
if (n < 16) {
|
|
134
|
+
const name = ANSI16_COLOR_NAMES[n] ?? "white";
|
|
135
|
+
return ansiColorRgb(name) ?? {
|
|
136
|
+
r: 255,
|
|
137
|
+
g: 255,
|
|
138
|
+
b: 255
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
if (n >= 232) {
|
|
142
|
+
const c = 8 + (n - 232) * 10;
|
|
143
|
+
return {
|
|
144
|
+
r: c,
|
|
145
|
+
g: c,
|
|
146
|
+
b: c
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const i = n - 16;
|
|
150
|
+
const rr = Math.floor(i / 36);
|
|
151
|
+
const gg = Math.floor(i % 36 / 6);
|
|
152
|
+
const bb = i % 6;
|
|
153
|
+
const levels = [
|
|
154
|
+
0,
|
|
155
|
+
95,
|
|
156
|
+
135,
|
|
157
|
+
175,
|
|
158
|
+
215,
|
|
159
|
+
255
|
|
160
|
+
];
|
|
161
|
+
return {
|
|
162
|
+
r: levels[rr],
|
|
163
|
+
g: levels[gg],
|
|
164
|
+
b: levels[bb]
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function rgbToAnsi256(rgb) {
|
|
168
|
+
const r = clampByte(rgb.r);
|
|
169
|
+
const g = clampByte(rgb.g);
|
|
170
|
+
const b = clampByte(rgb.b);
|
|
171
|
+
const levels = [
|
|
172
|
+
0,
|
|
173
|
+
95,
|
|
174
|
+
135,
|
|
175
|
+
175,
|
|
176
|
+
215,
|
|
177
|
+
255
|
|
178
|
+
];
|
|
179
|
+
const nearestLevelIndex = (v) => {
|
|
180
|
+
let best = 0;
|
|
181
|
+
let bestDist = Number.POSITIVE_INFINITY;
|
|
182
|
+
for (let i = 0; i < levels.length; i++) {
|
|
183
|
+
const d = (v - levels[i]) ** 2;
|
|
184
|
+
if (d < bestDist) {
|
|
185
|
+
bestDist = d;
|
|
186
|
+
best = i;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return best;
|
|
190
|
+
};
|
|
191
|
+
const ri = nearestLevelIndex(r);
|
|
192
|
+
const gi = nearestLevelIndex(g);
|
|
193
|
+
const bi = nearestLevelIndex(b);
|
|
194
|
+
const cubeIndex = 16 + 36 * ri + 6 * gi + bi;
|
|
195
|
+
const cube = ansi256ToRgb(cubeIndex);
|
|
196
|
+
const cubeDist = (r - cube.r) ** 2 + (g - cube.g) ** 2 + (b - cube.b) ** 2;
|
|
197
|
+
const gray = Math.round((r + g + b) / 3);
|
|
198
|
+
const grayIndex = gray < 8 ? 16 : gray > 248 ? 231 : 232 + Math.round((gray - 8) / 10);
|
|
199
|
+
const grayRgb = ansi256ToRgb(grayIndex);
|
|
200
|
+
const grayDist = (r - grayRgb.r) ** 2 + (g - grayRgb.g) ** 2 + (b - grayRgb.b) ** 2;
|
|
201
|
+
return grayDist < cubeDist ? grayIndex : cubeIndex;
|
|
202
|
+
}
|
|
203
|
+
function ansi8Palette() {
|
|
204
|
+
return ANSI8_COLOR_NAMES.map((name, index) => {
|
|
205
|
+
const rgb = ansiColorRgb(name) ?? {
|
|
206
|
+
r: 255,
|
|
207
|
+
g: 255,
|
|
208
|
+
b: 255
|
|
209
|
+
};
|
|
210
|
+
return Object.freeze({
|
|
211
|
+
level: 8,
|
|
212
|
+
index,
|
|
213
|
+
name,
|
|
214
|
+
rgb,
|
|
215
|
+
fgOpen: ansi8FgOpen(name),
|
|
216
|
+
bgOpen: ansi8BgOpen(name)
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
function ansi16Palette() {
|
|
221
|
+
return ANSI16_COLOR_NAMES.map((name, index) => {
|
|
222
|
+
const rgb = ansiColorRgb(name) ?? {
|
|
223
|
+
r: 255,
|
|
224
|
+
g: 255,
|
|
225
|
+
b: 255
|
|
226
|
+
};
|
|
227
|
+
return Object.freeze({
|
|
228
|
+
level: 16,
|
|
229
|
+
index,
|
|
230
|
+
name,
|
|
231
|
+
rgb,
|
|
232
|
+
fgOpen: ansi16FgOpen(name),
|
|
233
|
+
bgOpen: ansi16BgOpen(name)
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
function ansi256Palette() {
|
|
238
|
+
const out = [];
|
|
239
|
+
for (let index = 0; index < 256; index++) out.push(Object.freeze({
|
|
240
|
+
level: 256,
|
|
241
|
+
index,
|
|
242
|
+
rgb: ansi256ToRgb(index),
|
|
243
|
+
fgOpen: ansi256FgOpen(index),
|
|
244
|
+
bgOpen: ansi256BgOpen(index)
|
|
245
|
+
}));
|
|
246
|
+
return Object.freeze(out);
|
|
247
|
+
}
|
|
248
|
+
function clampAnsiIndex(n) {
|
|
249
|
+
if (!Number.isFinite(n)) return 0;
|
|
250
|
+
return Math.max(0, Math.min(255, Math.trunc(n)));
|
|
251
|
+
}
|
|
252
|
+
function clampByte(n) {
|
|
253
|
+
if (!Number.isFinite(n)) return 0;
|
|
254
|
+
return Math.max(0, Math.min(255, Math.round(n)));
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region src/ansi-styles.ts
|
|
259
|
+
const ESC = "\x1B[";
|
|
260
|
+
function createStyle(open, close) {
|
|
261
|
+
return Object.freeze({
|
|
262
|
+
open,
|
|
263
|
+
close
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
const ansiStyles = Object.freeze({
|
|
267
|
+
reset: createStyle(SGR_RESET, SGR_RESET),
|
|
268
|
+
bold: createStyle(SGR_BOLD, `${ESC}22m`),
|
|
269
|
+
dim: createStyle(SGR_DIM, `${ESC}22m`),
|
|
270
|
+
italic: createStyle(SGR_ITALIC, `${ESC}23m`),
|
|
271
|
+
underline: createStyle(SGR_UNDERLINE, `${ESC}24m`),
|
|
272
|
+
inverse: createStyle(SGR_INVERSE, `${ESC}27m`),
|
|
273
|
+
black: createStyle(ansi16FgOpen("black"), `${ESC}39m`),
|
|
274
|
+
red: createStyle(ansi16FgOpen("red"), `${ESC}39m`),
|
|
275
|
+
green: createStyle(ansi16FgOpen("green"), `${ESC}39m`),
|
|
276
|
+
yellow: createStyle(ansi16FgOpen("yellow"), `${ESC}39m`),
|
|
277
|
+
blue: createStyle(ansi16FgOpen("blue"), `${ESC}39m`),
|
|
278
|
+
magenta: createStyle(ansi16FgOpen("magenta"), `${ESC}39m`),
|
|
279
|
+
cyan: createStyle(ansi16FgOpen("cyan"), `${ESC}39m`),
|
|
280
|
+
white: createStyle(ansi16FgOpen("white"), `${ESC}39m`),
|
|
281
|
+
blackBright: createStyle(ansi16FgOpen("blackBright"), `${ESC}39m`),
|
|
282
|
+
redBright: createStyle(ansi16FgOpen("redBright"), `${ESC}39m`),
|
|
283
|
+
greenBright: createStyle(ansi16FgOpen("greenBright"), `${ESC}39m`),
|
|
284
|
+
yellowBright: createStyle(ansi16FgOpen("yellowBright"), `${ESC}39m`),
|
|
285
|
+
blueBright: createStyle(ansi16FgOpen("blueBright"), `${ESC}39m`),
|
|
286
|
+
magentaBright: createStyle(ansi16FgOpen("magentaBright"), `${ESC}39m`),
|
|
287
|
+
cyanBright: createStyle(ansi16FgOpen("cyanBright"), `${ESC}39m`),
|
|
288
|
+
whiteBright: createStyle(ansi16FgOpen("whiteBright"), `${ESC}39m`),
|
|
289
|
+
bgBlack: createStyle(ansi16BgOpen("black"), `${ESC}49m`),
|
|
290
|
+
bgRed: createStyle(ansi16BgOpen("red"), `${ESC}49m`),
|
|
291
|
+
bgGreen: createStyle(ansi16BgOpen("green"), `${ESC}49m`),
|
|
292
|
+
bgYellow: createStyle(ansi16BgOpen("yellow"), `${ESC}49m`),
|
|
293
|
+
bgBlue: createStyle(ansi16BgOpen("blue"), `${ESC}49m`),
|
|
294
|
+
bgMagenta: createStyle(ansi16BgOpen("magenta"), `${ESC}49m`),
|
|
295
|
+
bgCyan: createStyle(ansi16BgOpen("cyan"), `${ESC}49m`),
|
|
296
|
+
bgWhite: createStyle(ansi16BgOpen("white"), `${ESC}49m`),
|
|
297
|
+
bgBlackBright: createStyle(ansi16BgOpen("blackBright"), `${ESC}49m`),
|
|
298
|
+
bgRedBright: createStyle(ansi16BgOpen("redBright"), `${ESC}49m`),
|
|
299
|
+
bgGreenBright: createStyle(ansi16BgOpen("greenBright"), `${ESC}49m`),
|
|
300
|
+
bgYellowBright: createStyle(ansi16BgOpen("yellowBright"), `${ESC}49m`),
|
|
301
|
+
bgBlueBright: createStyle(ansi16BgOpen("blueBright"), `${ESC}49m`),
|
|
302
|
+
bgMagentaBright: createStyle(ansi16BgOpen("magentaBright"), `${ESC}49m`),
|
|
303
|
+
bgCyanBright: createStyle(ansi16BgOpen("cyanBright"), `${ESC}49m`),
|
|
304
|
+
bgWhiteBright: createStyle(ansi16BgOpen("whiteBright"), `${ESC}49m`),
|
|
305
|
+
color: Object.freeze({
|
|
306
|
+
ansi256: (idx) => ansi256FgOpen(idx),
|
|
307
|
+
ansi16m: (r, g, b) => truecolorFgOpen({
|
|
308
|
+
r,
|
|
309
|
+
g,
|
|
310
|
+
b
|
|
311
|
+
})
|
|
312
|
+
}),
|
|
313
|
+
bgColor: Object.freeze({
|
|
314
|
+
ansi256: (idx) => ansi256BgOpen(idx),
|
|
315
|
+
ansi16m: (r, g, b) => truecolorBgOpen({
|
|
316
|
+
r,
|
|
317
|
+
g,
|
|
318
|
+
b
|
|
319
|
+
})
|
|
320
|
+
})
|
|
321
|
+
});
|
|
322
|
+
/**
|
|
323
|
+
* Cached palettes for convenience.
|
|
324
|
+
* Note: ANSI 0..15 are terminal-theme-dependent in many terminals; treat `rgb` as an approximation.
|
|
325
|
+
*/
|
|
326
|
+
const ANSI8_COLORS = ansi8Palette();
|
|
327
|
+
const ANSI16_COLORS = ansi16Palette();
|
|
328
|
+
const ANSI256_COLORS = ansi256Palette();
|
|
329
|
+
function ansiColors(level) {
|
|
330
|
+
if (level === 8) return ANSI8_COLORS;
|
|
331
|
+
if (level === 16) return ANSI16_COLORS;
|
|
332
|
+
return ANSI256_COLORS;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
//#endregion
|
|
336
|
+
//#region src/core/ansi/capability.ts
|
|
337
|
+
function parseColorMode(raw) {
|
|
338
|
+
const v = String(raw ?? "").trim().toLowerCase();
|
|
339
|
+
if (!v) return null;
|
|
340
|
+
if (v === "truecolor" || v === "24bit" || v === "rgb") return "truecolor";
|
|
341
|
+
if (v === "ansi256" || v === "256" || v === "xterm256" || v === "xterm-256color") return "ansi256";
|
|
342
|
+
if (v === "ansi16" || v === "16") return "ansi16";
|
|
343
|
+
if (v === "ansi8" || v === "8") return "ansi8";
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
function levelForMode(mode) {
|
|
347
|
+
if (mode === "ansi8") return 8;
|
|
348
|
+
if (mode === "ansi16") return 16;
|
|
349
|
+
return 256;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Detect terminal output color capability.
|
|
353
|
+
*
|
|
354
|
+
* - `mode` is the best-effort actual output mode.
|
|
355
|
+
* - `level` is the CLI theme tier (256/16/8). `truecolor` folds into `256`.
|
|
356
|
+
* - Pass `platform` (e.g. `process.platform`) to improve Windows detection.
|
|
357
|
+
*
|
|
358
|
+
* Env overrides:
|
|
359
|
+
* - `VUE_TUI_COLOR_MODE` / legacy `DIMCODE_COLOR_MODE`
|
|
360
|
+
*/
|
|
361
|
+
function detectTerminalColorCapability(opts) {
|
|
362
|
+
const env = opts?.env ?? {};
|
|
363
|
+
const isTTY = opts?.isTTY ?? false;
|
|
364
|
+
const platform = String(opts?.platform ?? "").trim().toLowerCase();
|
|
365
|
+
const isWindows = platform === "win32" || String(env.OS ?? "").trim().toLowerCase() === "windows_nt";
|
|
366
|
+
const forced = parseColorMode(firstNonEmptyEnv(env, "VUE_TUI_COLOR_MODE", "DIMCODE_COLOR_MODE"));
|
|
367
|
+
if (forced) return {
|
|
368
|
+
mode: forced,
|
|
369
|
+
level: levelForMode(forced)
|
|
370
|
+
};
|
|
371
|
+
if (!isTTY) return {
|
|
372
|
+
mode: "truecolor",
|
|
373
|
+
level: 256
|
|
374
|
+
};
|
|
375
|
+
const termProgram = String(env.TERM_PROGRAM ?? "").toLowerCase();
|
|
376
|
+
const isAppleTerminal = termProgram.includes("apple_terminal");
|
|
377
|
+
const colorterm = String(env.COLORTERM ?? "").toLowerCase();
|
|
378
|
+
if (!isAppleTerminal && (colorterm.includes("truecolor") || colorterm.includes("24bit"))) return {
|
|
379
|
+
mode: "truecolor",
|
|
380
|
+
level: 256
|
|
381
|
+
};
|
|
382
|
+
if (termProgram.includes("vscode")) return {
|
|
383
|
+
mode: "truecolor",
|
|
384
|
+
level: 256
|
|
385
|
+
};
|
|
386
|
+
if (termProgram.includes("wezterm") || termProgram.includes("alacritty") || termProgram.includes("ghostty") || termProgram.includes("kitty") || termProgram.includes("iterm") || termProgram.includes("windows terminal") || termProgram.includes("windowsterminal") || termProgram.includes("tabby") || termProgram.includes("hyper") || termProgram.includes("rio") || termProgram.includes("contour")) return {
|
|
387
|
+
mode: "truecolor",
|
|
388
|
+
level: 256
|
|
389
|
+
};
|
|
390
|
+
const term = String(env.TERM ?? "").toLowerCase();
|
|
391
|
+
if (isWindows) {
|
|
392
|
+
const hasWindowsTerminal = "WT_SESSION" in env || "WT_PROFILE_ID" in env || "WT_ID" in env;
|
|
393
|
+
const hasWezterm = "WEZTERM_EXECUTABLE" in env || "WEZTERM_PANE" in env;
|
|
394
|
+
const hasAlacritty = "ALACRITTY_LOG" in env || "ALACRITTY_WINDOW_ID" in env;
|
|
395
|
+
const hasTabby = "TABBY_CONFIG_DIRECTORY" in env;
|
|
396
|
+
if (hasWindowsTerminal || hasWezterm || hasAlacritty || hasTabby) return {
|
|
397
|
+
mode: "truecolor",
|
|
398
|
+
level: 256
|
|
399
|
+
};
|
|
400
|
+
if (term.includes("xterm") && term.includes("256color")) return {
|
|
401
|
+
mode: "truecolor",
|
|
402
|
+
level: 256
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
if (term.includes("256color")) return {
|
|
406
|
+
mode: "ansi256",
|
|
407
|
+
level: 256
|
|
408
|
+
};
|
|
409
|
+
if (term.includes("color")) return {
|
|
410
|
+
mode: "ansi16",
|
|
411
|
+
level: 16
|
|
412
|
+
};
|
|
413
|
+
if (term.includes("dumb")) return {
|
|
414
|
+
mode: "ansi8",
|
|
415
|
+
level: 8
|
|
416
|
+
};
|
|
417
|
+
return {
|
|
418
|
+
mode: "ansi16",
|
|
419
|
+
level: 16
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
//#endregion
|
|
424
|
+
export { ANSI16_COLORS, ANSI256_COLORS, ANSI8_COLORS, SGR_RESET, TERMINAL_RENDER_PLANES, ansiColors, ansiStyles, charCellWidth, createTerminal, detectTerminalColorCapability, isSafeRelativeHref, normalizeNewlines, parseAnsiSgr, parsePathQuery, resolveUserPath, rgbToAnsi256, sanitizeDomHref, sanitizeTerminalHref, suggestParentHint, suggestPaths, truecolorBgOpen, truecolorFgOpen };
|