@simon_he/vue-tui 1.0.2 → 1.1.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 (125) hide show
  1. package/README.md +84 -26
  2. package/dist/TMermaidText-frVr8Ysb.js +885 -0
  3. package/dist/{TSelect-DR0FomSu.js → TSelect-tJ87rKPM.js} +59 -242
  4. package/dist/{TTree-kzhlB5P0.js → TTree-CGdE-CYu.js} +138 -102
  5. package/dist/agent/mermaid.cjs +2 -0
  6. package/dist/agent/mermaid.d.cts +2 -0
  7. package/dist/agent/mermaid.d.ts +2 -0
  8. package/dist/agent/mermaid.js +1 -0
  9. package/dist/agent.cjs +31188 -24907
  10. package/dist/agent.d.cts +11 -1
  11. package/dist/agent.d.ts +11 -1
  12. package/dist/agent.js +516 -11
  13. package/dist/{block-source-CKUOnkgT.js → block-source-CrlmaBM5.js} +1039 -66
  14. package/dist/cli/input.d.ts +8 -0
  15. package/dist/cli/stdin-buffer.d.ts +1 -1
  16. package/dist/cli/video/ffmpeg-frame-source.d.ts +10 -0
  17. package/dist/cli/video/png-frame-parser.d.ts +4 -0
  18. package/dist/cli/video/raw-frame-parser.d.ts +1 -0
  19. package/dist/cli/video/yt-dlp-frame-source.d.ts +11 -0
  20. package/dist/cli.cjs +5146 -6767
  21. package/dist/cli.d.cts +5 -1
  22. package/dist/cli.d.ts +5 -1
  23. package/dist/cli.js +2869 -154
  24. package/dist/core/buffer/eaw-ranges-unicode-17.d.ts +14 -0
  25. package/dist/core/perf/instrumentation-noop.d.ts +48 -0
  26. package/dist/core/perf/instrumentation.d.ts +136 -0
  27. package/dist/core/terminal/create-terminal.d.ts +1 -0
  28. package/dist/core.cjs +843 -1469
  29. package/dist/core.js +4 -5
  30. package/dist/create-terminal-app.d.ts +24 -1
  31. package/dist/debug-logger-CmsGI4of.js +74 -0
  32. package/dist/{dom-renderer-BniJSQyX.js → dom-renderer-DXx8fWzD.js} +2 -3
  33. package/dist/experimental/3d/bun/contributor-avatar-atlas.d.ts +12 -0
  34. package/dist/experimental/3d/bun/png.d.ts +1 -0
  35. package/dist/experimental/3d/bun/terminal-badge-scene.d.ts +11 -0
  36. package/dist/experimental/3d/bun/terminal-badge.wgsl.d.ts +1 -0
  37. package/dist/experimental/3d/bun/webgpu-renderer.d.ts +26 -0
  38. package/dist/experimental/3d/bun.cjs +7271 -0
  39. package/dist/experimental/3d/bun.d.cts +4 -0
  40. package/dist/experimental/3d/bun.d.ts +4 -0
  41. package/dist/experimental/3d/bun.js +7390 -0
  42. package/dist/experimental/video/node.cjs +497 -0
  43. package/dist/experimental/video/node.d.cts +4 -0
  44. package/dist/experimental/video/node.d.ts +4 -0
  45. package/dist/experimental/video/node.js +610 -0
  46. package/dist/experimental.cjs +6876 -6192
  47. package/dist/experimental.d.cts +7 -0
  48. package/dist/experimental.d.ts +7 -0
  49. package/dist/experimental.js +3005 -9
  50. package/dist/frame-perf-CHpWhbC4.js +111 -0
  51. package/dist/{create-terminal-DBFNYr8f.js → hyperlink-_1FAj7Wq.js} +440 -13
  52. package/dist/index.cjs +5017 -10339
  53. package/dist/index.js +14 -13
  54. package/dist/{linkify-D_gzn9Xq.js → linkify-D68T7rdW.js} +193 -3
  55. package/dist/markdown.cjs +21295 -12691
  56. package/dist/markdown.d.cts +1 -1
  57. package/dist/markdown.d.ts +1 -1
  58. package/dist/markdown.js +211 -51
  59. package/dist/mermaid-BNhM1jAZ.js +123 -0
  60. package/dist/mermaid.cjs +1707 -0
  61. package/dist/mermaid.d.cts +3 -0
  62. package/dist/mermaid.d.ts +3 -0
  63. package/dist/mermaid.js +6 -0
  64. package/dist/observability/frame-perf-store.d.ts +2 -1
  65. package/dist/observability/frame-perf.d.ts +33 -0
  66. package/dist/observability.cjs +106 -107
  67. package/dist/observability.d.cts +2 -2
  68. package/dist/observability.d.ts +2 -2
  69. package/dist/observability.js +3 -3
  70. package/dist/{wheel-scroll-vBRaQ7p-.js → rect-DUpeDfBg.js} +253 -117
  71. package/dist/renderer/cli/stdout-metrics.d.ts +10 -0
  72. package/dist/renderer/cli/stdout-renderer.d.ts +3 -0
  73. package/dist/renderer/terminal-graphic-render-queue.d.ts +50 -0
  74. package/dist/renderer/terminal-graphics-trace.d.ts +53 -0
  75. package/dist/renderer/terminal-graphics.d.ts +147 -0
  76. package/dist/renderer-dom.cjs +364 -903
  77. package/dist/renderer-dom.js +4 -5
  78. package/dist/runtime/index.d.ts +2 -0
  79. package/dist/{runtime-rfcZCyJq.js → runtime-Byf8XXOT.js} +28 -15
  80. package/dist/runtime.cjs +427 -889
  81. package/dist/runtime.js +2 -2
  82. package/dist/terminal-graphics-Bbe83wSr.js +597 -0
  83. package/dist/{terminal-selection-DBinO6p5.js → terminal-selection-4W1SJj4c.js} +4 -1
  84. package/dist/{tlog-theme-CvLFNMwk.js → tlog-theme-Bul2Na3u.js} +1237 -12
  85. package/dist/{trace-CjzYeIxN.js → trace-Bh8WnoMo.js} +5 -0
  86. package/dist/vue/agent/create-png-terminal-graphic-renderer.d.ts +19 -0
  87. package/dist/vue/components/T3DViewport.d.ts +473 -0
  88. package/dist/vue/components/TAgentTerminalGraphic.d.ts +494 -0
  89. package/dist/vue/components/TCharts.d.ts +1121 -0
  90. package/dist/vue/components/TFeedback.d.ts +1 -1
  91. package/dist/vue/components/TFlex.d.ts +389 -0
  92. package/dist/vue/components/TForm.d.ts +4 -4
  93. package/dist/vue/components/TLogSearchBar.d.ts +3 -3
  94. package/dist/vue/components/TLogSearchPager.d.ts +2 -2
  95. package/dist/vue/components/TMarkdownText.d.ts +162 -4
  96. package/dist/vue/components/TMermaidText.d.ts +900 -0
  97. package/dist/vue/components/TVideo.d.ts +291 -0
  98. package/dist/vue/components/TVirtualList.d.ts +9 -0
  99. package/dist/vue/components/TVirtualMarkdown.d.ts +170 -9
  100. package/dist/vue/components/TVirtualRows.d.ts +9 -0
  101. package/dist/vue/components/TerminalProvider.d.ts +2 -0
  102. package/dist/vue/context.d.ts +24 -0
  103. package/dist/vue/index.d.ts +5 -0
  104. package/dist/vue/layout/flex.d.ts +67 -0
  105. package/dist/vue/markdown/ast.d.ts +5 -2
  106. package/dist/vue/markdown/document.d.ts +5 -0
  107. package/dist/vue/markdown/image-actions.d.ts +14 -0
  108. package/dist/vue/markdown/image.d.ts +11 -0
  109. package/dist/vue/markdown/link-actions.d.ts +14 -0
  110. package/dist/vue/markdown/math-actions.d.ts +14 -0
  111. package/dist/vue/markdown/math.d.ts +6 -0
  112. package/dist/vue/markdown/render.d.ts +28 -0
  113. package/dist/vue/markdown/types.d.ts +78 -0
  114. package/dist/vue/mermaid/beautiful-mermaid.d.ts +1436 -0
  115. package/dist/vue/render/render-manager.d.ts +7 -0
  116. package/dist/vue/video/types.d.ts +39 -0
  117. package/dist/vue.cjs +7207 -12437
  118. package/dist/vue.js +704 -38
  119. package/dist/wheel-scroll-DASkEZr-.js +106 -0
  120. package/dist/{hyperlink-Bn02UXJb.js → width-GqllnV8C.js} +166 -111
  121. package/package.json +119 -14
  122. package/dist/frame-perf-C6Xfg85O.js +0 -24
  123. package/dist/sgr-BmzxEjAO.js +0 -304
  124. /package/dist/{ansi-palette-CNXqFciC.js → ansi-palette-CH6jc2Z7.js} +0 -0
  125. /package/dist/{path-suggest-BNqcuE3-.js → path-suggest-Dndu4dTi.js} +0 -0
