@simon_he/vue-tui 1.1.1 → 1.1.2

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 (66) hide show
  1. package/README.md +68 -28
  2. package/dist/{TMermaidText-CXm_L969.js → TMermaidText-frVr8Ysb.js} +1 -1
  3. package/dist/{TSelect-CiyMvwl-.js → TSelect-tJ87rKPM.js} +6 -168
  4. package/dist/{TTree-DKGiuIcM.js → TTree-CGdE-CYu.js} +12 -13
  5. package/dist/agent.cjs +9 -5
  6. package/dist/agent.js +15 -1197
  7. package/dist/{block-source-5CQp4tF8.js → block-source-CrlmaBM5.js} +7 -601
  8. package/dist/cli/input.d.ts +8 -0
  9. package/dist/cli/video/ffmpeg-frame-source.d.ts +10 -0
  10. package/dist/cli/video/png-frame-parser.d.ts +4 -0
  11. package/dist/cli/video/raw-frame-parser.d.ts +1 -0
  12. package/dist/cli/video/yt-dlp-frame-source.d.ts +11 -0
  13. package/dist/cli.cjs +142 -33
  14. package/dist/cli.d.cts +1 -1
  15. package/dist/cli.d.ts +1 -1
  16. package/dist/cli.js +167 -37
  17. package/dist/core.js +5 -6
  18. package/dist/create-terminal-app.d.ts +24 -1
  19. package/dist/{debug-logger-ChY_PXVk.js → debug-logger-CmsGI4of.js} +1 -1
  20. package/dist/{dom-renderer-DNzmg2As.js → dom-renderer-DXx8fWzD.js} +2 -3
  21. package/dist/experimental/3d/bun/contributor-avatar-atlas.d.ts +12 -0
  22. package/dist/experimental/3d/bun/png.d.ts +1 -0
  23. package/dist/experimental/3d/bun/terminal-badge-scene.d.ts +11 -0
  24. package/dist/experimental/3d/bun/terminal-badge.wgsl.d.ts +1 -0
  25. package/dist/experimental/3d/bun/webgpu-renderer.d.ts +26 -0
  26. package/dist/experimental/3d/bun.cjs +7271 -0
  27. package/dist/experimental/3d/bun.d.cts +4 -0
  28. package/dist/experimental/3d/bun.d.ts +4 -0
  29. package/dist/experimental/3d/bun.js +7390 -0
  30. package/dist/experimental/video/node.cjs +497 -0
  31. package/dist/experimental/video/node.d.cts +4 -0
  32. package/dist/experimental/video/node.d.ts +4 -0
  33. package/dist/experimental/video/node.js +610 -0
  34. package/dist/experimental.cjs +3064 -567
  35. package/dist/experimental.d.cts +5 -0
  36. package/dist/experimental.d.ts +5 -0
  37. package/dist/experimental.js +1524 -9
  38. package/dist/{create-terminal-DXuZ2fci.js → hyperlink-_1FAj7Wq.js} +403 -2
  39. package/dist/index.js +15 -16
  40. package/dist/{linkify-CuuquMQT.js → linkify-D68T7rdW.js} +164 -3
  41. package/dist/markdown.js +8 -8
  42. package/dist/{mermaid-CWto52Wk.js → mermaid-BNhM1jAZ.js} +1 -1
  43. package/dist/mermaid.js +3 -3
  44. package/dist/observability.js +2 -2
  45. package/dist/{path-suggest-fPzRsgPv.js → path-suggest-Dndu4dTi.js} +1 -1
  46. package/dist/renderer/terminal-graphics.d.ts +1 -0
  47. package/dist/renderer-dom.js +3 -4
  48. package/dist/runtime.js +2 -2
  49. package/dist/terminal-graphics-Bbe83wSr.js +597 -0
  50. package/dist/{tlog-theme-CopRt9SC.js → tlog-theme-Bul2Na3u.js} +1206 -12
  51. package/dist/{trace-CYHDKM1m.js → trace-Bh8WnoMo.js} +1 -1
  52. package/dist/vue/components/T3DViewport.d.ts +473 -0
  53. package/dist/vue/components/TAgentTerminalGraphic.d.ts +13 -0
  54. package/dist/vue/components/TVideo.d.ts +291 -0
  55. package/dist/vue/video/types.d.ts +39 -0
  56. package/dist/vue.js +17 -18
  57. package/package.json +38 -1
  58. package/dist/hyperlink-B35-O-cW.js +0 -403
  59. /package/dist/{ansi-palette-CNXqFciC.js → ansi-palette-CH6jc2Z7.js} +0 -0
  60. /package/dist/{env-DNCzvX8b.js → env-Cl8qmNFN.js} +0 -0
  61. /package/dist/{frame-perf-BBhE-iuS.js → frame-perf-CHpWhbC4.js} +0 -0
  62. /package/dist/{path-BI9W15Zt.js → path-mnSgEpCm.js} +0 -0
  63. /package/dist/{rect-Ng-3eKzF.js → rect-DUpeDfBg.js} +0 -0
  64. /package/dist/{runtime-D77C03RM.js → runtime-Byf8XXOT.js} +0 -0
  65. /package/dist/{terminal-selection-CQYr--26.js → terminal-selection-4W1SJj4c.js} +0 -0
  66. /package/dist/{wheel-scroll-CQ22Hcyj.js → wheel-scroll-DASkEZr-.js} +0 -0
