@simon_he/vue-tui 0.0.8 → 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 (210) hide show
  1. package/README.md +130 -27
  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 +1777 -1244
  52. package/dist/experimental.d.cts +39 -0
  53. package/dist/experimental.d.ts +39 -825
  54. package/dist/experimental.js +492 -343
  55. package/dist/frame-perf-C-w8mjJL.js +98 -0
  56. package/dist/hyperlink-B5PD7a3Q.js +331 -0
  57. package/dist/index.cjs +13133 -19960
  58. package/dist/index.d.cts +13 -0
  59. package/dist/index.d.ts +13 -1528
  60. package/dist/index.js +13 -20026
  61. package/dist/markdown.cjs +8728 -7359
  62. package/dist/markdown.d.cts +10 -0
  63. package/dist/markdown.d.ts +10 -112
  64. package/dist/markdown.js +169 -101
  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-DmrmeueH.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-CiNsasLf.js → wheel-scroll-B-WlFuNB.js} +361 -367
  206. package/package.json +165 -35
  207. package/dist/path-suggest-BeV6n7m-.js +0 -3
  208. package/dist/sgr-Tko2EQ0U.js +0 -484
  209. package/dist/theme-Bsm65g8k.d.ts +0 -32
  210. package/dist/types-ClIV2h1o.d.ts +0 -103
