@simon_he/vue-tui 1.1.2 → 1.1.4

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 (52) hide show
  1. package/dist/{TMermaidText-frVr8Ysb.js → TMermaidText-wLnMMvVS.js} +1 -1
  2. package/dist/{TSelect-tJ87rKPM.js → TSelect-CMBOOFwK.js} +4 -4
  3. package/dist/{TTree-CGdE-CYu.js → TTree-kk8ntrpg.js} +6 -5
  4. package/dist/agent/mermaid.d.cts +2 -2
  5. package/dist/agent/mermaid.d.ts +2 -2
  6. package/dist/agent.cjs +3896 -13616
  7. package/dist/agent.js +25 -82
  8. package/dist/{block-source-CrlmaBM5.js → block-source-D3YGTErb.js} +447 -326
  9. package/dist/cli.cjs +52 -15
  10. package/dist/cli.js +69 -14
  11. package/dist/core.js +3 -3
  12. package/dist/{hyperlink-_1FAj7Wq.js → create-terminal-Db_-UGVQ.js} +474 -102
  13. package/dist/{dom-renderer-DXx8fWzD.js → dom-renderer-BfwAEQMf.js} +3 -2
  14. package/dist/experimental.cjs +99 -66
  15. package/dist/experimental.js +20 -74
  16. package/dist/hyperlink-clbb_ha_.js +100 -0
  17. package/dist/index.js +8 -8
  18. package/dist/{linkify-D68T7rdW.js → linkify-CL9wwnZN.js} +2 -2
  19. package/dist/markdown.cjs +3376 -13056
  20. package/dist/markdown.d.cts +4 -0
  21. package/dist/markdown.d.ts +4 -0
  22. package/dist/markdown.js +79 -8
  23. package/dist/math-image-BZhmfUeu.js +308 -0
  24. package/dist/mermaid-uEfRItDe.js +1205 -0
  25. package/dist/mermaid.cjs +1089 -3
  26. package/dist/mermaid.d.cts +4 -0
  27. package/dist/mermaid.d.ts +4 -0
  28. package/dist/mermaid.js +7 -5
  29. package/dist/{rect-DUpeDfBg.js → rect-JzWMJxxc.js} +1 -1
  30. package/dist/renderer/cli/stdout-renderer.d.ts +44 -0
  31. package/dist/renderer/terminal-graphics.d.ts +44 -0
  32. package/dist/renderer-dom.js +4 -4
  33. package/dist/{terminal-graphics-Bbe83wSr.js → terminal-graphics-DWZrl3oh.js} +85 -2
  34. package/dist/{tlog-theme-Bul2Na3u.js → tlog-theme-DqnF_zNe.js} +5 -4
  35. package/dist/vue/components/TAgentTerminalGraphic.d.ts +1 -1
  36. package/dist/vue/components/TMarkdownText.d.ts +70 -2
  37. package/dist/vue/components/TMermaidImage.d.ts +733 -0
  38. package/dist/vue/components/TMermaidText.d.ts +2 -2
  39. package/dist/vue/components/TVirtualMarkdown.d.ts +70 -2
  40. package/dist/vue/markdown/ast.d.ts +5 -0
  41. package/dist/vue/markdown/document.d.ts +3 -0
  42. package/dist/vue/markdown/math-image.d.ts +68 -0
  43. package/dist/vue/markdown/math.d.ts +2 -0
  44. package/dist/vue/markdown/theme.d.ts +12 -0
  45. package/dist/vue/markdown/types.d.ts +12 -2
  46. package/dist/vue/mermaid/beautiful-mermaid.d.ts +4 -4
  47. package/dist/vue/mermaid/mermaid-image.d.ts +65 -0
  48. package/dist/vue.js +9 -9
  49. package/package.json +20 -3
  50. package/dist/mermaid-BNhM1jAZ.js +0 -123
  51. package/dist/width-GqllnV8C.js +0 -474
  52. /package/dist/{ansi-palette-CH6jc2Z7.js → ansi-palette-BHF1rN7R.js} +0 -0
@@ -522,10 +522,10 @@ export declare const TMermaidText: import("vue").DefineComponent<import("vue").E
522
522
  }>;
523
523
  readonly final: boolean;
524
524
  readonly streaming: boolean;
525
+ readonly ascii: boolean;
525
526
  readonly paddingX: number;
526
527
  readonly paddingY: number;
527
528
  readonly boxBorderPadding: number;
