@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.
Files changed (249) hide show
  1. package/README.md +142 -30
  2. package/dist/TSelect-BwJJbuTt.js +6089 -0
  3. package/dist/TTree-DK_DQBYm.js +6480 -0
  4. package/dist/agent.cjs +39416 -0
  5. package/dist/agent.d.cts +44 -0
  6. package/dist/agent.d.ts +44 -0
  7. package/dist/agent.js +828 -0
  8. package/dist/ansi-palette-CNXqFciC.js +57 -0
  9. package/dist/ansi-styles.d.ts +200 -0
  10. package/dist/block-source-CKUOnkgT.js +1663 -0
  11. package/dist/cli/headless-renderer.d.ts +29 -0
  12. package/dist/cli/input.d.ts +49 -0
  13. package/dist/cli/node-file-writers.d.ts +13 -0
  14. package/dist/cli/node-module.d.ts +2 -0
  15. package/dist/cli/parse-kitty.d.ts +2 -0
  16. package/dist/cli/parse-mouse.d.ts +2 -0
  17. package/dist/cli/parse-utils.d.ts +14 -0
  18. package/dist/cli/parse-xterm.d.ts +2 -0
  19. package/dist/cli/path-provider-types.d.ts +1 -0
  20. package/dist/cli/path-provider.d.ts +4 -0
  21. package/dist/cli/path-suggest-core.d.ts +1 -0
  22. package/dist/cli/path-suggest.d.ts +15 -0
  23. package/dist/cli/recording.d.ts +4 -0
  24. package/dist/cli/stdin-buffer.d.ts +33 -0
  25. package/dist/cli.cjs +11061 -0
  26. package/dist/cli.d.cts +23 -0
  27. package/dist/cli.d.ts +23 -0
  28. package/dist/cli.js +9875 -0
  29. package/dist/core/ansi/capability.d.ts +20 -0
  30. package/dist/core/ansi/colors.d.ts +41 -0
  31. package/dist/core/ansi/sgr.d.ts +7 -0
  32. package/dist/core/ansi/theme.d.ts +6 -0
  33. package/dist/core/ansi-palette.d.ts +14 -0
  34. package/dist/core/buffer/buffer.d.ts +54 -0
  35. package/dist/core/buffer/width.d.ts +4 -0
  36. package/dist/core/debug-logger.d.ts +18 -0
  37. package/dist/core/hyperlink.d.ts +9 -0
  38. package/dist/core/index.d.ts +4 -0
  39. package/dist/core/path-provider-types.d.ts +24 -0
  40. package/dist/core/path-suggest.d.ts +35 -0
  41. package/dist/core/render-plane.d.ts +3 -0
  42. package/dist/core/terminal/create-terminal.d.ts +8 -0
  43. package/dist/core/terminal/emitter.d.ts +7 -0
  44. package/dist/core/types.d.ts +107 -0
  45. package/dist/core.cjs +3153 -0
  46. package/dist/core.d.cts +14 -0
  47. package/dist/core.d.ts +14 -0
  48. package/dist/core.js +424 -0
  49. package/dist/create-terminal-C2oiWFJU.js +1434 -0
  50. package/dist/create-terminal-app.d.ts +36 -0
  51. package/dist/dom-renderer-BqGijQID.js +1173 -0
  52. package/dist/env-Cl8qmNFN.js +19 -0
  53. package/dist/events/index.d.ts +6 -0
  54. package/dist/events/manager/cli-event-manager.d.ts +22 -0
  55. package/dist/events/manager/event-manager.d.ts +30 -0
  56. package/dist/events/manager/selection-suppression.d.ts +3 -0
  57. package/dist/events/manager/types.d.ts +108 -0
  58. package/dist/events/recording.d.ts +44 -0
  59. package/dist/experimental.cjs +4412 -1641
  60. package/dist/experimental.d.cts +42 -0
  61. package/dist/experimental.d.ts +42 -825
  62. package/dist/experimental.js +31 -7392
  63. package/dist/frame-perf-C6Xfg85O.js +24 -0
  64. package/dist/hyperlink-Bn02UXJb.js +419 -0
  65. package/dist/index.cjs +14765 -17582
  66. package/dist/index.d.cts +35 -0
  67. package/dist/index.d.ts +35 -1528
  68. package/dist/index.js +17 -20026
  69. package/dist/linkify-D_gzn9Xq.js +562 -0
  70. package/dist/markdown.cjs +9321 -7623
  71. package/dist/markdown.d.cts +11 -0
  72. package/dist/markdown.d.ts +11 -112
  73. package/dist/markdown.js +36 -1427
  74. package/dist/observability/cli-latency-node.d.ts +3 -0
  75. package/dist/observability/cli-latency-types.d.ts +41 -0
  76. package/dist/observability/cli-latency.d.ts +3 -0
  77. package/dist/observability/frame-perf-store.d.ts +18 -0
  78. package/dist/observability/frame-perf.d.ts +40 -0
  79. package/dist/observability/perf-sink.d.ts +56 -0
  80. package/dist/observability/trace.d.ts +40 -0
  81. package/dist/observability/tui-profiler.d.ts +33 -0
  82. package/dist/observability.cjs +221 -0
  83. package/dist/observability.d.cts +8 -0
  84. package/dist/observability.d.ts +8 -0
  85. package/dist/observability.js +4 -0
  86. package/dist/path-mnSgEpCm.js +81 -0
  87. package/dist/path-suggest-BNqcuE3-.js +274 -0
  88. package/dist/path-suggest-Dk9TRLh5.js +3 -0
  89. package/dist/{path-suggest-DmrmeueH.js → path-suggest-bvR9SY6Q.js} +86 -18
  90. package/dist/renderer/capabilities.d.ts +13 -0
  91. package/dist/renderer/cli/index.d.ts +2 -0
  92. package/dist/renderer/cli/stdout-metrics.d.ts +18 -0
  93. package/dist/renderer/cli/stdout-renderer.d.ts +48 -0
  94. package/dist/renderer/dom/dom-renderer.d.ts +157 -0
  95. package/dist/renderer/dom/index.d.ts +2 -0
  96. package/dist/renderer/index.d.ts +2 -0
  97. package/dist/renderer-dom.cjs +1505 -0
  98. package/dist/renderer-dom.d.cts +4 -0
  99. package/dist/renderer-dom.d.ts +4 -0
  100. package/dist/renderer-dom.js +7 -0
  101. package/dist/runtime/index.d.ts +36 -0
  102. package/dist/runtime/osc52.d.ts +9 -0
  103. package/dist/runtime-rfcZCyJq.js +1197 -0
  104. package/dist/runtime.cjs +1698 -0
  105. package/dist/runtime.d.cts +9 -0
  106. package/dist/runtime.d.ts +9 -0
  107. package/dist/runtime.js +4 -0
  108. package/dist/selection/terminal-selection.d.ts +123 -0
  109. package/dist/sgr-BmzxEjAO.js +304 -0
  110. package/dist/terminal-selection-DBinO6p5.js +330 -0
  111. package/dist/tlog-theme-qPBt5rge.js +9254 -0
  112. package/dist/trace-CjzYeIxN.js +182 -0
  113. package/dist/utils/env.d.ts +3 -0
  114. package/dist/utils/grapheme.d.ts +5 -0
  115. package/dist/utils/newlines.d.ts +1 -0
  116. package/dist/utils/path.d.ts +7 -0
  117. package/dist/utils/url-safety.d.ts +2 -0
  118. package/dist/vue/agent/view-models.d.ts +98 -0
  119. package/dist/vue/components/TAnchor.d.ts +108 -0
  120. package/dist/vue/components/TBox.d.ts +144 -0
  121. package/dist/vue/components/TCommandPalette.d.ts +587 -0
  122. package/dist/vue/components/TDataTable.d.ts +367 -0
  123. package/dist/vue/components/TDebugOverlay.d.ts +43 -0
  124. package/dist/vue/components/TDialog.d.ts +255 -0
  125. package/dist/vue/components/TFeedback.d.ts +635 -0
  126. package/dist/vue/components/TFlow.d.ts +85 -0
  127. package/dist/vue/components/TForm.d.ts +1230 -0
  128. package/dist/vue/components/TInput.d.ts +545 -0
  129. package/dist/vue/components/TInputBox.d.ts +158 -0
  130. package/dist/vue/components/TJsonEditor.d.ts +165 -0
  131. package/dist/vue/components/TLink.d.ts +239 -0
  132. package/dist/vue/components/TLinkifyText.d.ts +141 -0
  133. package/dist/vue/components/TList.d.ts +119 -0
  134. package/dist/vue/components/TLogLinksPanel.d.ts +238 -0
  135. package/dist/vue/components/TLogMinimap.d.ts +263 -0
  136. package/dist/vue/components/TLogScrollbar.d.ts +236 -0
  137. package/dist/vue/components/TLogSearchBar.d.ts +267 -0
  138. package/dist/vue/components/TLogSearchPager.d.ts +162 -0
  139. package/dist/vue/components/TLogSearchResults.d.ts +200 -0
  140. package/dist/vue/components/TLogView.d.ts +536 -0
  141. package/dist/vue/components/TLogVirtualLinksPanel.d.ts +141 -0
  142. package/dist/vue/components/TLogVirtualSearchResults.d.ts +146 -0
  143. package/dist/vue/components/TMarkdownText.d.ts +134 -0
  144. package/dist/vue/components/TMultilineModal.d.ts +62 -0
  145. package/dist/vue/components/TNavigation.d.ts +324 -0
  146. package/dist/vue/components/TOverlay.d.ts +366 -0
  147. package/dist/vue/components/TPanels.d.ts +244 -0
  148. package/dist/vue/components/TPathPicker.d.ts +213 -0
  149. package/dist/vue/components/TRenderLayer.d.ts +16 -0
  150. package/dist/vue/components/TRenderPlane.d.ts +17 -0
  151. package/dist/vue/components/TSelect.d.ts +335 -0
  152. package/dist/vue/components/TTable.d.ts +317 -0
  153. package/dist/vue/components/TText.d.ts +116 -0
  154. package/dist/vue/components/TThinkingView.d.ts +233 -0
  155. package/dist/vue/components/TToolCallView.d.ts +384 -0
  156. package/dist/vue/components/TTranscriptView.d.ts +221 -0
  157. package/dist/vue/components/TTransition.d.ts +83 -0
  158. package/dist/vue/components/TTree.d.ts +200 -0
  159. package/dist/vue/components/TUserMessageView.d.ts +344 -0
  160. package/dist/vue/components/TView.d.ts +127 -0
  161. package/dist/vue/components/TVirtualList.d.ts +182 -0
  162. package/dist/vue/components/TVirtualMarkdown.d.ts +168 -0
  163. package/dist/vue/components/TVirtualRows.d.ts +247 -0
  164. package/dist/vue/components/TerminalProvider.d.ts +218 -0
  165. package/dist/vue/components/input/host.d.ts +17 -0
  166. package/dist/vue/components/input/plugins/hostPlugin.d.ts +7 -0
  167. package/dist/vue/components/input/plugins/hostPlugin.node.d.ts +15 -0
  168. package/dist/vue/components/input/plugins/mentionUtils.d.ts +17 -0
  169. package/dist/vue/components/input/plugins/nodeMentionPathProvider.d.ts +2 -0
  170. package/dist/vue/components/input/plugins/promptMentionPlugin.d.ts +8 -0
  171. package/dist/vue/components/input/plugins/promptMentionState.d.ts +98 -0
  172. package/dist/vue/components/input/plugins/restrictText.d.ts +27 -0
  173. package/dist/vue/components/input/plugins/types.d.ts +90 -0
  174. package/dist/vue/components/input/utils/inlineText.d.ts +57 -0
  175. package/dist/vue/components/input/utils/inlineTextTokens.d.ts +34 -0
  176. package/dist/vue/components/input/utils/primitives.d.ts +3 -0
  177. package/dist/vue/components/input/utils/wordNavigation.d.ts +6 -0
  178. package/dist/vue/components/link/host.d.ts +15 -0
  179. package/dist/vue/components/list/list-geometry.d.ts +16 -0
  180. package/dist/vue/components/list/list-paint.d.ts +1 -0
  181. package/dist/vue/components/list/scroll-state.d.ts +25 -0
  182. package/dist/vue/components/list/selection-state.d.ts +6 -0
  183. package/dist/vue/components/simple-utils.d.ts +5 -0
  184. package/dist/vue/components/terminal-provider/copy-toast.d.ts +6 -0
  185. package/dist/vue/components/terminal-provider/portals.d.ts +17 -0
  186. package/dist/vue/components/terminal-provider/scheduler.d.ts +29 -0
  187. package/dist/vue/components/terminal-provider/selection-config.d.ts +15 -0
  188. package/dist/vue/components/terminal-provider/utils.d.ts +5 -0
  189. package/dist/vue/composables/use-layout.d.ts +2 -0
  190. package/dist/vue/composables/use-render-node.d.ts +19 -0
  191. package/dist/vue/composables/use-render-stack.d.ts +3 -0
  192. package/dist/vue/composables/use-runtime.d.ts +5 -0
  193. package/dist/vue/composables/use-terminal-node.d.ts +14 -0
  194. package/dist/vue/composables/use-terminal.d.ts +2 -0
  195. package/dist/vue/composables/use-visibility.d.ts +12 -0
  196. package/dist/vue/context.d.ts +153 -0
  197. package/dist/vue/index.d.ts +69 -0
  198. package/dist/vue/injection-key.d.ts +2 -0
  199. package/dist/vue/linkify.d.ts +11 -0
  200. package/dist/vue/log/append-only-log-store.d.ts +2 -0
  201. package/dist/vue/log/tlog-keymap.d.ts +28 -0
  202. package/dist/vue/log/tlog-plugins.d.ts +144 -0
  203. package/dist/vue/log/tlog-session.d.ts +81 -0
  204. package/dist/vue/log/tlog-theme.d.ts +68 -0
  205. package/dist/vue/log/types.d.ts +43 -0
  206. package/dist/vue/log/use-tlog-link-controller.d.ts +31 -0
  207. package/dist/vue/log/use-tlog-retained-index.d.ts +26 -0
  208. package/dist/vue/log/use-tlog-search-controller.d.ts +51 -0
  209. package/dist/vue/log/use-tlog-search-results-page.d.ts +31 -0
  210. package/dist/vue/log/use-tlog-virtual-search-results.d.ts +22 -0
  211. package/dist/vue/markdown/ast.d.ts +3 -0
  212. package/dist/vue/markdown/block-source.d.ts +22 -0
  213. package/dist/vue/markdown/document.d.ts +20 -0
  214. package/dist/vue/markdown/layout.d.ts +21 -0
  215. package/dist/vue/markdown/parser.d.ts +11 -0
  216. package/dist/vue/markdown/render.d.ts +10 -0
  217. package/dist/vue/markdown/theme.d.ts +186 -0
  218. package/dist/vue/markdown/types.d.ts +59 -0
  219. package/dist/vue/overlay.d.ts +27 -0
  220. package/dist/vue/render/context.d.ts +3 -0
  221. package/dist/vue/render/render-manager.d.ts +94 -0
  222. package/dist/vue/router/RouterView.d.ts +25 -0
  223. package/dist/vue/router/composables.d.ts +4 -0
  224. package/dist/vue/router/context.d.ts +4 -0
  225. package/dist/vue/router/router.d.ts +7 -0
  226. package/dist/vue/router/types.d.ts +29 -0
  227. package/dist/vue/scheduler/frame-mailbox.d.ts +55 -0
  228. package/dist/vue/scheduler/frame-scheduler.d.ts +51 -0
  229. package/dist/vue/theme.d.ts +48 -0
  230. package/dist/vue/transcript/hit-regions.d.ts +2 -0
  231. package/dist/vue/transcript/layout.d.ts +20 -0
  232. package/dist/vue/transcript/plain-text.d.ts +2 -0
  233. package/dist/vue/transcript/types.d.ts +122 -0
  234. package/dist/vue/utils/frame-task.d.ts +6 -0
  235. package/dist/vue/utils/rect.d.ts +4 -0
  236. package/dist/vue/utils/row-scroll.d.ts +25 -0
  237. package/dist/vue/utils/style-cache.d.ts +3 -0
  238. package/dist/vue/utils/text.d.ts +27 -0
  239. package/dist/vue/utils/wheel-scroll.d.ts +18 -0
  240. package/dist/vue.cjs +23668 -0
  241. package/dist/vue.d.cts +1 -0
  242. package/dist/vue.d.ts +1 -0
  243. package/dist/vue.js +3957 -0
  244. package/dist/{wheel-scroll-CiNsasLf.js → wheel-scroll-vBRaQ7p-.js} +404 -405
  245. package/package.json +185 -35
  246. package/dist/path-suggest-BeV6n7m-.js +0 -3
  247. package/dist/sgr-Tko2EQ0U.js +0 -484
  248. package/dist/theme-Bsm65g8k.d.ts +0 -32
  249. package/dist/types-ClIV2h1o.d.ts +0 -103
