@simon_he/vue-tui 0.0.7 → 1.0.0-rc.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.
Files changed (207) hide show
  1. package/README.md +222 -444
  2. package/dist/TSelect-BmSkar0D.js +8697 -0
  3. package/dist/ansi-palette-Bv5Vqr4k.js +1499 -0
  4. package/dist/ansi-styles.d.ts +200 -0
  5. package/dist/cli/headless-renderer.d.ts +29 -0
  6. package/dist/cli/input.d.ts +49 -0
  7. package/dist/cli/node-file-writers.d.ts +12 -0
  8. package/dist/cli/node-module.d.ts +2 -0
  9. package/dist/cli/parse-kitty.d.ts +2 -0
  10. package/dist/cli/parse-mouse.d.ts +2 -0
  11. package/dist/cli/parse-utils.d.ts +14 -0
  12. package/dist/cli/parse-xterm.d.ts +2 -0
  13. package/dist/cli/path-provider-types.d.ts +1 -0
  14. package/dist/cli/path-provider.d.ts +4 -0
  15. package/dist/cli/path-suggest-core.d.ts +1 -0
  16. package/dist/cli/path-suggest.d.ts +15 -0
  17. package/dist/cli/recording.d.ts +4 -0
  18. package/dist/cli/stdin-buffer.d.ts +33 -0
  19. package/dist/cli.cjs +10664 -0
  20. package/dist/cli.d.cts +22 -0
  21. package/dist/cli.d.ts +22 -0
  22. package/dist/cli.js +9521 -0
  23. package/dist/core/ansi/capability.d.ts +20 -0
  24. package/dist/core/ansi/colors.d.ts +41 -0
  25. package/dist/core/ansi/sgr.d.ts +7 -0
  26. package/dist/core/ansi/theme.d.ts +6 -0
  27. package/dist/core/ansi-palette.d.ts +14 -0
  28. package/dist/core/buffer/buffer.d.ts +54 -0
  29. package/dist/core/buffer/width.d.ts +4 -0
  30. package/dist/core/debug-logger.d.ts +18 -0
  31. package/dist/core/hyperlink.d.ts +9 -0
  32. package/dist/core/index.d.ts +4 -0
  33. package/dist/core/path-provider-types.d.ts +24 -0
  34. package/dist/core/path-suggest.d.ts +35 -0
  35. package/dist/core/render-plane.d.ts +3 -0
  36. package/dist/core/terminal/create-terminal.d.ts +7 -0
  37. package/dist/core/terminal/emitter.d.ts +7 -0
  38. package/dist/core/types.d.ts +107 -0
  39. package/dist/core.cjs +3072 -0
  40. package/dist/core.d.cts +14 -0
  41. package/dist/core.d.ts +14 -0
  42. package/dist/core.js +422 -0
  43. package/dist/create-terminal-app.d.ts +34 -0
  44. package/dist/dom-renderer-CDVQIcIL.js +1172 -0
  45. package/dist/events/index.d.ts +6 -0
  46. package/dist/events/manager/cli-event-manager.d.ts +22 -0
  47. package/dist/events/manager/event-manager.d.ts +30 -0
  48. package/dist/events/manager/selection-suppression.d.ts +3 -0
  49. package/dist/events/manager/types.d.ts +108 -0
  50. package/dist/events/recording.d.ts +44 -0
  51. package/dist/experimental.cjs +9380 -0
  52. package/dist/experimental.d.cts +39 -0
  53. package/dist/experimental.d.ts +39 -0
  54. package/dist/experimental.js +7624 -0
  55. package/dist/frame-perf-C-w8mjJL.js +98 -0
  56. package/dist/hyperlink-B5PD7a3Q.js +331 -0
  57. package/dist/index.cjs +12037 -16507
  58. package/dist/index.d.cts +13 -0
  59. package/dist/index.d.ts +13 -1353
  60. package/dist/index.js +13 -18738
  61. package/dist/markdown.cjs +21929 -0
  62. package/dist/markdown.d.cts +10 -0
  63. package/dist/markdown.d.ts +10 -0
  64. package/dist/markdown.js +1649 -0
  65. package/dist/observability/cli-latency-node.d.ts +3 -0
  66. package/dist/observability/cli-latency-types.d.ts +41 -0
  67. package/dist/observability/cli-latency.d.ts +3 -0
  68. package/dist/observability/frame-perf-store.d.ts +13 -0
  69. package/dist/observability/frame-perf.d.ts +40 -0
  70. package/dist/observability/trace.d.ts +40 -0
  71. package/dist/observability/tui-profiler.d.ts +33 -0
  72. package/dist/observability.cjs +99 -0
  73. package/dist/observability.d.cts +6 -0
  74. package/dist/observability.d.ts +6 -0
  75. package/dist/observability.js +3 -0
  76. package/dist/path-DDiSCXrQ.js +99 -0
  77. package/dist/path-suggest-0Q2BDsuj.js +274 -0
  78. package/dist/path-suggest-Dk9TRLh5.js +3 -0
  79. package/dist/{path-suggest-CZQYJIIg.js → path-suggest-bvR9SY6Q.js} +86 -18
  80. package/dist/renderer/capabilities.d.ts +13 -0
  81. package/dist/renderer/cli/index.d.ts +2 -0
  82. package/dist/renderer/cli/stdout-metrics.d.ts +18 -0
  83. package/dist/renderer/cli/stdout-renderer.d.ts +48 -0
  84. package/dist/renderer/dom/dom-renderer.d.ts +157 -0
  85. package/dist/renderer/dom/index.d.ts +2 -0
  86. package/dist/renderer/index.d.ts +2 -0
  87. package/dist/renderer-dom.cjs +1511 -0
  88. package/dist/renderer-dom.d.cts +4 -0
  89. package/dist/renderer-dom.d.ts +4 -0
  90. package/dist/renderer-dom.js +6 -0
  91. package/dist/runtime/index.d.ts +36 -0
  92. package/dist/runtime/osc52.d.ts +9 -0
  93. package/dist/runtime-DtrcQidD.js +1197 -0
  94. package/dist/runtime.cjs +1697 -0
  95. package/dist/runtime.d.cts +9 -0
  96. package/dist/runtime.d.ts +9 -0
  97. package/dist/runtime.js +4 -0
  98. package/dist/selection/terminal-selection.d.ts +122 -0
  99. package/dist/sgr-DMK2AvuT.js +304 -0
  100. package/dist/style-cache-i0ZABZRq.js +178 -0
  101. package/dist/terminal-selection-BCOh9jsL.js +329 -0
  102. package/dist/utils/env.d.ts +3 -0
  103. package/dist/utils/newlines.d.ts +1 -0
  104. package/dist/utils/path.d.ts +7 -0
  105. package/dist/utils/url-safety.d.ts +2 -0
  106. package/dist/vue/components/TAnchor.d.ts +108 -0
  107. package/dist/vue/components/TBox.d.ts +144 -0
  108. package/dist/vue/components/TDebugOverlay.d.ts +43 -0
  109. package/dist/vue/components/TDialog.d.ts +256 -0
  110. package/dist/vue/components/TFlow.d.ts +85 -0
  111. package/dist/vue/components/TInput.d.ts +554 -0
  112. package/dist/vue/components/TInputBox.d.ts +158 -0
  113. package/dist/vue/components/TJsonEditor.d.ts +165 -0
  114. package/dist/vue/components/TList.d.ts +119 -0
  115. package/dist/vue/components/TLogLinksPanel.d.ts +238 -0
  116. package/dist/vue/components/TLogMinimap.d.ts +263 -0
  117. package/dist/vue/components/TLogScrollbar.d.ts +236 -0
  118. package/dist/vue/components/TLogSearchBar.d.ts +267 -0
  119. package/dist/vue/components/TLogSearchPager.d.ts +162 -0
  120. package/dist/vue/components/TLogSearchResults.d.ts +200 -0
  121. package/dist/vue/components/TLogView.d.ts +502 -0
  122. package/dist/vue/components/TLogVirtualLinksPanel.d.ts +141 -0
  123. package/dist/vue/components/TLogVirtualSearchResults.d.ts +146 -0
  124. package/dist/vue/components/TMarkdownText.d.ts +134 -0
  125. package/dist/vue/components/TMultilineModal.d.ts +62 -0
  126. package/dist/vue/components/TPathPicker.d.ts +213 -0
  127. package/dist/vue/components/TRenderLayer.d.ts +16 -0
  128. package/dist/vue/components/TRenderPlane.d.ts +17 -0
  129. package/dist/vue/components/TSelect.d.ts +215 -0
  130. package/dist/vue/components/TText.d.ts +116 -0
  131. package/dist/vue/components/TTransition.d.ts +83 -0
  132. package/dist/vue/components/TView.d.ts +127 -0
  133. package/dist/vue/components/TVirtualList.d.ts +182 -0
  134. package/dist/vue/components/TVirtualMarkdown.d.ts +168 -0
  135. package/dist/vue/components/TerminalProvider.d.ts +195 -0
  136. package/dist/vue/components/input/host.d.ts +17 -0
  137. package/dist/vue/components/input/plugins/hostPlugin.d.ts +7 -0
  138. package/dist/vue/components/input/plugins/hostPlugin.node.d.ts +15 -0
  139. package/dist/vue/components/input/plugins/mentionUtils.d.ts +17 -0
  140. package/dist/vue/components/input/plugins/nodeMentionPathProvider.d.ts +2 -0
  141. package/dist/vue/components/input/plugins/promptMentionPlugin.d.ts +8 -0
  142. package/dist/vue/components/input/plugins/promptMentionState.d.ts +98 -0
  143. package/dist/vue/components/input/plugins/restrictText.d.ts +27 -0
  144. package/dist/vue/components/input/plugins/types.d.ts +90 -0
  145. package/dist/vue/components/input/utils/inlineText.d.ts +57 -0
  146. package/dist/vue/components/input/utils/inlineTextTokens.d.ts +34 -0
  147. package/dist/vue/components/input/utils/primitives.d.ts +3 -0
  148. package/dist/vue/components/input/utils/wordNavigation.d.ts +6 -0
  149. package/dist/vue/components/list/list-geometry.d.ts +16 -0
  150. package/dist/vue/components/list/list-paint.d.ts +1 -0
  151. package/dist/vue/components/list/scroll-state.d.ts +25 -0
  152. package/dist/vue/components/list/selection-state.d.ts +6 -0
  153. package/dist/vue/components/terminal-provider/copy-toast.d.ts +6 -0
  154. package/dist/vue/components/terminal-provider/portals.d.ts +17 -0
  155. package/dist/vue/components/terminal-provider/scheduler.d.ts +29 -0
  156. package/dist/vue/components/terminal-provider/selection-config.d.ts +15 -0
  157. package/dist/vue/components/terminal-provider/utils.d.ts +5 -0
  158. package/dist/vue/composables/use-layout.d.ts +2 -0
  159. package/dist/vue/composables/use-render-node.d.ts +19 -0
  160. package/dist/vue/composables/use-render-stack.d.ts +3 -0
  161. package/dist/vue/composables/use-runtime.d.ts +5 -0
  162. package/dist/vue/composables/use-terminal-node.d.ts +14 -0
  163. package/dist/vue/composables/use-terminal.d.ts +2 -0
  164. package/dist/vue/composables/use-visibility.d.ts +12 -0
  165. package/dist/vue/context.d.ts +153 -0
  166. package/dist/vue/index.d.ts +39 -0
  167. package/dist/vue/injection-key.d.ts +2 -0
  168. package/dist/vue/log/append-only-log-store.d.ts +2 -0
  169. package/dist/vue/log/tlog-keymap.d.ts +28 -0
  170. package/dist/vue/log/tlog-plugins.d.ts +144 -0
  171. package/dist/vue/log/tlog-session.d.ts +81 -0
  172. package/dist/vue/log/tlog-theme.d.ts +68 -0
  173. package/dist/vue/log/types.d.ts +43 -0
  174. package/dist/vue/log/use-tlog-link-controller.d.ts +31 -0
  175. package/dist/vue/log/use-tlog-retained-index.d.ts +26 -0
  176. package/dist/vue/log/use-tlog-search-controller.d.ts +51 -0
  177. package/dist/vue/log/use-tlog-search-results-page.d.ts +31 -0
  178. package/dist/vue/log/use-tlog-virtual-search-results.d.ts +22 -0
  179. package/dist/vue/markdown/ast.d.ts +3 -0
  180. package/dist/vue/markdown/block-source.d.ts +22 -0
  181. package/dist/vue/markdown/document.d.ts +18 -0
  182. package/dist/vue/markdown/layout.d.ts +16 -0
  183. package/dist/vue/markdown/parser.d.ts +11 -0
  184. package/dist/vue/markdown/render.d.ts +10 -0
  185. package/dist/vue/markdown/theme.d.ts +186 -0
  186. package/dist/vue/markdown/types.d.ts +47 -0
  187. package/dist/vue/render/context.d.ts +3 -0
  188. package/dist/vue/render/render-manager.d.ts +94 -0
  189. package/dist/vue/router/RouterView.d.ts +25 -0
  190. package/dist/vue/router/composables.d.ts +4 -0
  191. package/dist/vue/router/context.d.ts +4 -0
  192. package/dist/vue/router/router.d.ts +7 -0
  193. package/dist/vue/router/types.d.ts +29 -0
  194. package/dist/vue/scheduler/frame-mailbox.d.ts +55 -0
  195. package/dist/vue/scheduler/frame-scheduler.d.ts +51 -0
  196. package/dist/vue/utils/frame-task.d.ts +6 -0
  197. package/dist/vue/utils/rect.d.ts +4 -0
  198. package/dist/vue/utils/style-cache.d.ts +3 -0
  199. package/dist/vue/utils/text.d.ts +26 -0
  200. package/dist/vue/utils/wheel-scroll.d.ts +18 -0
  201. package/dist/vue.cjs +18882 -0
  202. package/dist/vue.d.cts +3 -0
  203. package/dist/vue.d.ts +3 -0
  204. package/dist/vue.js +3066 -0
  205. package/dist/wheel-scroll-B-WlFuNB.js +819 -0
  206. package/package.json +226 -58
  207. package/dist/path-suggest-DIMby3r0.js +0 -3