@@ -0,0 +1,10 @@
1
+ export { TMarkdownText } from "./vue/components/TMarkdownText.js";
2
+ export { TVirtualMarkdown } from "./vue/components/TVirtualMarkdown.js";
3
+ export { createMarkdownBlockSource } from "./vue/markdown/block-source.js";
4
+ export { buildMarkdownBlocks, buildMarkdownVisualRows } from "./vue/markdown/document.js";
5
+ export { layoutMarkdownBlocks } from "./vue/markdown/layout.js";
6
+ export { createTuiMarkdownParser, isSafeMarkdownLink } from "./vue/markdown/parser.js";
7
+ export type { TuiMarkdownBlockSource, TuiMarkdownBlockSourceOptions, TuiMarkdownBlockSourceSnapshot, } from "./vue/markdown/block-source.js";
8
+ export type { TuiMarkdownBlock, TuiMarkdownInlineSegment, TuiMarkdownNode, TuiMarkdownVisualRow, TuiMarkdownVisualSegment, } from "./vue/markdown/types.js";
9
+ export type { TuiMarkdownParseConfig, TuiMarkdownParser } from "./vue/markdown/parser.js";
10
+ export type { TuiMarkdownTheme, TuiMarkdownThemeOverrides } from "./vue/markdown/theme.js";
@@ -1,112 +1,10 @@
1
- import { Style } from "./types-ClIV2h1o.js";
2
- import { TuiMarkdownTheme, TuiMarkdownThemeOverrides } from "./theme-Bsm65g8k.js";
3
- import { ParsedNode } from "stream-markdown-parser";
4
-
5
- //#region src/vue/components/TMarkdownText.d.ts
6
- declare const TMarkdownText: any;
7
-
8
- //#endregion
9
- //#region src/vue/components/TVirtualMarkdown.d.ts
10
- declare const TVirtualMarkdown: any;
11
-
12
- //#endregion
13
- //#region src/vue/markdown/parser.d.ts
14
- interface TuiMarkdownParseConfig {
15
- streaming?: boolean;
16
- customHtmlTags?: readonly string[];
17
- }
18
- interface TuiMarkdownParser {
19
- parse: (content: string, final: boolean) => ParsedNode[];
20
- }
21
- declare function isSafeMarkdownLink(url: string): boolean;
22
- declare function createTuiMarkdownParser(config?: TuiMarkdownParseConfig): TuiMarkdownParser;
23
-
24
- //#endregion
25
- //#region src/vue/markdown/types.d.ts
26
- type TuiMarkdownInlineSegment = Readonly<{
27
- text: string;
28
- style?: Style;
29
- hardBreak?: boolean;
30
- }>;
31
- type TuiMarkdownBlock = Readonly<{
32
- type: "inline";
33
- key: string;
34
- segments: readonly TuiMarkdownInlineSegment[];
35
- prefixSegments?: readonly TuiMarkdownInlineSegment[];
36
- continuationPrefixSegments?: readonly TuiMarkdownInlineSegment[];
37
- }> | Readonly<{
38
- type: "code_block";
39
- key: string;
40
- lines: readonly string[];
41
- style?: Style;
42
- prefixSegments?: readonly TuiMarkdownInlineSegment[];
43
- continuationPrefixSegments?: readonly TuiMarkdownInlineSegment[];
44
- }> | Readonly<{
45
- type: "thematic_break";
46
- key: string;
47
- char?: string;
48
- style?: Style;
49
- prefixSegments?: readonly TuiMarkdownInlineSegment[];
50
- }> | Readonly<{
51
- type: "blank";
52
- key: string;
53
- }>;
54
- type TuiMarkdownVisualSegment = Readonly<{
55
- text: string;
56
- style?: Style;
57
- cells: number;
58
- }>;
59
- type TuiMarkdownVisualRow = Readonly<{
60
- key: string;
61
- blockKey: string;
62
- rowInBlock: number;
63
- plainText: string;
64
- segments: readonly TuiMarkdownVisualSegment[];
65
- }>;
66
-
67
- //#endregion
68
- //#region src/vue/markdown/block-source.d.ts
69
- type TuiMarkdownBlockSourceSnapshot = Readonly<{
70
- version: number;
71
- blocks: readonly TuiMarkdownBlock[];
72
- }>;
73
- type TuiMarkdownBlockSource = Readonly<{
74
- version: number;
75
- blocks: readonly TuiMarkdownBlock[];
76
- appendDelta: (text: string) => void;
77
- replaceTailBlock: (text: string) => void;
78
- finalizeBlock: () => void;
79
- clear: () => void;
80
- snapshot: () => TuiMarkdownBlockSourceSnapshot;
81
- }>;
82
- type TuiMarkdownBlockSourceOptions = Readonly<{
83
- parser?: TuiMarkdownParser;
84
- customHtmlTags?: readonly string[];
85
- theme?: TuiMarkdownThemeOverrides;
86
- }>;
87
- declare function createMarkdownBlockSource(options?: TuiMarkdownBlockSourceOptions): TuiMarkdownBlockSource;
88
-
89
- //#endregion
90
- //#region src/vue/markdown/document.d.ts
91
- /**
92
- * This helper always builds visual rows from the full source string. Components
93
- * that need streaming reuse can call buildMarkdownBlocks and cache block layout.
94
- */
95
- declare function buildMarkdownBlocks(content: string, parser: TuiMarkdownParser, options?: Readonly<{
96
- final?: boolean;
97
- theme?: TuiMarkdownThemeOverrides;
98
- }>): Readonly<{
99
- nodes: readonly ParsedNode[];
100
- blocks: readonly TuiMarkdownBlock[];
101
- }>;
102
- declare function buildMarkdownVisualRows(content: string, width: number, parser: TuiMarkdownParser, options?: Readonly<{
103
- final?: boolean;
104
- theme?: TuiMarkdownThemeOverrides;
105
- }>): readonly TuiMarkdownVisualRow[];
106
-
107
- //#endregion
108
- //#region src/vue/markdown/layout.d.ts
109
- declare function layoutMarkdownBlocks(blocks: readonly TuiMarkdownBlock[], width: number): readonly TuiMarkdownVisualRow[];
110
-
111
- //#endregion
112
- export { TMarkdownText, TVirtualMarkdown, TuiMarkdownBlock, TuiMarkdownBlockSource, TuiMarkdownBlockSourceOptions, TuiMarkdownBlockSourceSnapshot, TuiMarkdownInlineSegment, TuiMarkdownParseConfig, TuiMarkdownParser, TuiMarkdownTheme, TuiMarkdownThemeOverrides, TuiMarkdownVisualRow, TuiMarkdownVisualSegment, buildMarkdownBlocks, buildMarkdownVisualRows, createMarkdownBlockSource, createTuiMarkdownParser, isSafeMarkdownLink, layoutMarkdownBlocks };
1
+ export { TMarkdownText } from "./vue/components/TMarkdownText.js";
2
+ export { TVirtualMarkdown } from "./vue/components/TVirtualMarkdown.js";
3
+ export { createMarkdownBlockSource } from "./vue/markdown/block-source.js";
4
+ export { buildMarkdownBlocks, buildMarkdownVisualRows } from "./vue/markdown/document.js";
5
+ export { layoutMarkdownBlocks } from "./vue/markdown/layout.js";
6
+ export { createTuiMarkdownParser, isSafeMarkdownLink } from "./vue/markdown/parser.js";
7
+ export type { TuiMarkdownBlockSource, TuiMarkdownBlockSourceOptions, TuiMarkdownBlockSourceSnapshot, } from "./vue/markdown/block-source.js";
8
+ export type { TuiMarkdownBlock, TuiMarkdownInlineSegment, TuiMarkdownNode, TuiMarkdownVisualRow, TuiMarkdownVisualSegment, } from "./vue/markdown/types.js";
9
+ export type { TuiMarkdownParseConfig, TuiMarkdownParser } from "./vue/markdown/parser.js";
10
+ export type { TuiMarkdownTheme, TuiMarkdownThemeOverrides } from "./vue/markdown/theme.js";
package/dist/markdown.js CHANGED
@@ -1,70 +1,49 @@
1
- import { EventZIndexContextKey, applyWheelScroll, createWheelScrollState, forEachTextCellSegment, intersectRect, normalizeCellRect, repeatChar, resetWheelScrollState, sanitizeInlineText, sanitizeTextBlock, sliceByCellsRange, spaces, textCellWidth, translateRect, useLayout, useRenderNode, useTerminal, useTerminalNode, useVisibility } from "./wheel-scroll-CiNsasLf.js";
1
+ import { sanitizeDomHref } from "./hyperlink-B5PD7a3Q.js";
2
+ import { terminalSelectionRowSpans, terminalSelectionVisibleRowSpans } from "./terminal-selection-BCOh9jsL.js";
3
+ import { EventZIndexContextKey, applyWheelScroll, createWheelScrollState, forEachTextCellSegment, intersectRect, normalizeCellRect, repeatChar, resetWheelScrollState, sanitizeInlineText, sanitizeTextBlock, sliceByCellsRange, spaces, textCellWidth, translateRect, useLayout, useRenderNode, useTerminal, useTerminalNode, useVisibility } from "./wheel-scroll-B-WlFuNB.js";
2
4
  import { computed, defineComponent, getCurrentInstance, h, inject, markRaw, onBeforeUnmount, ref, shallowRef, watch, watchEffect } from "vue";
