@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.
- package/dist/{TMermaidText-frVr8Ysb.js → TMermaidText-wLnMMvVS.js} +1 -1
- package/dist/{TSelect-tJ87rKPM.js → TSelect-CMBOOFwK.js} +4 -4
- package/dist/{TTree-CGdE-CYu.js → TTree-kk8ntrpg.js} +6 -5
- package/dist/agent/mermaid.d.cts +2 -2
- package/dist/agent/mermaid.d.ts +2 -2
- package/dist/agent.cjs +3896 -13616
- package/dist/agent.js +25 -82
- package/dist/{block-source-CrlmaBM5.js → block-source-D3YGTErb.js} +447 -326
- package/dist/cli.cjs +52 -15
- package/dist/cli.js +69 -14
- package/dist/core.js +3 -3
- package/dist/{hyperlink-_1FAj7Wq.js → create-terminal-Db_-UGVQ.js} +474 -102
- package/dist/{dom-renderer-DXx8fWzD.js → dom-renderer-BfwAEQMf.js} +3 -2
- package/dist/experimental.cjs +99 -66
- package/dist/experimental.js +20 -74
- package/dist/hyperlink-clbb_ha_.js +100 -0
- package/dist/index.js +8 -8
- package/dist/{linkify-D68T7rdW.js → linkify-CL9wwnZN.js} +2 -2
- package/dist/markdown.cjs +3376 -13056
- package/dist/markdown.d.cts +4 -0
- package/dist/markdown.d.ts +4 -0
- package/dist/markdown.js +79 -8
- package/dist/math-image-BZhmfUeu.js +308 -0
- package/dist/mermaid-uEfRItDe.js +1205 -0
- package/dist/mermaid.cjs +1089 -3
- package/dist/mermaid.d.cts +4 -0
- package/dist/mermaid.d.ts +4 -0
- package/dist/mermaid.js +7 -5
- package/dist/{rect-DUpeDfBg.js → rect-JzWMJxxc.js} +1 -1
- package/dist/renderer/cli/stdout-renderer.d.ts +44 -0
- package/dist/renderer/terminal-graphics.d.ts +44 -0
- package/dist/renderer-dom.js +4 -4
- package/dist/{terminal-graphics-Bbe83wSr.js → terminal-graphics-DWZrl3oh.js} +85 -2
- package/dist/{tlog-theme-Bul2Na3u.js → tlog-theme-DqnF_zNe.js} +5 -4
- package/dist/vue/components/TAgentTerminalGraphic.d.ts +1 -1
- package/dist/vue/components/TMarkdownText.d.ts +70 -2
- package/dist/vue/components/TMermaidImage.d.ts +733 -0
- package/dist/vue/components/TMermaidText.d.ts +2 -2
- package/dist/vue/components/TVirtualMarkdown.d.ts +70 -2
- package/dist/vue/markdown/ast.d.ts +5 -0
- package/dist/vue/markdown/document.d.ts +3 -0
- package/dist/vue/markdown/math-image.d.ts +68 -0
- package/dist/vue/markdown/math.d.ts +2 -0
- package/dist/vue/markdown/theme.d.ts +12 -0
- package/dist/vue/markdown/types.d.ts +12 -2
- package/dist/vue/mermaid/beautiful-mermaid.d.ts +4 -4
- package/dist/vue/mermaid/mermaid-image.d.ts +65 -0
- package/dist/vue.js +9 -9
- package/package.json +20 -3
- package/dist/mermaid-BNhM1jAZ.js +0 -123
- package/dist/width-GqllnV8C.js +0 -474
- /package/dist/{ansi-palette-CH6jc2Z7.js → ansi-palette-BHF1rN7R.js} +0 -0
|
@@ -0,0 +1,1205 @@
|
|
|
1
|
+
import { EventZIndexContextKey, intersectRect, padEndByCells$1 as padEndByCells, repeatChar, sanitizeInlineText, sanitizeTextBlock, sliceByCells, sliceByCellsRange, spaces, textCellWidth$1 as textCellWidth, translateRect, useLayout, useRenderNode, useTerminal, useTerminalNode, useVisibility, withTextWidthProvider } from "./rect-JzWMJxxc.js";
|
|
2
|
+
import { TMermaidText$1 as TMermaidText, isSimpleMermaidFlowchartSource, markMermaidRenderErrorFatal, tMermaidTextProps } from "./TMermaidText-wLnMMvVS.js";
|
|
3
|
+
import { createTerminalGraphicPngSequence, getTerminalGraphicsOutput, getTerminalGraphicsOutputVersion, stableTerminalGraphicNumericId, subscribeTerminalGraphicsOutput } from "./terminal-graphics-DWZrl3oh.js";
|
|
4
|
+
import { resolveMarkdownMathColor } from "./math-image-BZhmfUeu.js";
|
|
5
|
+
import { computed, defineComponent, getCurrentInstance, h, inject, onBeforeUnmount, shallowRef, watch } from "vue";
|
|
6
|
+
|
|
7
|
+
//#region src/vue/mermaid/beautiful-mermaid.ts
|
|
8
|
+
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.";
|
|
9
|
+
const MISSING_BEAUTIFUL_MERMAID_ERROR_CODE = "VUE_TUI_MISSING_BEAUTIFUL_MERMAID";
|
|
10
|
+
const INVALID_BEAUTIFUL_MERMAID_EXPORT_ERROR_CODE = "VUE_TUI_INVALID_BEAUTIFUL_MERMAID_EXPORT";
|
|
11
|
+
let cachedBeautifulMermaid = null;
|
|
12
|
+
function functionValue(value) {
|
|
13
|
+
return typeof value === "function" ? value : null;
|
|
14
|
+
}
|
|
15
|
+
function functionProp(target, key) {
|
|
16
|
+
if (!target || typeof target !== "object") return null;
|
|
17
|
+
if (!(key in target)) return null;
|
|
18
|
+
const value = target[key];
|
|
19
|
+
return typeof value === "function" ? value : null;
|
|
20
|
+
}
|
|
21
|
+
function errorMessage(error) {
|
|
22
|
+
return error instanceof Error ? error.message : String(error);
|
|
23
|
+
}
|
|
24
|
+
function codedError(message, code) {
|
|
25
|
+
const error = new Error(message);
|
|
26
|
+
error.code = code;
|
|
27
|
+
return error;
|
|
28
|
+
}
|
|
29
|
+
function missingBeautifulMermaidError(error) {
|
|
30
|
+
if (error && typeof error === "object" && errorCode(error) === MISSING_BEAUTIFUL_MERMAID_ERROR_CODE) return markMermaidRenderErrorFatal(error);
|
|
31
|
+
const detail = errorMessage(error);
|
|
32
|
+
return markMermaidRenderErrorFatal(codedError(`${BEAUTIFUL_MERMAID_INSTALL_HINT} (${detail})`, MISSING_BEAUTIFUL_MERMAID_ERROR_CODE));
|
|
33
|
+
}
|
|
34
|
+
function errorCode(error) {
|
|
35
|
+
if (!error || typeof error !== "object") return "";
|
|
36
|
+
const value = error.code;
|
|
37
|
+
return typeof value === "string" ? value : "";
|
|
38
|
+
}
|
|
39
|
+
function errorCause(error) {
|
|
40
|
+
if (!error || typeof error !== "object") return void 0;
|
|
41
|
+
return error.cause;
|
|
42
|
+
}
|
|
43
|
+
function isMissingBeautifulMermaid(error) {
|
|
44
|
+
return isMissingBeautifulMermaidWithSeen(error, new WeakSet());
|
|
45
|
+
}
|
|
46
|
+
function isMissingBeautifulMermaidWithSeen(error, seen) {
|
|
47
|
+
if (error && typeof error === "object") {
|
|
48
|
+
if (seen.has(error)) return false;
|
|
49
|
+
seen.add(error);
|
|
50
|
+
}
|
|
51
|
+
const message = errorMessage(error);
|
|
52
|
+
const code = errorCode(error);
|
|
53
|
+
if (code === MISSING_BEAUTIFUL_MERMAID_ERROR_CODE) return true;
|
|
54
|
+
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);
|
|
55
|
+
if (mentionsBeautifulMermaid && (code === "" || code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND" || code === "UNRESOLVED_IMPORT")) return true;
|
|
56
|
+
const cause = errorCause(error);
|
|
57
|
+
return cause !== void 0 && isMissingBeautifulMermaidWithSeen(cause, seen);
|
|
58
|
+
}
|
|
59
|
+
function resolveBeautifulMermaidRenderer(mod) {
|
|
60
|
+
const renderer = functionProp(mod, "renderMermaidASCII") ?? functionProp(mod, "renderMermaidAscii") ?? functionValue(mod.default) ?? functionProp(mod.default, "renderMermaidASCII") ?? functionProp(mod.default, "renderMermaidAscii");
|
|
61
|
+
if (!renderer) throw markMermaidRenderErrorFatal(codedError("beautiful-mermaid is installed but does not export renderMermaidASCII.", INVALID_BEAUTIFUL_MERMAID_EXPORT_ERROR_CODE));
|
|
62
|
+
return renderer;
|
|
63
|
+
}
|
|
64
|
+
function hasErrorCode(error, code, seen = new WeakSet()) {
|
|
65
|
+
if (!error || typeof error !== "object") return false;
|
|
66
|
+
if (seen.has(error)) return false;
|
|
67
|
+
seen.add(error);
|
|
68
|
+
if (errorCode(error) === code) return true;
|
|
69
|
+
const cause = errorCause(error);
|
|
70
|
+
return cause !== void 0 && hasErrorCode(cause, code, seen);
|
|
71
|
+
}
|
|
72
|
+
function isBeautifulMermaidExportError(error) {
|
|
73
|
+
return hasErrorCode(error, INVALID_BEAUTIFUL_MERMAID_EXPORT_ERROR_CODE);
|
|
74
|
+
}
|
|
75
|
+
const isTransientBeautifulMermaidRenderError = (error) => {
|
|
76
|
+
if (isMissingBeautifulMermaid(error)) return false;
|
|
77
|
+
if (isBeautifulMermaidExportError(error)) return false;
|
|
78
|
+
return true;
|
|
79
|
+
};
|
|
80
|
+
async function loadBeautifulMermaid() {
|
|
81
|
+
if (!cachedBeautifulMermaid) cachedBeautifulMermaid = import("beautiful-mermaid").then((mod) => mod).catch((error) => {
|
|
82
|
+
cachedBeautifulMermaid = null;
|
|
83
|
+
if (isMissingBeautifulMermaid(error)) throw missingBeautifulMermaidError(error);
|
|
84
|
+
throw markMermaidRenderErrorFatal(error);
|
|
85
|
+
});
|
|
86
|
+
return cachedBeautifulMermaid;
|
|
87
|
+
}
|
|
88
|
+
const beautifulMermaidRenderer = async (code, options) => {
|
|
89
|
+
try {
|
|
90
|
+
const mod = await loadBeautifulMermaid();
|
|
91
|
+
const renderer = resolveBeautifulMermaidRenderer(mod);
|
|
92
|
+
return await renderer(code, options);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
if (isMissingBeautifulMermaid(error)) throw missingBeautifulMermaidError(error);
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
function createBeautifulMermaidRenderer() {
|
|
99
|
+
return beautifulMermaidRenderer;
|
|
100
|
+
}
|
|
101
|
+
const TMermaidText$1 = defineComponent({
|
|
102
|
+
name: "TMermaidText",
|
|
103
|
+
inheritAttrs: false,
|
|
104
|
+
props: tMermaidTextProps,
|
|
105
|
+
emits: { copy: (_payload) => true },
|
|
106
|
+
setup(props, { attrs, emit, slots }) {
|
|
107
|
+
return () => {
|
|
108
|
+
const renderer = props.renderer ?? beautifulMermaidRenderer;
|
|
109
|
+
const shouldRenderSource = props.shouldRenderSource ?? isSimpleMermaidFlowchartSource;
|
|
110
|
+
return h(TMermaidText, {
|
|
111
|
+
...attrs,
|
|
112
|
+
...props,
|
|
113
|
+
renderer,
|
|
114
|
+
shouldRenderSource,
|
|
115
|
+
isTransientError: props.isTransientError ?? isTransientBeautifulMermaidRenderError,
|
|
116
|
+
onCopy: (payload) => emit("copy", payload)
|
|
117
|
+
}, slots);
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
const TMermaid = TMermaidText$1;
|
|
122
|
+
const TBeautifulMermaidText = TMermaidText$1;
|
|
123
|
+
const TBeautifulMermaid = TMermaidText$1;
|
|
124
|
+
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/vue/mermaid/mermaid-image.ts
|
|
127
|
+
const DEFAULT_MERMAID_IMAGE_OPTIONS = Object.freeze({
|
|
128
|
+
cellWidthPx: 8,
|
|
129
|
+
cellHeightPx: 16,
|
|
130
|
+
scale: 2,
|
|
131
|
+
bg: "#1e1e2e",
|
|
132
|
+
fg: "#f8f8f2",
|
|
133
|
+
maxWidthCells: 0,
|
|
134
|
+
maxHeightCells: 0,
|
|
135
|
+
padding: 40
|
|
136
|
+
});
|
|
137
|
+
const MAX_CACHE_ENTRIES = 48;
|
|
138
|
+
const MAX_FAILED_ENTRIES = 96;
|
|
139
|
+
const mermaidImageCache = new Map();
|
|
140
|
+
const mermaidImageFailed = new Set();
|
|
141
|
+
const mermaidImageInflight = new Map();
|
|
142
|
+
const mermaidImageListeners = new Set();
|
|
143
|
+
let customRasterizer = null;
|
|
144
|
+
let builtinRasterizerLoad = null;
|
|
145
|
+
let builtinRasterizerReady = false;
|
|
146
|
+
function normalizeMermaidImageOptions(options) {
|
|
147
|
+
return {
|
|
148
|
+
cellWidthPx: Math.max(1, Math.floor(options?.cellWidthPx ?? DEFAULT_MERMAID_IMAGE_OPTIONS.cellWidthPx)),
|
|
149
|
+
cellHeightPx: Math.max(1, Math.floor(options?.cellHeightPx ?? DEFAULT_MERMAID_IMAGE_OPTIONS.cellHeightPx)),
|
|
150
|
+
scale: Math.max(1, Math.floor(options?.scale ?? DEFAULT_MERMAID_IMAGE_OPTIONS.scale)),
|
|
151
|
+
bg: options?.bg ?? DEFAULT_MERMAID_IMAGE_OPTIONS.bg,
|
|
152
|
+
fg: options?.fg ?? DEFAULT_MERMAID_IMAGE_OPTIONS.fg,
|
|
153
|
+
maxWidthCells: Math.max(0, Math.floor(options?.maxWidthCells ?? 0)),
|
|
154
|
+
maxHeightCells: Math.max(0, Math.floor(options?.maxHeightCells ?? 0)),
|
|
155
|
+
padding: Math.max(0, Math.floor(options?.padding ?? DEFAULT_MERMAID_IMAGE_OPTIONS.padding))
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Resolve a diagram foreground/background from a terminal style value.
|
|
160
|
+
* Reuses the named-color table shared with the math rasterizer.
|
|
161
|
+
*/
|
|
162
|
+
function resolveMermaidImageColor(fg) {
|
|
163
|
+
return resolveMarkdownMathColor(fg);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Install a custom mermaid -> PNG rasterizer (e.g. consumers that render
|
|
167
|
+
* mermaid through their own pipeline). Passing `null` restores the built-in
|
|
168
|
+
* lazy loader (beautiful-mermaid SVG + @resvg/resvg-js).
|
|
169
|
+
*/
|
|
170
|
+
function setMermaidImageRasterizer(rasterizer) {
|
|
171
|
+
customRasterizer = rasterizer;
|
|
172
|
+
}
|
|
173
|
+
function subscribeMermaidImage(listener) {
|
|
174
|
+
mermaidImageListeners.add(listener);
|
|
175
|
+
return () => mermaidImageListeners.delete(listener);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* True when a rasterizer is confirmed available (custom one installed, or the
|
|
179
|
+
* built-in beautiful-mermaid + resvg stack finished loading). Components gate
|
|
180
|
+
* image production on this so they never re-rasterize while the engine is
|
|
181
|
+
* still loading or missing.
|
|
182
|
+
*/
|
|
183
|
+
function isMermaidImageRendererReady() {
|
|
184
|
+
return customRasterizer != null || builtinRasterizerReady;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Ensure the mermaid rasterizer is loaded (or resolved as unavailable).
|
|
188
|
+
* Resolves `true` once a rasterizer is usable. Safe to call repeatedly; the
|
|
189
|
+
* underlying load is shared and its outcome is cached.
|
|
190
|
+
*/
|
|
191
|
+
async function loadMermaidImageRenderer() {
|
|
192
|
+
if (isMermaidImageRendererReady()) return true;
|
|
193
|
+
const rasterizer = customRasterizer ?? await loadBuiltinMermaidRasterizer();
|
|
194
|
+
builtinRasterizerReady = rasterizer != null;
|
|
195
|
+
return builtinRasterizerReady;
|
|
196
|
+
}
|
|
197
|
+
function hashMermaidImageKey(value) {
|
|
198
|
+
let hash = 2166136261;
|
|
199
|
+
for (let i = 0; i < value.length; i++) {
|
|
200
|
+
hash ^= value.charCodeAt(i);
|
|
201
|
+
hash = Math.imul(hash, 16777619);
|
|
202
|
+
}
|
|
203
|
+
return (hash >>> 0).toString(36);
|
|
204
|
+
}
|
|
205
|
+
function mermaidImageCacheKey(code, options) {
|
|
206
|
+
return hashMermaidImageKey([
|
|
207
|
+
code,
|
|
208
|
+
options.cellWidthPx,
|
|
209
|
+
options.cellHeightPx,
|
|
210
|
+
options.scale,
|
|
211
|
+
options.bg,
|
|
212
|
+
options.fg,
|
|
213
|
+
options.maxWidthCells,
|
|
214
|
+
options.maxHeightCells,
|
|
215
|
+
options.padding
|
|
216
|
+
].join(""));
|
|
217
|
+
}
|
|
218
|
+
function notifyMermaidImageListeners() {
|
|
219
|
+
for (const listener of mermaidImageListeners) try {
|
|
220
|
+
listener();
|
|
221
|
+
} catch {}
|
|
222
|
+
}
|
|
223
|
+
/** Synchronous cache lookup used by components before deciding to re-render. */
|
|
224
|
+
function getCachedMermaidImage(code, options) {
|
|
225
|
+
return mermaidImageCache.get(mermaidImageCacheKey(code, normalizeMermaidImageOptions(options))) ?? null;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Drop all cached mermaid images (PNG + failed lookups). Useful for long
|
|
229
|
+
* running processes that change cell metrics, and for tests.
|
|
230
|
+
*/
|
|
231
|
+
function clearMermaidImageCache() {
|
|
232
|
+
mermaidImageCache.clear();
|
|
233
|
+
mermaidImageFailed.clear();
|
|
234
|
+
}
|
|
235
|
+
function evictOldestMermaidImageEntry() {
|
|
236
|
+
const oldest = mermaidImageCache.keys().next().value;
|
|
237
|
+
if (oldest != null) mermaidImageCache.delete(oldest);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Resolve a mermaid diagram to a PNG base64 + cell size. Cached per
|
|
241
|
+
* (code, cell metrics, colors). In-flight requests are deduped. When a new
|
|
242
|
+
* image finishes, `subscribeMermaidImage` listeners are notified so components
|
|
243
|
+
* can rebuild/re-paint with the real size.
|
|
244
|
+
*/
|
|
245
|
+
async function getMermaidImage(code, options) {
|
|
246
|
+
const source = String(code ?? "").trim();
|
|
247
|
+
if (!source) return null;
|
|
248
|
+
const normalized = normalizeMermaidImageOptions(options);
|
|
249
|
+
const key = mermaidImageCacheKey(source, normalized);
|
|
250
|
+
const cached = mermaidImageCache.get(key);
|
|
251
|
+
if (cached) return cached;
|
|
252
|
+
if (mermaidImageFailed.has(key)) return null;
|
|
253
|
+
const inflight = mermaidImageInflight.get(key);
|
|
254
|
+
if (inflight) return inflight;
|
|
255
|
+
const pending = (async () => {
|
|
256
|
+
try {
|
|
257
|
+
const rasterizer = customRasterizer ?? await loadBuiltinMermaidRasterizer();
|
|
258
|
+
if (!rasterizer) return null;
|
|
259
|
+
const result = await rasterizer(source, normalized);
|
|
260
|
+
if (result && result.base64) {
|
|
261
|
+
mermaidImageCache.set(key, result);
|
|
262
|
+
if (mermaidImageCache.size > MAX_CACHE_ENTRIES) evictOldestMermaidImageEntry();
|
|
263
|
+
notifyMermaidImageListeners();
|
|
264
|
+
} else if (result === null) {
|
|
265
|
+
mermaidImageFailed.add(key);
|
|
266
|
+
if (mermaidImageFailed.size > MAX_FAILED_ENTRIES) {
|
|
267
|
+
const oldest = mermaidImageFailed.values().next().value;
|
|
268
|
+
if (oldest != null) mermaidImageFailed.delete(oldest);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return result;
|
|
272
|
+
} catch {
|
|
273
|
+
return null;
|
|
274
|
+
} finally {
|
|
275
|
+
mermaidImageInflight.delete(key);
|
|
276
|
+
}
|
|
277
|
+
})();
|
|
278
|
+
mermaidImageInflight.set(key, pending);
|
|
279
|
+
return pending;
|
|
280
|
+
}
|
|
281
|
+
function base64FromBytes(bytes) {
|
|
282
|
+
const chunk = 32768;
|
|
283
|
+
let binary = "";
|
|
284
|
+
for (let offset = 0; offset < bytes.length; offset += chunk) binary += String.fromCharCode(...bytes.subarray(offset, offset + chunk));
|
|
285
|
+
return typeof btoa === "function" ? btoa(binary) : Buffer.from(bytes).toString("base64");
|
|
286
|
+
}
|
|
287
|
+
function positiveInt(value) {
|
|
288
|
+
const n = Math.floor(Number(value));
|
|
289
|
+
return Number.isFinite(n) && n > 0 ? n : void 0;
|
|
290
|
+
}
|
|
291
|
+
function clampCellsToLimits(widthCells, heightCells, maxWidthCells, maxHeightCells) {
|
|
292
|
+
let w = widthCells;
|
|
293
|
+
let h$1 = heightCells;
|
|
294
|
+
if (maxWidthCells > 0 && w > maxWidthCells) {
|
|
295
|
+
h$1 = Math.max(1, Math.round(h$1 * maxWidthCells / w));
|
|
296
|
+
w = maxWidthCells;
|
|
297
|
+
}
|
|
298
|
+
if (maxHeightCells > 0 && h$1 > maxHeightCells) {
|
|
299
|
+
w = Math.max(1, Math.round(w * maxHeightCells / h$1));
|
|
300
|
+
h$1 = maxHeightCells;
|
|
301
|
+
}
|
|
302
|
+
return {
|
|
303
|
+
widthCells: Math.max(1, w),
|
|
304
|
+
heightCells: Math.max(1, h$1)
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* @resvg/resvg-js is a Node-only native addon. Keeping the specifier in a
|
|
309
|
+
* variable (a non-literal dynamic import) stops browser bundlers
|
|
310
|
+
* (vite/rolldown) from statically resolving it and failing on its platform
|
|
311
|
+
* `.node` binding; at runtime a browser load fails and the rasterizer falls
|
|
312
|
+
* back to raw source.
|
|
313
|
+
*/
|
|
314
|
+
const RESVG_MODULE_ID = "@resvg/resvg-js";
|
|
315
|
+
function svgRenderFunction(mod) {
|
|
316
|
+
const candidates = [
|
|
317
|
+
mod.renderMermaidSVGAsync,
|
|
318
|
+
mod.renderMermaidSVG,
|
|
319
|
+
mod.renderMermaid,
|
|
320
|
+
mod.default?.renderMermaidSVGAsync,
|
|
321
|
+
mod.default?.renderMermaidSVG
|
|
322
|
+
];
|
|
323
|
+
for (const candidate of candidates) if (typeof candidate === "function") return candidate;
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
function loadBuiltinMermaidRasterizer() {
|
|
327
|
+
if (!builtinRasterizerLoad) builtinRasterizerLoad = (async () => {
|
|
328
|
+
try {
|
|
329
|
+
const [mermaidMod, resvgMod] = await Promise.all([import("beautiful-mermaid").then((mod) => mod, () => null), import(RESVG_MODULE_ID).then((mod) => mod, () => null)]);
|
|
330
|
+
const renderSvg = svgRenderFunction(mermaidMod ?? {});
|
|
331
|
+
const Resvg = resvgMod?.Resvg;
|
|
332
|
+
if (!renderSvg || typeof Resvg !== "function") return null;
|
|
333
|
+
return async (code, options) => {
|
|
334
|
+
const svg = await renderSvg(code, {
|
|
335
|
+
bg: options.bg,
|
|
336
|
+
fg: options.fg,
|
|
337
|
+
padding: options.padding,
|
|
338
|
+
transparent: true
|
|
339
|
+
});
|
|
340
|
+
const svgText = String(svg ?? "");
|
|
341
|
+
if (!svgText.includes("<svg")) return null;
|
|
342
|
+
const rendered = new Resvg(svgText, { background: "rgba(0,0,0,0)" }).render();
|
|
343
|
+
const naturalWidth = positiveInt(rendered?.width);
|
|
344
|
+
const naturalHeight = positiveInt(rendered?.height);
|
|
345
|
+
const png = typeof rendered?.asPng === "function" ? rendered.asPng() : void 0;
|
|
346
|
+
if (!png || png.length < 8 || naturalWidth == null || naturalHeight == null) return null;
|
|
347
|
+
const rawWidthCells = Math.max(1, Math.round(naturalWidth / (options.cellWidthPx * options.scale)));
|
|
348
|
+
const rawHeightCells = Math.max(1, Math.round(naturalHeight / (options.cellHeightPx * options.scale)));
|
|
349
|
+
const { widthCells, heightCells } = clampCellsToLimits(rawWidthCells, rawHeightCells, options.maxWidthCells, options.maxHeightCells);
|
|
350
|
+
return {
|
|
351
|
+
base64: base64FromBytes(png),
|
|
352
|
+
widthCells,
|
|
353
|
+
heightCells,
|
|
354
|
+
naturalWidth,
|
|
355
|
+
naturalHeight
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
} catch {
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
})();
|
|
362
|
+
return builtinRasterizerLoad;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
//#endregion
|
|
366
|
+
//#region src/vue/components/TMermaidImage.ts
|
|
367
|
+
const UNICODE_MERMAID_IMAGE_BOX_CHARS = Object.freeze({
|
|
368
|
+
tl: "┌",
|
|
369
|
+
tr: "┐",
|
|
370
|
+
bl: "└",
|
|
371
|
+
br: "┘",
|
|
372
|
+
h: "─",
|
|
373
|
+
v: "│"
|
|
374
|
+
});
|
|
375
|
+
const ASCII_MERMAID_IMAGE_BOX_CHARS = Object.freeze({
|
|
376
|
+
tl: "+",
|
|
377
|
+
tr: "+",
|
|
378
|
+
bl: "+",
|
|
379
|
+
br: "+",
|
|
380
|
+
h: "-",
|
|
381
|
+
v: "|"
|
|
382
|
+
});
|
|
383
|
+
const DEFAULT_MERMAID_IMAGE_COPIED_DURATION_MS = 1200;
|
|
384
|
+
const DEFAULT_MERMAID_IMAGE_MAX_RENDER_SOURCE_CHARS = 2e4;
|
|
385
|
+
const DEFAULT_MERMAID_IMAGE_MAX_RENDER_SOURCE_LINES = 400;
|
|
386
|
+
const ESC = String.fromCharCode(27);
|
|
387
|
+
const BEL = String.fromCharCode(7);
|
|
388
|
+
const TERMINAL_ESCAPE_RE = new RegExp([
|
|
389
|
+
`${ESC}\\][\\s\\S]*?(?:${BEL}|${ESC}\\\\)`,
|
|
390
|
+
`${ESC}[PX^_][\\s\\S]*?${ESC}\\\\`,
|
|
391
|
+
`${ESC}\\[[0-?]*[ -/]*[@-~]`,
|
|
392
|
+
`${ESC}[@-Z\\\\-_]`
|
|
393
|
+
].join("|"), "g");
|
|
394
|
+
function stripTerminalEscapes(value) {
|
|
395
|
+
return value.replace(TERMINAL_ESCAPE_RE, "");
|
|
396
|
+
}
|
|
397
|
+
function normalizeNonNegativeInt(value, fallback) {
|
|
398
|
+
const n = Number(value);
|
|
399
|
+
if (!Number.isFinite(n)) return fallback;
|
|
400
|
+
return Math.max(0, Math.floor(n));
|
|
401
|
+
}
|
|
402
|
+
function countLinesUpTo(value, max) {
|
|
403
|
+
if (max <= 0) return 0;
|
|
404
|
+
let lines = 1;
|
|
405
|
+
for (let index = 0; index < value.length; index++) {
|
|
406
|
+
const code = value.charCodeAt(index);
|
|
407
|
+
if (code !== 10 && code !== 13) continue;
|
|
408
|
+
lines++;
|
|
409
|
+
if (code === 13 && value.charCodeAt(index + 1) === 10) index++;
|
|
410
|
+
if (lines > max) return lines;
|
|
411
|
+
}
|
|
412
|
+
return lines;
|
|
413
|
+
}
|
|
414
|
+
function splitRenderedOutput(value) {
|
|
415
|
+
const normalized = sanitizeTextBlock(stripTerminalEscapes(String(value ?? "")).replace(/\r\n?/g, "\n"));
|
|
416
|
+
const lines = normalized.split("\n");
|
|
417
|
+
return lines.length ? lines : [""];
|
|
418
|
+
}
|
|
419
|
+
function fitImageCells(cells, maxW, maxH) {
|
|
420
|
+
if (maxW <= 0 || maxH <= 0) return null;
|
|
421
|
+
let w = Math.max(1, Math.floor(cells.widthCells));
|
|
422
|
+
let h$1 = Math.max(1, Math.floor(cells.heightCells));
|
|
423
|
+
if (w > maxW) {
|
|
424
|
+
h$1 = Math.max(1, Math.round(h$1 * maxW / w));
|
|
425
|
+
w = maxW;
|
|
426
|
+
}
|
|
427
|
+
if (h$1 > maxH) {
|
|
428
|
+
w = Math.max(1, Math.round(w * maxH / h$1));
|
|
429
|
+
h$1 = maxH;
|
|
430
|
+
}
|
|
431
|
+
return {
|
|
432
|
+
displayW: Math.max(1, w),
|
|
433
|
+
displayH: Math.max(1, h$1)
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
const tMermaidImageProps = {
|
|
437
|
+
x: {
|
|
438
|
+
type: Number,
|
|
439
|
+
required: true
|
|
440
|
+
},
|
|
441
|
+
y: {
|
|
442
|
+
type: Number,
|
|
443
|
+
required: true
|
|
444
|
+
},
|
|
445
|
+
w: {
|
|
446
|
+
type: Number,
|
|
447
|
+
required: true
|
|
448
|
+
},
|
|
449
|
+
h: {
|
|
450
|
+
type: Number,
|
|
451
|
+
default: void 0
|
|
452
|
+
},
|
|
453
|
+
zIndex: {
|
|
454
|
+
type: Number,
|
|
455
|
+
default: 0
|
|
456
|
+
},
|
|
457
|
+
content: {
|
|
458
|
+
type: String,
|
|
459
|
+
default: ""
|
|
460
|
+
},
|
|
461
|
+
code: {
|
|
462
|
+
type: String,
|
|
463
|
+
default: void 0
|
|
464
|
+
},
|
|
465
|
+
style: {
|
|
466
|
+
type: Object,
|
|
467
|
+
default: void 0
|
|
468
|
+
},
|
|
469
|
+
clear: {
|
|
470
|
+
type: Boolean,
|
|
471
|
+
default: true
|
|
472
|
+
},
|
|
473
|
+
final: {
|
|
474
|
+
type: Boolean,
|
|
475
|
+
default: true
|
|
476
|
+
},
|
|
477
|
+
streaming: {
|
|
478
|
+
type: Boolean,
|
|
479
|
+
default: false
|
|
480
|
+
},
|
|
481
|
+
renderer: {
|
|
482
|
+
type: Function,
|
|
483
|
+
default: void 0
|
|
484
|
+
},
|
|
485
|
+
cellWidthPx: {
|
|
486
|
+
type: Number,
|
|
487
|
+
default: void 0
|
|
488
|
+
},
|
|
489
|
+
cellHeightPx: {
|
|
490
|
+
type: Number,
|
|
491
|
+
default: void 0
|
|
492
|
+
},
|
|
493
|
+
scale: {
|
|
494
|
+
type: Number,
|
|
495
|
+
default: void 0
|
|
496
|
+
},
|
|
497
|
+
bg: {
|
|
498
|
+
type: String,
|
|
499
|
+
default: void 0
|
|
500
|
+
},
|
|
501
|
+
fg: {
|
|
502
|
+
type: String,
|
|
503
|
+
default: void 0
|
|
504
|
+
},
|
|
505
|
+
maxWidthCells: {
|
|
506
|
+
type: Number,
|
|
507
|
+
default: void 0
|
|
508
|
+
},
|
|
509
|
+
maxHeightCells: {
|
|
510
|
+
type: Number,
|
|
511
|
+
default: void 0
|
|
512
|
+
},
|
|
513
|
+
padding: {
|
|
514
|
+
type: Number,
|
|
515
|
+
default: void 0
|
|
516
|
+
},
|
|
517
|
+
box: {
|
|
518
|
+
type: Boolean,
|
|
519
|
+
default: true
|
|
520
|
+
},
|
|
521
|
+
title: {
|
|
522
|
+
type: String,
|
|
523
|
+
default: "mermaid"
|
|
524
|
+
},
|
|
525
|
+
copyButton: {
|
|
526
|
+
type: Boolean,
|
|
527
|
+
default: true
|
|
528
|
+
},
|
|
529
|
+
copyText: {
|
|
530
|
+
type: String,
|
|
531
|
+
default: "copy"
|
|
532
|
+
},
|
|
533
|
+
copiedText: {
|
|
534
|
+
type: String,
|
|
535
|
+
default: "copied"
|
|
536
|
+
},
|
|
537
|
+
copiedDurationMs: {
|
|
538
|
+
type: Number,
|
|
539
|
+
default: DEFAULT_MERMAID_IMAGE_COPIED_DURATION_MS
|
|
540
|
+
},
|
|
541
|
+
renderTimeoutMs: {
|
|
542
|
+
type: Number,
|
|
543
|
+
default: 0
|
|
544
|
+
},
|
|
545
|
+
maxRenderSourceChars: {
|
|
546
|
+
type: Number,
|
|
547
|
+
default: DEFAULT_MERMAID_IMAGE_MAX_RENDER_SOURCE_CHARS
|
|
548
|
+
},
|
|
549
|
+
maxRenderSourceLines: {
|
|
550
|
+
type: Number,
|
|
551
|
+
default: DEFAULT_MERMAID_IMAGE_MAX_RENDER_SOURCE_LINES
|
|
552
|
+
},
|
|
553
|
+
copyOnClick: {
|
|
554
|
+
type: Boolean,
|
|
555
|
+
default: true
|
|
556
|
+
},
|
|
557
|
+
ascii: {
|
|
558
|
+
type: Boolean,
|
|
559
|
+
default: false
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
const TMermaidImage = defineComponent({
|
|
563
|
+
name: "TMermaidImage",
|
|
564
|
+
props: tMermaidImageProps,
|
|
565
|
+
emits: { copy: (_payload) => true },
|
|
566
|
+
setup(props, { emit }) {
|
|
567
|
+
const instance = getCurrentInstance();
|
|
568
|
+
const terminalContext = useTerminal();
|
|
569
|
+
const { terminal, defaultStyle, scheduler, widthProvider } = terminalContext;
|
|
570
|
+
const layout = useLayout();
|
|
571
|
+
const { visible, rootProps } = useVisibility();
|
|
572
|
+
const parentEventZ = inject(EventZIndexContextKey, computed(() => 0));
|
|
573
|
+
const imageCells = shallowRef(null);
|
|
574
|
+
const documentVersion = shallowRef(0);
|
|
575
|
+
const copied = shallowRef(false);
|
|
576
|
+
let builtOnce = false;
|
|
577
|
+
let renderVersion = 0;
|
|
578
|
+
let alive = true;
|
|
579
|
+
const frameTaskId = `TMermaidImage:${instance?.uid ?? "unknown"}:mermaid-image`;
|
|
580
|
+
const uid = instance?.uid ?? 0;
|
|
581
|
+
let copiedTimer = null;
|
|
582
|
+
let copyRequestVersion = 0;
|
|
583
|
+
let activeGraphicId = null;
|
|
584
|
+
const source = computed(() => props.code ?? props.content ?? "");
|
|
585
|
+
const waitingForStreamingSourceToFinish = computed(() => props.streaming && !props.final);
|
|
586
|
+
const graphicsOutputVersion = shallowRef(getTerminalGraphicsOutputVersion(terminal));
|
|
587
|
+
const graphicsOutput = computed(() => {
|
|
588
|
+
graphicsOutputVersion.value;
|
|
589
|
+
return getTerminalGraphicsOutput(terminal);
|
|
590
|
+
});
|
|
591
|
+
const graphicsProtocol = computed(() => {
|
|
592
|
+
const output = graphicsOutput.value;
|
|
593
|
+
if (!output?.capabilities.supported) return null;
|
|
594
|
+
const protocol = output.capabilities.preferredProtocol;
|
|
595
|
+
if (protocol === "kitty" || protocol === "iterm2") return protocol;
|
|
596
|
+
return null;
|
|
597
|
+
});
|
|
598
|
+
function bump() {
|
|
599
|
+
documentVersion.value++;
|
|
600
|
+
}
|
|
601
|
+
function clearCopiedTimer() {
|
|
602
|
+
if (copiedTimer == null) return;
|
|
603
|
+
clearTimeout(copiedTimer);
|
|
604
|
+
copiedTimer = null;
|
|
605
|
+
}
|
|
606
|
+
function setCopied(next, repaint = true) {
|
|
607
|
+
if (!next) clearCopiedTimer();
|
|
608
|
+
if (copied.value === next) return;
|
|
609
|
+
copied.value = next;
|
|
610
|
+
if (repaint) bump();
|
|
611
|
+
}
|
|
612
|
+
function resetCopyFeedback(repaint = true) {
|
|
613
|
+
copyRequestVersion++;
|
|
614
|
+
setCopied(false, repaint);
|
|
615
|
+
}
|
|
616
|
+
function showCopiedFeedback() {
|
|
617
|
+
clearCopiedTimer();
|
|
618
|
+
const duration = normalizeNonNegativeInt(props.copiedDurationMs, DEFAULT_MERMAID_IMAGE_COPIED_DURATION_MS);
|
|
619
|
+
if (duration <= 0) {
|
|
620
|
+
setCopied(false);
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
setCopied(true);
|
|
624
|
+
copiedTimer = setTimeout(() => {
|
|
625
|
+
copiedTimer = null;
|
|
626
|
+
if (!alive) return;
|
|
627
|
+
setCopied(false);
|
|
628
|
+
}, duration);
|
|
629
|
+
}
|
|
630
|
+
function queueClearGraphic() {
|
|
631
|
+
if (activeGraphicId == null) return;
|
|
632
|
+
const id = activeGraphicId;
|
|
633
|
+
activeGraphicId = null;
|
|
634
|
+
try {
|
|
635
|
+
graphicsOutput.value?.clear?.(id);
|
|
636
|
+
} catch {}
|
|
637
|
+
}
|
|
638
|
+
const hasBox = computed(() => props.box !== false);
|
|
639
|
+
const normalizedWidth = computed(() => {
|
|
640
|
+
const width = Math.floor(Number(props.w));
|
|
641
|
+
return Number.isFinite(width) ? Math.max(0, width) : 0;
|
|
642
|
+
});
|
|
643
|
+
const reservesBoxRows = computed(() => hasBox.value && normalizedWidth.value >= 2);
|
|
644
|
+
const boxChars = computed(() => props.ascii ? ASCII_MERMAID_IMAGE_BOX_CHARS : UNICODE_MERMAID_IMAGE_BOX_CHARS);
|
|
645
|
+
const sourceLines = computed(() => splitRenderedOutput(source.value));
|
|
646
|
+
const currentStyle = computed(() => props.style ?? defaultStyle.value);
|
|
647
|
+
const innerWidth = computed(() => {
|
|
648
|
+
const w = normalizedWidth.value;
|
|
649
|
+
return reservesBoxRows.value ? Math.max(0, w - 2) : w;
|
|
650
|
+
});
|
|
651
|
+
const fixedInnerHeight = computed(() => {
|
|
652
|
+
if (props.h == null) return 0;
|
|
653
|
+
const h$1 = Math.floor(Number(props.h));
|
|
654
|
+
if (!Number.isFinite(h$1)) return 0;
|
|
655
|
+
const value = Math.max(0, h$1);
|
|
656
|
+
return reservesBoxRows.value ? Math.max(0, value - 2) : value;
|
|
657
|
+
});
|
|
658
|
+
const autoHeight = computed(() => props.h == null);
|
|
659
|
+
const displayFit = computed(() => {
|
|
660
|
+
const cells = imageCells.value;
|
|
661
|
+
if (!cells) return null;
|
|
662
|
+
if (autoHeight.value) return fitImageCells(cells, innerWidth.value, Number.MAX_SAFE_INTEGER);
|
|
663
|
+
return fitImageCells(cells, innerWidth.value, fixedInnerHeight.value);
|
|
664
|
+
});
|
|
665
|
+
const contentHeight = computed(() => {
|
|
666
|
+
if (!autoHeight.value) return fixedInnerHeight.value;
|
|
667
|
+
return displayFit.value?.displayH ?? Math.max(1, sourceLines.value.length);
|
|
668
|
+
});
|
|
669
|
+
const fullHeight = computed(() => {
|
|
670
|
+
if (props.h != null) {
|
|
671
|
+
const h$1 = Math.floor(Number(props.h));
|
|
672
|
+
return Number.isFinite(h$1) ? Math.max(0, h$1) : 0;
|
|
673
|
+
}
|
|
674
|
+
return reservesBoxRows.value ? contentHeight.value + 2 : contentHeight.value;
|
|
675
|
+
});
|
|
676
|
+
const fullRect = computed(() => {
|
|
677
|
+
return translateRect({
|
|
678
|
+
x: props.x,
|
|
679
|
+
y: props.y,
|
|
680
|
+
w: props.w,
|
|
681
|
+
h: fullHeight.value
|
|
682
|
+
}, layout.originX, layout.originY);
|
|
683
|
+
});
|
|
684
|
+
const absRect = computed(() => {
|
|
685
|
+
const translated = fullRect.value;
|
|
686
|
+
if (!layout.clipRect) return translated;
|
|
687
|
+
return intersectRect(translated, layout.clipRect) ?? {
|
|
688
|
+
x: 0,
|
|
689
|
+
y: 0,
|
|
690
|
+
w: 0,
|
|
691
|
+
h: 0
|
|
692
|
+
};
|
|
693
|
+
});
|
|
694
|
+
const copyLabel = computed(() => copied.value ? props.copiedText : props.copyText);
|
|
695
|
+
function cellWidth(value) {
|
|
696
|
+
return withTextWidthProvider(widthProvider, () => textCellWidth(value));
|
|
697
|
+
}
|
|
698
|
+
function sliceCells(text, maxCells) {
|
|
699
|
+
return withTextWidthProvider(widthProvider, () => sliceByCells(text, maxCells));
|
|
700
|
+
}
|
|
701
|
+
function sliceCellsRange(text, startCells, endCells) {
|
|
702
|
+
return withTextWidthProvider(widthProvider, () => sliceByCellsRange(text, startCells, endCells));
|
|
703
|
+
}
|
|
704
|
+
function padCells(text, width) {
|
|
705
|
+
return withTextWidthProvider(widthProvider, () => padEndByCells(text, width));
|
|
706
|
+
}
|
|
707
|
+
function resolveImageOptions() {
|
|
708
|
+
const resolvedFg = props.fg ?? resolveMermaidImageColor(currentStyle.value.fg) ?? void 0;
|
|
709
|
+
return normalizeMermaidImageOptions({
|
|
710
|
+
cellWidthPx: props.cellWidthPx,
|
|
711
|
+
cellHeightPx: props.cellHeightPx,
|
|
712
|
+
scale: props.scale,
|
|
713
|
+
bg: props.bg,
|
|
714
|
+
fg: resolvedFg,
|
|
715
|
+
maxWidthCells: props.maxWidthCells,
|
|
716
|
+
maxHeightCells: props.maxHeightCells,
|
|
717
|
+
padding: props.padding
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
function shouldSkipRenderForSize(code) {
|
|
721
|
+
const maxChars = normalizeNonNegativeInt(props.maxRenderSourceChars, DEFAULT_MERMAID_IMAGE_MAX_RENDER_SOURCE_CHARS);
|
|
722
|
+
if (maxChars > 0 && code.length > maxChars) return true;
|
|
723
|
+
const maxLines = normalizeNonNegativeInt(props.maxRenderSourceLines, DEFAULT_MERMAID_IMAGE_MAX_RENDER_SOURCE_LINES);
|
|
724
|
+
if (maxLines > 0 && countLinesUpTo(code, maxLines) > maxLines) return true;
|
|
725
|
+
return false;
|
|
726
|
+
}
|
|
727
|
+
async function rasterizeWithTimeout(code, options) {
|
|
728
|
+
const timeoutMs = normalizeNonNegativeInt(props.renderTimeoutMs, 0);
|
|
729
|
+
if (timeoutMs <= 0) return await getMermaidImage(code, options);
|
|
730
|
+
let timer = null;
|
|
731
|
+
try {
|
|
732
|
+
return await Promise.race([getMermaidImage(code, options), new Promise((resolve) => {
|
|
733
|
+
timer = setTimeout(() => resolve(null), timeoutMs);
|
|
734
|
+
})]);
|
|
735
|
+
} finally {
|
|
736
|
+
if (timer != null) clearTimeout(timer);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
async function renderImage(version) {
|
|
740
|
+
const code = source.value;
|
|
741
|
+
if (!code.trim()) {
|
|
742
|
+
if (!alive || version !== renderVersion) return;
|
|
743
|
+
imageCells.value = null;
|
|
744
|
+
bump();
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
if (waitingForStreamingSourceToFinish.value || shouldSkipRenderForSize(code)) {
|
|
748
|
+
if (!alive || version !== renderVersion) return;
|
|
749
|
+
imageCells.value = null;
|
|
750
|
+
bump();
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
imageCells.value = null;
|
|
754
|
+
bump();
|
|
755
|
+
const protocol = graphicsProtocol.value;
|
|
756
|
+
if (!protocol) return;
|
|
757
|
+
const options = resolveImageOptions();
|
|
758
|
+
const cached = getCachedMermaidImage(code, options);
|
|
759
|
+
if (cached) {
|
|
760
|
+
if (!alive || version !== renderVersion) return;
|
|
761
|
+
imageCells.value = cached;
|
|
762
|
+
bump();
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
if (!isMermaidImageRendererReady()) {
|
|
766
|
+
loadMermaidImageRenderer().then((ready) => {
|
|
767
|
+
if (!alive || version !== renderVersion || !ready) return;
|
|
768
|
+
renderImage(version);
|
|
769
|
+
});
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
const result = await rasterizeWithTimeout(code, options);
|
|
773
|
+
if (!alive || version !== renderVersion) return;
|
|
774
|
+
imageCells.value = result;
|
|
775
|
+
bump();
|
|
776
|
+
}
|
|
777
|
+
function scheduleRender() {
|
|
778
|
+
const version = ++renderVersion;
|
|
779
|
+
resetCopyFeedback(false);
|
|
780
|
+
imageCells.value = null;
|
|
781
|
+
if (waitingForStreamingSourceToFinish.value) {
|
|
782
|
+
builtOnce = true;
|
|
783
|
+
scheduler.cancelFrameTask?.(frameTaskId);
|
|
784
|
+
bump();
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
if (!builtOnce || !props.streaming) {
|
|
788
|
+
builtOnce = true;
|
|
789
|
+
renderImage(version);
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
const accepted = scheduler.queueFrameTask({
|
|
793
|
+
id: frameTaskId,
|
|
794
|
+
reason: "stream",
|
|
795
|
+
priority: "low",
|
|
796
|
+
sync: false,
|
|
797
|
+
run: () => {
|
|
798
|
+
if (!alive) return;
|
|
799
|
+
if (version !== renderVersion) return;
|
|
800
|
+
renderImage(version);
|
|
801
|
+
}
|
|
802
|
+
});
|
|
803
|
+
if (accepted === false) renderImage(version);
|
|
804
|
+
}
|
|
805
|
+
watch([
|
|
806
|
+
source,
|
|
807
|
+
() => props.renderer,
|
|
808
|
+
() => props.cellWidthPx,
|
|
809
|
+
() => props.cellHeightPx,
|
|
810
|
+
() => props.scale,
|
|
811
|
+
() => props.bg,
|
|
812
|
+
() => props.fg,
|
|
813
|
+
() => props.maxWidthCells,
|
|
814
|
+
() => props.maxHeightCells,
|
|
815
|
+
() => props.padding,
|
|
816
|
+
() => props.streaming,
|
|
817
|
+
() => props.final,
|
|
818
|
+
() => props.maxRenderSourceChars,
|
|
819
|
+
() => props.maxRenderSourceLines,
|
|
820
|
+
graphicsOutputVersion
|
|
821
|
+
], () => {
|
|
822
|
+
scheduleRender();
|
|
823
|
+
}, {
|
|
824
|
+
immediate: true,
|
|
825
|
+
deep: true
|
|
826
|
+
});
|
|
827
|
+
const unsubscribeMermaidImage = subscribeMermaidImage(() => {
|
|
828
|
+
if (!alive) return;
|
|
829
|
+
scheduleRender();
|
|
830
|
+
});
|
|
831
|
+
const unsubscribeGraphicsOutput = subscribeTerminalGraphicsOutput(terminal, () => {
|
|
832
|
+
if (!alive) return;
|
|
833
|
+
graphicsOutputVersion.value = getTerminalGraphicsOutputVersion(terminal);
|
|
834
|
+
scheduleRender();
|
|
835
|
+
});
|
|
836
|
+
onBeforeUnmount(() => {
|
|
837
|
+
alive = false;
|
|
838
|
+
renderVersion++;
|
|
839
|
+
clearCopiedTimer();
|
|
840
|
+
queueClearGraphic();
|
|
841
|
+
unsubscribeMermaidImage();
|
|
842
|
+
unsubscribeGraphicsOutput();
|
|
843
|
+
scheduler.cancelFrameTask?.(frameTaskId);
|
|
844
|
+
});
|
|
845
|
+
function canDrawBox(width, height) {
|
|
846
|
+
return hasBox.value && Math.floor(width) >= 2 && Math.floor(height) >= 2;
|
|
847
|
+
}
|
|
848
|
+
function headerCopySegment(width) {
|
|
849
|
+
if (!hasBox.value || !props.copyButton) return null;
|
|
850
|
+
const rowWidth = Math.max(0, Math.floor(width));
|
|
851
|
+
if (rowWidth < 4) return null;
|
|
852
|
+
const label = sanitizeInlineText(copyLabel.value);
|
|
853
|
+
if (!label) return null;
|
|
854
|
+
const maxCells = Math.max(0, rowWidth - 2);
|
|
855
|
+
const text = sliceCells(` ${label} `, maxCells);
|
|
856
|
+
const cells = cellWidth(text);
|
|
857
|
+
if (!text || cells <= 0) return null;
|
|
858
|
+
return {
|
|
859
|
+
text,
|
|
860
|
+
start: Math.max(1, rowWidth - cells - 1),
|
|
861
|
+
cells
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
function headerTitleSegment(width, copy) {
|
|
865
|
+
if (!hasBox.value) return null;
|
|
866
|
+
const rowWidth = Math.max(0, Math.floor(width));
|
|
867
|
+
if (rowWidth < 4) return null;
|
|
868
|
+
const title = sanitizeInlineText(props.title);
|
|
869
|
+
if (!title) return null;
|
|
870
|
+
const titleStart = 1;
|
|
871
|
+
const titleEnd = copy ? Math.max(titleStart, copy.start - 1) : rowWidth - 1;
|
|
872
|
+
const maxCells = Math.max(0, titleEnd - titleStart);
|
|
873
|
+
if (maxCells <= 0) return null;
|
|
874
|
+
const text = sliceCells(` ${title} `, maxCells);
|
|
875
|
+
const cells = cellWidth(text);
|
|
876
|
+
if (!text || cells <= 0) return null;
|
|
877
|
+
return {
|
|
878
|
+
text,
|
|
879
|
+
start: titleStart,
|
|
880
|
+
cells
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
function overlayCells(row, segment, width) {
|
|
884
|
+
const rowWidth = Math.max(0, Math.floor(width));
|
|
885
|
+
const start = Math.max(0, Math.floor(segment.start));
|
|
886
|
+
if (rowWidth <= 1 || start >= rowWidth - 1 || segment.cells <= 0) return row;
|
|
887
|
+
const maxCells = Math.max(0, rowWidth - 1 - start);
|
|
888
|
+
const text = sliceCells(segment.text, maxCells);
|
|
889
|
+
const cells = cellWidth(text);
|
|
890
|
+
if (!text || cells <= 0) return row;
|
|
891
|
+
return `${sliceCells(row, start)}${text}${sliceCellsRange(row, start + cells, rowWidth)}`;
|
|
892
|
+
}
|
|
893
|
+
function boxRow(rowIndex, width, height) {
|
|
894
|
+
const rowWidth = Math.max(0, Math.floor(width));
|
|
895
|
+
const rowHeight = Math.max(0, Math.floor(height));
|
|
896
|
+
if (!canDrawBox(rowWidth, rowHeight)) return contentLine(rowIndex, rowWidth, props.clear);
|
|
897
|
+
const chars = boxChars.value;
|
|
898
|
+
const innerW = Math.max(0, rowWidth - 2);
|
|
899
|
+
if (rowIndex === 0) {
|
|
900
|
+
let row = `${chars.tl}${repeatChar(chars.h, innerW)}${chars.tr}`;
|
|
901
|
+
const copy = headerCopySegment(rowWidth);
|
|
902
|
+
const title = headerTitleSegment(rowWidth, copy);
|
|
903
|
+
if (title) row = overlayCells(row, title, rowWidth);
|
|
904
|
+
if (copy) row = overlayCells(row, copy, rowWidth);
|
|
905
|
+
return row;
|
|
906
|
+
}
|
|
907
|
+
if (rowIndex === rowHeight - 1) return `${chars.bl}${repeatChar(chars.h, innerW)}${chars.br}`;
|
|
908
|
+
return `${chars.v}${contentLine(rowIndex - 1, innerW, true)}${chars.v}`;
|
|
909
|
+
}
|
|
910
|
+
function contentLine(rowIndex, width, pad) {
|
|
911
|
+
const showImage = imageCells.value != null && displayFit.value != null && graphicsProtocol.value != null;
|
|
912
|
+
const src = showImage ? spaces(width) : sourceLines.value[rowIndex] ?? "";
|
|
913
|
+
const clipped = sliceCells(src, width);
|
|
914
|
+
return pad ? padCells(clipped, width) : clipped;
|
|
915
|
+
}
|
|
916
|
+
function innerRectFrom(full) {
|
|
917
|
+
const x = Math.floor(full.x) + (reservesBoxRows.value ? 1 : 0);
|
|
918
|
+
const y = Math.floor(full.y) + (reservesBoxRows.value ? 1 : 0);
|
|
919
|
+
const w = Math.max(0, Math.floor(full.w) - (reservesBoxRows.value ? 2 : 0));
|
|
920
|
+
const h$1 = Math.max(0, Math.floor(full.h) - (reservesBoxRows.value ? 2 : 0));
|
|
921
|
+
return {
|
|
922
|
+
x,
|
|
923
|
+
y,
|
|
924
|
+
w,
|
|
925
|
+
h: h$1
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
function queueImageGraphic(full, fit) {
|
|
929
|
+
const protocol = graphicsProtocol.value;
|
|
930
|
+
const cells = imageCells.value;
|
|
931
|
+
if (!protocol || !cells) {
|
|
932
|
+
queueClearGraphic();
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
const inner = innerRectFrom(full);
|
|
936
|
+
if (inner.w <= 0 || inner.h <= 0) {
|
|
937
|
+
queueClearGraphic();
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
const offsetX = inner.w > fit.displayW ? Math.floor((inner.w - fit.displayW) / 2) : 0;
|
|
941
|
+
const rect = {
|
|
942
|
+
x: inner.x + offsetX,
|
|
943
|
+
y: inner.y,
|
|
944
|
+
w: fit.displayW,
|
|
945
|
+
h: fit.displayH
|
|
946
|
+
};
|
|
947
|
+
const imageId = stableTerminalGraphicNumericId(`mermaid-image:${uid}:${renderVersion}:img`);
|
|
948
|
+
const placementId = stableTerminalGraphicNumericId(`mermaid-image:${uid}:${renderVersion}:plc`);
|
|
949
|
+
const built = createTerminalGraphicPngSequence({
|
|
950
|
+
protocol,
|
|
951
|
+
base64: cells.base64,
|
|
952
|
+
imageId,
|
|
953
|
+
placementId,
|
|
954
|
+
cols: cells.widthCells,
|
|
955
|
+
rows: cells.heightCells,
|
|
956
|
+
sourceWidth: cells.naturalWidth,
|
|
957
|
+
sourceHeight: cells.naturalHeight,
|
|
958
|
+
placementColumns: fit.displayW,
|
|
959
|
+
placementRows: fit.displayH,
|
|
960
|
+
rect,
|
|
961
|
+
fullRect: rect,
|
|
962
|
+
zIndex: -1,
|
|
963
|
+
fallback: source.value
|
|
964
|
+
});
|
|
965
|
+
if (!built) {
|
|
966
|
+
queueClearGraphic();
|
|
967
|
+
return;
|
|
968
|
+
}
|
|
969
|
+
const id = `mermaid-image:${uid}:${renderVersion}`;
|
|
970
|
+
const output = graphicsOutput.value;
|
|
971
|
+
if (!output) {
|
|
972
|
+
queueClearGraphic();
|
|
973
|
+
return;
|
|
974
|
+
}
|
|
975
|
+
if (activeGraphicId != null && activeGraphicId !== id) {
|
|
976
|
+
try {
|
|
977
|
+
output.clear?.(activeGraphicId);
|
|
978
|
+
} catch {}
|
|
979
|
+
activeGraphicId = null;
|
|
980
|
+
}
|
|
981
|
+
const accepted = output.queue({
|
|
982
|
+
id,
|
|
983
|
+
x: rect.x,
|
|
984
|
+
y: rect.y,
|
|
985
|
+
w: fit.displayW,
|
|
986
|
+
h: fit.displayH,
|
|
987
|
+
protocol,
|
|
988
|
+
sequence: built.sequence,
|
|
989
|
+
resizeSequence: built.resizeSequence,
|
|
990
|
+
clearSequence: built.clearSequence,
|
|
991
|
+
fallbackText: source.value
|
|
992
|
+
});
|
|
993
|
+
if (accepted) activeGraphicId = id;
|
|
994
|
+
else queueClearGraphic();
|
|
995
|
+
}
|
|
996
|
+
const copyHitRect = computed(() => {
|
|
997
|
+
const full = fullRect.value;
|
|
998
|
+
if (!visible.value || !props.copyButton || !canDrawBox(full.w, full.h)) return {
|
|
999
|
+
x: 0,
|
|
1000
|
+
y: 0,
|
|
1001
|
+
w: 0,
|
|
1002
|
+
h: 0
|
|
1003
|
+
};
|
|
1004
|
+
const copy = headerCopySegment(Math.max(0, Math.floor(full.w)));
|
|
1005
|
+
if (!copy) return {
|
|
1006
|
+
x: 0,
|
|
1007
|
+
y: 0,
|
|
1008
|
+
w: 0,
|
|
1009
|
+
h: 0
|
|
1010
|
+
};
|
|
1011
|
+
const raw = {
|
|
1012
|
+
x: Math.floor(full.x) + copy.start,
|
|
1013
|
+
y: Math.floor(full.y),
|
|
1014
|
+
w: copy.cells,
|
|
1015
|
+
h: 1
|
|
1016
|
+
};
|
|
1017
|
+
if (!layout.clipRect) return raw;
|
|
1018
|
+
return intersectRect(raw, layout.clipRect) ?? {
|
|
1019
|
+
x: 0,
|
|
1020
|
+
y: 0,
|
|
1021
|
+
w: 0,
|
|
1022
|
+
h: 0
|
|
1023
|
+
};
|
|
1024
|
+
});
|
|
1025
|
+
const contentHitRect = computed(() => {
|
|
1026
|
+
if (!visible.value || !props.copyOnClick) return {
|
|
1027
|
+
x: 0,
|
|
1028
|
+
y: 0,
|
|
1029
|
+
w: 0,
|
|
1030
|
+
h: 0
|
|
1031
|
+
};
|
|
1032
|
+
const full = fullRect.value;
|
|
1033
|
+
if (full.w <= 0 || full.h <= 0) return {
|
|
1034
|
+
x: 0,
|
|
1035
|
+
y: 0,
|
|
1036
|
+
w: 0,
|
|
1037
|
+
h: 0
|
|
1038
|
+
};
|
|
1039
|
+
const inner = innerRectFrom(full);
|
|
1040
|
+
if (inner.w <= 0 || inner.h <= 0) return {
|
|
1041
|
+
x: 0,
|
|
1042
|
+
y: 0,
|
|
1043
|
+
w: 0,
|
|
1044
|
+
h: 0
|
|
1045
|
+
};
|
|
1046
|
+
if (!layout.clipRect) return inner;
|
|
1047
|
+
return intersectRect(inner, layout.clipRect) ?? {
|
|
1048
|
+
x: 0,
|
|
1049
|
+
y: 0,
|
|
1050
|
+
w: 0,
|
|
1051
|
+
h: 0
|
|
1052
|
+
};
|
|
1053
|
+
});
|
|
1054
|
+
function clipboardCanWrite(api) {
|
|
1055
|
+
return api.canWrite ?? api.supported;
|
|
1056
|
+
}
|
|
1057
|
+
async function writeClipboardText(text) {
|
|
1058
|
+
const contextClipboard = terminalContext.clipboard;
|
|
1059
|
+
if (contextClipboard) {
|
|
1060
|
+
if (!clipboardCanWrite(contextClipboard)) throw new Error("Clipboard write not available in this runtime");
|
|
1061
|
+
await contextClipboard.writeText(text);
|
|
1062
|
+
return;
|
|
1063
|
+
}
|
|
1064
|
+
const navClipboard = globalThis.navigator?.clipboard;
|
|
1065
|
+
if (navClipboard && typeof navClipboard.writeText === "function") {
|
|
1066
|
+
await navClipboard.writeText(text);
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
throw new Error("Clipboard write not available in this runtime");
|
|
1070
|
+
}
|
|
1071
|
+
async function copySource() {
|
|
1072
|
+
const text = source.value;
|
|
1073
|
+
const requestVersion = ++copyRequestVersion;
|
|
1074
|
+
let ok = false;
|
|
1075
|
+
let copyError;
|
|
1076
|
+
try {
|
|
1077
|
+
await writeClipboardText(text);
|
|
1078
|
+
ok = true;
|
|
1079
|
+
} catch (err) {
|
|
1080
|
+
copyError = err;
|
|
1081
|
+
}
|
|
1082
|
+
if (!alive) return;
|
|
1083
|
+
const isLatestForCurrentSource = requestVersion === copyRequestVersion && source.value === text;
|
|
1084
|
+
if (isLatestForCurrentSource) if (ok) showCopiedFeedback();
|
|
1085
|
+
else setCopied(false);
|
|
1086
|
+
emit("copy", ok ? {
|
|
1087
|
+
text,
|
|
1088
|
+
ok
|
|
1089
|
+
} : {
|
|
1090
|
+
text,
|
|
1091
|
+
ok,
|
|
1092
|
+
error: copyError
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
function onCopyClick(event) {
|
|
1096
|
+
event.preventDefault();
|
|
1097
|
+
event.stopPropagation();
|
|
1098
|
+
copySource();
|
|
1099
|
+
}
|
|
1100
|
+
function onCopyKeydown(event) {
|
|
1101
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
1102
|
+
event.preventDefault();
|
|
1103
|
+
event.stopPropagation();
|
|
1104
|
+
copySource();
|
|
1105
|
+
}
|
|
1106
|
+
const copyNodeActive = computed(() => visible.value && props.copyButton && copyHitRect.value.w > 0 && copyHitRect.value.h > 0);
|
|
1107
|
+
useTerminalNode(() => ({
|
|
1108
|
+
rect: copyHitRect.value,
|
|
1109
|
+
zIndex: (parentEventZ.value ?? 0) + props.zIndex + 1,
|
|
1110
|
+
visible: copyNodeActive.value,
|
|
1111
|
+
focusable: copyNodeActive.value,
|
|
1112
|
+
selectable: false,
|
|
1113
|
+
handlers: copyNodeActive.value ? {
|
|
1114
|
+
click: onCopyClick,
|
|
1115
|
+
keydown: onCopyKeydown
|
|
1116
|
+
} : {}
|
|
1117
|
+
}));
|
|
1118
|
+
const contentNodeActive = computed(() => visible.value && props.copyOnClick && contentHitRect.value.w > 0 && contentHitRect.value.h > 0);
|
|
1119
|
+
useTerminalNode(() => ({
|
|
1120
|
+
rect: contentHitRect.value,
|
|
1121
|
+
zIndex: (parentEventZ.value ?? 0) + props.zIndex,
|
|
1122
|
+
visible: contentNodeActive.value,
|
|
1123
|
+
focusable: false,
|
|
1124
|
+
selectable: false,
|
|
1125
|
+
handlers: contentNodeActive.value ? { click: onCopyClick } : {}
|
|
1126
|
+
}));
|
|
1127
|
+
useRenderNode(() => ({
|
|
1128
|
+
zIndex: props.zIndex,
|
|
1129
|
+
rect: visible.value ? absRect.value : {
|
|
1130
|
+
x: 0,
|
|
1131
|
+
y: 0,
|
|
1132
|
+
w: 0,
|
|
1133
|
+
h: 0
|
|
1134
|
+
},
|
|
1135
|
+
deps: [
|
|
1136
|
+
visible.value,
|
|
1137
|
+
absRect.value,
|
|
1138
|
+
fullRect.value,
|
|
1139
|
+
imageCells.value,
|
|
1140
|
+
displayFit.value,
|
|
1141
|
+
sourceLines.value,
|
|
1142
|
+
currentStyle.value,
|
|
1143
|
+
props.clear,
|
|
1144
|
+
hasBox.value,
|
|
1145
|
+
boxChars.value,
|
|
1146
|
+
props.title,
|
|
1147
|
+
props.copyButton,
|
|
1148
|
+
copyLabel.value,
|
|
1149
|
+
graphicsOutputVersion.value,
|
|
1150
|
+
documentVersion.value
|
|
1151
|
+
],
|
|
1152
|
+
paint: (dirtyRows) => {
|
|
1153
|
+
withTextWidthProvider(widthProvider, () => {
|
|
1154
|
+
if (!visible.value) {
|
|
1155
|
+
queueClearGraphic();
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
const r = absRect.value;
|
|
1159
|
+
const full = fullRect.value;
|
|
1160
|
+
if (r.w <= 0 || r.h <= 0) {
|
|
1161
|
+
queueClearGraphic();
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
const style = currentStyle.value;
|
|
1165
|
+
const dx = Math.max(0, Math.floor(r.x - full.x));
|
|
1166
|
+
const fullY = Math.floor(full.y);
|
|
1167
|
+
const fullW = Math.max(0, Math.floor(full.w));
|
|
1168
|
+
const fullH = Math.max(0, Math.floor(full.h));
|
|
1169
|
+
const blank = props.clear ? spaces(r.w) : "";
|
|
1170
|
+
const paintRow = (y) => {
|
|
1171
|
+
if (y < r.y || y >= r.y + r.h) return;
|
|
1172
|
+
const rowIndex = y - fullY;
|
|
1173
|
+
if (rowIndex < 0 || rowIndex >= fullH) {
|
|
1174
|
+
if (props.clear) terminal.write(blank, {
|
|
1175
|
+
x: r.x,
|
|
1176
|
+
y,
|
|
1177
|
+
style
|
|
1178
|
+
});
|
|
1179
|
+
return;
|
|
1180
|
+
}
|
|
1181
|
+
const src = boxRow(rowIndex, fullW, fullH);
|
|
1182
|
+
const clipped = dx > 0 ? sliceCellsRange(src, dx, dx + r.w) : sliceCells(src, r.w);
|
|
1183
|
+
const value = props.clear ? padCells(clipped, r.w) : clipped;
|
|
1184
|
+
if (value || props.clear) terminal.write(value, {
|
|
1185
|
+
x: r.x,
|
|
1186
|
+
y,
|
|
1187
|
+
style
|
|
1188
|
+
});
|
|
1189
|
+
};
|
|
1190
|
+
if (imageCells.value && displayFit.value) queueImageGraphic(full, displayFit.value);
|
|
1191
|
+
else queueClearGraphic();
|
|
1192
|
+
if (dirtyRows?.length) {
|
|
1193
|
+
for (const y of dirtyRows) paintRow(y);
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
for (let y = r.y; y < r.y + r.h; y++) paintRow(y);
|
|
1197
|
+
});
|
|
1198
|
+
}
|
|
1199
|
+
}));
|
|
1200
|
+
return () => h("span", rootProps);
|
|
1201
|
+
}
|
|
1202
|
+
});
|
|
1203
|
+
|
|
1204
|
+
//#endregion
|
|
1205
|
+
export { TBeautifulMermaid, TBeautifulMermaidText, TMermaid, TMermaidImage, TMermaidText$1 as TMermaidText, beautifulMermaidRenderer, clearMermaidImageCache, createBeautifulMermaidRenderer, getCachedMermaidImage, getMermaidImage, isMermaidImageRendererReady, loadMermaidImageRenderer, normalizeMermaidImageOptions, resolveMermaidImageColor, setMermaidImageRasterizer, subscribeMermaidImage };
|