@@ -6,6 +6,6 @@ export { layoutMarkdownBlocks } from "./vue/markdown/layout.js";
6
6
  export { createTuiMarkdownParser, isSafeMarkdownLink } from "./vue/markdown/parser.js";
7
7
  export type { TuiMarkdownBlockSource, TuiMarkdownBlockSourceOptions, TuiMarkdownBlockSourceSnapshot, } from "./vue/markdown/block-source.js";
8
8
  export type { TuiMarkdownLayoutOptions } from "./vue/markdown/layout.js";
9
- export type { TuiMarkdownBlock, TuiMarkdownInlineSegment, TuiMarkdownNode, TuiMarkdownTableCell, TuiMarkdownTableCellAlign, TuiMarkdownVisualRow, TuiMarkdownVisualSegment, } from "./vue/markdown/types.js";
9
+ export type { TuiMarkdownBlock, TuiMarkdownGraphicSegment, TuiMarkdownImageActionPayload, TuiMarkdownImageResolver, TuiMarkdownImageResolverResult, TuiMarkdownImageSize, TuiMarkdownInlineSegment, TuiMarkdownLinkActionPayload, TuiMarkdownMathActionPayload, TuiMarkdownMathSegment, TuiMarkdownNode, TuiMarkdownTableCell, TuiMarkdownTableCellAlign, TuiMarkdownVisualRow, TuiMarkdownVisualSegment, } from "./vue/markdown/types.js";
10
10
  export type { TuiMarkdownParseConfig, TuiMarkdownParser } from "./vue/markdown/parser.js";