3
5
  import { getMarkdown, parseMarkdownToStructure } from "stream-markdown-parser";
4
6
 
5
7
  //#region src/vue/markdown/parser.ts
6
- const RELATIVE_LINK_PREFIXES = [
7
- "#",
8
- "/",
9
- "./",
10
- "../"
11
- ];
12
- const SAFE_PROTOCOLS = new Set([
13
- "http:",
14
- "https:",
15
- "mailto:"
16
- ]);
17
8
  const markdownInstanceCache = new Map();
18
9
  const MAX_MARKDOWN_INSTANCE_CACHE = 32;
19
- const SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i;
20
- function hasControlChars(value) {
21
- for (const ch of value) {
22
- const code = ch.codePointAt(0);
23
- if (code >= 0 && code <= 31 || code >= 127 && code <= 159) return true;
24
- }
25
- return false;
10
+ function sanitizeMarkdownLink(url) {
11
+ return sanitizeDomHref(url, { allowRelative: true });
26
12
  }
27
13
  function isSafeMarkdownLink(url) {
28
- const raw = String(url ?? "").trim();
29
- if (!raw) return false;
30
- if (hasControlChars(raw)) return false;
31
- if (raw.startsWith("//")) return false;
32
- const value = raw.toLowerCase();
33
- if (value.startsWith("javascript:")) return false;
34
- if (value.startsWith("data:")) return false;
35
- if (RELATIVE_LINK_PREFIXES.some((prefix) => raw.startsWith(prefix))) return true;
36
- if (!SCHEME_RE.test(raw)) return true;
37
- try {
38
- const parsed = new URL(raw);
39
- return SAFE_PROTOCOLS.has(parsed.protocol);
40
- } catch {
41
- return false;
42
- }
14
+ return sanitizeMarkdownLink(url) != null;
15
+ }
16
+ function normalizeCustomHtmlTags(config) {
17
+ return Array.from(new Set(config?.customHtmlTags?.filter(Boolean) ?? [])).sort();
43
18
  }
44
- function markdownInstanceCacheKey(config) {
45
- var _config$customHtmlTag;
46
- return JSON.stringify({ customHtmlTags: [...(config === null || config === void 0 || (_config$customHtmlTag = config.customHtmlTags) === null || _config$customHtmlTag === void 0 ? void 0 : _config$customHtmlTag.filter(Boolean)) ?? []].sort() });
19
+ function markdownInstanceCacheKey(customHtmlTags) {
20
+ return JSON.stringify({ customHtmlTags });
47
21
  }
48
- function getCachedMarkdownInstance(config) {
49
- var _config$customHtmlTag2;
50
- const cacheKey = markdownInstanceCacheKey(config);
22
+ function getCachedMarkdownInstance(customHtmlTags) {
23
+ const cacheKey = markdownInstanceCacheKey(customHtmlTags);
51
24
  const cached = markdownInstanceCache.get(cacheKey);
52
- if (cached) return cached;
53
- const customHtmlTags = config === null || config === void 0 || (_config$customHtmlTag2 = config.customHtmlTags) === null || _config$customHtmlTag2 === void 0 ? void 0 : _config$customHtmlTag2.filter(Boolean);
25
+ if (cached) {
26
+ markdownInstanceCache.delete(cacheKey);
27
+ markdownInstanceCache.set(cacheKey, cached);
28
+ return cached;
29
+ }
54
30
  const created = getMarkdown(`vue-tui-markdown:${cacheKey}`, { customHtmlTags });
55
- if (markdownInstanceCache.size >= MAX_MARKDOWN_INSTANCE_CACHE) markdownInstanceCache.clear();
56
31
  markdownInstanceCache.set(cacheKey, created);
32
+ while (markdownInstanceCache.size > MAX_MARKDOWN_INSTANCE_CACHE) {
33
+ const oldest = markdownInstanceCache.keys().next().value;
34
+ if (oldest == null) break;
35
+ markdownInstanceCache.delete(oldest);
36
+ }
57
37
  return created;
58
38
  }
59
39
  function createTuiMarkdownParser(config) {
60
- var _config$customHtmlTag3;
61
- const customHtmlTags = config === null || config === void 0 || (_config$customHtmlTag3 = config.customHtmlTags) === null || _config$customHtmlTag3 === void 0 ? void 0 : _config$customHtmlTag3.filter(Boolean);
62
- const md = getCachedMarkdownInstance(config);
40
+ const customHtmlTags = normalizeCustomHtmlTags(config);
41
+ const md = getCachedMarkdownInstance(customHtmlTags);
63
42
  function parse(content, final) {
64
43
  return parseMarkdownToStructure(content, md, {
65
44
  final,
66
45
  customHtmlTags,
67
- requireClosingStrong: final || !(config === null || config === void 0 ? void 0 : config.streaming),
46
+ requireClosingStrong: final || !config?.streaming,
68
47
  validateLink: isSafeMarkdownLink
69
48
  });
70
49
  }
@@ -87,11 +66,10 @@ function mergeStyle$1(base, overlay) {
87
66
  };
88
67
  }
89
68
  function trimBlockArray(blocks) {
90
- var _blocks$start, _blocks;
91
69
  let start = 0;
92
70
  let end = blocks.length;
93
- while (start < end && ((_blocks$start = blocks[start]) === null || _blocks$start === void 0 ? void 0 : _blocks$start.type) === "blank") start++;
94
- while (end > start && ((_blocks = blocks[end - 1]) === null || _blocks === void 0 ? void 0 : _blocks.type) === "blank") end--;
71
+ while (start < end && blocks[start]?.type === "blank") start++;
72
+ while (end > start && blocks[end - 1]?.type === "blank") end--;
95
73
  return blocks.slice(start, end);
96
74
  }
97
75
  function nodeChildren(node) {
@@ -104,6 +82,14 @@ function stringProp(node, key) {
104
82
  function booleanProp(node, key) {
105
83
  return node[key] === true;
106
84
  }
85
+ function numberProp(node, key) {
86
+ const value = node[key];
87
+ return typeof value === "number" && Number.isFinite(value) ? value : null;
88
+ }
89
+ function nodeItems(node) {
90
+ const value = node.items;
91
+ return Array.isArray(value) ? value : [];
92
+ }
107
93
  function pushTextSegments(out, text, style) {
108
94
  if (!text) return;
109
95
  const normalized = sanitizeTextBlock(text);
@@ -165,7 +151,7 @@ function inlineNodeSegments(nodes, theme, inheritedStyle) {
165
151
  break;
166
152
  case "link": {
167
153
  const href = stringProp(node, "href");
168
- const safeHref = href && isSafeMarkdownLink(href) ? href : "";
154
+ const safeHref = href ? sanitizeMarkdownLink(href) : null;
169
155
  const linkStyle = safeHref ? mergeStyle$1(inheritedStyle, {
170
156
  ...theme.link,
171
157
  href: safeHref
@@ -191,7 +177,7 @@ function inlineNodeSegments(nodes, theme, inheritedStyle) {
191
177
  case "reference":
192
178
  case "footnote_reference":
193
179
  case "footnote_anchor":
194
- pushTextSegments(out, node.raw, inheritedStyle);
180
+ pushTextSegments(out, stringProp(node, "raw"), inheritedStyle);
195
181
  break;
196
182
  case "html_inline":
197
183
  pushTextSegments(out, stringProp(node, "content"), mergeStyle$1(inheritedStyle, theme.html));
@@ -204,7 +190,7 @@ function inlineNodeSegments(nodes, theme, inheritedStyle) {
204
190
  out.push(...inlineNodeSegments(nodeChildren(node), theme, inheritedStyle));
205
191
  break;
206
192
  }
207
- pushTextSegments(out, node.raw, inheritedStyle);
193
+ pushTextSegments(out, stringProp(node, "raw"), inheritedStyle);
208
194
  break;
209
195
  }
210
196
  return out;
@@ -219,17 +205,17 @@ function inlineBlock(key, segments, context) {
219
205
  };
220
206
  }
221
207
  function blockFromParagraph(node, key, context, theme) {
222
- return inlineBlock(key, inlineNodeSegments(node.children, theme), context);
208
+ return inlineBlock(key, inlineNodeSegments(nodeChildren(node), theme), context);
223
209
  }
224
210
  function blockFromHeading(node, key, context, theme) {
225
- const level = Math.min(6, Math.max(1, Math.floor(node.level || 1)));
226
- return inlineBlock(key, inlineNodeSegments(node.children, theme, theme.heading[level - 1]), context);
211
+ const level = Math.min(6, Math.max(1, Math.floor(numberProp(node, "level") ?? 1)));
212
+ return inlineBlock(key, inlineNodeSegments(nodeChildren(node), theme, theme.heading[level - 1]), context);
227
213
  }
228
214
  function blockFromCodeBlock(node, key, context, theme) {
229
215
  return {
230
216
  type: "code_block",
231
217
  key,
232
- lines: sanitizeCodeBlockText(node.code ?? "").split("\n"),
218
+ lines: sanitizeCodeBlockText(stringProp(node, "code")).split("\n"),
233
219
  style: theme.codeBlock,
234
220
  prefixSegments: context.prefixSegments,
235
221
  continuationPrefixSegments: context.continuationPrefixSegments
@@ -238,18 +224,17 @@ function blockFromCodeBlock(node, key, context, theme) {
238
224
  function blockFromHtmlBlock(node, key, context, theme) {
239
225
  return inlineBlock(key, inlineNodeSegments([{
240
226
  type: "html_block",
241
- raw: node.raw,
242
- content: node.content
227
+ raw: stringProp(node, "raw"),
228
+ content: stringProp(node, "content")
243
229
  }], theme), context);
244
230
  }
245
231
  function childSequenceToBlocks(nodes, context, theme, keyPrefix) {
246
232
  const out = [];
247
233
  let appended = false;
248
234
  for (let i = 0; i < nodes.length; i++) {
249
- var _out, _childBlocks$;
250
235
  const childBlocks = trimBlockArray(nodeToBlocks(nodes[i], context, theme, `${keyPrefix}-${i}`));
251
236
  if (!childBlocks.length) continue;
252
- if (appended && ((_out = out[out.length - 1]) === null || _out === void 0 ? void 0 : _out.type) !== "blank" && ((_childBlocks$ = childBlocks[0]) === null || _childBlocks$ === void 0 ? void 0 : _childBlocks$.type) !== "blank") out.push({
237
+ if (appended && out[out.length - 1]?.type !== "blank" && childBlocks[0]?.type !== "blank") out.push({
253
238
  type: "blank",
254
239
  key: `${keyPrefix}-${i}-gap`
255
240
  });
@@ -274,12 +259,12 @@ function listItemBlocks(item, index, ordered, start, context, theme, keyPrefix)
274
259
  prefixSegments: [...context.continuationPrefixSegments, indentSegment],
275
260
  continuationPrefixSegments: [...context.continuationPrefixSegments, indentSegment]
276
261
  };
277
- if (!item.children.length) return [inlineBlock(`${keyPrefix}-empty`, [], firstContext)];
262
+ const children = nodeChildren(item);
263
+ if (!children.length) return [inlineBlock(`${keyPrefix}-empty`, [], firstContext)];
278
264
  const out = [];
279
265
  let usedLead = false;
280
- for (let i = 0; i < item.children.length; i++) {
281
- var _out2, _childBlocks$2, _out3, _childBlocks$3;
282
- const child = item.children[i];
266
+ for (let i = 0; i < children.length; i++) {
267
+ const child = children[i];
283
268
  const useLeadContext = !usedLead && (child.type === "paragraph" || child.type === "heading" || child.type === "code_block");
284
269
  if (!usedLead && !useLeadContext) {
285
270
  out.push(inlineBlock(`${keyPrefix}-marker`, [], firstContext));
@@ -287,8 +272,8 @@ function listItemBlocks(item, index, ordered, start, context, theme, keyPrefix)
287
272
  }
288
273
  const childBlocks = trimBlockArray(nodeToBlocks(child, useLeadContext && !usedLead ? firstContext : nestedContext, theme, `${keyPrefix}-${i}`));
289
274
  if (!childBlocks.length) continue;
290
- const startsNestedList = child.type === "list" && out.length > 0 && ((_out2 = out[out.length - 1]) === null || _out2 === void 0 ? void 0 : _out2.type) === "inline" && ((_childBlocks$2 = childBlocks[0]) === null || _childBlocks$2 === void 0 ? void 0 : _childBlocks$2.type) === "inline";
291
- if (out.length && ((_out3 = out[out.length - 1]) === null || _out3 === void 0 ? void 0 : _out3.type) !== "blank" && ((_childBlocks$3 = childBlocks[0]) === null || _childBlocks$3 === void 0 ? void 0 : _childBlocks$3.type) !== "blank" && !startsNestedList) out.push({
275
+ const startsNestedList = child.type === "list" && out.length > 0 && out[out.length - 1]?.type === "inline" && childBlocks[0]?.type === "inline";
276
+ if (out.length && out[out.length - 1]?.type !== "blank" && childBlocks[0]?.type !== "blank" && !startsNestedList) out.push({
292
277
  type: "blank",
293
278
  key: `${keyPrefix}-${i}-gap`
294
279
  });
@@ -300,7 +285,8 @@ function listItemBlocks(item, index, ordered, start, context, theme, keyPrefix)
300
285
  }
301
286
  function listBlocks(node, context, theme, keyPrefix) {
302
287
  const out = [];
303
- for (let i = 0; i < node.items.length; i++) out.push(...listItemBlocks(node.items[i], i, node.ordered, node.start ?? 1, context, theme, `${keyPrefix}-${i}`));
288
+ const items = nodeItems(node);
289
+ for (let i = 0; i < items.length; i++) out.push(...listItemBlocks(items[i], i, booleanProp(node, "ordered"), numberProp(node, "start") ?? 1, context, theme, `${keyPrefix}-${i}`));
304
290
  return out;
305
291
  }
306
292
  function nodeToBlocks(node, context, theme, keyPrefix) {
@@ -621,13 +607,13 @@ function layoutMarkdownBlocksCached(blocks, width, previous) {
621
607
  };
622
608
  const rows = [];
623
609
  const entries = new Map();
624
- const previousEntries = (previous === null || previous === void 0 ? void 0 : previous.width) === normalizedWidth ? previous.entries : void 0;
610
+ const previousEntries = previous?.width === normalizedWidth ? previous.entries : void 0;
625
611
  for (let index = 0; index < blocks.length; index++) {
626
612
  const block = blocks[index];
627
613
  const cacheKey = `${index}\u0000${block.key}`;
628
614
  const signature = blockLayoutSignature(block);
629
- const cached = previousEntries === null || previousEntries === void 0 ? void 0 : previousEntries.get(cacheKey);
630
- const blockRows = (cached === null || cached === void 0 ? void 0 : cached.signature) === signature ? cached.rows : layoutMarkdownBlock(block, normalizedWidth);
615
+ const cached = previousEntries?.get(cacheKey);
616
+ const blockRows = cached?.signature === signature ? cached.rows : layoutMarkdownBlock(block, normalizedWidth);
631
617
  if (blockRows.length) {
632
618
  rows.push(...blockRows);
633
619
  entries.set(cacheKey, {
@@ -725,10 +711,7 @@ function markdownThemeSignature(overrides) {
725
711
  }
726
712
  function resolveTuiMarkdownTheme(overrides) {
727
713
  if (!overrides) return DEFAULT_TUI_MARKDOWN_THEME;
728
- const heading = DEFAULT_TUI_MARKDOWN_THEME.heading.map((style, index) => {
729
- var _overrides$heading;
730
- return mergeFrozenStyle(style, (_overrides$heading = overrides.heading) === null || _overrides$heading === void 0 ? void 0 : _overrides$heading[index]);
731
- });
714
+ const heading = DEFAULT_TUI_MARKDOWN_THEME.heading.map((style, index) => mergeFrozenStyle(style, overrides.heading?.[index]));
732
715
  return Object.freeze({
733
716
  heading: Object.freeze(heading),
734
717
  strong: mergeFrozenStyle(DEFAULT_TUI_MARKDOWN_THEME.strong, overrides.strong),
@@ -751,9 +734,9 @@ function resolveTuiMarkdownTheme(overrides) {
751
734
  * that need streaming reuse can call buildMarkdownBlocks and cache block layout.
752
735
  */
753
736
  function buildMarkdownBlocks(content, parser, options) {
754
- const theme = resolveTuiMarkdownTheme(options === null || options === void 0 ? void 0 : options.theme);
737
+ const theme = resolveTuiMarkdownTheme(options?.theme);
755
738
  try {
756
- const nodes = parser.parse(content, (options === null || options === void 0 ? void 0 : options.final) ?? true);
739
+ const nodes = parser.parse(content, options?.final ?? true);
757
740
  const blocks = markdownAstToBlocks(nodes, theme);
758
741
  return {
759
742
  nodes,
@@ -972,7 +955,7 @@ const TMarkdownText = defineComponent({
972
955
  return;
973
956
  }
974
957
  scheduler.queueFrameTask({
975
- id: `TMarkdownText:${(instance === null || instance === void 0 ? void 0 : instance.uid) ?? "unknown"}:markdown`,
958
+ id: `TMarkdownText:${instance?.uid ?? "unknown"}:markdown`,
976
959
  reason: props.streaming ? "stream" : "data",
977
960
  priority: props.streaming ? "low" : "normal",
978
961
  sync: false,
@@ -1053,7 +1036,7 @@ const TMarkdownText = defineComponent({
1053
1036
  clear: props.clear
1054
1037
  });
1055
1038
  };
1056
- if (dirtyRows === null || dirtyRows === void 0 ? void 0 : dirtyRows.length) {
1039
+ if (dirtyRows?.length) {
1057
1040
  for (const y of dirtyRows) paintRow(y);
1058
1041
  return;
1059
1042
  }
@@ -1183,7 +1166,7 @@ const TVirtualMarkdown = defineComponent({
1183
1166
  ],
1184
1167
  setup(props, { emit }) {
1185
1168
  const instance = getCurrentInstance();
1186
- const { terminal, defaultStyle, events, scheduler } = useTerminal();
1169
+ const { terminal, defaultStyle, events, scheduler, selection } = useTerminal();
1187
1170
  const layout = useLayout();
1188
1171
  const { visible, rootProps } = useVisibility();
1189
1172
  const parentEventZ = inject(EventZIndexContextKey, computed(() => 0));
@@ -1191,6 +1174,7 @@ const TVirtualMarkdown = defineComponent({
1191
1174
  const internalScrollTop = ref(0);
1192
1175
  const documentVersion = ref(0);
1193
1176
  const rows = shallowRef(markRaw([]));
1177
+ let pendingSelectionScrollFocusRemap = false;
1194
1178
  const wheelState = createWheelScrollState();
1195
1179
  let builtOnce = false;
1196
1180
  let rebuildVersion = 0;
@@ -1221,7 +1205,10 @@ const TVirtualMarkdown = defineComponent({
1221
1205
  const nextScrollTop = internalScrollTop.value;
1222
1206
  const nextVisibleRows = visibleRowSignatures(nextRows, nextScrollTop);
1223
1207
  const visibleChanged = prevVisibleRows.length !== nextVisibleRows.length || prevVisibleRows.some((row, index) => row !== nextVisibleRows[index]);
1224
- if (!builtOnce || prevScrollTop !== nextScrollTop || visibleChanged) documentVersion.value++;
1208
+ if (!builtOnce || prevScrollTop !== nextScrollTop || visibleChanged) {
1209
+ documentVersion.value++;
1210
+ selection.refresh();
1211
+ }
1225
1212
  }
1226
1213
  function scheduleRebuild() {
1227
1214
  const currentVersion = ++rebuildVersion;
@@ -1231,7 +1218,7 @@ const TVirtualMarkdown = defineComponent({
1231
1218
  return;
1232
1219
  }
1233
1220
  scheduler.queueFrameTask({
1234
- id: `TVirtualMarkdown:${(instance === null || instance === void 0 ? void 0 : instance.uid) ?? "unknown"}:markdown`,
1221
+ id: `TVirtualMarkdown:${instance?.uid ?? "unknown"}:markdown`,
1235
1222
  reason: props.streaming ? "stream" : "data",
1236
1223
  priority: props.streaming ? "low" : "normal",
1237
1224
  sync: false,
@@ -1287,16 +1274,29 @@ const TVirtualMarkdown = defineComponent({
1287
1274
  return out;
1288
1275
  }
1289
1276
  function hasControlledScrollTop() {
1290
- return Object.prototype.hasOwnProperty.call((instance === null || instance === void 0 ? void 0 : instance.vnode.props) ?? {}, "scrollTop");
1277
+ return Object.prototype.hasOwnProperty.call(instance?.vnode.props ?? {}, "scrollTop");
1291
1278
  }
1292
- function setScrollTop(next, emitChange = true) {
1293
- const clamped = clamp(Math.floor(Number(next) || 0), 0, maxScrollTop());
1294
- if (internalScrollTop.value === clamped) return;
1295
- internalScrollTop.value = clamped;
1296
- if (emitChange) {
1279
+ function applyControlledScrollTop(next, remapSelectionFocus = false) {
1280
+ const desired = Math.floor(Number(next) || 0);
1281
+ const clamped = clamp(desired, 0, maxScrollTop());
1282
+ const changed = internalScrollTop.value !== clamped;
1283
+ if (changed) internalScrollTop.value = clamped;
1284
+ if (desired !== clamped) {
1285
+ emit("update:scrollTop", clamped);
1286
+ emit("scroll", clamped);
1287
+ }
1288
+ if (changed || remapSelectionFocus) selection.refresh(remapSelectionFocus ? { remapFocus: true } : void 0);
1289
+ }
1290
+ function setScrollTop(next, emitChange = true, refreshOptions) {
1291
+ const desired = Math.floor(Number(next) || 0);
1292
+ const clamped = clamp(desired, 0, maxScrollTop());
1293
+ const changed = internalScrollTop.value !== clamped;
1294
+ if (changed) internalScrollTop.value = clamped;
1295
+ if (emitChange && (changed || refreshOptions?.emitClampEvenIfUnchanged && desired !== clamped)) {
1297
1296
  emit("update:scrollTop", clamped);
1298
1297
  emit("scroll", clamped);
1299
1298
  }
1299
+ if (changed || refreshOptions?.remapSelectionFocus) selection.refresh(refreshOptions?.remapSelectionFocus ? { remapFocus: true } : void 0);
1300
1300
  }
1301
1301
  function reconcileScrollTop() {
1302
1302
  const desired = hasControlledScrollTop() ? Math.floor(Number(props.scrollTop) || 0) : internalScrollTop.value;
@@ -1307,16 +1307,13 @@ const TVirtualMarkdown = defineComponent({
1307
1307
  emit("update:scrollTop", clamped);
1308
1308
  emit("scroll", clamped);
1309
1309
  }
1310
+ selection.refresh();
1310
1311
  }
1311
1312
  watch(() => props.scrollTop, () => {
1312
1313
  if (!hasControlledScrollTop()) return;
1313
- const desired = Math.floor(Number(props.scrollTop) || 0);
1314
- const clamped = clamp(desired, 0, maxScrollTop());
1315
- internalScrollTop.value = clamped;
1316
- if (desired !== clamped) {
1317
- emit("update:scrollTop", clamped);
1318
- emit("scroll", clamped);
1319
- }
1314
+ const remap = pendingSelectionScrollFocusRemap;
1315
+ pendingSelectionScrollFocusRemap = false;
1316
+ applyControlledScrollTop(props.scrollTop, remap);
1320
1317
  });
1321
1318
  watch([
1322
1319
  () => props.content,
@@ -1345,6 +1342,65 @@ const TVirtualMarkdown = defineComponent({
1345
1342
  ], () => {
1346
1343
  reconcileScrollTop();
1347
1344
  }, { immediate: true });
1345
+ function scrollSelectionBy(delta) {
1346
+ const n = Math.trunc(Number(delta));
1347
+ if (!Number.isFinite(n) || n === 0) return false;
1348
+ if (hasControlledScrollTop()) {
1349
+ const nextTop = clamp(internalScrollTop.value + n, 0, maxScrollTop());
1350
+ if (nextTop === internalScrollTop.value) return false;
1351
+ if (pendingSelectionScrollFocusRemap) return false;
1352
+ pendingSelectionScrollFocusRemap = true;
1353
+ emit("update:scrollTop", nextTop);
1354
+ emit("scroll", nextTop);
1355
+ return true;
1356
+ }
1357
+ const before = internalScrollTop.value;
1358
+ setScrollTop(before + n, true, { remapSelectionFocus: true });
1359
+ return internalScrollTop.value !== before;
1360
+ }
1361
+ function selectionPointForCell(point) {
1362
+ const r = normalizedRect();
1363
+ if (point.x < r.x || point.y < r.y || point.x >= r.x + r.w || point.y >= r.y + r.h) return null;
1364
+ const { x: clipX, y: clipY } = clipOffsets();
1365
+ const visualY = internalScrollTop.value + clipY + (point.y - r.y);
1366
+ if (visualY < 0 || visualY >= rows.value.length) return null;
1367
+ return {
1368
+ x: clamp(clipX + (point.x - r.x), 0, Math.max(0, props.w - 1)),
1369
+ y: visualY
1370
+ };
1371
+ }
1372
+ function canHandleSelectionRange(range) {
1373
+ return Boolean(selectionPointForCell(range.anchor) && selectionPointForCell(range.focus));
1374
+ }
1375
+ function textForSelectionRange(range) {
1376
+ const cols = Math.max(1, Math.floor(props.w));
1377
+ return terminalSelectionRowSpans(range, cols, rows.value.length).map((span) => {
1378
+ const text = sliceByCellsRange(rows.value[span.y]?.plainText ?? "", span.x0, span.x1);
1379
+ return span.x1 >= cols ? text.trimEnd() : text;
1380
+ }).join("\n");
1381
+ }
1382
+ function visibleSpansForSelectionRange(providerRange, _screenRange) {
1383
+ const r = normalizedRect();
1384
+ const { x: clipX, y: clipY } = clipOffsets();
1385
+ const cols = Math.max(1, Math.floor(props.w));
1386
+ const top = internalScrollTop.value + clipY;
1387
+ const bottom = top + r.h;
1388
+ const providerSpans = terminalSelectionVisibleRowSpans(providerRange, cols, rows.value.length, top, bottom);
1389
+ const result = [];
1390
+ for (const span of providerSpans) {
1391
+ const screenY = r.y + (span.y - top);
1392
+ const screenX0 = r.x + span.x0 - clipX;
1393
+ const screenX1 = r.x + span.x1 - clipX;
1394
+ const x0 = Math.max(r.x, screenX0);
1395
+ const x1 = Math.min(r.x + r.w, screenX1);
1396
+ if (screenY >= r.y && screenY < r.y + r.h && x1 > x0) result.push({
1397
+ y: screenY,
1398
+ x0,
1399
+ x1
1400
+ });
1401
+ }
1402
+ return result;
1403
+ }
1348
1404
  function onKeydown(event) {
1349
1405
  emit("keydown", event);
1350
1406
  const page = Math.max(1, normalizedRect().h);
@@ -1378,22 +1434,34 @@ const TVirtualMarkdown = defineComponent({
1378
1434
  setScrollTop(maxScrollTop());
1379
1435
  }
1380
1436
  }
1437
+ const selectionTextProvider = {
1438
+ id: `TVirtualMarkdown:${instance?.uid ?? "unknown"}:selection-text`,
1439
+ get rect() {
1440
+ return normalizedRect();
1441
+ },
1442
+ canHandle: canHandleSelectionRange,
1443
+ pointForCell: selectionPointForCell,
1444
+ getText: textForSelectionRange,
1445
+ getVisibleSpans: visibleSpansForSelectionRange
1446
+ };
1447
+ const unregisterSelectionTextProvider = selection.registerTextProvider(selectionTextProvider);
1448
+ onBeforeUnmount(unregisterSelectionTextProvider);
1381
1449
  const eventNode = useTerminalNode(() => ({
1382
1450
  rect: normalizedRect(),
1383
1451
  zIndex: eventZ.value,
1384
1452
  visible: visible.value,
1385
1453
  focusable: true,
1386
1454
  selectable: props.selectable,
1455
+ selectionScrollBy: scrollSelectionBy,
1387
1456
  handlers: {
1388
1457
  click: (_event) => {},
1389
1458
  wheel: (event) => {
1390
- var _event$preventDefault;
1391
1459
  const { deltaY, mode } = getWheelScrollInput(event);
1392
1460
  if (!deltaY) return;
1393
1461
  const now = typeof event.time === "number" ? event.time : typeof event.timeStamp === "number" ? event.timeStamp : Date.now();
1394
1462
  const { nextTop, dir } = applyWheelScroll(wheelState, deltaY, internalScrollTop.value, maxScrollTop(), now, mode, { disableAcceleration: mode === "pixel" });
1395
1463
  if (!dir || nextTop === internalScrollTop.value) return;
1396
- (_event$preventDefault = event.preventDefault) === null || _event$preventDefault === void 0 || _event$preventDefault.call(event);
1464
+ event.preventDefault?.();
1397
1465
  setScrollTop(nextTop);
1398
1466
  },
1399
1467
  focus: () => {
@@ -1453,7 +1521,7 @@ const TVirtualMarkdown = defineComponent({
1453
1521
  clear: true
1454
1522
  });
1455
1523
  };
1456
- if (dirtyRows === null || dirtyRows === void 0 ? void 0 : dirtyRows.length) {
1524
+ if (dirtyRows?.length) {
1457
1525
  for (const y of dirtyRows) paintRow(y);
1458
1526
  return;
1459
1527
  }
@@ -1513,11 +1581,11 @@ function mergeGroups(groups) {
1513
1581
  return out;
1514
1582
  }
1515
1583
  function createMarkdownBlockSource(options) {
1516
- const parser = (options === null || options === void 0 ? void 0 : options.parser) ?? createTuiMarkdownParser({
1584
+ const parser = options?.parser ?? createTuiMarkdownParser({
1517
1585
  streaming: true,
1518
- customHtmlTags: options === null || options === void 0 ? void 0 : options.customHtmlTags
1586
+ customHtmlTags: options?.customHtmlTags
1519
1587
  });
1520
- const theme = options === null || options === void 0 ? void 0 : options.theme;
1588
+ const theme = options?.theme;
1521
1589
  const finalizedGroups = [];
1522
1590
  let tailText = "";
1523
1591
  let nextGroupIndex = 0;
@@ -0,0 +1,3 @@
1
+ import type { CliLatencyProfiler } from "./cli-latency-types.js";
2
+ export declare function defaultCliLatencyLogPath(): string;
3
+ export declare function getCliLatencyProfiler(): CliLatencyProfiler | null;