@simon_he/vue-tui 1.0.2 → 1.1.1
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.
- package/README.md +44 -26
- package/dist/TMermaidText-CXm_L969.js +885 -0
- package/dist/{TSelect-DR0FomSu.js → TSelect-CiyMvwl-.js} +60 -81
- package/dist/{TTree-kzhlB5P0.js → TTree-DKGiuIcM.js} +140 -103
- package/dist/agent/mermaid.cjs +2 -0
- package/dist/agent/mermaid.d.cts +2 -0
- package/dist/agent/mermaid.d.ts +2 -0
- package/dist/agent/mermaid.js +1 -0
- package/dist/agent.cjs +31184 -24907
- package/dist/agent.d.cts +11 -1
- package/dist/agent.d.ts +11 -1
- package/dist/agent.js +1700 -13
- package/dist/block-source-5CQp4tF8.js +3230 -0
- package/dist/cli/stdin-buffer.d.ts +1 -1
- package/dist/cli.cjs +5037 -6767
- package/dist/cli.d.cts +4 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +2733 -148
- package/dist/core/buffer/eaw-ranges-unicode-17.d.ts +14 -0
- package/dist/core/perf/instrumentation-noop.d.ts +48 -0
- package/dist/core/perf/instrumentation.d.ts +136 -0
- package/dist/core/terminal/create-terminal.d.ts +1 -0
- package/dist/core.cjs +843 -1469
- package/dist/core.js +6 -6
- package/dist/{create-terminal-DBFNYr8f.js → create-terminal-DXuZ2fci.js} +39 -13
- package/dist/debug-logger-ChY_PXVk.js +74 -0
- package/dist/{dom-renderer-BniJSQyX.js → dom-renderer-DNzmg2As.js} +2 -2
- package/dist/experimental.cjs +4115 -5928
- package/dist/experimental.d.cts +2 -0
- package/dist/experimental.d.ts +2 -0
- package/dist/experimental.js +1490 -9
- package/dist/frame-perf-BBhE-iuS.js +111 -0
- package/dist/{sgr-BmzxEjAO.js → hyperlink-B35-O-cW.js} +100 -1
- package/dist/index.cjs +5017 -10339
- package/dist/index.js +16 -14
- package/dist/{linkify-D_gzn9Xq.js → linkify-CuuquMQT.js} +32 -3
- package/dist/markdown.cjs +21295 -12691
- package/dist/markdown.d.cts +1 -1
- package/dist/markdown.d.ts +1 -1
- package/dist/markdown.js +211 -51
- package/dist/mermaid-CWto52Wk.js +123 -0
- package/dist/mermaid.cjs +1707 -0
- package/dist/mermaid.d.cts +3 -0
- package/dist/mermaid.d.ts +3 -0
- package/dist/mermaid.js +6 -0
- package/dist/observability/frame-perf-store.d.ts +2 -1
- package/dist/observability/frame-perf.d.ts +33 -0
- package/dist/observability.cjs +106 -107
- package/dist/observability.d.cts +2 -2
- package/dist/observability.d.ts +2 -2
- package/dist/observability.js +3 -3
- package/dist/{path-suggest-BNqcuE3-.js → path-suggest-fPzRsgPv.js} +1 -1
- package/dist/{wheel-scroll-vBRaQ7p-.js → rect-Ng-3eKzF.js} +253 -117
- package/dist/renderer/cli/stdout-metrics.d.ts +10 -0
- package/dist/renderer/cli/stdout-renderer.d.ts +3 -0
- package/dist/renderer/terminal-graphic-render-queue.d.ts +50 -0
- package/dist/renderer/terminal-graphics-trace.d.ts +53 -0
- package/dist/renderer/terminal-graphics.d.ts +146 -0
- package/dist/renderer-dom.cjs +364 -903
- package/dist/renderer-dom.js +4 -4
- package/dist/runtime/index.d.ts +2 -0
- package/dist/{runtime-rfcZCyJq.js → runtime-D77C03RM.js} +28 -15
- package/dist/runtime.cjs +427 -889
- package/dist/runtime.js +2 -2
- package/dist/{terminal-selection-DBinO6p5.js → terminal-selection-CQYr--26.js} +4 -1
- package/dist/{tlog-theme-CvLFNMwk.js → tlog-theme-CopRt9SC.js} +37 -6
- package/dist/{trace-CjzYeIxN.js → trace-CYHDKM1m.js} +5 -0
- package/dist/vue/agent/create-png-terminal-graphic-renderer.d.ts +19 -0
- package/dist/vue/components/TAgentTerminalGraphic.d.ts +481 -0
- package/dist/vue/components/TCharts.d.ts +1121 -0
- package/dist/vue/components/TFeedback.d.ts +1 -1
- package/dist/vue/components/TFlex.d.ts +389 -0
- package/dist/vue/components/TForm.d.ts +4 -4
- package/dist/vue/components/TLogSearchBar.d.ts +3 -3
- package/dist/vue/components/TLogSearchPager.d.ts +2 -2
- package/dist/vue/components/TMarkdownText.d.ts +162 -4
- package/dist/vue/components/TMermaidText.d.ts +900 -0
- package/dist/vue/components/TVirtualList.d.ts +9 -0
- package/dist/vue/components/TVirtualMarkdown.d.ts +170 -9
- package/dist/vue/components/TVirtualRows.d.ts +9 -0
- package/dist/vue/components/TerminalProvider.d.ts +2 -0
- package/dist/vue/context.d.ts +24 -0
- package/dist/vue/index.d.ts +5 -0
- package/dist/vue/layout/flex.d.ts +67 -0
- package/dist/vue/markdown/ast.d.ts +5 -2
- package/dist/vue/markdown/document.d.ts +5 -0
- package/dist/vue/markdown/image-actions.d.ts +14 -0
- package/dist/vue/markdown/image.d.ts +11 -0
- package/dist/vue/markdown/link-actions.d.ts +14 -0
- package/dist/vue/markdown/math-actions.d.ts +14 -0
- package/dist/vue/markdown/math.d.ts +6 -0
- package/dist/vue/markdown/render.d.ts +28 -0
- package/dist/vue/markdown/types.d.ts +78 -0
- package/dist/vue/mermaid/beautiful-mermaid.d.ts +1436 -0
- package/dist/vue/render/render-manager.d.ts +7 -0
- package/dist/vue.cjs +7207 -12437
- package/dist/vue.js +706 -39
- package/dist/wheel-scroll-CQ22Hcyj.js +106 -0
- package/dist/{hyperlink-Bn02UXJb.js → width-GqllnV8C.js} +166 -111
- package/package.json +85 -14
- package/dist/block-source-CKUOnkgT.js +0 -1663
- package/dist/frame-perf-C6Xfg85O.js +0 -24
- /package/dist/{env-Cl8qmNFN.js → env-DNCzvX8b.js} +0 -0
- /package/dist/{path-mnSgEpCm.js → path-BI9W15Zt.js} +0 -0
package/dist/markdown.d.cts
CHANGED
|
@@ -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.d.ts
CHANGED
|
@@ -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 "./
|
|
2
|
-
import
|
|
3
|
-
import "./
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
1
|
+
import "./create-terminal-DXuZ2fci.js";
|
|
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";
|
|
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
|
-
|
|
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
|
-
() =>
|
|
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
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
|
|
174
|
-
clear: props.clear
|
|
318
|
+
isGraphicCovered
|
|
175
319
|
});
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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-CXm_L969.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 };
|