@@ -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,422 @@
1
+ import { TERMINAL_RENDER_PLANES, ansiColorRgb, createTerminal } from "./ansi-palette-Bv5Vqr4k.js";
2
+ import { parseAnsiSgr } from "./sgr-DMK2AvuT.js";
3
+ import { charCellWidth, isSafeRelativeHref, sanitizeDomHref, sanitizeTerminalHref } from "./hyperlink-B5PD7a3Q.js";
4
+ import { firstNonEmptyEnv, normalizeNewlines } from "./path-DDiSCXrQ.js";
5
+ import { parsePathQuery, resolveUserPath, suggestParentHint, suggestPaths } from "./path-suggest-0Q2BDsuj.js";
6
+
7
+ //#region src/core/ansi/colors.ts
8
+ const ANSI8_COLOR_NAMES = Object.freeze([
9
+ "black",
10
+ "red",
11
+ "green",
12
+ "yellow",
13
+ "blue",
14
+ "magenta",
15
+ "cyan",
16
+ "white"
17
+ ]);
18
+ const ANSI16_COLOR_NAMES = Object.freeze([
19
+ "black",
20
+ "red",
21
+ "green",
22
+ "yellow",
23
+ "blue",
24
+ "magenta",
25
+ "cyan",
26
+ "white",
27
+ "blackBright",
28
+ "redBright",
29
+ "greenBright",
30
+ "yellowBright",
31
+ "blueBright",
32
+ "magentaBright",
33
+ "cyanBright",
34
+ "whiteBright"
35
+ ]);
36
+ const ESC$1 = "\x1B[";
37
+ const SGR_RESET = `${ESC$1}0m`;
38
+ const SGR_BOLD = `${ESC$1}1m`;
39
+ const SGR_DIM = `${ESC$1}2m`;
40
+ const SGR_ITALIC = `${ESC$1}3m`;
41
+ const SGR_UNDERLINE = `${ESC$1}4m`;
42
+ const SGR_INVERSE = `${ESC$1}7m`;
43
+ function toAnsi8ColorName(name) {
44
+ switch (name) {
45
+ case "black":
46
+ case "red":
47
+ case "green":
48
+ case "yellow":
49
+ case "blue":
50
+ case "magenta":
51
+ case "cyan":
52
+ case "white": return name;
53
+ case "blackBright": return "black";
54
+ case "redBright": return "red";
55
+ case "greenBright": return "green";
56
+ case "yellowBright": return "yellow";
57
+ case "blueBright": return "blue";
58
+ case "magentaBright": return "magenta";
59
+ case "cyanBright": return "cyan";
60
+ case "whiteBright": return "white";
61
+ }
62
+ }
63
+ const ANSI16_FG_CODE = Object.freeze({
64
+ black: 30,
65
+ red: 31,
66
+ green: 32,
67
+ yellow: 33,
68
+ blue: 34,
69
+ magenta: 35,
70
+ cyan: 36,
71
+ white: 37,
72
+ blackBright: 90,
73
+ redBright: 91,
74
+ greenBright: 92,
75
+ yellowBright: 93,
76
+ blueBright: 94,
77
+ magentaBright: 95,
78
+ cyanBright: 96,
79
+ whiteBright: 97
80
+ });
81
+ const ANSI16_BG_CODE = Object.freeze({
82
+ black: 40,
83
+ red: 41,
84
+ green: 42,
85
+ yellow: 43,
86
+ blue: 44,
87
+ magenta: 45,
88
+ cyan: 46,
89
+ white: 47,
90
+ blackBright: 100,
91
+ redBright: 101,
92
+ greenBright: 102,
93
+ yellowBright: 103,
94
+ blueBright: 104,
95
+ magentaBright: 105,
96
+ cyanBright: 106,
97
+ whiteBright: 107
98
+ });
99
+ function ansi8FgOpen(name) {
100
+ const base = toAnsi8ColorName(name);
101
+ const idx = ANSI8_COLOR_NAMES.indexOf(base);
102
+ return `${ESC$1}${30 + (idx < 0 ? 7 : idx)}m`;
103
+ }
104
+ function ansi8BgOpen(name) {
105
+ const base = toAnsi8ColorName(name);
106
+ const idx = ANSI8_COLOR_NAMES.indexOf(base);
107
+ return `${ESC$1}${40 + (idx < 0 ? 0 : idx)}m`;
108
+ }
109
+ function ansi16FgOpen(name) {
110
+ return `${ESC$1}${ANSI16_FG_CODE[name]}m`;
111
+ }
112
+ function ansi16BgOpen(name) {
113
+ return `${ESC$1}${ANSI16_BG_CODE[name]}m`;
114
+ }
115
+ function ansi256FgOpen(index) {
116
+ const n = clampAnsiIndex(index);
117
+ return `${ESC$1}38;5;${n}m`;
118
+ }
119
+ function ansi256BgOpen(index) {
120
+ const n = clampAnsiIndex(index);
121
+ return `${ESC$1}48;5;${n}m`;
122
+ }
123
+ function truecolorFgOpen(rgb) {
124
+ return `${ESC$1}38;2;${clampByte(rgb.r)};${clampByte(rgb.g)};${clampByte(rgb.b)}m`;
125
+ }
126
+ function truecolorBgOpen(rgb) {
127
+ return `${ESC$1}48;2;${clampByte(rgb.r)};${clampByte(rgb.g)};${clampByte(rgb.b)}m`;
128
+ }
129
+ function ansi256ToRgb(index) {
130
+ const n = clampAnsiIndex(index);
131
+ if (n < 16) {
132
+ const name = ANSI16_COLOR_NAMES[n] ?? "white";
133
+ return ansiColorRgb(name) ?? {
134
+ r: 255,
135
+ g: 255,
136
+ b: 255
137
+ };
138
+ }
139
+ if (n >= 232) {
140
+ const c = 8 + (n - 232) * 10;
141
+ return {
142
+ r: c,
143
+ g: c,
144
+ b: c
145
+ };
146
+ }
147
+ const i = n - 16;
148
+ const rr = Math.floor(i / 36);
149
+ const gg = Math.floor(i % 36 / 6);
150
+ const bb = i % 6;
151
+ const levels = [
152
+ 0,
153
+ 95,
154
+ 135,
155
+ 175,
156
+ 215,
157
+ 255
158
+ ];
159
+ return {
160
+ r: levels[rr],
161
+ g: levels[gg],
162
+ b: levels[bb]
163
+ };
164
+ }
165
+ function rgbToAnsi256(rgb) {
166
+ const r = clampByte(rgb.r);
167
+ const g = clampByte(rgb.g);
168
+ const b = clampByte(rgb.b);
169
+ const levels = [
170
+ 0,
171
+ 95,
172
+ 135,
173
+ 175,
174
+ 215,
175
+ 255
176
+ ];
177
+ const nearestLevelIndex = (v) => {
178
+ let best = 0;
179
+ let bestDist = Number.POSITIVE_INFINITY;
180
+ for (let i = 0; i < levels.length; i++) {
181
+ const d = (v - levels[i]) ** 2;
182
+ if (d < bestDist) {
183
+ bestDist = d;
184
+ best = i;
185
+ }
186
+ }
187
+ return best;
188
+ };
189
+ const ri = nearestLevelIndex(r);
190
+ const gi = nearestLevelIndex(g);
191
+ const bi = nearestLevelIndex(b);
192
+ const cubeIndex = 16 + 36 * ri + 6 * gi + bi;
193
+ const cube = ansi256ToRgb(cubeIndex);
194
+ const cubeDist = (r - cube.r) ** 2 + (g - cube.g) ** 2 + (b - cube.b) ** 2;
195
+ const gray = Math.round((r + g + b) / 3);
196
+ const grayIndex = gray < 8 ? 16 : gray > 248 ? 231 : 232 + Math.round((gray - 8) / 10);
197
+ const grayRgb = ansi256ToRgb(grayIndex);
198
+ const grayDist = (r - grayRgb.r) ** 2 + (g - grayRgb.g) ** 2 + (b - grayRgb.b) ** 2;
199
+ return grayDist < cubeDist ? grayIndex : cubeIndex;
200
+ }
201
+ function ansi8Palette() {
202
+ return ANSI8_COLOR_NAMES.map((name, index) => {
203
+ const rgb = ansiColorRgb(name) ?? {
204
+ r: 255,
205
+ g: 255,
206
+ b: 255
207
+ };
208
+ return Object.freeze({
209
+ level: 8,
210
+ index,
211
+ name,
212
+ rgb,
213
+ fgOpen: ansi8FgOpen(name),
214
+ bgOpen: ansi8BgOpen(name)
215
+ });
216
+ });
217
+ }
218
+ function ansi16Palette() {
219
+ return ANSI16_COLOR_NAMES.map((name, index) => {
220
+ const rgb = ansiColorRgb(name) ?? {
221
+ r: 255,
222
+ g: 255,
223
+ b: 255
224
+ };
225
+ return Object.freeze({
226
+ level: 16,
227
+ index,
228
+ name,
229
+ rgb,
230
+ fgOpen: ansi16FgOpen(name),
231
+ bgOpen: ansi16BgOpen(name)
232
+ });
233
+ });
234
+ }
235
+ function ansi256Palette() {
236
+ const out = [];
237
+ for (let index = 0; index < 256; index++) out.push(Object.freeze({
238
+ level: 256,
239
+ index,
240
+ rgb: ansi256ToRgb(index),
241
+ fgOpen: ansi256FgOpen(index),
242
+ bgOpen: ansi256BgOpen(index)
243
+ }));
244
+ return Object.freeze(out);
245
+ }
246
+ function clampAnsiIndex(n) {
247
+ if (!Number.isFinite(n)) return 0;
248
+ return Math.max(0, Math.min(255, Math.trunc(n)));
249
+ }
250
+ function clampByte(n) {
251
+ if (!Number.isFinite(n)) return 0;
252
+ return Math.max(0, Math.min(255, Math.round(n)));
253
+ }
254
+
255
+ //#endregion
256
+ //#region src/ansi-styles.ts
257
+ const ESC = "\x1B[";
258
+ function createStyle(open, close) {
259
+ return Object.freeze({
260
+ open,
261
+ close
262
+ });
263
+ }
264
+ const ansiStyles = Object.freeze({
265
+ reset: createStyle(SGR_RESET, SGR_RESET),
266
+ bold: createStyle(SGR_BOLD, `${ESC}22m`),
267
+ dim: createStyle(SGR_DIM, `${ESC}22m`),
268
+ italic: createStyle(SGR_ITALIC, `${ESC}23m`),
269
+ underline: createStyle(SGR_UNDERLINE, `${ESC}24m`),
270
+ inverse: createStyle(SGR_INVERSE, `${ESC}27m`),
271
+ black: createStyle(ansi16FgOpen("black"), `${ESC}39m`),
272
+ red: createStyle(ansi16FgOpen("red"), `${ESC}39m`),
273
+ green: createStyle(ansi16FgOpen("green"), `${ESC}39m`),
274
+ yellow: createStyle(ansi16FgOpen("yellow"), `${ESC}39m`),
275
+ blue: createStyle(ansi16FgOpen("blue"), `${ESC}39m`),
276
+ magenta: createStyle(ansi16FgOpen("magenta"), `${ESC}39m`),
277
+ cyan: createStyle(ansi16FgOpen("cyan"), `${ESC}39m`),
278
+ white: createStyle(ansi16FgOpen("white"), `${ESC}39m`),
279
+ blackBright: createStyle(ansi16FgOpen("blackBright"), `${ESC}39m`),
280
+ redBright: createStyle(ansi16FgOpen("redBright"), `${ESC}39m`),
281
+ greenBright: createStyle(ansi16FgOpen("greenBright"), `${ESC}39m`),
282
+ yellowBright: createStyle(ansi16FgOpen("yellowBright"), `${ESC}39m`),
283
+ blueBright: createStyle(ansi16FgOpen("blueBright"), `${ESC}39m`),
284
+ magentaBright: createStyle(ansi16FgOpen("magentaBright"), `${ESC}39m`),
285
+ cyanBright: createStyle(ansi16FgOpen("cyanBright"), `${ESC}39m`),
286
+ whiteBright: createStyle(ansi16FgOpen("whiteBright"), `${ESC}39m`),
287
+ bgBlack: createStyle(ansi16BgOpen("black"), `${ESC}49m`),
288
+ bgRed: createStyle(ansi16BgOpen("red"), `${ESC}49m`),
289
+ bgGreen: createStyle(ansi16BgOpen("green"), `${ESC}49m`),
290
+ bgYellow: createStyle(ansi16BgOpen("yellow"), `${ESC}49m`),
291
+ bgBlue: createStyle(ansi16BgOpen("blue"), `${ESC}49m`),
292
+ bgMagenta: createStyle(ansi16BgOpen("magenta"), `${ESC}49m`),
293
+ bgCyan: createStyle(ansi16BgOpen("cyan"), `${ESC}49m`),
294
+ bgWhite: createStyle(ansi16BgOpen("white"), `${ESC}49m`),
295
+ bgBlackBright: createStyle(ansi16BgOpen("blackBright"), `${ESC}49m`),
296
+ bgRedBright: createStyle(ansi16BgOpen("redBright"), `${ESC}49m`),
297
+ bgGreenBright: createStyle(ansi16BgOpen("greenBright"), `${ESC}49m`),
298
+ bgYellowBright: createStyle(ansi16BgOpen("yellowBright"), `${ESC}49m`),
299
+ bgBlueBright: createStyle(ansi16BgOpen("blueBright"), `${ESC}49m`),
300
+ bgMagentaBright: createStyle(ansi16BgOpen("magentaBright"), `${ESC}49m`),
301
+ bgCyanBright: createStyle(ansi16BgOpen("cyanBright"), `${ESC}49m`),
302
+ bgWhiteBright: createStyle(ansi16BgOpen("whiteBright"), `${ESC}49m`),
303
+ color: Object.freeze({
304
+ ansi256: (idx) => ansi256FgOpen(idx),
305
+ ansi16m: (r, g, b) => truecolorFgOpen({
306
+ r,
307
+ g,
308
+ b
309
+ })
310
+ }),
311
+ bgColor: Object.freeze({
312
+ ansi256: (idx) => ansi256BgOpen(idx),
313
+ ansi16m: (r, g, b) => truecolorBgOpen({
314
+ r,
315
+ g,
316
+ b
317
+ })
318
+ })
319
+ });
320
+ /**
321
+ * Cached palettes for convenience.
322
+ * Note: ANSI 0..15 are terminal-theme-dependent in many terminals; treat `rgb` as an approximation.
323
+ */
324
+ const ANSI8_COLORS = ansi8Palette();
325
+ const ANSI16_COLORS = ansi16Palette();
326
+ const ANSI256_COLORS = ansi256Palette();
327
+ function ansiColors(level) {
328
+ if (level === 8) return ANSI8_COLORS;
329
+ if (level === 16) return ANSI16_COLORS;
330
+ return ANSI256_COLORS;
331
+ }
332
+
333
+ //#endregion
334
+ //#region src/core/ansi/capability.ts
335
+ function parseColorMode(raw) {
336
+ const v = String(raw ?? "").trim().toLowerCase();
337
+ if (!v) return null;
338
+ if (v === "truecolor" || v === "24bit" || v === "rgb") return "truecolor";
339
+ if (v === "ansi256" || v === "256" || v === "xterm256" || v === "xterm-256color") return "ansi256";
340
+ if (v === "ansi16" || v === "16") return "ansi16";
341
+ if (v === "ansi8" || v === "8") return "ansi8";
342
+ return null;
343
+ }
344
+ function levelForMode(mode) {
345
+ if (mode === "ansi8") return 8;
346
+ if (mode === "ansi16") return 16;
347
+ return 256;
348
+ }
349
+ /**
350
+ * Detect terminal output color capability.
351
+ *
352
+ * - `mode` is the best-effort actual output mode.
353
+ * - `level` is the CLI theme tier (256/16/8). `truecolor` folds into `256`.
354
+ * - Pass `platform` (e.g. `process.platform`) to improve Windows detection.
355
+ *
356
+ * Env overrides:
357
+ * - `VUE_TUI_COLOR_MODE` / legacy `DIMCODE_COLOR_MODE`
358
+ */
359
+ function detectTerminalColorCapability(opts) {
360
+ const env = opts?.env ?? {};
361
+ const isTTY = opts?.isTTY ?? false;
362
+ const platform = String(opts?.platform ?? "").trim().toLowerCase();
363
+ const isWindows = platform === "win32" || String(env.OS ?? "").trim().toLowerCase() === "windows_nt";
364
+ const forced = parseColorMode(firstNonEmptyEnv(env, "VUE_TUI_COLOR_MODE", "DIMCODE_COLOR_MODE"));
365
+ if (forced) return {
366
+ mode: forced,
367
+ level: levelForMode(forced)
368
+ };
369
+ if (!isTTY) return {
370
+ mode: "truecolor",
371
+ level: 256
372
+ };
373
+ const termProgram = String(env.TERM_PROGRAM ?? "").toLowerCase();
374
+ const isAppleTerminal = termProgram.includes("apple_terminal");
375
+ const colorterm = String(env.COLORTERM ?? "").toLowerCase();
376
+ if (!isAppleTerminal && (colorterm.includes("truecolor") || colorterm.includes("24bit"))) return {
377
+ mode: "truecolor",
378
+ level: 256
379
+ };
380
+ if (termProgram.includes("vscode")) return {
381
+ mode: "truecolor",
382
+ level: 256
383
+ };
384
+ 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 {
385
+ mode: "truecolor",
386
+ level: 256
387
+ };
388
+ const term = String(env.TERM ?? "").toLowerCase();
389
+ if (isWindows) {
390
+ const hasWindowsTerminal = "WT_SESSION" in env || "WT_PROFILE_ID" in env || "WT_ID" in env;
391
+ const hasWezterm = "WEZTERM_EXECUTABLE" in env || "WEZTERM_PANE" in env;
392
+ const hasAlacritty = "ALACRITTY_LOG" in env || "ALACRITTY_WINDOW_ID" in env;
393
+ const hasTabby = "TABBY_CONFIG_DIRECTORY" in env;
394
+ if (hasWindowsTerminal || hasWezterm || hasAlacritty || hasTabby) return {
395
+ mode: "truecolor",
396
+ level: 256
397
+ };
398
+ if (term.includes("xterm") && term.includes("256color")) return {
399
+ mode: "truecolor",
400
+ level: 256
401
+ };
402
+ }
403
+ if (term.includes("256color")) return {
404
+ mode: "ansi256",
405
+ level: 256
406
+ };
407
+ if (term.includes("color")) return {
408
+ mode: "ansi16",
409
+ level: 16
410
+ };
411
+ if (term.includes("dumb")) return {
412
+ mode: "ansi8",
413
+ level: 8
414
+ };
415
+ return {
416
+ mode: "ansi16",
417
+ level: 16
418
+ };
419
+ }
420
+
421
+ //#endregion
422
+ 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 };
@@ -0,0 +1,34 @@
1
+ import type { App, Component, Ref } from "vue";
2
+ import type { WidthProvider } from "./core/buffer/width.js";
3
+ import type { PathPickerProvider } from "./core/path-provider-types.js";
4
+ import type { Style, Terminal } from "./core/types.js";
5
+ import type { CliEventManager } from "./events/index.js";
6
+ import type { ClipboardApi } from "./runtime/index.js";
7
+ import type { TerminalSelectionConfig, TerminalSelectionCopyPayload } from "./selection/terminal-selection.js";
8
+ import type { TInputPlugin } from "./vue/components/input/plugins/types.js";
9
+ import type { ImeAnchor, TerminalScheduler } from "./vue/context.js";
10
+ export type TerminalApp = Readonly<{
11
+ app: App;
12
+ terminal: Terminal;
13
+ events: CliEventManager;
14
+ scheduler: TerminalScheduler;
15
+ defaultStyle: Ref<Style>;
16
+ /** Returns the current IME anchor position (cursor position in cell coordinates), or null if no input is focused */
17
+ getImeAnchor: () => ImeAnchor | null;
18
+ mount: () => void;
19
+ dispose: () => void;
20
+ }>;
21
+ export type CreateTerminalAppOptions = Readonly<{
22
+ cols: number;
23
+ rows: number;
24
+ component: Component;
25
+ widthProvider?: WidthProvider;
26
+ props?: Record<string, unknown>;
27
+ defaultStyle?: Style;
28
+ clipboard?: ClipboardApi;
29
+ selection?: TerminalSelectionConfig;
30
+ onSelectionCopy?: (payload: TerminalSelectionCopyPayload) => void;
31
+ inputPlugins?: readonly TInputPlugin[];
32
+ pathPickerProvider?: PathPickerProvider;
33
+ }>;
34
+ export declare function createTerminalApp(options: CreateTerminalAppOptions): TerminalApp;