@tdacorp/hyle-sdk 0.17.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +155 -28
- package/dist/check-routes-bin.js +38 -13
- package/dist/chunk-56Y24XBV.js +840 -0
- package/dist/{chunk-MGSUQBDW.js → chunk-75JFLML4.js} +176 -14
- package/dist/chunk-HJX57NLI.js +1105 -0
- package/dist/chunk-K5VDLROQ.js +145 -0
- package/dist/{chunk-BUJFMR3M.js → chunk-QVYQM5R2.js} +15 -6
- package/dist/chunk-U74B7AUG.js +398 -0
- package/dist/{chunk-6VOHFFA5.js → chunk-X2TLYM7Y.js} +2 -2
- package/dist/client-41fU6OY2.d.cts +201 -0
- package/dist/client-LwzHwqpM.d.ts +201 -0
- package/dist/code-copy.cjs +72 -0
- package/dist/code-copy.d.cts +15 -0
- package/dist/code-copy.d.ts +15 -0
- package/dist/code-copy.js +48 -0
- package/dist/comments.cjs +728 -275
- package/dist/comments.d.cts +66 -3
- package/dist/comments.d.ts +66 -3
- package/dist/comments.js +409 -326
- package/dist/{diagram-viewer-FJPED4SN.js → diagram-viewer-XY3CG75U.js} +62 -21
- package/dist/{embed-BmdwA2G9.d.cts → embed-BUFRQboD.d.ts} +2 -2
- package/dist/{embed-DNTZ2UXv.d.ts → embed-CYt-q13P.d.cts} +2 -2
- package/dist/fragment-alias.cjs +51 -0
- package/dist/fragment-alias.d.cts +7 -0
- package/dist/fragment-alias.d.ts +7 -0
- package/dist/fragment-alias.js +27 -0
- package/dist/html.cjs +881 -0
- package/dist/html.d.cts +20 -0
- package/dist/html.d.ts +20 -0
- package/dist/html.js +45 -0
- package/dist/index.cjs +181 -14
- package/dist/index.d.cts +14 -62
- package/dist/index.d.ts +14 -62
- package/dist/index.js +11 -1
- package/dist/{labels-nmukKYgL.d.ts → labels-CrA-iqTN.d.cts} +9 -0
- package/dist/{labels-nmukKYgL.d.cts → labels-CrA-iqTN.d.ts} +9 -0
- package/dist/mermaid-diagram.cjs +401 -125
- package/dist/mermaid-diagram.d.cts +23 -7
- package/dist/mermaid-diagram.d.ts +23 -7
- package/dist/mermaid-diagram.js +204 -51
- package/dist/mermaid-image.cjs +134 -60
- package/dist/mermaid-image.d.cts +4 -3
- package/dist/mermaid-image.d.ts +4 -3
- package/dist/mermaid-image.js +27 -28
- package/dist/next.cjs +627 -264
- package/dist/next.d.cts +11 -8
- package/dist/next.d.ts +11 -8
- package/dist/next.js +39 -12
- package/dist/print-coordinator.cjs +157 -0
- package/dist/print-coordinator.d.cts +27 -0
- package/dist/print-coordinator.d.ts +27 -0
- package/dist/print-coordinator.js +83 -0
- package/dist/react.cjs +556 -226
- package/dist/react.d.cts +136 -29
- package/dist/react.d.ts +136 -29
- package/dist/react.js +23 -3
- package/dist/reactions.cjs +653 -0
- package/dist/reactions.d.cts +27 -0
- package/dist/reactions.d.ts +27 -0
- package/dist/reactions.js +364 -0
- package/dist/{resolve-Ae7UFjsQ.d.ts → resolve-BjAK0k_Y.d.ts} +2 -2
- package/dist/{resolve-euZ4-aC9.d.cts → resolve-eI1muCKL.d.cts} +2 -2
- package/dist/revalidation-callback-BQl77tQR.d.cts +75 -0
- package/dist/revalidation-callback-BQl77tQR.d.ts +75 -0
- package/dist/sanitize-ijiWjEm9.d.cts +23 -0
- package/dist/sanitize-ijiWjEm9.d.ts +23 -0
- package/dist/styles.css +96 -25
- package/dist/toc-spy.cjs +59 -0
- package/dist/toc-spy.d.cts +15 -0
- package/dist/toc-spy.d.ts +15 -0
- package/dist/toc-spy.js +35 -0
- package/dist/{types-Czt887Iv.d.cts → types-3F0wqD-o.d.cts} +26 -2
- package/dist/{types-Czt887Iv.d.ts → types-3F0wqD-o.d.ts} +26 -2
- package/dist/use-cache.cjs +37 -11
- package/dist/use-cache.d.cts +12 -5
- package/dist/use-cache.d.ts +12 -5
- package/dist/use-cache.js +7 -7
- package/dist/youtube-facade.cjs +50 -0
- package/dist/youtube-facade.d.cts +17 -0
- package/dist/youtube-facade.d.ts +17 -0
- package/dist/youtube-facade.js +26 -0
- package/package.json +16 -3
- package/dist/chunk-DMK4XQLU.js +0 -1556
- package/dist/chunk-PJMJMP66.js +0 -63
- package/dist/revalidation-callback-D7Ms_Puz.d.cts +0 -42
- package/dist/revalidation-callback-D7Ms_Puz.d.ts +0 -42
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Component, ReactNode } from 'react';
|
|
3
|
+
import { V as ViewerLabels } from './labels-CrA-iqTN.cjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
-
* base URL or client (a test pins this). Mermaid is a dynamic import, so the chunk loads only on pages that
|
|
7
|
-
* from the host's own origin.
|
|
6
|
+
* Draws one diagram and opens it in the viewer on click. It receives the diagram text and presentational strings and nothing else:
|
|
7
|
+
* never a token, base URL or client (a test pins this). Mermaid is a dynamic import, so the chunk loads only on pages that draw a
|
|
8
|
+
* diagram, from the host's own origin; the viewer is another, fetched by the first click.
|
|
8
9
|
*/
|
|
9
10
|
interface MermaidDiagramProps {
|
|
10
11
|
source: string;
|
|
@@ -14,9 +15,24 @@ interface MermaidDiagramProps {
|
|
|
14
15
|
errorText: string;
|
|
15
16
|
/** Accessible name of the loader shown while the diagram renders (English when omitted). */
|
|
16
17
|
loadingText?: string;
|
|
17
|
-
/** Strings of the diagram viewer (English when omitted). */
|
|
18
|
+
/** Strings of the large-diagram notice, the print note and the diagram viewer (English when omitted). */
|
|
18
19
|
labels?: ViewerLabels;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
+
/** A throw anywhere in a diagram (the viewer included) must not blank the page: fall back to the source, as without JavaScript. */
|
|
22
|
+
declare class DiagramBoundary extends Component<{
|
|
23
|
+
source: string;
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
}, {
|
|
26
|
+
failed: boolean;
|
|
27
|
+
}> {
|
|
28
|
+
state: {
|
|
29
|
+
failed: boolean;
|
|
30
|
+
};
|
|
31
|
+
static getDerivedStateFromError(): {
|
|
32
|
+
failed: boolean;
|
|
33
|
+
};
|
|
34
|
+
render(): ReactNode;
|
|
35
|
+
}
|
|
36
|
+
declare function MermaidDiagram(props: MermaidDiagramProps): react.JSX.Element;
|
|
21
37
|
|
|
22
|
-
export { MermaidDiagram, type MermaidDiagramProps };
|
|
38
|
+
export { DiagramBoundary, MermaidDiagram, type MermaidDiagramProps };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Component, ReactNode } from 'react';
|
|
3
|
+
import { V as ViewerLabels } from './labels-CrA-iqTN.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
-
* base URL or client (a test pins this). Mermaid is a dynamic import, so the chunk loads only on pages that
|
|
7
|
-
* from the host's own origin.
|
|
6
|
+
* Draws one diagram and opens it in the viewer on click. It receives the diagram text and presentational strings and nothing else:
|
|
7
|
+
* never a token, base URL or client (a test pins this). Mermaid is a dynamic import, so the chunk loads only on pages that draw a
|
|
8
|
+
* diagram, from the host's own origin; the viewer is another, fetched by the first click.
|
|
8
9
|
*/
|
|
9
10
|
interface MermaidDiagramProps {
|
|
10
11
|
source: string;
|
|
@@ -14,9 +15,24 @@ interface MermaidDiagramProps {
|
|
|
14
15
|
errorText: string;
|
|
15
16
|
/** Accessible name of the loader shown while the diagram renders (English when omitted). */
|
|
16
17
|
loadingText?: string;
|
|
17
|
-
/** Strings of the diagram viewer (English when omitted). */
|
|
18
|
+
/** Strings of the large-diagram notice, the print note and the diagram viewer (English when omitted). */
|
|
18
19
|
labels?: ViewerLabels;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
+
/** A throw anywhere in a diagram (the viewer included) must not blank the page: fall back to the source, as without JavaScript. */
|
|
22
|
+
declare class DiagramBoundary extends Component<{
|
|
23
|
+
source: string;
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
}, {
|
|
26
|
+
failed: boolean;
|
|
27
|
+
}> {
|
|
28
|
+
state: {
|
|
29
|
+
failed: boolean;
|
|
30
|
+
};
|
|
31
|
+
static getDerivedStateFromError(): {
|
|
32
|
+
failed: boolean;
|
|
33
|
+
};
|
|
34
|
+
render(): ReactNode;
|
|
35
|
+
}
|
|
36
|
+
declare function MermaidDiagram(props: MermaidDiagramProps): react.JSX.Element;
|
|
21
37
|
|
|
22
|
-
export { MermaidDiagram, type MermaidDiagramProps };
|
|
38
|
+
export { DiagramBoundary, MermaidDiagram, type MermaidDiagramProps };
|
package/dist/mermaid-diagram.js
CHANGED
|
@@ -1,97 +1,250 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
+
DARK_VARIABLES,
|
|
3
4
|
MAX_MERMAID_EDGES,
|
|
4
5
|
MAX_MERMAID_SOURCE,
|
|
5
6
|
RENDER_TIMEOUT_MS,
|
|
7
|
+
afterFullscreen,
|
|
8
|
+
isClampedSource,
|
|
9
|
+
isLargeDiagram,
|
|
6
10
|
nextMermaidId,
|
|
7
|
-
pickMermaidTheme,
|
|
8
11
|
stripMermaidConfig,
|
|
12
|
+
watchPageTheme,
|
|
9
13
|
whenNearViewport,
|
|
10
14
|
withTimeout
|
|
11
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-K5VDLROQ.js";
|
|
12
16
|
import {
|
|
13
17
|
VIEWER_LABELS_EN
|
|
14
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-QVYQM5R2.js";
|
|
15
19
|
|
|
16
20
|
// src/react/mermaid-diagram.tsx
|
|
17
|
-
import { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
18
|
-
|
|
21
|
+
import { Component, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
22
|
+
|
|
23
|
+
// src/react/diagram-frame.tsx
|
|
24
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
25
|
+
function LargeDiagram({ source, sourceId, labels, errorText, live, drawing, busy, failed, clamped, showAll, onDraw, onToggle }) {
|
|
26
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
27
|
+
/* @__PURE__ */ jsxs("div", { className: "hyle-mermaid-gate", inert: !live, children: [
|
|
28
|
+
/* @__PURE__ */ jsxs("div", { className: "hyle-mermaid-gate-text", children: [
|
|
29
|
+
/* @__PURE__ */ jsx("p", { className: "hyle-mermaid-gate-title", children: labels.largeTitle }),
|
|
30
|
+
/* @__PURE__ */ jsx("p", { className: "hyle-mermaid-gate-body", children: labels.largeBody })
|
|
31
|
+
] }),
|
|
32
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "hyle-mermaid-draw", "aria-disabled": busy ? true : void 0, onClick: onDraw, children: busy ? labels.drawing : failed ? labels.drawAgain : labels.drawLarge }),
|
|
33
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", role: "status", children: drawing ? labels.drawingBody : failed ? errorText : "" }),
|
|
34
|
+
failed ? /* @__PURE__ */ jsx("p", { className: "hyle-mermaid-note", "aria-hidden": "true", children: errorText }) : null
|
|
35
|
+
] }),
|
|
36
|
+
drawing ? (
|
|
37
|
+
// The status above speaks for it; this is what a sighted reader watches while the page is blocked.
|
|
38
|
+
/* @__PURE__ */ jsxs("div", { className: "hyle-mermaid-drawing", "aria-hidden": "true", children: [
|
|
39
|
+
/* @__PURE__ */ jsx("span", { className: "hyle-mermaid-spinner" }),
|
|
40
|
+
/* @__PURE__ */ jsx("span", { children: labels.drawingBody })
|
|
41
|
+
] })
|
|
42
|
+
) : null,
|
|
43
|
+
/* @__PURE__ */ jsxs("div", { className: "hyle-mermaid-source", "data-drawing": drawing ? "" : void 0, "data-clamped": live && clamped && !showAll ? "" : void 0, children: [
|
|
44
|
+
/* @__PURE__ */ jsx("pre", { id: sourceId, tabIndex: 0, children: /* @__PURE__ */ jsx("code", { className: "language-mermaid", children: source }) }),
|
|
45
|
+
clamped ? /* @__PURE__ */ jsx("button", { type: "button", className: "hyle-mermaid-more", inert: !live, "aria-expanded": showAll, "aria-controls": sourceId, onClick: (e) => onToggle(e.currentTarget), children: showAll ? labels.hideSource : labels.showSource }) : null
|
|
46
|
+
] })
|
|
47
|
+
] });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/react/mermaid-diagram.tsx
|
|
51
|
+
import { installPrintShortcut, registerPrintTarget } from "./print-coordinator.js";
|
|
52
|
+
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
53
|
+
var DiagramBoundary = class extends Component {
|
|
54
|
+
state = { failed: false };
|
|
55
|
+
static getDerivedStateFromError() {
|
|
56
|
+
return { failed: true };
|
|
57
|
+
}
|
|
58
|
+
render() {
|
|
59
|
+
if (!this.state.failed) return this.props.children;
|
|
60
|
+
return /* @__PURE__ */ jsx2("figure", { className: "hyle-mermaid", children: /* @__PURE__ */ jsx2("pre", { tabIndex: 0, children: /* @__PURE__ */ jsx2("code", { className: "language-mermaid", children: this.props.source }) }) });
|
|
61
|
+
}
|
|
62
|
+
};
|
|
19
63
|
var queue = Promise.resolve();
|
|
20
|
-
|
|
64
|
+
var afterPaint = () => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve())));
|
|
65
|
+
async function renderSvg(id, source, theme, onSvg, stillWanted) {
|
|
21
66
|
const { default: mermaid } = await import("mermaid");
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} finally {
|
|
26
|
-
document.getElementById(`d${id}`)?.remove();
|
|
67
|
+
if (stillWanted) {
|
|
68
|
+
await afterPaint();
|
|
69
|
+
if (!stillWanted()) return;
|
|
27
70
|
}
|
|
71
|
+
mermaid.initialize({ startOnLoad: false, securityLevel: "strict", theme, ...theme === "dark" ? { themeVariables: DARK_VARIABLES } : {}, maxTextSize: MAX_MERMAID_SOURCE, maxEdges: MAX_MERMAID_EDGES, suppressErrorRendering: true });
|
|
72
|
+
const drawing = mermaid.render(id, stripMermaidConfig(source)).then((out) => onSvg({ markup: out.svg, id, theme })).finally(() => document.getElementById(`d${id}`)?.remove());
|
|
73
|
+
await withTimeout(drawing, RENDER_TIMEOUT_MS);
|
|
28
74
|
}
|
|
29
|
-
var
|
|
30
|
-
|
|
75
|
+
var noSubscription = () => () => {
|
|
76
|
+
};
|
|
77
|
+
function Diagram({ source, title, errorText, loadingText = "Rendering the diagram", labels = VIEWER_LABELS_EN }) {
|
|
31
78
|
const figure = useRef(null);
|
|
32
79
|
const trigger = useRef(null);
|
|
33
80
|
const captionId = useId();
|
|
81
|
+
const sourceId = useId();
|
|
82
|
+
const live = useSyncExternalStore(noSubscription, () => true, () => false);
|
|
34
83
|
const [open, setOpen] = useState(false);
|
|
35
84
|
const [Viewer, setViewer] = useState(null);
|
|
85
|
+
const [viewerFailed, setViewerFailed] = useState(false);
|
|
36
86
|
const [theme, setTheme] = useState(null);
|
|
37
87
|
const [near, setNear] = useState(false);
|
|
38
88
|
const [svg, setSvg] = useState(null);
|
|
39
89
|
const [failed, setFailed] = useState(false);
|
|
90
|
+
const large = useMemo(() => isLargeDiagram(source), [source]);
|
|
91
|
+
const [asked, setAsked] = useState(false);
|
|
92
|
+
const [attempt, setAttempt] = useState(0);
|
|
93
|
+
const [showAll, setShowAll] = useState(false);
|
|
94
|
+
const refocus = useRef(false);
|
|
95
|
+
const allowed = !large || asked;
|
|
96
|
+
const clamped = large && isClampedSource(source);
|
|
97
|
+
useEffect(() => figure.current ? watchPageTheme(figure.current, setTheme) : void 0, []);
|
|
98
|
+
useEffect(() => figure.current ? whenNearViewport(figure.current, () => setNear(true)) : void 0, []);
|
|
40
99
|
useEffect(() => {
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
100
|
+
const toPrint = window.matchMedia("print");
|
|
101
|
+
const draw2 = () => setNear(true);
|
|
102
|
+
if (toPrint.matches) draw2();
|
|
103
|
+
const onChange = (e) => {
|
|
104
|
+
if (e.matches) draw2();
|
|
105
|
+
};
|
|
106
|
+
window.addEventListener("beforeprint", draw2);
|
|
107
|
+
toPrint.addEventListener("change", onChange);
|
|
47
108
|
return () => {
|
|
48
|
-
|
|
49
|
-
|
|
109
|
+
window.removeEventListener("beforeprint", draw2);
|
|
110
|
+
toPrint.removeEventListener("change", onChange);
|
|
50
111
|
};
|
|
51
112
|
}, []);
|
|
52
|
-
|
|
113
|
+
const settled = useRef(false);
|
|
114
|
+
const shown = useRef(false);
|
|
115
|
+
const allowedNow = useRef(allowed);
|
|
116
|
+
const waiters = useRef([]);
|
|
53
117
|
useEffect(() => {
|
|
54
|
-
|
|
118
|
+
allowedNow.current = allowed;
|
|
119
|
+
settled.current = svg !== null || failed || !allowed;
|
|
120
|
+
shown.current = svg !== null;
|
|
121
|
+
if (settled.current) waiters.current.splice(0).forEach((resolve) => resolve());
|
|
122
|
+
}, [svg, failed, allowed]);
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
const pending = waiters.current;
|
|
125
|
+
const uninstall = installPrintShortcut();
|
|
126
|
+
const unregister = registerPrintTarget({
|
|
127
|
+
status: labels.printPreparing,
|
|
128
|
+
settled: () => settled.current,
|
|
129
|
+
prepare: () => allowedNow.current ? import("mermaid") : Promise.resolve(),
|
|
130
|
+
ensureDrawn: () => settled.current ? Promise.resolve() : new Promise((resolve) => {
|
|
131
|
+
pending.push(resolve);
|
|
132
|
+
setNear(true);
|
|
133
|
+
})
|
|
134
|
+
});
|
|
135
|
+
return () => {
|
|
136
|
+
unregister();
|
|
137
|
+
uninstall();
|
|
138
|
+
pending.splice(0).forEach((resolve) => resolve());
|
|
139
|
+
};
|
|
140
|
+
}, [labels.printPreparing]);
|
|
141
|
+
const wanted = near && allowed;
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
if (theme === null || !wanted) return;
|
|
55
144
|
let current = true;
|
|
56
145
|
const id = nextMermaidId();
|
|
57
|
-
|
|
58
|
-
(
|
|
59
|
-
()
|
|
60
|
-
|
|
146
|
+
const show = (out) => {
|
|
147
|
+
if (!current) return;
|
|
148
|
+
setSvg(out);
|
|
149
|
+
setFailed(false);
|
|
150
|
+
};
|
|
151
|
+
queue = queue.then(() => current ? renderSvg(id, source, theme, show, large && !shown.current ? () => current : void 0) : void 0).catch(() => {
|
|
152
|
+
if (current) setFailed(true);
|
|
153
|
+
});
|
|
61
154
|
return () => {
|
|
62
155
|
current = false;
|
|
63
156
|
};
|
|
64
|
-
}, [source, theme,
|
|
157
|
+
}, [source, theme, wanted, attempt, large]);
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
if (!refocus.current || svg === null && !failed) return;
|
|
160
|
+
refocus.current = false;
|
|
161
|
+
const active = document.activeElement;
|
|
162
|
+
if (svg && (!active || active === document.body)) trigger.current?.focus({ preventScroll: true });
|
|
163
|
+
}, [svg, failed]);
|
|
164
|
+
const collapsed = useRef(null);
|
|
165
|
+
useLayoutEffect(() => {
|
|
166
|
+
collapsed.current?.scrollIntoView({ block: "nearest" });
|
|
167
|
+
collapsed.current = null;
|
|
168
|
+
}, [showAll]);
|
|
169
|
+
const toggleSource = (button) => {
|
|
170
|
+
collapsed.current = showAll ? button : null;
|
|
171
|
+
setShowAll(!showAll);
|
|
172
|
+
};
|
|
65
173
|
const html = useMemo(() => svg ? { __html: svg.markup } : void 0, [svg]);
|
|
174
|
+
const drawing = wanted && svg === null && !failed;
|
|
175
|
+
const busy = asked && !failed;
|
|
176
|
+
const draw = () => {
|
|
177
|
+
if (busy) return;
|
|
178
|
+
refocus.current = true;
|
|
179
|
+
setAsked(true);
|
|
180
|
+
setNear(true);
|
|
181
|
+
if (failed) {
|
|
182
|
+
setFailed(false);
|
|
183
|
+
setAttempt((n) => n + 1);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
66
186
|
const expand = (e) => {
|
|
67
187
|
if (e.target.closest("a")) return;
|
|
188
|
+
const selection = window.getSelection();
|
|
189
|
+
if (selection && !selection.isCollapsed && figure.current?.contains(selection.anchorNode)) return;
|
|
68
190
|
setOpen(true);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
/* @__PURE__ */ jsx("span", { className: "hyle-mermaid-svg", dangerouslySetInnerHTML: html }),
|
|
75
|
-
/* @__PURE__ */ jsx("span", { className: "hyle-mermaid-hint", "aria-hidden": "true", children: labels.expandHint })
|
|
76
|
-
] }),
|
|
77
|
-
open && Viewer && svg ? /* @__PURE__ */ jsx(
|
|
78
|
-
Viewer,
|
|
79
|
-
{
|
|
80
|
-
svg: svg.markup,
|
|
81
|
-
svgId: svg.id,
|
|
82
|
-
source,
|
|
83
|
-
title,
|
|
84
|
-
labels,
|
|
85
|
-
onClose: () => {
|
|
191
|
+
setViewerFailed(false);
|
|
192
|
+
if (!Viewer) {
|
|
193
|
+
void import("./diagram-viewer-XY3CG75U.js").then(
|
|
194
|
+
(m) => setViewer(() => m.DiagramViewer),
|
|
195
|
+
() => {
|
|
86
196
|
setOpen(false);
|
|
87
|
-
|
|
197
|
+
setViewerFailed(true);
|
|
88
198
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
return /* @__PURE__ */ jsxs2(
|
|
203
|
+
"figure",
|
|
204
|
+
{
|
|
205
|
+
ref: figure,
|
|
206
|
+
className: "hyle-mermaid",
|
|
207
|
+
"data-slot-component": "Mermaid",
|
|
208
|
+
"data-mermaid-theme": svg?.theme,
|
|
209
|
+
...allowed && svg === null && !failed ? { "data-state": "pending" } : {},
|
|
210
|
+
...!live && clamped ? { "data-clamp": "" } : {},
|
|
211
|
+
children: [
|
|
212
|
+
svg !== null ? (
|
|
213
|
+
// The whole diagram is a click target for the mouse; the button is the one control for keyboard and assistive technology, and its
|
|
214
|
+
// text ("Expand") is the start of its name. A diagram's own text must not be inside a button (axe label-content-name-mismatch).
|
|
215
|
+
/* @__PURE__ */ jsxs2("div", { className: "hyle-mermaid-open", role: "presentation", onClick: expand, children: [
|
|
216
|
+
/* @__PURE__ */ jsx2("span", { className: "hyle-mermaid-svg", dangerouslySetInnerHTML: html }),
|
|
217
|
+
/* @__PURE__ */ jsx2("button", { ref: trigger, type: "button", className: "hyle-mermaid-hint", "aria-label": labels.expand, "aria-describedby": captionId, "aria-haspopup": "dialog", children: labels.expandHint })
|
|
218
|
+
] })
|
|
219
|
+
) : large ? /* @__PURE__ */ jsx2(LargeDiagram, { source, sourceId, labels, errorText, live, drawing, busy, failed, clamped, showAll, onDraw: draw, onToggle: toggleSource }) : /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
220
|
+
drawing ? /* @__PURE__ */ jsx2("span", { className: "hyle-mermaid-loader", role: "status", "aria-busy": "true", children: /* @__PURE__ */ jsx2("span", { className: "sr-only", children: loadingText }) }) : null,
|
|
221
|
+
/* @__PURE__ */ jsx2("pre", { tabIndex: 0, children: /* @__PURE__ */ jsx2("code", { className: "language-mermaid", children: source }) })
|
|
222
|
+
] }),
|
|
223
|
+
open && Viewer && svg ? /* @__PURE__ */ jsx2(
|
|
224
|
+
Viewer,
|
|
225
|
+
{
|
|
226
|
+
svg: svg.markup,
|
|
227
|
+
svgId: svg.id,
|
|
228
|
+
source,
|
|
229
|
+
title,
|
|
230
|
+
labels,
|
|
231
|
+
onClose: () => afterFullscreen(figure.current, () => {
|
|
232
|
+
setOpen(false);
|
|
233
|
+
trigger.current?.focus({ preventScroll: true });
|
|
234
|
+
})
|
|
235
|
+
}
|
|
236
|
+
) : null,
|
|
237
|
+
failed && (svg !== null || !large) ? /* @__PURE__ */ jsx2("p", { className: "hyle-mermaid-note", role: "status", children: errorText }) : null,
|
|
238
|
+
viewerFailed ? /* @__PURE__ */ jsx2("p", { className: "hyle-mermaid-note", role: "status", children: labels.unavailable }) : null,
|
|
239
|
+
/* @__PURE__ */ jsx2("figcaption", { id: svg ? captionId : void 0, className: "sr-only", children: title })
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
function MermaidDiagram(props) {
|
|
245
|
+
return /* @__PURE__ */ jsx2(DiagramBoundary, { source: props.source, children: /* @__PURE__ */ jsx2(Diagram, { ...props }) });
|
|
94
246
|
}
|
|
95
247
|
export {
|
|
248
|
+
DiagramBoundary,
|
|
96
249
|
MermaidDiagram
|
|
97
250
|
};
|