@@ -0,0 +1,562 @@
1
+ import { sanitizeDomHref } from "./hyperlink-Bn02UXJb.js";
2
+ import { EventZIndexContextKey, LayoutContextKey, RenderStackKey, injectionKey, intersectRect, translateRect, useLayout, useRenderStack, useTerminal, useTerminalNode, useVisibility } from "./wheel-scroll-vBRaQ7p-.js";
3
+ import { computed, defineComponent, h, inject, provide, shallowReactive, watchEffect } from "vue";
4
+
5
+ //#region src/vue/theme.ts
6
+ const tuiDefaultTheme = Object.freeze({
7
+ colors: Object.freeze({
8
+ link: "cyanBright",
9
+ linkVisited: "magentaBright",
10
+ danger: "redBright",
11
+ success: "greenBright",
12
+ warning: "yellowBright",
13
+ info: "cyanBright",
14
+ muted: "white",
15
+ accent: "blueBright"
16
+ }),
17
+ components: Object.freeze({
18
+ TLink: Object.freeze({
19
+ style: Object.freeze({
20
+ fg: "cyanBright",
21
+ underline: true
22
+ }),
23
+ hoverStyle: Object.freeze({ underline: true }),
24
+ focusStyle: Object.freeze({ inverse: true }),
25
+ visitedStyle: Object.freeze({
26
+ fg: "magentaBright",
27
+ underline: true
28
+ }),
29
+ underline: true,
30
+ hoverUnderline: true
31
+ }),
32
+ TTable: Object.freeze({
33
+ headerStyle: Object.freeze({
34
+ bold: true,
35
+ underline: true
36
+ }),
37
+ borderStyle: Object.freeze({ dim: true }),
38
+ rowStyle: Object.freeze({}),
39
+ selectedStyle: Object.freeze({ inverse: true }),
40
+ activeStyle: Object.freeze({ underline: true })
41
+ }),
42
+ TFormField: Object.freeze({
43
+ labelStyle: Object.freeze({ bold: true }),
44
+ helpStyle: Object.freeze({ dim: true }),
45
+ errorStyle: Object.freeze({ fg: "redBright" })
46
+ })
47
+ })
48
+ });
49
+ function mergeStyleToken(base, override) {
50
+ if (!base && !override) return void 0;
51
+ return {
52
+ ...base ?? {},
53
+ ...override ?? {}
54
+ };
55
+ }
56
+ function createTheme(overrides = {}) {
57
+ const components = overrides.components ?? {};
58
+ const link = components.TLink;
59
+ const table = components.TTable;
60
+ const formField = components.TFormField;
61
+ const defaultLink = tuiDefaultTheme.components.TLink;
62
+ const defaultTable = tuiDefaultTheme.components.TTable;
63
+ const defaultFormField = tuiDefaultTheme.components.TFormField;
64
+ const colors = {
65
+ ...tuiDefaultTheme.colors,
66
+ ...overrides.colors ?? {}
67
+ };
68
+ const defaultLinkFromColors = {
69
+ ...defaultLink ?? {},
70
+ style: mergeStyleToken(defaultLink?.style, colors.link ? { fg: colors.link } : void 0),
71
+ visitedStyle: mergeStyleToken(defaultLink?.visitedStyle, colors.linkVisited ? { fg: colors.linkVisited } : void 0)
72
+ };
73
+ const linkStyle = link?.underline === false ? mergeStyleToken(mergeStyleToken(defaultLinkFromColors.style, link?.style), { underline: false }) : mergeStyleToken(defaultLinkFromColors.style, link?.style);
74
+ const linkVisitedStyle = link?.underline === false ? mergeStyleToken(mergeStyleToken(defaultLinkFromColors.visitedStyle, link?.visitedStyle), { underline: false }) : mergeStyleToken(defaultLinkFromColors.visitedStyle, link?.visitedStyle);
75
+ const linkHoverStyle = mergeStyleToken(defaultLinkFromColors.hoverStyle, link?.hoverStyle);
76
+ return {
77
+ colors,
78
+ components: {
79
+ TLink: {
80
+ ...defaultLinkFromColors,
81
+ ...link ?? {},
82
+ style: linkStyle,
83
+ hoverStyle: link?.hoverUnderline === false && link?.hoverStyle?.underline == null ? mergeStyleToken(linkHoverStyle, { underline: false }) : linkHoverStyle,
84
+ focusStyle: mergeStyleToken(defaultLinkFromColors.focusStyle, link?.focusStyle),
85
+ visitedStyle: linkVisitedStyle
86
+ },
87
+ TTable: {
88
+ ...defaultTable ?? {},
89
+ ...table ?? {},
90
+ headerStyle: mergeStyleToken(defaultTable?.headerStyle, table?.headerStyle),
91
+ borderStyle: mergeStyleToken(defaultTable?.borderStyle, table?.borderStyle),
92
+ rowStyle: mergeStyleToken(defaultTable?.rowStyle, table?.rowStyle),
93
+ selectedStyle: mergeStyleToken(defaultTable?.selectedStyle, table?.selectedStyle),
94
+ activeStyle: mergeStyleToken(defaultTable?.activeStyle, table?.activeStyle)
95
+ },
96
+ TFormField: {
97
+ ...defaultFormField ?? {},
98
+ ...formField ?? {},
99
+ labelStyle: mergeStyleToken(defaultFormField?.labelStyle, formField?.labelStyle),
100
+ helpStyle: mergeStyleToken(defaultFormField?.helpStyle, formField?.helpStyle),
101
+ errorStyle: mergeStyleToken(defaultFormField?.errorStyle, formField?.errorStyle)
102
+ }
103
+ }
104
+ };
105
+ }
106
+ const TuiThemeContextKey = injectionKey("TuiTheme");
107
+
108
+ //#endregion
109
+ //#region src/vue/components/TView.ts
110
+ const EMPTY_RECT = Object.freeze({
111
+ x: 0,
112
+ y: 0,
113
+ w: 0,
114
+ h: 0
115
+ });
116
+ const TView = defineComponent({
117
+ name: "TView",
118
+ props: {
119
+ x: {
120
+ type: Number,
121
+ required: true
122
+ },
123
+ y: {
124
+ type: Number,
125
+ required: true
126
+ },
127
+ w: {
128
+ type: Number,
129
+ required: true
130
+ },
131
+ h: {
132
+ type: Number,
133
+ required: true
134
+ },
135
+ zIndex: {
136
+ type: Number,
137
+ default: 0
138
+ },
139
+ scrollX: {
140
+ type: Number,
141
+ default: 0
142
+ },
143
+ scrollY: {
144
+ type: Number,
145
+ default: 0
146
+ },
147
+ focusable: {
148
+ type: Boolean,
149
+ default: false
150
+ },
151
+ selectable: {
152
+ type: Boolean,
153
+ default: void 0
154
+ },
155
+ selectionScrollBy: {
156
+ type: Function,
157
+ default: void 0
158
+ },
159
+ autoFocus: {
160
+ type: Boolean,
161
+ default: false
162
+ }
163
+ },
164
+ emits: [
165
+ "clickCapture",
166
+ "click",
167
+ "dblclickCapture",
168
+ "dblclick",
169
+ "pointerdownCapture",
170
+ "pointerdown",
171
+ "pointerupCapture",
172
+ "pointerup",
173
+ "pointermoveCapture",
174
+ "pointermove",
175
+ "pointerenterCapture",
176
+ "pointerenter",
177
+ "pointerleaveCapture",
178
+ "pointerleave",
179
+ "wheelCapture",
180
+ "wheel",
181
+ "keydownCapture",
182
+ "keydown",
183
+ "keyupCapture",
184
+ "keyup",
185
+ "focusCapture",
186
+ "focus",
187
+ "blurCapture",
188
+ "blur"
189
+ ],
190
+ setup(props, { emit, slots }) {
191
+ const parent = useLayout();
192
+ const { render, events } = useTerminal();
193
+ const parentStack = useRenderStack();
194
+ const { visible, rootProps } = useVisibility({ provide: true });
195
+ const parentEventZ = inject(EventZIndexContextKey, computed(() => 0));
196
+ const eventZ = computed(() => (parentEventZ.value ?? 0) + (props.zIndex ?? 0));
197
+ const rawRect = computed(() => translateRect({
198
+ x: props.x,
199
+ y: props.y,
200
+ w: props.w,
201
+ h: props.h
202
+ }, parent.originX, parent.originY));
203
+ const rect = computed(() => {
204
+ const translated = rawRect.value;
205
+ if (!parent.clipRect) return translated;
206
+ return intersectRect(translated, parent.clipRect) ?? EMPTY_RECT;
207
+ });
208
+ const { id } = useTerminalNode(() => ({
209
+ rect: rect.value,
210
+ zIndex: eventZ.value,
211
+ visible: visible.value,
212
+ focusable: props.focusable,
213
+ selectable: props.selectable,
214
+ selectionScrollBy: props.selectionScrollBy,
215
+ handlers: {
216
+ clickCapture: (e) => emit("clickCapture", e),
217
+ click: (e) => emit("click", e),
218
+ dblclickCapture: (e) => emit("dblclickCapture", e),
219
+ dblclick: (e) => emit("dblclick", e),
220
+ pointerdownCapture: (e) => emit("pointerdownCapture", e),
221
+ pointerdown: (e) => emit("pointerdown", e),
222
+ pointerupCapture: (e) => emit("pointerupCapture", e),
223
+ pointerup: (e) => emit("pointerup", e),
224
+ pointermoveCapture: (e) => emit("pointermoveCapture", e),
225
+ pointermove: (e) => emit("pointermove", e),
226
+ pointerenterCapture: (e) => emit("pointerenterCapture", e),
227
+ pointerenter: (e) => emit("pointerenter", e),
228
+ pointerleaveCapture: (e) => emit("pointerleaveCapture", e),
229
+ pointerleave: (e) => emit("pointerleave", e),
230
+ wheelCapture: (e) => emit("wheelCapture", e),
231
+ wheel: (e) => emit("wheel", e),
232
+ keydownCapture: (e) => emit("keydownCapture", e),
233
+ keydown: (e) => emit("keydown", e),
234
+ keyupCapture: (e) => emit("keyupCapture", e),
235
+ keyup: (e) => emit("keyup", e),
236
+ focusCapture: (e) => emit("focusCapture", e),
237
+ focus: (e) => emit("focus", e),
238
+ blurCapture: (e) => emit("blurCapture", e),
239
+ blur: (e) => emit("blur", e)
240
+ }
241
+ }));
242
+ watchEffect(() => {
243
+ if (!props.autoFocus) return;
244
+ if (!visible.value) return;
245
+ const manager = events.value;
246
+ const nodeId = id.value;
247
+ if (!manager || !nodeId) return;
248
+ if (manager.getFocused() === nodeId) return;
249
+ manager.focus(nodeId);
250
+ });
251
+ const childLayout = shallowReactive({
252
+ originX: 0,
253
+ originY: 0,
254
+ clipRect: null
255
+ });
256
+ const childStack = computed(() => render.createStack(parentStack.value, props.zIndex));
257
+ watchEffect(() => {
258
+ const translated = rawRect.value;
259
+ childLayout.originX = translated.x - Math.floor(props.scrollX);
260
+ childLayout.originY = translated.y - Math.floor(props.scrollY);
261
+ childLayout.clipRect = rect.value;
262
+ });
263
+ provide(LayoutContextKey, childLayout);
264
+ provide(RenderStackKey, childStack);
265
+ provide(EventZIndexContextKey, eventZ);
266
+ return () => h("div", rootProps, slots.default?.());
267
+ }
268
+ });
269
+
270
+ //#endregion
271
+ //#region src/vue/scheduler/frame-mailbox.ts
272
+ const EMPTY = Symbol("frame-mailbox-empty");
273
+ /**
274
+ * Coalesces many producer updates into a single scheduler frame task.
275
+ *
276
+ * This helper is currently internal to vue-tui. It is used by library
277
+ * components and internal tests, but it is not exported from the package root.
278
+ *
279
+ * Default behavior keeps only the latest queued value. If `merge` is provided,
280
+ * the pending value is updated with `merge(prev, next)`.
281
+ *
282
+ * Only the first queue() call in a pending cycle schedules a frame task.
283
+ * Later queue() calls update the pending payload and are reported as dropped
284
+ * producer updates when the frame task runs.
285
+ *
286
+ * droppedUpdates are reported after apply() succeeds. They only appear in
287
+ * framePerf when apply() also invalidates and produces a rendered frame sample.
288
+ * If apply() throws, scheduler error stats include mailbox queued/dropped
289
+ * metadata for the failed delivery attempt. The pending payload has already
290
+ * been cleared; mailbox delivery is fail-fast and does not retry stale payloads
291
+ * on later frames.
292
+ *
293
+ * cancel() is best-effort at scheduler level. The run callback still guards
294
+ * `disposed || !hasPending`, because a scheduler may already have taken a
295
+ * snapshot of tasks for the current frame.
296
+ *
297
+ * queue() returns false only when the scheduler explicitly rejects the task.
298
+ * Legacy void-returning schedulers are treated as accepted for compatibility.
299
+ * Owners should call dispose() before the component/scope that owns the
300
+ * mailbox is destroyed.
301
+ *
302
+ * id is scheduler-global. Components should include instance id and producer
303
+ * name, for example `TList:${uid}:wheel`.
304
+ */
305
+ function createFrameMailbox(options) {
306
+ let disposed = false;
307
+ let hasPending = false;
308
+ let pending = EMPTY;
309
+ let queued = 0;
310
+ let pendingTaskId = null;
311
+ function clearPending() {
312
+ hasPending = false;
313
+ pending = EMPTY;
314
+ queued = 0;
315
+ pendingTaskId = null;
316
+ }
317
+ function currentTaskId() {
318
+ if (pendingTaskId) return pendingTaskId;
319
+ const id = typeof options.id === "function" ? options.id() : options.id;
320
+ if (!id) throw new Error("createFrameMailbox requires a non-empty task id");
321
+ pendingTaskId = id;
322
+ return pendingTaskId;
323
+ }
324
+ function queue(value) {
325
+ if (disposed) return false;
326
+ const wasPending = hasPending;
327
+ const taskId = wasPending ? pendingTaskId : currentTaskId();
328
+ let nextPending;
329
+ try {
330
+ nextPending = hasPending && options.merge ? options.merge(pending, value) : value;
331
+ } catch (error) {
332
+ clearPending();
333
+ if (wasPending) options.scheduler.cancelFrameTask?.(taskId);
334
+ throw error;
335
+ }
336
+ pending = nextPending;
337
+ hasPending = true;
338
+ queued++;
339
+ if (wasPending) return true;
340
+ let accepted;
341
+ try {
342
+ accepted = options.scheduler.queueFrameTask({
343
+ id: taskId,
344
+ reason: options.reason,
345
+ priority: options.priority,
346
+ sync: options.sync,
347
+ run(ctx) {
348
+ if (disposed || !hasPending) return;
349
+ const value$1 = pending;
350
+ const count = queued;
351
+ const dropped = Math.max(0, count - 1);
352
+ clearPending();
353
+ ctx.reportMailboxDeliveryAttempt?.({
354
+ id: taskId,
355
+ queued: count,
356
+ dropped
357
+ });
358
+ options.apply(value$1, ctx, {
359
+ queued: count,
360
+ dropped
361
+ });
362
+ ctx.reportDroppedUpdates?.(dropped);
363
+ }
364
+ });
365
+ } catch (error) {
366
+ clearPending();
367
+ throw error;
368
+ }
369
+ if (accepted === false) {
370
+ clearPending();
371
+ return false;
372
+ }
373
+ return true;
374
+ }
375
+ function replacePending(value) {
376
+ if (disposed) return false;
377
+ if (!hasPending) return queue(value);
378
+ pending = value;
379
+ return true;
380
+ }
381
+ function cancel() {
382
+ const taskId = pendingTaskId;
383
+ clearPending();
384
+ if (taskId) options.scheduler.cancelFrameTask?.(taskId);
385
+ }
386
+ function dispose() {
387
+ cancel();
388
+ disposed = true;
389
+ }
390
+ return {
391
+ queue,
392
+ replacePending,
393
+ cancel,
394
+ dispose,
395
+ hasPending: () => hasPending,
396
+ peek: () => hasPending ? pending : void 0
397
+ };
398
+ }
399
+
400
+ //#endregion
401
+ //#region src/vue/utils/style-cache.ts
402
+ const EMPTY_STYLE = Object.freeze({});
403
+ const inverseStyleCache = new WeakMap();
404
+ const dimStyleCache = new WeakMap();
405
+ function cacheBase(base) {
406
+ for (const key in base) if (Object.prototype.hasOwnProperty.call(base, key)) return base;
407
+ return EMPTY_STYLE;
408
+ }
409
+ function cacheable(base) {
410
+ return Object.isFrozen(base);
411
+ }
412
+ function defaultActiveStyle(base) {
413
+ if (base.inverse) return base;
414
+ base = cacheBase(base);
415
+ if (!cacheable(base)) return {
416
+ ...base,
417
+ inverse: true
418
+ };
419
+ let cached = inverseStyleCache.get(base);
420
+ if (!cached) {
421
+ cached = Object.freeze({
422
+ ...base,
423
+ inverse: true
424
+ });
425
+ inverseStyleCache.set(base, cached);
426
+ }
427
+ return cached;
428
+ }
429
+ function defaultDimStyle(base) {
430
+ if (base.dim) return base;
431
+ base = cacheBase(base);
432
+ if (!cacheable(base)) return {
433
+ ...base,
434
+ dim: true
435
+ };
436
+ let cached = dimStyleCache.get(base);
437
+ if (!cached) {
438
+ cached = Object.freeze({
439
+ ...base,
440
+ dim: true
441
+ });
442
+ dimStyleCache.set(base, cached);
443
+ }
444
+ return cached;
445
+ }
446
+
447
+ //#endregion
448
+ //#region src/vue/linkify.ts
449
+ const DEFAULT_PROTOCOLS = Object.freeze([
450
+ "http",
451
+ "https",
452
+ "mailto"
453
+ ]);
454
+ const URL_TEXT_RE = /(?:https?:\/\/|mailto:|\.{1,2}\/|\/|#|\?)[^\s<>"'`,。;:!?、]+/giu;
455
+ const TRAILING_PUNCTUATION_RE = /[.,;:!?,。;:!?、]/u;
456
+ const TRAILING_CLOSER_RE = /[)\]})】》」』”’]/u;
457
+ const TEXT_BOUNDARY_RE = /[\s([{<:="'`,。;:!?、(【《「『“‘]/u;
458
+ const CLOSE_TO_OPEN = {
459
+ ")": "(",
460
+ "]": "[",
461
+ "}": "{",
462
+ ")": "(",
463
+ "】": "【",
464
+ "》": "《",
465
+ "」": "「",
466
+ "』": "『",
467
+ "”": "“",
468
+ "’": "‘"
469
+ };
470
+ function protocolSet(options) {
471
+ return new Set(options.protocols ?? DEFAULT_PROTOCOLS);
472
+ }
473
+ function scheme(raw) {
474
+ return raw.match(/^[a-z][a-z0-9+.-]*:/i)?.[0].slice(0, -1).toLowerCase() ?? null;
475
+ }
476
+ function isRelativeCandidate(raw) {
477
+ if (raw.startsWith("./")) return raw.length > 2;
478
+ if (raw.startsWith("../")) return raw.length > 3;
479
+ if (raw.startsWith("/")) return raw.length > 1;
480
+ if (raw.startsWith("#")) return raw.length > 1;
481
+ if (raw.startsWith("?")) return raw.length > 1;
482
+ return false;
483
+ }
484
+ function hasTextBoundary(text, index) {
485
+ return index === 0 || TEXT_BOUNDARY_RE.test(text[index - 1] ?? "");
486
+ }
487
+ function lastChar(value) {
488
+ return value[value.length - 1] ?? "";
489
+ }
490
+ function splitTrailingPunctuation(raw) {
491
+ let body = raw;
492
+ let suffix = "";
493
+ let changed = true;
494
+ while (changed && body) {
495
+ changed = false;
496
+ while (body && TRAILING_PUNCTUATION_RE.test(lastChar(body))) {
497
+ suffix = lastChar(body) + suffix;
498
+ body = body.slice(0, -1);
499
+ changed = true;
500
+ }
501
+ while (body && TRAILING_CLOSER_RE.test(lastChar(body))) {
502
+ const ch = lastChar(body);
503
+ const open = CLOSE_TO_OPEN[ch];
504
+ if (!open) break;
505
+ let opens = 0;
506
+ let closes = 0;
507
+ for (const c of body) if (c === open) opens++;
508
+ else if (c === ch) closes++;
509
+ if (closes <= opens) break;
510
+ suffix = ch + suffix;
511
+ body = body.slice(0, -1);
512
+ changed = true;
513
+ }
514
+ }
515
+ return {
516
+ body,
517
+ suffix
518
+ };
519
+ }
520
+ function normalizeLinkifiedHref(body, options) {
521
+ const protocols = protocolSet(options);
522
+ const maxUrlLength = options.maxUrlLength;
523
+ if (maxUrlLength != null && body.length > Math.max(0, Math.floor(maxUrlLength))) return null;
524
+ const rawScheme = scheme(body);
525
+ if (rawScheme === "http" || rawScheme === "https" || rawScheme === "mailto") {
526
+ if (!protocols.has(rawScheme)) return null;
527
+ return sanitizeDomHref(body, { allowRelative: false });
528
+ }
529
+ if (options.allowRelative && isRelativeCandidate(body)) return sanitizeDomHref(body, { allowRelative: true });
530
+ return null;
531
+ }
532
+ function linkifyTextSegments(text, options = {}) {
533
+ if (!text) return [];
534
+ const out = [];
535
+ const regex = new RegExp(URL_TEXT_RE.source, URL_TEXT_RE.flags);
536
+ let cursor = 0;
537
+ let match;
538
+ while ((match = regex.exec(text)) != null) {
539
+ const raw = match[0] ?? "";
540
+ if (!raw) {
541
+ regex.lastIndex = Math.max(regex.lastIndex, match.index + 1);
542
+ continue;
543
+ }
544
+ const { body, suffix } = splitTrailingPunctuation(raw);
545
+ if (!hasTextBoundary(text, match.index)) continue;
546
+ if (isRelativeCandidate(body) && text[match.index - 1] === ":" && /[a-z0-9]/iu.test(text[match.index - 2] ?? "")) continue;
547
+ const href = normalizeLinkifiedHref(body, options);
548
+ if (!href) continue;
549
+ if (match.index > cursor) out.push({ text: text.slice(cursor, match.index) });
550
+ out.push({
551
+ text: body,
552
+ href
553
+ });
554
+ if (suffix) out.push({ text: suffix });
555
+ cursor = match.index + raw.length;
556
+ }
557
+ if (cursor < text.length) out.push({ text: text.slice(cursor) });
558
+ return out.length ? out : [{ text }];
559
+ }
560
+
561
+ //#endregion
562
+ export { TView, TuiThemeContextKey, createFrameMailbox, createTheme, defaultActiveStyle, defaultDimStyle, linkifyTextSegments, tuiDefaultTheme };