11
11
  export type { TuiMarkdownTheme, TuiMarkdownThemeOverrides } from "./vue/markdown/theme.js";
@@ -6,6 +6,6 @@ export { layoutMarkdownBlocks } from "./vue/markdown/layout.js";
6
6
  export { createTuiMarkdownParser, isSafeMarkdownLink } from "./vue/markdown/parser.js";
7
7
  export type { TuiMarkdownBlockSource, TuiMarkdownBlockSourceOptions, TuiMarkdownBlockSourceSnapshot, } from "./vue/markdown/block-source.js";
8
8
  export type { TuiMarkdownLayoutOptions } from "./vue/markdown/layout.js";
9
- export type { TuiMarkdownBlock, TuiMarkdownInlineSegment, TuiMarkdownNode, TuiMarkdownTableCell, TuiMarkdownTableCellAlign, TuiMarkdownVisualRow, TuiMarkdownVisualSegment, } from "./vue/markdown/types.js";
9
+ export type { TuiMarkdownBlock, TuiMarkdownGraphicSegment, TuiMarkdownImageActionPayload, TuiMarkdownImageResolver, TuiMarkdownImageResolverResult, TuiMarkdownImageSize, TuiMarkdownInlineSegment, TuiMarkdownLinkActionPayload, TuiMarkdownMathActionPayload, TuiMarkdownMathSegment, TuiMarkdownNode, TuiMarkdownTableCell, TuiMarkdownTableCellAlign, TuiMarkdownVisualRow, TuiMarkdownVisualSegment, } from "./vue/markdown/types.js";
10
10
  export type { TuiMarkdownParseConfig, TuiMarkdownParser } from "./vue/markdown/parser.js";