@@ -1,5 +1,4 @@
1
1
  import { charCellWidth, segmentedGraphemes } from "./width-GqllnV8C.js";
2
- import { parseAnsiSgr } from "./hyperlink-B35-O-cW.js";
3
2
 
4
3
  //#region src/core/render-plane.ts
5
4
  const TERMINAL_RENDER_PLANES = [
@@ -9,6 +8,309 @@ const TERMINAL_RENDER_PLANES = [
9
8
  "overlay"
10
9
  ];
11
10
 
11
+ //#endregion
12
+ //#region src/core/ansi/sgr.ts
13
+ const ESC = "\x1B";
14
+ function ansi16ToColorName(code) {
15
+ switch (code) {
16
+ case 30: return "black";
17
+ case 31: return "red";
18
+ case 32: return "green";
19
+ case 33: return "yellow";
20
+ case 34: return "blue";
21
+ case 35: return "magenta";
22
+ case 36: return "cyan";
23
+ case 37: return "white";
24
+ case 90: return "blackBright";
25
+ case 91: return "redBright";
26
+ case 92: return "greenBright";
27
+ case 93: return "yellowBright";
28
+ case 94: return "blueBright";
29
+ case 95: return "magentaBright";
30
+ case 96: return "cyanBright";
31
+ case 97: return "whiteBright";
32
+ default: return void 0;
33
+ }
34
+ }
35
+ function ansi16BgToColorName(code) {
36
+ const fgCode = code >= 40 && code <= 47 ? code - 10 : code >= 100 && code <= 107 ? code - 10 : null;
37
+ if (fgCode == null) return void 0;
38
+ return ansi16ToColorName(fgCode);
39
+ }
40
+ const ANSI16_RGB = {
41
+ black: {
42
+ r: 0,
43
+ g: 0,
44
+ b: 0
45
+ },
46
+ red: {
47
+ r: 201,
48
+ g: 27,
49
+ b: 0
50
+ },
51
+ green: {
52
+ r: 0,
53
+ g: 194,
54
+ b: 0
55
+ },
56
+ yellow: {
57
+ r: 199,
58
+ g: 196,
59
+ b: 0
60
+ },
61
+ blue: {
62
+ r: 2,
63
+ g: 37,
64
+ b: 199
65
+ },
66
+ magenta: {
67
+ r: 201,
68
+ g: 48,
69
+ b: 199
70
+ },
71
+ cyan: {
72
+ r: 0,
73
+ g: 197,
74
+ b: 199
75
+ },
76
+ white: {
77
+ r: 199,
78
+ g: 199,
79
+ b: 199
80
+ },
81
+ blackBright: {
82
+ r: 104,
83
+ g: 104,
84
+ b: 104
85
+ },
86
+ redBright: {
87
+ r: 255,
88
+ g: 110,
89
+ b: 103
90
+ },
91
+ greenBright: {
92
+ r: 95,
93
+ g: 250,
94
+ b: 104
95
+ },
96
+ yellowBright: {
97
+ r: 255,
98
+ g: 252,
99
+ b: 103
100
+ },
101
+ blueBright: {
102
+ r: 104,
103
+ g: 113,
104
+ b: 255
105
+ },
106
+ magentaBright: {
107
+ r: 255,
108
+ g: 118,
109
+ b: 255
110
+ },
111
+ cyanBright: {
112
+ r: 95,
113
+ g: 253,
114
+ b: 255
115
+ },
116
+ whiteBright: {
117
+ r: 255,
118
+ g: 255,
119
+ b: 255
120
+ }
121
+ };
122
+ function nearestAnsi16(r, g, b) {
123
+ let best = "white";
124
+ let bestDist = Number.POSITIVE_INFINITY;
125
+ for (const [name, rgb] of Object.entries(ANSI16_RGB)) {
126
+ const dr = r - rgb.r;
127
+ const dg = g - rgb.g;
128
+ const db = b - rgb.b;
129
+ const d = dr * dr + dg * dg + db * db;
130
+ if (d < bestDist) {
131
+ bestDist = d;
132
+ best = name;
133
+ }
134
+ }
135
+ return best;
136
+ }
137
+ function ansi256ToRgb(index) {
138
+ const n = Math.max(0, Math.min(255, Math.trunc(index)));
139
+ if (n < 16) {
140
+ const map = [
141
+ "black",
142
+ "red",
143
+ "green",
144
+ "yellow",
145
+ "blue",
146
+ "magenta",
147
+ "cyan",
148
+ "white",
149
+ "blackBright",
150
+ "redBright",
151
+ "greenBright",
152
+ "yellowBright",
153
+ "blueBright",
154
+ "magentaBright",
155
+ "cyanBright",
156
+ "whiteBright"
157
+ ];
158
+ const name = map[n] ?? "white";
159
+ return ANSI16_RGB[name];
160
+ }
161
+ if (n >= 232) {
162
+ const c = 8 + (n - 232) * 10;
163
+ return {
164
+ r: c,
165
+ g: c,
166
+ b: c
167
+ };
168
+ }
169
+ const i = n - 16;
170
+ const rr = Math.floor(i / 36);
171
+ const gg = Math.floor(i % 36 / 6);
172
+ const bb = i % 6;
173
+ const toComponent = (v) => v === 0 ? 0 : 55 + v * 40;
174
+ return {
175
+ r: toComponent(rr),
176
+ g: toComponent(gg),
177
+ b: toComponent(bb)
178
+ };
179
+ }
180
+ function applyAnsiSgrStyle(current, codes) {
181
+ let next = { ...current };
182
+ for (let i = 0; i < codes.length; i++) {
183
+ const code = codes[i];
184
+ if (code === 0) {
185
+ next = {};
186
+ continue;
187
+ }
188
+ if (code === 1) next = {
189
+ ...next,
190
+ bold: true
191
+ };
192
+ else if (code === 2) next = {
193
+ ...next,
194
+ dim: true
195
+ };
196
+ else if (code === 3) next = {
197
+ ...next,
198
+ italic: true
199
+ };
200
+ else if (code === 4) next = {
201
+ ...next,
202
+ underline: true
203
+ };
204
+ else if (code === 7) next = {
205
+ ...next,
206
+ inverse: true
207
+ };
208
+ else if (code === 22) next = {
209
+ ...next,
210
+ bold: false,
211
+ dim: false
212
+ };
213
+ else if (code === 23) next = {
214
+ ...next,
215
+ italic: false
216
+ };
217
+ else if (code === 24) next = {
218
+ ...next,
219
+ underline: false
220
+ };
221
+ else if (code === 27) next = {
222
+ ...next,
223
+ inverse: false
224
+ };
225
+ else if (code === 39) next = {
226
+ ...next,
227
+ fg: void 0
228
+ };
229
+ else if (code === 49) next = {
230
+ ...next,
231
+ bg: void 0
232
+ };
233
+ else if (code >= 30 && code <= 37 || code >= 90 && code <= 97) {
234
+ const fg = ansi16ToColorName(code);
235
+ next = {
236
+ ...next,
237
+ fg: fg ?? next.fg
238
+ };
239
+ } else if (code >= 40 && code <= 47 || code >= 100 && code <= 107) {
240
+ const bg = ansi16BgToColorName(code);
241
+ next = {
242
+ ...next,
243
+ bg: bg ?? next.bg
244
+ };
245
+ } else if (code === 38 || code === 48) {
246
+ const mode = codes[i + 1];
247
+ if (mode === 5) {
248
+ const idx = codes[i + 2];
249
+ if (idx != null) {
250
+ const { r, g, b } = ansi256ToRgb(idx);
251
+ const name = nearestAnsi16(r, g, b);
252
+ next = code === 38 ? {
253
+ ...next,
254
+ fg: name
255
+ } : {
256
+ ...next,
257
+ bg: name
258
+ };
259
+ }
260
+ i += 2;
261
+ } else if (mode === 2) {
262
+ const r = codes[i + 2];
263
+ const g = codes[i + 3];
264
+ const b = codes[i + 4];
265
+ if (r != null && g != null && b != null) {
266
+ const name = nearestAnsi16(r, g, b);
267
+ next = code === 38 ? {
268
+ ...next,
269
+ fg: name
270
+ } : {
271
+ ...next,
272
+ bg: name
273
+ };
274
+ }
275
+ i += 4;
276
+ }
277
+ }
278
+ }
279
+ return next;
280
+ }
281
+ function parseAnsiSgr(input, baseStyle = {}) {
282
+ const segments = [];
283
+ let style = { ...baseStyle };
284
+ let lastIndex = 0;
285
+ for (let i = 0; i < input.length; i++) {
286
+ if (input[i] !== ESC || input[i + 1] !== "[") continue;
287
+ let j = i + 2;
288
+ while (j < input.length) {
289
+ const c = input.charCodeAt(j);
290
+ if (c >= 48 && c <= 57 || c === 59) {
291
+ j++;
292
+ continue;
293
+ }
294
+ break;
295
+ }
296
+ if (j >= input.length || input[j] !== "m") continue;
297
+ if (i > lastIndex) segments.push({
298
+ text: input.slice(lastIndex, i),
299
+ style
300
+ });
301
+ const body = input.slice(i + 2, j);
302
+ const codes = body.split(";").filter(Boolean).map((n) => Number.parseInt(n, 10)).filter((n) => Number.isFinite(n));
303
+ style = applyAnsiSgrStyle(style, codes.length ? codes : [0]);
304
+ lastIndex = j + 1;
305
+ i = j;
306
+ }
307
+ if (lastIndex < input.length) segments.push({
308
+ text: input.slice(lastIndex),
309
+ style
310
+ });
311
+ return segments;
312
+ }
313
+
12
314
  //#endregion
13
315
  //#region src/core/buffer/buffer.ts
14
316
  const DEFAULT_STYLE = Object.freeze({});
@@ -1466,4 +1768,103 @@ function createTerminal(opts) {
1466
1768
  }
1467
1769
 
1468
1770
  //#endregion
1469
- export { TERMINAL_RENDER_PLANES, createTerminal, getPlaneTerminal, getRootTerminal, resetPlaneRowsForRender, scrollPlaneRows };
1771
+ //#region src/utils/url-safety.ts
1772
+ const ENCODED_ASCII_CONTROL_RE = /%(?:0[0-9a-f]|1[0-9a-f]|7f)/i;
1773
+ function hasControlCodePoint(value) {
1774
+ for (let i = 0; i < value.length; i++) {
1775
+ const code = value.charCodeAt(i);
1776
+ if (code <= 31 || code >= 127 && code <= 159) return true;
1777
+ }
1778
+ return false;
1779
+ }
1780
+ function hasEncodedControl(value) {
1781
+ let current = String(value ?? "");
1782
+ for (let depth = 0; depth < 3; depth++) {
1783
+ if (ENCODED_ASCII_CONTROL_RE.test(current)) return true;
1784
+ let decoded;
1785
+ try {
1786
+ decoded = decodeURIComponent(current);
1787
+ } catch {
1788
+ return true;
1789
+ }
1790
+ if (hasControlCodePoint(decoded)) return true;
1791
+ if (decoded === current) return false;
1792
+ current = decoded;
1793
+ }
1794
+ return ENCODED_ASCII_CONTROL_RE.test(current) || hasControlCodePoint(current);
1795
+ }
1796
+
1797
+ //#endregion
1798
+ //#region src/core/hyperlink.ts
1799
+ const SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i;
1800
+ const BLOCKED_SCHEME_RE = /^(?:javascript|data|vbscript):/i;
1801
+ const SAFE_RELATIVE_HREF_RE = /^(?:[A-Za-z0-9._~!$&()*+,;=:@/?#-]|%[0-9A-Fa-f]{2})+$/u;
1802
+ function normalizeRawHref(value) {
1803
+ if (typeof value !== "string") return null;
1804
+ const raw = value.trim();
1805
+ if (!raw) return null;
1806
+ if (raw !== value) return null;
1807
+ for (let i = 0; i < value.length; i++) {
1808
+ const code = value.charCodeAt(i);
1809
+ if (code <= 31 || code >= 127 && code <= 159) return null;
1810
+ }
1811
+ if (/\s/u.test(raw)) return null;
1812
+ if (raw.startsWith("//")) return null;
1813
+ if (BLOCKED_SCHEME_RE.test(raw)) return null;
1814
+ if (hasEncodedControl(raw)) return null;
1815
+ return raw;
1816
+ }
1817
+ function hrefScheme(raw) {
1818
+ return raw.match(SCHEME_RE)?.[0].toLowerCase() ?? null;
1819
+ }
1820
+ function parseSafeAbsoluteUrl(raw) {
1821
+ if (raw.includes("\\")) return null;
1822
+ try {
1823
+ return new URL(raw);
1824
+ } catch {
1825
+ return null;
1826
+ }
1827
+ }
1828
+ function sanitizeAbsoluteHref(raw, options = {}) {
1829
+ const url = parseSafeAbsoluteUrl(raw);
1830
+ if (!url) return null;
1831
+ if (url.protocol === "http:" || url.protocol === "https:") {
1832
+ if (!/^https?:\/\//i.test(raw)) return null;
1833
+ return options.preserveHttpHref ? raw : url.toString();
1834
+ }
1835
+ if (url.protocol === "mailto:") return raw;
1836
+ return null;
1837
+ }
1838
+ function isSafeNormalizedRelativeHref(raw) {
1839
+ if (raw.includes("\\")) return false;
1840
+ if (raw.startsWith("//")) return false;
1841
+ if (SCHEME_RE.test(raw)) return false;
1842
+ if (hasEncodedControl(raw)) return false;
1843
+ if (!SAFE_RELATIVE_HREF_RE.test(raw)) return false;
1844
+ return raw.startsWith("#") || raw.startsWith("?") || raw.startsWith("/") || raw.startsWith("./") || raw.startsWith("../") || /^[A-Za-z0-9._~-]/u.test(raw);
1845
+ }
1846
+ function isSafeRelativeHref(value) {
1847
+ const raw = normalizeRawHref(value);
1848
+ return raw != null && isSafeNormalizedRelativeHref(raw);
1849
+ }
1850
+ function sanitizeTerminalHref(value, options = {}) {
1851
+ const raw = normalizeRawHref(value);
1852
+ if (!raw) return null;
1853
+ const sanitized = sanitizeAbsoluteHref(raw, { preserveHttpHref: true });
1854
+ if (sanitized) return sanitized;
1855
+ if (options.allowFileUrls) {
1856
+ const url = parseSafeAbsoluteUrl(raw);
1857
+ if (url?.protocol === "file:") return url.toString();
1858
+ }
1859
+ return null;
1860
+ }
1861
+ function sanitizeDomHref(value, options = {}) {
1862
+ const raw = normalizeRawHref(value);
1863
+ if (!raw) return null;
1864
+ const scheme = hrefScheme(raw);
1865
+ if (!scheme) return options.allowRelative !== false && isSafeNormalizedRelativeHref(raw) ? raw : null;
1866
+ return sanitizeAbsoluteHref(raw);
1867
+ }
1868
+
1869
+ //#endregion
1870
+ export { TERMINAL_RENDER_PLANES, applyAnsiSgrStyle, createTerminal, getPlaneTerminal, getRootTerminal, hasEncodedControl, isSafeRelativeHref, parseAnsiSgr, resetPlaneRowsForRender, sanitizeDomHref, sanitizeTerminalHref, scrollPlaneRows };
package/dist/index.js CHANGED
@@ -1,19 +1,18 @@
1
- import { createTerminal } from "./create-terminal-DXuZ2fci.js";
1
+ import { createTerminal } from "./hyperlink-_1FAj7Wq.js";
2
2
  import "./width-GqllnV8C.js";
3
- import "./hyperlink-B35-O-cW.js";
4
- import "./ansi-palette-CNXqFciC.js";
5
- import { createDomRenderer } from "./dom-renderer-DNzmg2As.js";
6
- import "./rect-Ng-3eKzF.js";
7
- import { TView, createTheme, linkifyTextSegments, tuiDefaultTheme } from "./linkify-CuuquMQT.js";
8
- import "./runtime-D77C03RM.js";
9
- import "./frame-perf-BBhE-iuS.js";
10
- import "./trace-CYHDKM1m.js";
11
- import "./env-DNCzvX8b.js";
12
- import { TAutocompleteInput, TBadge, TCheckbox, TCode, TDataTable, TDivider, TFormField, TLink, TLinkifyText, TList, TPasswordInput, TRadioGroup, TSlider, TSwitch, TTable, TTag, TTree, TerminalProvider, createTInputHostPlugin } from "./TTree-DKGiuIcM.js";
13
- import "./terminal-selection-CQYr--26.js";
14
- import "./debug-logger-ChY_PXVk.js";
15
- import { TBox, TCommandPalette, TDialog, TInput, TSelect, TText, computeCommandPaletteMatchRanges } from "./TSelect-CiyMvwl-.js";
16
- import "./path-BI9W15Zt.js";
17
- import "./wheel-scroll-CQ22Hcyj.js";
3
+ import "./ansi-palette-CH6jc2Z7.js";
4
+ import { createDomRenderer } from "./dom-renderer-DXx8fWzD.js";
5
+ import "./rect-DUpeDfBg.js";
6
+ import { TText, TView, createTheme, linkifyTextSegments, tuiDefaultTheme } from "./linkify-D68T7rdW.js";
7
+ import "./runtime-Byf8XXOT.js";
8
+ import "./frame-perf-CHpWhbC4.js";
9
+ import "./trace-Bh8WnoMo.js";
10
+ import "./env-Cl8qmNFN.js";
11
+ import { TAutocompleteInput, TBadge, TCheckbox, TCode, TDataTable, TDivider, TFormField, TLink, TLinkifyText, TList, TPasswordInput, TRadioGroup, TSlider, TSwitch, TTable, TTag, TTree, TerminalProvider, createTInputHostPlugin } from "./TTree-CGdE-CYu.js";
12
+ import "./terminal-selection-4W1SJj4c.js";
13
+ import "./debug-logger-CmsGI4of.js";
14
+ import { TBox, TCommandPalette, TDialog, TInput, TSelect, computeCommandPaletteMatchRanges } from "./TSelect-tJ87rKPM.js";
15
+ import "./path-mnSgEpCm.js";
16
+ import "./wheel-scroll-DASkEZr-.js";
18
17
 
19
18
  export { TAutocompleteInput, TBadge, TBox, TCheckbox, TCode, TCommandPalette, TDataTable, TDialog, TDivider, TFormField, TInput, TLink, TLinkifyText, TList, TPasswordInput, TRadioGroup, TSelect, TSlider, TSwitch, TTable, TTag, TText, TTree, TView, TerminalProvider, computeCommandPaletteMatchRanges, createDomRenderer, createTInputHostPlugin, createTerminal, createTheme, linkifyTextSegments, tuiDefaultTheme };
@@ -1,5 +1,5 @@
1
- import { sanitizeDomHref } from "./hyperlink-B35-O-cW.js";
2
- import { EventZIndexContextKey, LayoutContextKey, RenderStackKey, injectionKey, intersectRect, padEndByCells$1 as padEndByCells, sanitizeInlineText, sliceByCells, textCellWidth$1 as textCellWidth, translateRect, useLayout, useRenderStack, useTerminal, useTerminalNode, useVisibility } from "./rect-Ng-3eKzF.js";
1
+ import { sanitizeDomHref } from "./hyperlink-_1FAj7Wq.js";
2
+ import { EventZIndexContextKey, LayoutContextKey, RenderStackKey, injectionKey, intersectRect, padEndByCells$1 as padEndByCells, sanitizeInlineText, sanitizeTextBlock, sliceByCells, sliceByCellsRange, spaces, textCellWidth$1 as textCellWidth, translateRect, useLayout, useRenderNode, useRenderStack, useTerminal, useTerminalNode, useVisibility, wrapByCells } from "./rect-DUpeDfBg.js";
3
3
  import { computed, defineComponent, h, inject, provide, shallowReactive, watchEffect } from "vue";
4
4
 
5
5
  //#region src/vue/theme.ts
@@ -105,6 +105,167 @@ function createTheme(overrides = {}) {
105
105
  }
106
106
  const TuiThemeContextKey = injectionKey("TuiTheme");
107
107
 
108
+ //#endregion
109
+ //#region src/vue/components/TText.ts
110
+ function fitText(text, max) {
111
+ if (max <= 0) return "";
112
+ text = sanitizeInlineText(text);
113
+ return sliceByCells(text, max);
114
+ }
115
+ function splitLines(text) {
116
+ return sanitizeTextBlock(text).split("\n");
117
+ }
118
+ function computeDefaultWidth(text) {
119
+ const lines = splitLines(text);
120
+ let max = 0;
121
+ for (const line of lines) max = Math.max(max, textCellWidth(line));
122
+ return max;
123
+ }
124
+ const TText = defineComponent({
125
+ name: "TText",
126
+ props: {
127
+ x: {
128
+ type: Number,
129
+ required: true
130
+ },
131
+ y: {
132
+ type: Number,
133
+ required: true
134
+ },
135
+ zIndex: {
136
+ type: Number,
137
+ default: 0
138
+ },
139
+ value: {
140
+ type: String,
141
+ required: true
142
+ },
143
+ w: {
144
+ type: Number,
145
+ default: void 0
146
+ },
147
+ h: {
148
+ type: Number,
149
+ default: void 0
150
+ },
151
+ style: {
152
+ type: Object,
153
+ default: void 0
154
+ },
155
+ clear: {
156
+ type: Boolean,
157
+ default: true
158
+ },
159
+ wrap: {
160
+ type: Boolean,
161
+ default: false
162
+ },
163
+ depsKey: {
164
+ type: null,
165
+ default: void 0
166
+ }
167
+ },
168
+ setup(props) {
169
+ const { terminal, defaultStyle } = useTerminal();
170
+ const layout = useLayout();
171
+ const { visible, rootProps } = useVisibility();
172
+ const defaultWidth = computed(() => computeDefaultWidth(props.value));
173
+ const lines = computed(() => {
174
+ const w = props.w ?? defaultWidth.value;
175
+ if (w <= 0) return [""];
176
+ if (!props.wrap) return splitLines(props.value).map((l) => fitText(l, w));
177
+ const safe = sanitizeTextBlock(props.value);
178
+ return wrapByCells(safe, w).map((l) => fitText(l, w));
179
+ });
180
+ const absRect = computed(() => {
181
+ const width = props.w ?? defaultWidth.value;
182
+ const height = props.h ?? (props.wrap ? lines.value.length || 1 : lines.value.length || 1);
183
+ const raw = {
184
+ x: props.x,
185
+ y: props.y,
186
+ w: width,
187
+ h: height
188
+ };
189
+ const translated = translateRect(raw, layout.originX, layout.originY);
190
+ if (!layout.clipRect) return translated;
191
+ return intersectRect(translated, layout.clipRect) ?? {
192
+ x: 0,
193
+ y: 0,
194
+ w: 0,
195
+ h: 0
196
+ };
197
+ });
198
+ const fullRect = computed(() => {
199
+ const width = props.w ?? defaultWidth.value;
200
+ const height = props.h ?? (props.wrap ? lines.value.length || 1 : lines.value.length || 1);
201
+ return translateRect({
202
+ x: props.x,
203
+ y: props.y,
204
+ w: width,
205
+ h: height
206
+ }, layout.originX, layout.originY);
207
+ });
208
+ useRenderNode(() => ({
209
+ zIndex: props.zIndex,
210
+ rect: visible.value ? absRect.value : {
211
+ x: 0,
212
+ y: 0,
213
+ w: 0,
214
+ h: 0
215
+ },
216
+ deps: [
217
+ visible.value,
218
+ absRect.value,
219
+ fullRect.value,
220
+ props.value,
221
+ props.w,
222
+ props.h,
223
+ props.wrap,
224
+ props.style,
225
+ defaultStyle.value,
226
+ props.depsKey
227
+ ],
228
+ paint: (dirtyRows) => {
229
+ if (!visible.value) return;
230
+ const r = absRect.value;
231
+ if (r.w <= 0 || r.h <= 0) return;
232
+ const full = fullRect.value;
233
+ const style = props.style ?? defaultStyle.value;
234
+ const blank = props.clear ? spaces(r.w) : "";
235
+ const out = lines.value;
236
+ const dx = Math.max(0, Math.floor(r.x - full.x));
237
+ const fullY = Math.floor(full.y);
238
+ const paintRow = (y) => {
239
+ const relY = y - r.y;
240
+ if (relY < 0 || relY >= r.h) return;
241
+ const i = y - fullY;
242
+ if (i < 0 || i >= out.length) {
243
+ if (props.clear) terminal.write(blank, {
244
+ x: r.x,
245
+ y,
246
+ style
247
+ });
248
+ return;
249
+ }
250
+ const src = out[i] ?? "";
251
+ const clipped = dx > 0 ? sliceByCellsRange(src, dx, dx + r.w) : sliceByCells(src, r.w);
252
+ terminal.write(padEndByCells(clipped, r.w), {
253
+ x: r.x,
254
+ y,
255
+ style
256
+ });
257
+ };
258
+ if (!dirtyRows) {
259
+ for (let i = 0; i < r.h; i++) paintRow(r.y + i);
260
+ return;
261
+ }
262
+ for (const y of dirtyRows) paintRow(y);
263
+ }
264
+ }));
265
+ return () => h("span", rootProps);
266
+ }
267
+ });
268
+
108
269
  //#endregion
109
270
  //#region src/vue/components/TView.ts
110
271
  const EMPTY_RECT = Object.freeze({
@@ -588,4 +749,4 @@ function linkifyTextSegments(text, options = {}) {
588
749
  }
589
750
 
590
751
  //#endregion
591
- export { TView, TuiThemeContextKey, clamp, createFrameMailbox, createTheme, defaultActiveStyle, defaultDimStyle, fitCellText, linkifyTextSegments, mergeStyle, repeatToCells, tuiDefaultTheme };
752
+ export { TText, TView, TuiThemeContextKey, clamp, createFrameMailbox, createTheme, defaultActiveStyle, defaultDimStyle, fitCellText, linkifyTextSegments, mergeStyle, repeatToCells, tuiDefaultTheme };
package/dist/markdown.js CHANGED
@@ -1,12 +1,12 @@
1
- import "./create-terminal-DXuZ2fci.js";
1
+ import "./hyperlink-_1FAj7Wq.js";
2
2
  import "./width-GqllnV8C.js";
3
- import "./hyperlink-B35-O-cW.js";
4
- import { EventZIndexContextKey, intersectRect, translateRect, useLayout, useRenderNode, useTerminal, useTerminalNode, useVisibility, withTextWidthProvider } from "./rect-Ng-3eKzF.js";
5
- import "./env-DNCzvX8b.js";
6
- import "./terminal-selection-CQYr--26.js";
7
- import "./debug-logger-ChY_PXVk.js";
8
- import "./wheel-scroll-CQ22Hcyj.js";
9
- import { TVirtualMarkdown, buildMarkdownBlocks, buildMarkdownVisualRows, clearMarkdownImageGraphics, collectVisibleMarkdownImageGraphicIds, createMarkdownBlockSource, createTuiMarkdownParser, findMarkdownImageActionAt, findMarkdownLinkActionAt, findMarkdownMathActionAt, getTerminalGraphicsOutputVersion, isSafeMarkdownLink, layoutMarkdownBlocks, markdownThemeSignature, paintMarkdownVisualRow, subscribeTerminalGraphicsOutput } from "./block-source-5CQp4tF8.js";
3
+ import { EventZIndexContextKey, intersectRect, translateRect, useLayout, useRenderNode, useTerminal, useTerminalNode, useVisibility, withTextWidthProvider } from "./rect-DUpeDfBg.js";
4
+ import "./env-Cl8qmNFN.js";
5
+ import "./terminal-selection-4W1SJj4c.js";
6
+ import "./debug-logger-CmsGI4of.js";
7
+ import "./wheel-scroll-DASkEZr-.js";
8
+ import { getTerminalGraphicsOutputVersion, subscribeTerminalGraphicsOutput } from "./terminal-graphics-Bbe83wSr.js";
9
+ import { TVirtualMarkdown, buildMarkdownBlocks, buildMarkdownVisualRows, clearMarkdownImageGraphics, collectVisibleMarkdownImageGraphicIds, createMarkdownBlockSource, createTuiMarkdownParser, findMarkdownImageActionAt, findMarkdownLinkActionAt, findMarkdownMathActionAt, isSafeMarkdownLink, layoutMarkdownBlocks, markdownThemeSignature, paintMarkdownVisualRow } from "./block-source-CrlmaBM5.js";
10
10
  import { computed, defineComponent, getCurrentInstance, h, inject, markRaw, onBeforeUnmount, shallowRef, watch } from "vue";
11
11
 
12
12
  //#region src/vue/components/TMarkdownText.ts
@@ -1,4 +1,4 @@
1
- import { TMermaidText$1 as TMermaidText, isSimpleMermaidFlowchartSource, markMermaidRenderErrorFatal, tMermaidTextProps } from "./TMermaidText-CXm_L969.js";
1
+ import { TMermaidText$1 as TMermaidText, isSimpleMermaidFlowchartSource, markMermaidRenderErrorFatal, tMermaidTextProps } from "./TMermaidText-frVr8Ysb.js";
2
2
  import { defineComponent, h } from "vue";
3
3
 
4
4
  //#region src/vue/mermaid/beautiful-mermaid.ts
package/dist/mermaid.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./width-GqllnV8C.js";
2
- import "./rect-Ng-3eKzF.js";
3
- import { isSimpleMermaidFlowchartSource, markMermaidRenderErrorFatal } from "./TMermaidText-CXm_L969.js";
4
- import { TBeautifulMermaid, TBeautifulMermaidText, TMermaid, TMermaidText, beautifulMermaidRenderer, createBeautifulMermaidRenderer } from "./mermaid-CWto52Wk.js";
2
+ import "./rect-DUpeDfBg.js";
3
+ import { isSimpleMermaidFlowchartSource, markMermaidRenderErrorFatal } from "./TMermaidText-frVr8Ysb.js";
4
+ import { TBeautifulMermaid, TBeautifulMermaidText, TMermaid, TMermaidText, beautifulMermaidRenderer, createBeautifulMermaidRenderer } from "./mermaid-BNhM1jAZ.js";
5
5
 
6
6
  export { TBeautifulMermaid, TBeautifulMermaidText, TMermaid, TMermaidText, beautifulMermaidRenderer, createBeautifulMermaidRenderer, isSimpleMermaidFlowchartSource, markMermaidRenderErrorFatal };
@@ -1,4 +1,4 @@
1
- import { framePerfNow, summarizeFramePerf } from "./frame-perf-BBhE-iuS.js";
2
- import { createFramePerfStore, createJsonlPerfSink, createTraceStore, installTuiPerf } from "./trace-CYHDKM1m.js";
1
+ import { framePerfNow, summarizeFramePerf } from "./frame-perf-CHpWhbC4.js";
2
+ import { createFramePerfStore, createJsonlPerfSink, createTraceStore, installTuiPerf } from "./trace-Bh8WnoMo.js";
3
3
 
4
4
  export { createFramePerfStore, createJsonlPerfSink, createTraceStore, framePerfNow, installTuiPerf, summarizeFramePerf };
@@ -1,4 +1,4 @@
1
- import { dirname, isAbsolutePath, joinPath, normalizePath, resolvePath } from "./path-BI9W15Zt.js";
1
+ import { dirname, isAbsolutePath, joinPath, normalizePath, resolvePath } from "./path-mnSgEpCm.js";
2
2
 
3
3
  //#region src/core/path-suggest.ts
4
4
  function lower(s) {
@@ -67,6 +67,7 @@ export type TerminalGraphicsOutput = Readonly<{
67
67
  capabilities: TerminalGraphicsCapabilities;
68
68
  queue: (payload: TerminalGraphicsPayload) => boolean;
69
69
  clear?: (id: string) => boolean;
70
+ clearAll?: () => boolean;
70
71
  isActive?: (id: string) => boolean;
71
72
  }>;
72
73
  export declare const MAX_TERMINAL_GRAPHICS_SEQUENCE_CHARS: number;