528
- readonly ascii: boolean;
529
529
  readonly isTransientError: TMermaidTransientErrorClassifier;
530
530
  readonly shouldRenderSource: TMermaidRenderEligibility;
531
531
  readonly incompleteText: string;
@@ -880,10 +880,10 @@ export declare const TMermaid: import("vue").DefineComponent<import("vue").Extra
880
880
  }>;
881
881
  readonly final: boolean;
882
882
  readonly streaming: boolean;
883
+ readonly ascii: boolean;
883
884
  readonly paddingX: number;
884
885
  readonly paddingY: number;
885
886
  readonly boxBorderPadding: number;
886
- readonly ascii: boolean;
887
887
  readonly isTransientError: TMermaidTransientErrorClassifier;
888
888
  readonly shouldRenderSource: TMermaidRenderEligibility;
889
889
  readonly incompleteText: string;
@@ -88,6 +88,34 @@ export declare const TVirtualMarkdown: import("vue").DefineComponent<import("vue
88
88
  type: BooleanConstructor;
89
89
  default: boolean;
90
90
  };
91
+ mathImages: {
92
+ type: BooleanConstructor;
93
+ default: boolean;
94
+ };
95
+ mathCellWidthPx: {
96
+ type: NumberConstructor;
97
+ default: undefined;
98
+ };
99
+ mathCellHeightPx: {
100
+ type: NumberConstructor;
101
+ default: undefined;
102
+ };
103
+ mathScale: {
104
+ type: NumberConstructor;
105
+ default: undefined;
106
+ };
107
+ mathColor: {
108
+ type: StringConstructor;
109
+ default: undefined;
110
+ };
111
+ mathMaxWidthCells: {
112
+ type: NumberConstructor;
113
+ default: undefined;
114
+ };
115
+ mathBaselineRatio: {
116
+ type: NumberConstructor;
117
+ default: undefined;
118
+ };
91
119
  imageActions: {
92
120
  type: BooleanConstructor;
93
121
  default: boolean;
@@ -200,6 +228,34 @@ export declare const TVirtualMarkdown: import("vue").DefineComponent<import("vue
200
228
  type: BooleanConstructor;
201
229
  default: boolean;
202
230
  };
231
+ mathImages: {
232
+ type: BooleanConstructor;
233
+ default: boolean;
234
+ };
235
+ mathCellWidthPx: {
236
+ type: NumberConstructor;
237
+ default: undefined;
238
+ };
239
+ mathCellHeightPx: {
240
+ type: NumberConstructor;
241
+ default: undefined;
242
+ };
243
+ mathScale: {
244
+ type: NumberConstructor;
245
+ default: undefined;
246
+ };
247
+ mathColor: {
248
+ type: StringConstructor;
249
+ default: undefined;
250
+ };
251
+ mathMaxWidthCells: {
252
+ type: NumberConstructor;
253
+ default: undefined;
254
+ };
255
+ mathBaselineRatio: {
256
+ type: NumberConstructor;
257
+ default: undefined;
258
+ };
203
259
  imageActions: {
204
260
  type: BooleanConstructor;
205
261
  default: boolean;
@@ -227,6 +283,8 @@ export declare const TVirtualMarkdown: import("vue").DefineComponent<import("vue
227
283
  source: string;
228
284
  raw: string;
229
285
  rendered: boolean;
286
+ pendingImage?: boolean;
287
+ mode?: "inline" | "display";
230
288
  }>;
231
289
  rect: Readonly<{
232
290
  x: number;
@@ -241,9 +299,11 @@ export declare const TVirtualMarkdown: import("vue").DefineComponent<import("vue
241
299
  }>) => any) | undefined;
242
300
  onImageAction?: ((_payload: Readonly<{
243
301
  image: Readonly<{
244
- kind: "image";
245
- src: string;
302
+ kind: "image" | "math";
303
+ src?: string;
246
304
  alt?: string;
305
+ tex?: string;
306
+ raw?: string;
247
307
  mime?: string;
248
308
  base64?: string;
249
309
  originalBase64?: string;
@@ -309,6 +369,7 @@ export declare const TVirtualMarkdown: import("vue").DefineComponent<import("vue
309
369
  codeBlock: Partial<Style>;
310
370
  thematicBreak: Partial<Style>;
311
371
  html: Partial<Style>;
372
+ math: Partial<Style>;
312
373
  }>>;
313
374
  blocks: readonly TuiMarkdownBlock[];
314
375
  imageRenderer: TuiMarkdownImageResolver;
@@ -317,6 +378,13 @@ export declare const TVirtualMarkdown: import("vue").DefineComponent<import("vue
317
378
  imageMinHeight: number;
318
379
  imageMaxHeight: number;
319
380
  imagePreserveAspectRatio: boolean;
381
+ mathImages: boolean;
382
+ mathCellWidthPx: number;
383
+ mathCellHeightPx: number;
384
+ mathScale: number;
385
+ mathColor: string;
386
+ mathMaxWidthCells: number;
387
+ mathBaselineRatio: number;
320
388
  imageActions: boolean;
321
389
  mathActions: boolean;
322
390
  linkActions: boolean;
@@ -1,6 +1,11 @@
1
+ import { type TuiMarkdownMathImageOptions } from "./math-image.js";
1
2
  import { type TuiMarkdownTheme } from "./theme.js";
2
3
  import type { TuiMarkdownBlock, TuiMarkdownImageResolver, TuiMarkdownImageSize, TuiMarkdownNode } from "./types.js";
4
+ export type TuiMarkdownMathOptions = Readonly<{
5
+ enabled?: boolean;
6
+ } & TuiMarkdownMathImageOptions>;
3
7
  export declare function markdownAstToBlocks(nodes: readonly TuiMarkdownNode[], theme: TuiMarkdownTheme, options?: Readonly<{
4
8
  imageResolver?: TuiMarkdownImageResolver;
5
9
  imageSize?: TuiMarkdownImageSize;
10
+ math?: TuiMarkdownMathOptions;
6
11
  }>): readonly TuiMarkdownBlock[];
@@ -1,4 +1,5 @@
1
1
  import type { TuiMarkdownImageResolver, TuiMarkdownImageSize } from "./types.js";
2
+ import { type TuiMarkdownMathOptions } from "./ast.js";
2
3
  import { type TuiMarkdownParser } from "./parser.js";
3
4
  import { type TuiMarkdownThemeOverrides } from "./theme.js";
4
5
  import type { TuiMarkdownBlock, TuiMarkdownNode, TuiMarkdownVisualRow } from "./types.js";
@@ -12,6 +13,7 @@ export declare function buildMarkdownBlocks(content: string, parser: TuiMarkdown
12
13
  theme?: TuiMarkdownThemeOverrides;
13
14
  imageResolver?: TuiMarkdownImageResolver;
14
15
  imageSize?: TuiMarkdownImageSize;
16
+ math?: TuiMarkdownMathOptions;
15
17
  }>): Readonly<{
16
18
  nodes: readonly TuiMarkdownNode[];
17
19
  blocks: readonly TuiMarkdownBlock[];
@@ -22,4 +24,5 @@ export declare function buildMarkdownVisualRows(content: string, width: number,
22
24
  widthProvider?: WidthProvider;
23
25
  imageResolver?: TuiMarkdownImageResolver;
24
26
  imageSize?: TuiMarkdownImageSize;
27
+ math?: TuiMarkdownMathOptions;
25
28
  }>): readonly TuiMarkdownVisualRow[];
@@ -0,0 +1,68 @@
1
+ import type { TuiMarkdownVisualRow } from "./types.js";
2
+ export type TuiMarkdownMathMode = "inline" | "display";
3
+ export type TuiMarkdownMathImageCells = Readonly<{
4
+ base64: string;
5
+ widthCells: number;
6
+ heightCells: number;
7
+ }>;
8
+ export type TuiMarkdownMathImageOptions = Readonly<{
9
+ cellWidthPx?: number;
10
+ cellHeightPx?: number;
11
+ scale?: number;
12
+ color?: string;
13
+ maxWidthCells?: number;
14
+ /**
15
+ * Vertical position of the text baseline inside a terminal cell, as a
16
+ * fraction of the cell height (0 = top, 1 = bottom). Inline formula images
17
+ * are padded so their baseline lands here. Defaults to 0.78.
18
+ */
19
+ baselineRatio?: number;
20
+ }>;
21
+ export type TuiMarkdownMathRasterizer = (tex: string, mode: TuiMarkdownMathMode, options: Required<TuiMarkdownMathImageOptions>) => Promise<TuiMarkdownMathImageCells | null>;
22
+ type RequiredMathImageOptions = Required<TuiMarkdownMathImageOptions>;
23
+ export declare function resolveMarkdownMathColor(fg: unknown): string | undefined;
24
+ export declare function normalizeMathImageOptions(options?: TuiMarkdownMathImageOptions): RequiredMathImageOptions;
25
+ /**
26
+ * Install a custom TeX -> PNG rasterizer (e.g. consumers that already have a
27
+ * katex/mathjax pipeline). Passing `null` restores the built-in lazy loader.
28
+ */
29
+ export declare function setMarkdownMathRasterizer(rasterizer: TuiMarkdownMathRasterizer | null): void;
30
+ export declare function subscribeMarkdownMathImage(listener: () => void): () => void;
31
+ /**
32
+ * True when a rasterizer is confirmed available (a custom one was installed or
33
+ * the built-in MathJax+resvg stack finished loading). Components should gate
34
+ * image production on this so they never spend time rasterizing formulas while
35
+ * the math engine is still loading or missing.
36
+ */
37
+ export declare function isMarkdownMathImageRendererReady(): boolean;
38
+ /**
39
+ * Ensure the math image rasterizer is loaded (or resolved as unavailable).
40
+ * Resolves `true` once a rasterizer is usable. Safe to call repeatedly; the
41
+ * underlying load is shared and its outcome is cached.
42
+ */
43
+ export declare function loadMarkdownMathImageRenderer(): Promise<boolean>;
44
+ /** Synchronous cache lookup used by the markdown AST/layout phase. */
45
+ export declare function getCachedMarkdownMathImage(tex: string, mode: TuiMarkdownMathMode, options?: TuiMarkdownMathImageOptions): TuiMarkdownMathImageCells | null;
46
+ /**
47
+ * Drop all cached rasterized formulas (PNG + failed lookups). Useful for long
48
+ * running processes that change cell metrics, and for tests.
49
+ */
50
+ export declare function clearMarkdownMathImageCache(): void;
51
+ /**
52
+ * Resolve a TeX formula to a PNG base64 + cell size. Cached per
53
+ * (tex, mode, cell metrics, color). In-flight requests are deduped. When a new
54
+ * image finishes, `subscribeMarkdownMathImage` listeners are notified so
55
+ * components can rebuild/re-paint with the real size.
56
+ */
57
+ export declare function getMarkdownMathImage(tex: string, mode: TuiMarkdownMathMode, options?: TuiMarkdownMathImageOptions): Promise<TuiMarkdownMathImageCells | null>;
58
+ /**
59
+ * Kick off rasterization for every math graphic segment in the given row range
60
+ * that does not have a cached PNG yet. Safe to call after every row rebuild;
61
+ * in-flight and cached requests are deduped inside getMarkdownMathImage. Pass a
62
+ * viewport to avoid rasterizing off-screen formulas (e.g. virtualized views).
63
+ */
64
+ export declare function enqueueMarkdownMathImages(rows: readonly TuiMarkdownVisualRow[], options?: TuiMarkdownMathImageOptions, viewport?: Readonly<{
65
+ firstRow: number;
66
+ lastRow: number;
67
+ }>): void;
68
+ export {};
@@ -2,5 +2,7 @@ export type TuiMarkdownInlineMathRender = Readonly<{
2
2
  text: string;
3
3
  supported: boolean;
4
4
  }>;
5
+ export declare function subscribeMarkdownMathRenderer(listener: () => void): () => void;
6
+ export declare function loadMarkdownMathRenderer(): Promise<boolean>;
5
7
  export declare function renderMarkdownInlineMathSegment(tex: string): TuiMarkdownInlineMathRender;
6
8
  export declare function renderMarkdownInlineMath(tex: string): string;
@@ -11,6 +11,7 @@ export type TuiMarkdownTheme = Readonly<{
11
11
  codeBlock: Style;
12
12
  thematicBreak: Style;
13
13
  html: Style;
14
+ math: Style;
14
15
  }>;
15
16
  export type TuiMarkdownThemeOverrides = Readonly<Partial<{
16
17
  heading: readonly Partial<Style>[];
@@ -24,6 +25,7 @@ export type TuiMarkdownThemeOverrides = Readonly<Partial<{
24
25
  codeBlock: Partial<Style>;
25
26
  thematicBreak: Partial<Style>;
26
27
  html: Partial<Style>;
28
+ math: Partial<Style>;
27
29
  }>>;
28
30
  export declare const DEFAULT_TUI_MARKDOWN_THEME: Readonly<{
29
31
  heading: readonly [Readonly<{
@@ -181,6 +183,16 @@ export declare const DEFAULT_TUI_MARKDOWN_THEME: Readonly<{
181
183
  inverse?: boolean;
182
184
  href?: string;
183
185
  }>;
186
+ math: Readonly<{
187
+ fg?: string;
188
+ bg?: string;
189
+ bold?: boolean;
190
+ dim?: boolean;
191
+ italic?: boolean;
192
+ underline?: boolean;
193
+ inverse?: boolean;
194
+ href?: string;
195
+ }>;
184
196
  }>;
185
197
  export declare function markdownThemeSignature(overrides?: TuiMarkdownThemeOverrides): string;
186
198
  export declare function resolveTuiMarkdownTheme(overrides?: TuiMarkdownThemeOverrides): TuiMarkdownTheme;
@@ -13,9 +13,11 @@ export type TuiMarkdownImageSize = Readonly<{
13
13
  preserveAspectRatio?: boolean;
14
14
  }>;
15
15
  export type TuiMarkdownGraphicSegment = Readonly<{
16
- kind: "image";
17
- src: string;
16
+ kind: "image" | "math";
17
+ src?: string;
18
18
  alt?: string;
19
+ tex?: string;
20
+ raw?: string;
19
21
  mime?: string;
20
22
  base64?: string;
21
23
  originalBase64?: string;
@@ -63,6 +65,14 @@ export type TuiMarkdownMathSegment = Readonly<{
63
65
  source: string;
64
66
  raw: string;
65
67
  rendered: boolean;
68
+ /**
69
+ * Set on the boxed fallback of block-level math / raw inline math: the
70
+ * formula still needs to be rasterized once the graphics/raster stack is
71
+ * available. `mode` tells the rasterizer whether to render inline (fits one
72
+ * line, baseline-aligned) or display style.
73
+ */
74
+ pendingImage?: boolean;
75
+ mode?: "inline" | "display";
66
76
  }>;
67
77
  export type TuiMarkdownMathActionPayload = Readonly<{
68
78
  math: TuiMarkdownMathSegment;
@@ -342,10 +342,10 @@ export declare const TMermaidText: import("vue").DefineComponent<import("vue").E
342
342
  }>;
343
343
  readonly final: boolean;
344
344
  readonly streaming: boolean;
345
+ readonly ascii: boolean;
345
346
  readonly paddingX: number;
346
347
  readonly paddingY: number;
347
348
  readonly boxBorderPadding: number;
348
- readonly ascii: boolean;
349
349
  readonly isTransientError: TMermaidTransientErrorClassifier;
350
350
  readonly shouldRenderSource: import("../index.js").TMermaidRenderEligibility;
351
351
  readonly incompleteText: string;
@@ -700,10 +700,10 @@ export declare const TMermaid: import("vue").DefineComponent<import("vue").Extra
700
700
  }>;
701
701
  readonly final: boolean;
702
702
  readonly streaming: boolean;
703
+ readonly ascii: boolean;
703
704
  readonly paddingX: number;
704
705
  readonly paddingY: number;
705
706
  readonly boxBorderPadding: number;
706
- readonly ascii: boolean;
707
707
  readonly isTransientError: TMermaidTransientErrorClassifier;
708
708
  readonly shouldRenderSource: import("../index.js").TMermaidRenderEligibility;
709
709
  readonly incompleteText: string;
@@ -1058,10 +1058,10 @@ export declare const TBeautifulMermaidText: import("vue").DefineComponent<import
1058
1058
  }>;
1059
1059
  readonly final: boolean;
1060
1060
  readonly streaming: boolean;
1061
+ readonly ascii: boolean;
1061
1062
  readonly paddingX: number;
1062
1063
  readonly paddingY: number;
1063
1064
  readonly boxBorderPadding: number;
1064
- readonly ascii: boolean;
1065
1065
  readonly isTransientError: TMermaidTransientErrorClassifier;
1066
1066
  readonly shouldRenderSource: import("../index.js").TMermaidRenderEligibility;
1067
1067
  readonly incompleteText: string;
@@ -1416,10 +1416,10 @@ export declare const TBeautifulMermaid: import("vue").DefineComponent<import("vu
1416
1416
  }>;
1417
1417
  readonly final: boolean;
1418
1418
  readonly streaming: boolean;
1419
+ readonly ascii: boolean;
1419
1420
  readonly paddingX: number;
1420
1421
  readonly paddingY: number;
1421
1422
  readonly boxBorderPadding: number;
1422
- readonly ascii: boolean;
1423
1423
  readonly isTransientError: TMermaidTransientErrorClassifier;
1424
1424
  readonly shouldRenderSource: import("../index.js").TMermaidRenderEligibility;
1425
1425
  readonly incompleteText: string;
@@ -0,0 +1,65 @@
1
+ export type TuiMermaidImageCells = Readonly<{
2
+ base64: string;
3
+ widthCells: number;
4
+ heightCells: number;
5
+ naturalWidth?: number;
6
+ naturalHeight?: number;
7
+ }>;
8
+ export type TuiMermaidImageOptions = Readonly<{
9
+ cellWidthPx?: number;
10
+ cellHeightPx?: number;
11
+ scale?: number;
12
+ /** Diagram background color; the raster stays transparent and this is only
13
+ * used to derive the theme. Pass a CSS color (hex or named). */
14
+ bg?: string;
15
+ /** Diagram foreground color (nodes/edge labels). Resolved from the terminal
16
+ * style when the caller does not pass one. */
17
+ fg?: string;
18
+ maxWidthCells?: number;
19
+ maxHeightCells?: number;
20
+ /** Canvas padding in px (beautiful-mermaid default). */
21
+ padding?: number;
22
+ }>;
23
+ export type TuiMermaidImageRasterizer = (code: string, options: Required<TuiMermaidImageOptions>) => Promise<TuiMermaidImageCells | null>;
24
+ type RequiredMermaidImageOptions = Required<TuiMermaidImageOptions>;
25
+ export declare function normalizeMermaidImageOptions(options?: TuiMermaidImageOptions): RequiredMermaidImageOptions;
26
+ /**
27
+ * Resolve a diagram foreground/background from a terminal style value.
28
+ * Reuses the named-color table shared with the math rasterizer.
29
+ */
30
+ export declare function resolveMermaidImageColor(fg: unknown): string | undefined;
31
+ /**
32
+ * Install a custom mermaid -> PNG rasterizer (e.g. consumers that render
33
+ * mermaid through their own pipeline). Passing `null` restores the built-in
34
+ * lazy loader (beautiful-mermaid SVG + @resvg/resvg-js).
35
+ */
36
+ export declare function setMermaidImageRasterizer(rasterizer: TuiMermaidImageRasterizer | null): void;
37
+ export declare function subscribeMermaidImage(listener: () => void): () => void;
38
+ /**
39
+ * True when a rasterizer is confirmed available (custom one installed, or the
40
+ * built-in beautiful-mermaid + resvg stack finished loading). Components gate
41
+ * image production on this so they never re-rasterize while the engine is
42
+ * still loading or missing.
43
+ */
44
+ export declare function isMermaidImageRendererReady(): boolean;
45
+ /**
46
+ * Ensure the mermaid rasterizer is loaded (or resolved as unavailable).
47
+ * Resolves `true` once a rasterizer is usable. Safe to call repeatedly; the
48
+ * underlying load is shared and its outcome is cached.
49
+ */
50
+ export declare function loadMermaidImageRenderer(): Promise<boolean>;
51
+ /** Synchronous cache lookup used by components before deciding to re-render. */
52
+ export declare function getCachedMermaidImage(code: string, options?: TuiMermaidImageOptions): TuiMermaidImageCells | null;
53
+ /**
54
+ * Drop all cached mermaid images (PNG + failed lookups). Useful for long
55
+ * running processes that change cell metrics, and for tests.
56
+ */
57
+ export declare function clearMermaidImageCache(): void;
58
+ /**
59
+ * Resolve a mermaid diagram to a PNG base64 + cell size. Cached per
60
+ * (code, cell metrics, colors). In-flight requests are deduped. When a new
61
+ * image finishes, `subscribeMermaidImage` listeners are notified so components
62
+ * can rebuild/re-paint with the real size.
63
+ */
64
+ export declare function getMermaidImage(code: string, options?: TuiMermaidImageOptions): Promise<TuiMermaidImageCells | null>;
65
+ export {};
package/dist/vue.js CHANGED
@@ -1,21 +1,21 @@
1
- import "./hyperlink-_1FAj7Wq.js";
2
- import { charCellWidth } from "./width-GqllnV8C.js";
3
- import "./ansi-palette-CH6jc2Z7.js";
4
- import "./dom-renderer-DXx8fWzD.js";
5
- import { EventZIndexContextKey, LayoutContextKey, RenderStackKey, TInputPluginsContextKey, TPathPickerProviderContextKey, VisibilityContextKey, injectionKey, intersectRect, padEndByCells$1 as padEndByCells, repeatChar, sanitizeInlineText, sanitizeTextBlock, sliceByCells, sliceByCellsRange, spaces, textCellWidth$1 as textCellWidth, translateRect, useLayout, useRenderNode, useRenderStack, useTerminal, useTerminalNode, useVisibility, wrapByCells } from "./rect-DUpeDfBg.js";
6
- import { TText, TView, clamp, createTheme, fitCellText, linkifyTextSegments, mergeStyle, tuiDefaultTheme } from "./linkify-D68T7rdW.js";
1
+ import { charCellWidth } from "./create-terminal-Db_-UGVQ.js";
2
+ import "./ansi-palette-BHF1rN7R.js";
3
+ import "./hyperlink-clbb_ha_.js";
4
+ import "./dom-renderer-BfwAEQMf.js";
5
+ import { EventZIndexContextKey, LayoutContextKey, RenderStackKey, TInputPluginsContextKey, TPathPickerProviderContextKey, VisibilityContextKey, injectionKey, intersectRect, padEndByCells$1 as padEndByCells, repeatChar, sanitizeInlineText, sanitizeTextBlock, sliceByCells, sliceByCellsRange, spaces, textCellWidth$1 as textCellWidth, translateRect, useLayout, useRenderNode, useRenderStack, useTerminal, useTerminalNode, useVisibility, wrapByCells } from "./rect-JzWMJxxc.js";
6
+ import { TText, TView, clamp, createTheme, fitCellText, linkifyTextSegments, mergeStyle, tuiDefaultTheme } from "./linkify-CL9wwnZN.js";
7
7
  import "./runtime-Byf8XXOT.js";
8
8
  import "./frame-perf-CHpWhbC4.js";
9
9
  import "./trace-Bh8WnoMo.js";
10
10
  import "./env-Cl8qmNFN.js";
11
- import { TAutocompleteInput, TBadge, TCheckbox, TCode, TDataTable, TDivider, TForm, TFormContextKey, TFormField, TLink, TLinkifyText, TList, TPasswordInput, TProgress, TRadioGroup, TSlider, TSpinner, TSwitch, TTable, TTag, TToastViewport, TTree, TerminalProvider, createTInputHostPlugin, useTForm } from "./TTree-CGdE-CYu.js";
11
+ import { TAutocompleteInput, TBadge, TCheckbox, TCode, TDataTable, TDivider, TForm, TFormContextKey, TFormField, TLink, TLinkifyText, TList, TPasswordInput, TProgress, TRadioGroup, TSlider, TSpinner, TSwitch, TTable, TTag, TToastViewport, TTree, TerminalProvider, createTInputHostPlugin, useTForm } from "./TTree-kk8ntrpg.js";
12
12
  import "./terminal-selection-4W1SJj4c.js";
13
13
  import "./debug-logger-CmsGI4of.js";
14
- import { TBox, TCommandPalette, TDialog, TInput, TRenderPlane, TSelect, clamp$1, computeCommandPaletteMatchRanges, createOverlayFocusStack, isCommitMention, isWhitespace, mentionChipStyle, padEndByCells as padEndByCells$1, resolveOverlayPlacement, sliceByCellsWindow, textCellWidth as textCellWidth$1 } from "./TSelect-tJ87rKPM.js";
14
+ import { TBox, TCommandPalette, TDialog, TInput, TRenderPlane, TSelect, clamp$1, computeCommandPaletteMatchRanges, createOverlayFocusStack, isCommitMention, isWhitespace, mentionChipStyle, padEndByCells as padEndByCells$1, resolveOverlayPlacement, sliceByCellsWindow, textCellWidth as textCellWidth$1 } from "./TSelect-CMBOOFwK.js";
15
15
  import { normalizePath, stripTrailingSlash } from "./path-mnSgEpCm.js";
16
16
  import { applyWheelScroll, createWheelScrollState } from "./wheel-scroll-DASkEZr-.js";
17
17
  import { parsePathQuery, resolveUserPath, suggestPaths } from "./path-suggest-Dndu4dTi.js";
18
- import { TMermaid$1 as TMermaid, TMermaidText$1 as TMermaidText, isSimpleMermaidFlowchartSource, markMermaidRenderErrorFatal } from "./TMermaidText-frVr8Ysb.js";
18
+ import { TMermaid$1 as TMermaid, TMermaidText$1 as TMermaidText, isSimpleMermaidFlowchartSource, markMermaidRenderErrorFatal } from "./TMermaidText-wLnMMvVS.js";
19
19
  import { Comment, Fragment, computed, defineComponent, h, inject, onBeforeUnmount, onMounted, onUnmounted, provide, reactive, ref, shallowReactive, shallowRef, watch, watchEffect } from "vue";
20
20
 
21
21
  //#region src/observability/cli-latency.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simon_he/vue-tui",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "Vue 3 terminal UI components and renderers for browser DOM, CLI stdout, logs, markdown transcripts, and agent consoles",
5
5
  "keywords": [
6
6
  "agent-console",
@@ -246,12 +246,12 @@
246
246
  "access": "public"
247
247
  },
248
248
  "dependencies": {
249
- "katex": "^0.16.47",
250
- "stream-markdown-parser": "1.0.7"
249
+ "stream-markdown-parser": "1.1.9"
251
250
  },
252
251
  "devDependencies": {
253
252
  "@arethetypeswrong/core": "^0.18.3",
254
253
  "@playwright/test": "^1.61.0",
254
+ "@resvg/resvg-js": "^2.6.2",
255
255
  "@types/node": "^18.19.130",
256
256
  "@vitest/coverage-v8": "^4.1.9",
257
257
  "beautiful-mermaid": "^1.1.3",
@@ -259,7 +259,9 @@
259
259
  "bun-webgpu": "0.1.7",
260
260
  "esbuild": "^0.20.2",
261
261
  "happy-dom": "^17.6.3",
262
+ "katex": "^0.16.47",
262
263
  "lint-staged": "^13.3.0",
264
+ "mathjax-full": "^3.2.2",
263
265
  "oxfmt": "^0.47.0",
264
266
  "oxlint": "^1.70.0",
265
267
  "picocolors": "^1.1.1",
@@ -275,8 +277,11 @@
275
277
  "vue": "^3.5.38"
276
278
  },
277
279
  "peerDependencies": {
280
+ "@resvg/resvg-js": "^2.6.2",
278
281
  "beautiful-mermaid": "^1.1.3",
279
282
  "bun-webgpu": "^0.1.7",
283
+ "katex": "^0.16.47",
284
+ "mathjax-full": "^3.2.2",
280
285
  "vue": ">=3.3.0 <4"
281
286
  },
282
287
  "peerDependenciesMeta": {
@@ -285,6 +290,15 @@
285
290
  },
286
291
  "bun-webgpu": {
287
292
  "optional": true
293
+ },
294
+ "katex": {
295
+ "optional": true
296
+ },
297
+ "mathjax-full": {
298
+ "optional": true
299
+ },
300
+ "@resvg/resvg-js": {
301
+ "optional": true
288
302
  }
289
303
  },
290
304
  "lint-staged": {
@@ -317,6 +331,8 @@
317
331
  "profile:agent-console:abc": "tsx scripts/profile-agent-console-abc.ts",
318
332
  "profile:agent-console:abc:smoke": "AGENT_CONSOLE_PROFILE_SMOKE=1 tsx scripts/profile-agent-console-abc.ts",
319
333
  "example:tlog-view-lab": "pnpm run build && VT_SMOKE=1 tsx examples/tlog-view-lab.ts",
334
+ "example:chat-cli:smoke": "VT_SMOKE=1 tsx examples/chat-cli.ts",
335
+ "run:chat-cli:terminal": "pnpm run build && VT_INTERACTIVE=1 tsx examples/chat-cli.ts",
320
336
  "run:basic:terminal": "pnpm run build && pnpm -C examples/basic terminal",
321
337
  "run:agent-console:terminal": "pnpm run build && pnpm -C examples/agent-console terminal",
322
338
  "run:basic:multi-select:terminal": "pnpm run build && pnpm -C examples/basic build:terminal:multi-select && pnpm -C examples/basic terminal:multi-select",
@@ -333,6 +349,7 @@
333
349
  "test:3d:bun": "bun scripts/smoke-bun-3d.ts",
334
350
  "run:image-showcase:terminal": "tsx examples/image-showcase.ts",
335
351
  "run:katex-showcase:terminal": "tsx examples/katex-showcase.ts",
352
+ "run:mermaid-image-showcase:terminal": "tsx examples/mermaid-image-showcase.ts",
336
353
  "trace:terminal-resize": "node scripts/trace-terminal-resize.mjs",
337
354
  "test:component-terminal:smoke": "VT_SMOKE=1 tsx scripts/run-component-terminal.ts --all",
338
355
  "e2e:component-terminal-charts": "tsx scripts/run-component-terminal.ts --capture-charts",
@@ -1,123 +0,0 @@
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 };