11
11
  export type { TuiMarkdownTheme, TuiMarkdownThemeOverrides } from "./vue/markdown/theme.js";
package/dist/markdown.js CHANGED
@@ -1,8 +1,13 @@
1
- import "./hyperlink-Bn02UXJb.js";
2
- import { intersectRect, translateRect, useLayout, useRenderNode, useTerminal, useVisibility, withTextWidthProvider } from "./wheel-scroll-vBRaQ7p-.js";
3
- import "./terminal-selection-DBinO6p5.js";
4
- import { TVirtualMarkdown, buildMarkdownBlocks, buildMarkdownVisualRows, createMarkdownBlockSource, createTuiMarkdownParser, isSafeMarkdownLink, layoutMarkdownBlocks, markdownThemeSignature, paintMarkdownVisualRow } from "./block-source-CKUOnkgT.js";
5
- import { computed, defineComponent, getCurrentInstance, h, markRaw, onBeforeUnmount, shallowRef, watch } from "vue";
1
+ import "./hyperlink-_1FAj7Wq.js";
2
+ import "./width-GqllnV8C.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
+ import { computed, defineComponent, getCurrentInstance, h, inject, markRaw, onBeforeUnmount, shallowRef, watch } from "vue";
6
11
 
7
12
  //#region src/vue/components/TMarkdownText.ts
