@simon_he/vue-tui 1.1.3 → 1.1.5
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 +18 -18
- package/dist/{TMermaidText-frVr8Ysb.js → TMermaidText-wLnMMvVS.js} +1 -1
- package/dist/{TSelect-Dx34M1pF.js → TSelect-CMBOOFwK.js} +5 -5
- package/dist/{TTree-DdAjCPHu.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 +542 -266
- package/dist/agent.js +25 -82
- package/dist/{block-source-Crro3mxi.js → block-source-DhzajB9H.js} +299 -239
- package/dist/cli.cjs +57 -16
- package/dist/cli.js +70 -15
- 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 +103 -66
- package/dist/experimental.js +20 -74
- package/dist/hyperlink-clbb_ha_.js +100 -0
- package/dist/index.js +8 -8
- package/dist/{linkify-BjI4zVfY.js → linkify-CL9wwnZN.js} +3 -3
- package/dist/markdown.cjs +521 -212
- package/dist/markdown.d.cts +3 -0
- package/dist/markdown.d.ts +3 -0
- package/dist/markdown.js +75 -8
- package/dist/math-image-BZhmfUeu.js +308 -0
- package/dist/mermaid-N3kGTHFy.js +1697 -0
- package/dist/mermaid.cjs +1460 -6
- 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 +61 -0
- package/dist/renderer-dom.js +4 -4
- package/dist/{terminal-graphics-Bbe83wSr.js → terminal-graphics-2FTRg9x3.js} +90 -2
- package/dist/{tlog-theme-i6S_Oftd.js → tlog-theme-B91Wv7Zj.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 +920 -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/theme.d.ts +12 -0
- package/dist/vue/markdown/types.d.ts +12 -2
- package/dist/vue/mermaid/beautiful-mermaid.d.ts +284 -240
- package/dist/vue/mermaid/mermaid-image.d.ts +73 -0
- package/dist/vue.js +9 -9
- package/package.json +24 -10
- 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,73 @@
|
|
|
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
|
+
/**
|
|
66
|
+
* @resvg/resvg-js (usvg) does not support CSS custom properties (`var()`) or
|
|
67
|
+
* `color-mix()`. beautiful-mermaid 1.x emits both, so feeding the raw SVG to
|
|
68
|
+
* resvg renders every shape black. This resolver inlines all `var(--x)` /
|
|
69
|
+
* `color-mix(in srgb, ...)` color expressions into concrete hex values before
|
|
70
|
+
* rasterization. Exported for tests.
|
|
71
|
+
*/
|
|
72
|
+
export declare function resolveMermaidSvgForResvg(svg: string, fallbackBg: string, fallbackFg: string): string;
|
|
73
|
+
export {};
|
package/dist/vue.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import
|
|
3
|
-
import "./
|
|
4
|
-
import "./dom-renderer-
|
|
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-
|
|
6
|
-
import { TText, TView, clamp
|
|
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-
|
|
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
|
|
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-
|
|
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.
|
|
3
|
+
"version": "1.1.5",
|
|
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,13 +246,14 @@
|
|
|
246
246
|
"access": "public"
|
|
247
247
|
},
|
|
248
248
|
"dependencies": {
|
|
249
|
-
"stream-markdown-parser": "1.
|
|
249
|
+
"stream-markdown-parser": "1.2.3"
|
|
250
250
|
},
|
|
251
251
|
"devDependencies": {
|
|
252
|
-
"@arethetypeswrong/core": "^0.18.
|
|
253
|
-
"@playwright/test": "^1.
|
|
252
|
+
"@arethetypeswrong/core": "^0.18.5",
|
|
253
|
+
"@playwright/test": "^1.62.1",
|
|
254
|
+
"@resvg/resvg-js": "^2.6.2",
|
|
254
255
|
"@types/node": "^18.19.130",
|
|
255
|
-
"@vitest/coverage-v8": "^4.1.
|
|
256
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
256
257
|
"beautiful-mermaid": "^1.1.3",
|
|
257
258
|
"bumpp": "^8.2.1",
|
|
258
259
|
"bun-webgpu": "0.1.7",
|
|
@@ -260,24 +261,27 @@
|
|
|
260
261
|
"happy-dom": "^17.6.3",
|
|
261
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
|
-
"oxlint": "^1.
|
|
266
|
+
"oxlint": "^1.77.0",
|
|
265
267
|
"picocolors": "^1.1.1",
|
|
266
268
|
"pinia": "^3.0.4",
|
|
267
|
-
"publint": "^0.3.
|
|
269
|
+
"publint": "^0.3.23",
|
|
268
270
|
"rimraf": "^3.0.2",
|
|
269
271
|
"tsdown": "^0.9.9",
|
|
270
|
-
"tsx": "^4.
|
|
272
|
+
"tsx": "^4.23.11",
|
|
271
273
|
"typescript": "^5.9.3",
|
|
272
274
|
"vite": "8.0.16",
|
|
273
275
|
"vitepress": "^1.6.4",
|
|
274
|
-
"vitest": "^4.1.
|
|
275
|
-
"vue": "^3.5.
|
|
276
|
+
"vitest": "^4.1.10",
|
|
277
|
+
"vue": "^3.5.41"
|
|
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",
|
|
280
283
|
"katex": "^0.16.47",
|
|
284
|
+
"mathjax-full": "^3.2.2",
|
|
281
285
|
"vue": ">=3.3.0 <4"
|
|
282
286
|
},
|
|
283
287
|
"peerDependenciesMeta": {
|
|
@@ -289,6 +293,12 @@
|
|
|
289
293
|
},
|
|
290
294
|
"katex": {
|
|
291
295
|
"optional": true
|
|
296
|
+
},
|
|
297
|
+
"mathjax-full": {
|
|
298
|
+
"optional": true
|
|
299
|
+
},
|
|
300
|
+
"@resvg/resvg-js": {
|
|
301
|
+
"optional": true
|
|
292
302
|
}
|
|
293
303
|
},
|
|
294
304
|
"lint-staged": {
|
|
@@ -321,6 +331,8 @@
|
|
|
321
331
|
"profile:agent-console:abc": "tsx scripts/profile-agent-console-abc.ts",
|
|
322
332
|
"profile:agent-console:abc:smoke": "AGENT_CONSOLE_PROFILE_SMOKE=1 tsx scripts/profile-agent-console-abc.ts",
|
|
323
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",
|
|
324
336
|
"run:basic:terminal": "pnpm run build && pnpm -C examples/basic terminal",
|
|
325
337
|
"run:agent-console:terminal": "pnpm run build && pnpm -C examples/agent-console terminal",
|
|
326
338
|
"run:basic:multi-select:terminal": "pnpm run build && pnpm -C examples/basic build:terminal:multi-select && pnpm -C examples/basic terminal:multi-select",
|
|
@@ -337,6 +349,8 @@
|
|
|
337
349
|
"test:3d:bun": "bun scripts/smoke-bun-3d.ts",
|
|
338
350
|
"run:image-showcase:terminal": "tsx examples/image-showcase.ts",
|
|
339
351
|
"run:katex-showcase:terminal": "tsx examples/katex-showcase.ts",
|
|
352
|
+
"run:mermaid-image-showcase:terminal": "tsx examples/mermaid-image-showcase.ts",
|
|
353
|
+
"run:mermaid-adaptive-showcase:terminal": "tsx examples/mermaid-adaptive-showcase.ts",
|
|
340
354
|
"trace:terminal-resize": "node scripts/trace-terminal-resize.mjs",
|
|
341
355
|
"test:component-terminal:smoke": "VT_SMOKE=1 tsx scripts/run-component-terminal.ts --all",
|
|
342
356
|
"e2e:component-terminal-charts": "tsx scripts/run-component-terminal.ts --capture-charts",
|
package/dist/mermaid-BNhM1jAZ.js
DELETED
|
@@ -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 };
|