8
13
  const TMarkdownText = defineComponent({
@@ -55,13 +60,60 @@ const TMarkdownText = defineComponent({
55
60
  theme: {
56
61
  type: Object,
57
62
  default: void 0
63
+ },
64
+ imageRenderer: {
65
+ type: Function,
66
+ default: void 0
67
+ },
68
+ imageMinWidth: {
69
+ type: Number,
70
+ default: void 0
71
+ },
72
+ imageMaxWidth: {
73
+ type: Number,
74
+ default: void 0
75
+ },
76
+ imageMinHeight: {
77
+ type: Number,
78
+ default: void 0
79
+ },
80
+ imageMaxHeight: {
81
+ type: Number,
82
+ default: void 0
83
+ },
84
+ imagePreserveAspectRatio: {
85
+ type: Boolean,
86
+ default: true
87
+ },
88
+ imageActions: {
89
+ type: Boolean,
90
+ default: false
91
+ },
92
+ mathActions: {
93
+ type: Boolean,
94
+ default: false
95
+ },
96
+ linkActions: {
97
+ type: Boolean,
98
+ default: false
99
+ },
100
+ imageOcclusionRects: {
101
+ type: Array,
102
+ default: void 0
58
103
  }
59
104
  },
60
- setup(props) {
105
+ emits: {
106
+ imageAction: (_payload) => true,
107
+ mathAction: (_payload) => true,
108
+ linkAction: (_payload) => true
109
+ },
110
+ setup(props, { emit }) {
61
111
  const instance = getCurrentInstance();
62
112
  const { terminal, defaultStyle, scheduler, widthProvider } = useTerminal();
63
113
  const layout = useLayout();
64
114
  const { visible, rootProps } = useVisibility();
115
+ const parentEventZ = inject(EventZIndexContextKey, computed(() => 0));
116
+ const eventZ = computed(() => (parentEventZ.value ?? 0) + (props.zIndex ?? 0));
65
117
  const rows = shallowRef(markRaw([]));
66
118
  const documentVersion = shallowRef(0);
67
119
  let builtOnce = false;
@@ -71,6 +123,10 @@ const TMarkdownText = defineComponent({
71
123
  streaming: props.streaming,
72
124
  customHtmlTags: props.customHtmlTags
73
125
  })));
126
+ const graphicsOutputVersion = shallowRef(getTerminalGraphicsOutputVersion(terminal));
127
+ const unsubscribeGraphicsOutput = subscribeTerminalGraphicsOutput(terminal, () => {
128
+ graphicsOutputVersion.value = getTerminalGraphicsOutputVersion(terminal);
129
+ });
74
130
  watch(() => `${props.streaming ? 1 : 0}:${(props.customHtmlTags ?? []).join("\0")}`, () => {
75
131
  parser.value = markRaw(createTuiMarkdownParser({
76
132
  streaming: props.streaming,
@@ -80,7 +136,15 @@ const TMarkdownText = defineComponent({
80
136
  function rebuildRows() {
81
137
  rows.value = markRaw(withTextWidthProvider(widthProvider, () => buildMarkdownVisualRows(props.content, props.w, parser.value, {
82
138
  final: props.final,
83
- theme: props.theme
139
+ theme: props.theme,
140
+ imageResolver: props.imageRenderer,
141
+ imageSize: {
142
+ minWidth: props.imageMinWidth,
143
+ maxWidth: props.imageMaxWidth,
144
+ minHeight: props.imageMinHeight,
145
+ maxHeight: props.imageMaxHeight,
146
+ preserveAspectRatio: props.imagePreserveAspectRatio
147
+ }
84
148
  })));
85
149
  documentVersion.value++;
86
150
  }
@@ -108,13 +172,21 @@ const TMarkdownText = defineComponent({
108
172
  () => props.w,
109
173
  () => parser.value,
110
174
  () => props.final,
111
- () => markdownThemeSignature(props.theme)
175
+ () => props.imageRenderer,
176
+ () => markdownThemeSignature(props.theme),
177
+ () => props.imageMinWidth,
178
+ () => props.imageMaxWidth,
179
+ () => props.imageMinHeight,
180
+ () => props.imageMaxHeight,
181
+ () => props.imagePreserveAspectRatio
112
182
  ], () => {
113
183
  scheduleRebuild();
114
184
  }, { immediate: true });
115
185
  onBeforeUnmount(() => {
116
186
  alive = false;
117
187
  rebuildVersion++;
188
+ unsubscribeGraphicsOutput();
189
+ clearMarkdownImageGraphics(terminal, fullRect.value);
118
190
  });
119
191
  const fullRect = computed(() => {
120
192
  const height = props.h ?? Math.max(1, rows.value.length);
@@ -135,53 +207,141 @@ const TMarkdownText = defineComponent({
135
207
  h: 0
136
208
  };
137
209
  });
138
- useRenderNode(() => ({
139
- zIndex: props.zIndex,
140
- rect: visible.value ? absRect.value : {
141
- x: 0,
142
- y: 0,
143
- w: 0,
144
- h: 0
145
- },
146
- deps: [
147
- visible.value,
148
- absRect.value,
149
- fullRect.value,
150
- props.style,
151
- props.clear,
152
- documentVersion.value,
153
- defaultStyle.value
154
- ],
155
- paint: (dirtyRows) => {
156
- withTextWidthProvider(widthProvider, () => {
157
- if (!visible.value) return;
158
- const r = absRect.value;
159
- const full = fullRect.value;
160
- if (r.w <= 0 || r.h <= 0) return;
161
- const baseStyle = props.style ?? defaultStyle.value;
162
- const clipStart = Math.max(0, Math.floor(r.x - full.x));
163
- const paintRow = (y) => {
164
- if (y < r.y || y >= r.y + r.h) return;
165
- const rowIndex = Math.floor(y - full.y);
166
- const row = rows.value[rowIndex];
167
- if (!row && !props.clear) return;
168
- paintMarkdownVisualRow(terminal, row, {
210
+ function imageActionAt(event) {
211
+ const r = absRect.value;
212
+ const full = fullRect.value;
213
+ return findMarkdownImageActionAt(rows.value, {
214
+ cellX: event.cellX,
215
+ cellY: event.cellY
216
+ }, {
217
+ screenRect: r,
218
+ rowOffset: Math.max(0, Math.floor(r.y - full.y)),
219
+ clipStart: Math.max(0, Math.floor(r.x - full.x))
220
+ });
221
+ }
222
+ function linkActionAt(event) {
223
+ const r = absRect.value;
224
+ const full = fullRect.value;
225
+ return findMarkdownLinkActionAt(rows.value, {
226
+ cellX: event.cellX,
227
+ cellY: event.cellY
228
+ }, {
229
+ screenRect: r,
230
+ rowOffset: Math.max(0, Math.floor(r.y - full.y)),
231
+ clipStart: Math.max(0, Math.floor(r.x - full.x))
232
+ });
233
+ }
234
+ function mathActionAt(event) {
235
+ const r = absRect.value;
236
+ const full = fullRect.value;
237
+ return findMarkdownMathActionAt(rows.value, {
238
+ cellX: event.cellX,
239
+ cellY: event.cellY
240
+ }, {
241
+ screenRect: r,
242
+ rowOffset: Math.max(0, Math.floor(r.y - full.y)),
243
+ clipStart: Math.max(0, Math.floor(r.x - full.x))
244
+ });
245
+ }
246
+ useTerminalNode(() => ({
247
+ rect: absRect.value,
248
+ zIndex: eventZ.value,
249
+ visible: visible.value && (props.imageActions || props.mathActions || props.linkActions),
250
+ focusable: false,
251
+ selectable: false,
252
+ handlers: { click: (event) => {
253
+ if (props.imageActions) {
254
+ const hit = imageActionAt(event);
255
+ if (hit) {
256
+ event.preventDefault();
257
+ emit("imageAction", hit);
258
+ return;
259
+ }
260
+ }
261
+ if (props.mathActions) {
262
+ const math = mathActionAt(event);
263
+ if (math) {
264
+ event.preventDefault();
265
+ emit("mathAction", math);
266
+ return;
267
+ }
268
+ }
269
+ if (!props.linkActions) return;
270
+ const link = linkActionAt(event);
271
+ if (!link) return;
272
+ event.preventDefault();
273
+ emit("linkAction", link);
274
+ } }
275
+ }));
276
+ useRenderNode(() => {
277
+ const full = fullRect.value;
278
+ return {
279
+ zIndex: props.zIndex,
280
+ rect: visible.value ? full : {
281
+ x: 0,
282
+ y: 0,
283
+ w: 0,
284
+ h: 0
285
+ },
286
+ deps: [
287
+ visible.value,
288
+ full.x,
289
+ full.y,
290
+ full.w,
291
+ full.h,
292
+ props.style,
293
+ props.clear,
294
+ documentVersion.value,
295
+ graphicsOutputVersion.value,
296
+ defaultStyle.value,
297
+ props.imageOcclusionRects
298
+ ],
299
+ paint: (dirtyRows) => {
300
+ withTextWidthProvider(widthProvider, () => {
301
+ if (!visible.value) return;
302
+ const r = absRect.value;
303
+ const full$1 = fullRect.value;
304
+ if (r.w <= 0 || r.h <= 0) return;
305
+ const baseStyle = props.style ?? defaultStyle.value;
306
+ const clipStart = Math.max(0, Math.floor(r.x - full$1.x));
307
+ const rowOffset = Math.max(0, Math.floor(r.y - full$1.y));
308
+ const isGraphicCovered = (rect) => {
309
+ return props.imageOcclusionRects?.some((item) => intersectRect(rect, item)) === true;
310
+ };
311
+ const keepGraphicIds = collectVisibleMarkdownImageGraphicIds(rows.value, {
169
312
  x: r.x,
170
- y,
313
+ y: r.y,
171
314
  w: r.w,
315
+ h: r.h,
316
+ rowOffset,
172
317
  clipStart,
173
- baseStyle,
174
- clear: props.clear
318
+ isGraphicCovered
175
319
  });
176
- };
177
- if (dirtyRows?.length) {
178
- for (const y of dirtyRows) paintRow(y);
179
- return;
180
- }
181
- for (let y = r.y; y < r.y + r.h; y++) paintRow(y);
182
- });
183
- }
184
- }));
320
+ const paintRow = (y) => {
321
+ if (y < r.y || y >= r.y + r.h) return;
322
+ const rowIndex = Math.floor(y - full$1.y);
323
+ const row = rows.value[rowIndex];
324
+ if (!row && !props.clear) return;
325
+ paintMarkdownVisualRow(terminal, row, {
326
+ x: r.x,
327
+ y,
328
+ w: r.w,
329
+ clipStart,
330
+ baseStyle,
331
+ clear: props.clear,
332
+ keepGraphicIds,
333
+ isGraphicCovered
334
+ });
335
+ };
336
+ if (dirtyRows?.length) {
337
+ for (const y of dirtyRows) paintRow(y);
338
+ return;
339
+ }
340
+ for (let y = r.y; y < r.y + r.h; y++) paintRow(y);
341
+ });
342
+ }
343
+ };
344
+ });
185
345
  return () => h("span", rootProps);
186
346
  }
187
347
  });
@@ -0,0 +1,123 @@
1
+ import { TMermaidText$1 as TMermaidText, isSimpleMermaidFlowchartSource, markMermaidRenderErrorFatal, tMermaidTextProps } from "./TMermaidText-frVr8Ysb.js";
2
+ import { defineComponent, h } from "vue";
3
+
4
+ //#region src/vue/mermaid/beautiful-mermaid.ts
5
+ const BEAUTIFUL_MERMAID_INSTALL_HINT = "Install beautiful-mermaid and use TMermaidText from @simon_he/vue-tui/mermaid or @simon_he/vue-tui/agent/mermaid, or pass a custom renderer prop.";
6
+ const MISSING_BEAUTIFUL_MERMAID_ERROR_CODE = "VUE_TUI_MISSING_BEAUTIFUL_MERMAID";
7
+ const INVALID_BEAUTIFUL_MERMAID_EXPORT_ERROR_CODE = "VUE_TUI_INVALID_BEAUTIFUL_MERMAID_EXPORT";
8
+ let cachedBeautifulMermaid = null;
9
+ function functionValue(value) {
10
+ return typeof value === "function" ? value : null;
11
+ }
12
+ function functionProp(target, key) {
13
+ if (!target || typeof target !== "object") return null;
14
+ if (!(key in target)) return null;
15
+ const value = target[key];
16
+ return typeof value === "function" ? value : null;
17
+ }
18
+ function errorMessage(error) {
19
+ return error instanceof Error ? error.message : String(error);
20
+ }
21
+ function codedError(message, code) {
22
+ const error = new Error(message);
23
+ error.code = code;
24
+ return error;
25
+ }
26
+ function missingBeautifulMermaidError(error) {
27
+ if (error && typeof error === "object" && errorCode(error) === MISSING_BEAUTIFUL_MERMAID_ERROR_CODE) return markMermaidRenderErrorFatal(error);
28
+ const detail = errorMessage(error);
29
+ return markMermaidRenderErrorFatal(codedError(`${BEAUTIFUL_MERMAID_INSTALL_HINT} (${detail})`, MISSING_BEAUTIFUL_MERMAID_ERROR_CODE));
30
+ }
31
+ function errorCode(error) {
32
+ if (!error || typeof error !== "object") return "";
33
+ const value = error.code;
34
+ return typeof value === "string" ? value : "";
35
+ }
36
+ function errorCause(error) {
37
+ if (!error || typeof error !== "object") return void 0;
38
+ return error.cause;
39
+ }
40
+ function isMissingBeautifulMermaid(error) {
41
+ return isMissingBeautifulMermaidWithSeen(error, new WeakSet());
42
+ }
43
+ function isMissingBeautifulMermaidWithSeen(error, seen) {
44
+ if (error && typeof error === "object") {
45
+ if (seen.has(error)) return false;
46
+ seen.add(error);
47
+ }
48
+ const message = errorMessage(error);
49
+ const code = errorCode(error);
50
+ if (code === MISSING_BEAUTIFUL_MERMAID_ERROR_CODE) return true;
51
+ const mentionsBeautifulMermaid = /Cannot find package ['"]beautiful-mermaid['"]/.test(message) || /Cannot find module ['"]beautiful-mermaid['"]/.test(message) || /Cannot resolve module ['"]beautiful-mermaid['"]/.test(message) || /Can't resolve ['"]beautiful-mermaid['"]/.test(message) || /Failed to resolve module specifier ['"]beautiful-mermaid['"]/.test(message) || /Failed to resolve import ['"]beautiful-mermaid['"]/.test(message) || /Could not resolve ['"]beautiful-mermaid['"]/.test(message);
52
+ if (mentionsBeautifulMermaid && (code === "" || code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND" || code === "UNRESOLVED_IMPORT")) return true;
53
+ const cause = errorCause(error);
54
+ return cause !== void 0 && isMissingBeautifulMermaidWithSeen(cause, seen);
55
+ }
56
+ function resolveBeautifulMermaidRenderer(mod) {
57
+ const renderer = functionProp(mod, "renderMermaidASCII") ?? functionProp(mod, "renderMermaidAscii") ?? functionValue(mod.default) ?? functionProp(mod.default, "renderMermaidASCII") ?? functionProp(mod.default, "renderMermaidAscii");
58
+ if (!renderer) throw markMermaidRenderErrorFatal(codedError("beautiful-mermaid is installed but does not export renderMermaidASCII.", INVALID_BEAUTIFUL_MERMAID_EXPORT_ERROR_CODE));
59
+ return renderer;
60
+ }
61
+ function hasErrorCode(error, code, seen = new WeakSet()) {
62
+ if (!error || typeof error !== "object") return false;
63
+ if (seen.has(error)) return false;
64
+ seen.add(error);
65
+ if (errorCode(error) === code) return true;
66
+ const cause = errorCause(error);
67
+ return cause !== void 0 && hasErrorCode(cause, code, seen);
68
+ }
69
+ function isBeautifulMermaidExportError(error) {
70
+ return hasErrorCode(error, INVALID_BEAUTIFUL_MERMAID_EXPORT_ERROR_CODE);
71
+ }
72
+ const isTransientBeautifulMermaidRenderError = (error) => {
73
+ if (isMissingBeautifulMermaid(error)) return false;
74
+ if (isBeautifulMermaidExportError(error)) return false;
75
+ return true;
76
+ };
77
+ async function loadBeautifulMermaid() {
78
+ if (!cachedBeautifulMermaid) cachedBeautifulMermaid = import("beautiful-mermaid").then((mod) => mod).catch((error) => {
79
+ cachedBeautifulMermaid = null;
80
+ if (isMissingBeautifulMermaid(error)) throw missingBeautifulMermaidError(error);
81
+ throw markMermaidRenderErrorFatal(error);
82
+ });
83
+ return cachedBeautifulMermaid;
84
+ }
85
+ const beautifulMermaidRenderer = async (code, options) => {
86
+ try {
87
+ const mod = await loadBeautifulMermaid();
88
+ const renderer = resolveBeautifulMermaidRenderer(mod);
89
+ return await renderer(code, options);
90
+ } catch (error) {
91
+ if (isMissingBeautifulMermaid(error)) throw missingBeautifulMermaidError(error);
92
+ throw error;
93
+ }
94
+ };
95
+ function createBeautifulMermaidRenderer() {
96
+ return beautifulMermaidRenderer;
97
+ }
98
+ const TMermaidText$1 = defineComponent({
99
+ name: "TMermaidText",
100
+ inheritAttrs: false,
101
+ props: tMermaidTextProps,
102
+ emits: { copy: (_payload) => true },
103
+ setup(props, { attrs, emit, slots }) {
104
+ return () => {
105
+ const renderer = props.renderer ?? beautifulMermaidRenderer;
106
+ const shouldRenderSource = props.shouldRenderSource ?? isSimpleMermaidFlowchartSource;
107
+ return h(TMermaidText, {
108
+ ...attrs,
109
+ ...props,
110
+ renderer,
111
+ shouldRenderSource,
112
+ isTransientError: props.isTransientError ?? isTransientBeautifulMermaidRenderError,
113
+ onCopy: (payload) => emit("copy", payload)
114
+ }, slots);
115
+ };
116
+ }
117
+ });
118
+ const TMermaid = TMermaidText$1;
119
+ const TBeautifulMermaidText = TMermaidText$1;
120
+ const TBeautifulMermaid = TMermaidText$1;
121
+
122
+ //#endregion
123
+ export { TBeautifulMermaid, TBeautifulMermaidText, TMermaid, TMermaidText$1 as TMermaidText, beautifulMermaidRenderer, createBeautifulMermaidRenderer };