@tdacorp/hyle-sdk 0.14.1 → 0.17.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.
Files changed (37) hide show
  1. package/README.md +20 -8
  2. package/dist/check-routes-bin.js +10 -8
  3. package/dist/{chunk-4V4VKB3O.js → chunk-DMK4XQLU.js} +470 -385
  4. package/dist/{chunk-R5EMI4HQ.js → chunk-PJMJMP66.js} +3 -1
  5. package/dist/comments.cjs +6 -4
  6. package/dist/comments.js +6 -5
  7. package/dist/{diagram-viewer-DYX6R63Y.js → diagram-viewer-FJPED4SN.js} +46 -26
  8. package/dist/{embed-B76zRRPa.d.cts → embed-BmdwA2G9.d.cts} +9 -4
  9. package/dist/{embed-SqOBGI-E.d.ts → embed-DNTZ2UXv.d.ts} +9 -4
  10. package/dist/index.d.cts +2 -2
  11. package/dist/index.d.ts +2 -2
  12. package/dist/labels-nmukKYgL.d.cts +37 -0
  13. package/dist/labels-nmukKYgL.d.ts +37 -0
  14. package/dist/mermaid-diagram.cjs +59 -30
  15. package/dist/mermaid-diagram.d.cts +4 -37
  16. package/dist/mermaid-diagram.d.ts +4 -37
  17. package/dist/mermaid-diagram.js +7 -5
  18. package/dist/mermaid-image.cjs +1382 -0
  19. package/dist/mermaid-image.d.cts +29 -0
  20. package/dist/mermaid-image.d.ts +29 -0
  21. package/dist/mermaid-image.js +94 -0
  22. package/dist/next.cjs +1330 -1118
  23. package/dist/next.d.cts +61 -11
  24. package/dist/next.d.ts +61 -11
  25. package/dist/next.js +922 -793
  26. package/dist/react.cjs +267 -184
  27. package/dist/react.d.cts +29 -6
  28. package/dist/react.d.ts +29 -6
  29. package/dist/react.js +1 -1
  30. package/dist/{resolve-DC2ccfwA.d.ts → resolve-Ae7UFjsQ.d.ts} +1 -1
  31. package/dist/{resolve-DKLVftk_.d.cts → resolve-euZ4-aC9.d.cts} +1 -1
  32. package/dist/styles.css +11 -22
  33. package/dist/{types-ByodIyEv.d.cts → types-Czt887Iv.d.cts} +19 -3
  34. package/dist/{types-ByodIyEv.d.ts → types-Czt887Iv.d.ts} +19 -3
  35. package/dist/use-cache.d.cts +2 -2
  36. package/dist/use-cache.d.ts +2 -2
  37. package/package.json +1 -1
@@ -342,6 +342,37 @@ var init_scope_svg = __esm({
342
342
  }
343
343
  });
344
344
 
345
+ // src/react/viewer/svg-css.ts
346
+ var SVG_CSS;
347
+ var init_svg_css = __esm({
348
+ "src/react/viewer/svg-css.ts"() {
349
+ "use strict";
350
+ SVG_CSS = `
351
+ svg{display:block;position:static!important;width:100%;height:100%;max-width:none!important}
352
+ .hv-n{cursor:pointer;outline:none}
353
+ .hv-n,.hv-e{transition:opacity .15s}
354
+ @media (prefers-reduced-motion:reduce){.hv-n,.hv-e{transition:none}}
355
+ :host(.hv-plain) .hv-n,:host(.hv-plain) .hv-e{transition:none}
356
+ :host(.hv-active) .hv-n:not(.hv-on),:host(.hv-active) .hv-e:not(.hv-on){opacity:var(--hv-dim)}
357
+ .hv-n:focus-visible :is(rect,polygon,circle,ellipse,path){stroke:var(--hv-focus)!important;stroke-width:calc(3px / var(--hv-k,1))!important}
358
+ .hv-n.hv-nb :is(rect,polygon,circle,ellipse,path){stroke:var(--hv-accent)!important;stroke-width:calc(2px / var(--hv-k,1))!important}
359
+ .hv-n.hv-up :is(rect,polygon,circle,ellipse,path){stroke:var(--hv-up)!important;stroke-width:calc(2.5px / var(--hv-k,1))!important}
360
+ .hv-n.hv-down :is(rect,polygon,circle,ellipse,path){stroke:var(--hv-down)!important;stroke-width:calc(2.5px / var(--hv-k,1))!important}
361
+ .hv-n.hv-sel :is(rect,polygon,circle,ellipse,path){stroke:var(--hv-accent)!important;stroke-width:calc(3.5px / var(--hv-k,1))!important}
362
+ .hv-n.hv-hit :is(rect,polygon,circle,ellipse,path){stroke:var(--hv-accent)!important;stroke-width:calc(3px / var(--hv-k,1))!important}
363
+ .hv-n.hv-cur :is(rect,polygon,circle,ellipse,path){stroke-width:calc(5px / var(--hv-k,1))!important}
364
+ text.hv-hit,text.hv-hit tspan{fill:var(--hv-accent)!important;font-weight:700}
365
+ text.hv-cur{text-decoration:underline}
366
+ path.hv-nb{stroke:var(--hv-accent)!important;stroke-width:calc(2.5px / var(--hv-k,1))!important}
367
+ path.hv-up{stroke:var(--hv-up)!important;stroke-width:calc(2.5px / var(--hv-k,1))!important}
368
+ path.hv-down{stroke:var(--hv-down)!important;stroke-width:calc(2.5px / var(--hv-k,1))!important}
369
+ path.hv-flow{stroke-dasharray:calc(7px / var(--hv-k,1)) calc(6px / var(--hv-k,1))!important;animation:hv-dash .9s linear infinite}
370
+ @keyframes hv-dash{to{stroke-dashoffset:calc(-26px / var(--hv-k,1))}}
371
+ @media (prefers-reduced-motion:reduce){path.hv-flow{animation:none}}
372
+ `;
373
+ }
374
+ });
375
+
345
376
  // src/react/viewer/view-math.ts
346
377
  function zoomAt(v, px, py, k, min = MIN_K) {
347
378
  const next = clamp(k, min, MAX_K);
@@ -437,6 +468,7 @@ var init_controller = __esm({
437
468
  init_extract();
438
469
  init_graph();
439
470
  init_scope_svg();
471
+ init_svg_css();
440
472
  init_view_math();
441
473
  TAP_SLOP = 5;
442
474
  DOUBLE_TAP_MS = 350;
@@ -454,6 +486,7 @@ var init_controller = __esm({
454
486
  constructor(o) {
455
487
  this.o = o;
456
488
  const { viewport: vp, stage, minimap } = o;
489
+ const root = this.root = stage.shadowRoot ?? stage.attachShadow({ mode: "open" });
457
490
  const on = (el, type, fn, opts) => {
458
491
  el.addEventListener(type, fn, opts);
459
492
  this.off.push(() => el.removeEventListener(type, fn, opts));
@@ -463,21 +496,16 @@ var init_controller = __esm({
463
496
  on(vp, "pointermove", (e) => this.onMove(e));
464
497
  on(vp, "pointerup", (e) => this.onUp(e));
465
498
  on(vp, "pointercancel", (e) => this.onUp(e, true));
466
- on(stage, "pointerover", (e) => e.pointerType === "mouse" && !this.pointers.size && this.mouseOver(this.keyAt(e.target)));
467
- on(stage, "pointerout", (e) => e.pointerType === "mouse" && !this.pointers.size && this.mouseOver(this.keyAt(e.relatedTarget)));
468
- on(stage, "focusin", (e) => this.onFocusIn(e));
469
- on(stage, "focusout", () => this.focusLeft());
499
+ on(root, "pointerover", (e) => e.pointerType === "mouse" && !this.pointers.size && this.mouseOver(this.keyAt(e.target)));
500
+ on(root, "pointerout", (e) => e.pointerType === "mouse" && !this.pointers.size && this.mouseOver(this.keyAt(e.relatedTarget)));
501
+ on(root, "focusin", (e) => this.onFocusIn(e));
502
+ on(root, "focusout", () => this.focusLeft());
470
503
  on(minimap, "pointerdown", (e) => this.onMiniDown(e));
471
504
  on(minimap, "pointermove", (e) => this.miniDrag && this.miniTo(e));
472
505
  on(minimap, "pointerup", () => this.miniDrag = false);
473
506
  on(minimap, "pointercancel", () => this.miniDrag = false);
474
507
  this.ro = new ResizeObserver(() => this.measure());
475
508
  this.ro.observe(vp);
476
- this.watcher = new MutationObserver(() => {
477
- const now = stage.querySelector("svg");
478
- if (now && now !== this.svg && this.source) this.mount(now, this.source.markup, this.source.idPrefix);
479
- });
480
- this.watcher.observe(stage, { childList: true });
481
509
  this.measure();
482
510
  }
483
511
  o;
@@ -515,8 +543,7 @@ var init_controller = __esm({
515
543
  dragging = false;
516
544
  samples = [];
517
545
  ro;
518
- watcher;
519
- source;
546
+ root;
520
547
  miniDrag = false;
521
548
  miniColors = { node: "#888", edge: "#555", view: "#0af", bg: "transparent" };
522
549
  off = [];
@@ -524,16 +551,19 @@ var init_controller = __esm({
524
551
  this.anim?.stop();
525
552
  cancelAnimationFrame(this.frame);
526
553
  this.ro?.disconnect();
527
- this.watcher?.disconnect();
528
554
  for (const f of this.off) f();
529
555
  }
530
556
  // ---- mounting -----------------------------------------------------------------------------------------------------------------------
531
- /** (Re)attaches to the SVG now in the stage. A re-mount (theme change) keeps the view and a still-valid pin. */
557
+ /** Shows `markup` in the stage's shadow root and attaches to its SVG. A new SVG (theme change) keeps the view and a still-valid pin. */
558
+ show(markup, idPrefix) {
559
+ this.root.innerHTML = `<style>${SVG_CSS}</style>${markup}`;
560
+ const svg = this.root.querySelector("svg");
561
+ if (svg) this.mount(svg, markup, idPrefix);
562
+ }
532
563
  mount(svg, markup, idPrefix) {
533
564
  const size = svgSize(markup) ?? { w: svg.getBoundingClientRect().width || 600, h: svg.getBoundingClientRect().height || 400 };
534
565
  const first = this.svg === void 0;
535
566
  this.svg = svg;
536
- this.source = { markup, idPrefix };
537
567
  this.content = { x: 0, y: 0, w: size.w, h: size.h };
538
568
  this.o.stage.style.width = `${size.w}px`;
539
569
  this.o.stage.style.height = `${size.h}px`;
@@ -667,8 +697,9 @@ var init_controller = __esm({
667
697
  const at = this.local(e);
668
698
  this.pointers.set(e.pointerId, at);
669
699
  if (this.pointers.size === 1) {
670
- const key = this.keyAt(e.target);
671
- this.tap = { at, key, moved: false, link: Boolean(e.target.closest?.("a")), id: e.pointerId };
700
+ const target = e.composedPath()[0];
701
+ const key = this.keyAt(target);
702
+ this.tap = { at, key, moved: false, link: Boolean(target.closest?.("a")), id: e.pointerId };
672
703
  this.start = { view: this.view, at };
673
704
  this.dragging = false;
674
705
  this.samples = [{ t: e.timeStamp, ...at }];
@@ -800,7 +831,7 @@ var init_controller = __esm({
800
831
  }
801
832
  focusLeft() {
802
833
  queueMicrotask(() => {
803
- if (this.o.stage.contains(document.activeElement)) return;
834
+ if (this.root.activeElement) return;
804
835
  this.focusKey = null;
805
836
  this.refreshHot();
806
837
  });
@@ -856,7 +887,7 @@ var init_controller = __esm({
856
887
  }
857
888
  /** Arrow-key traversal from the focused node. Returns false when the key was not used. */
858
889
  traverse(dir) {
859
- const el = document.activeElement?.closest?.(".hv-n") ?? null;
890
+ const el = this.root.activeElement?.closest?.(".hv-n") ?? null;
860
891
  const key = el && this.stageHas(el) ? this.keyAt(el) : null;
861
892
  if (key === null || !this.graph) return false;
862
893
  const next = pickNeighbour(this.graph, key, dir);
@@ -868,7 +899,7 @@ var init_controller = __esm({
868
899
  return true;
869
900
  }
870
901
  stageHas(el) {
871
- return this.o.stage.contains(el);
902
+ return this.root.contains(el);
872
903
  }
873
904
  /** Keyboard commands of the viewer. Returns true when the key was handled (the caller then prevents the default). */
874
905
  key(e) {
@@ -882,7 +913,7 @@ var init_controller = __esm({
882
913
  this.set({ ...this.view, x: this.view.x + (dir === "left" ? step : dir === "right" ? -step : 0), y: this.view.y + (dir === "up" ? step : dir === "down" ? -step : 0) });
883
914
  return true;
884
915
  }
885
- const onNode = this.keyAt(document.activeElement);
916
+ const onNode = this.keyAt(this.root.activeElement);
886
917
  switch (e.key) {
887
918
  case "+":
888
919
  case "=":
@@ -1076,7 +1107,6 @@ function DiagramViewer({ svg, svgId, source, title, labels, onClose }) {
1076
1107
  const [scale, setScale] = (0, import_react.useState)("2");
1077
1108
  const [fullscreen, setFullscreen] = (0, import_react.useState)(false);
1078
1109
  const scoped = (0, import_react.useMemo)(() => scopeSvg(svg, svgId, ownId.current), [svg, svgId]);
1079
- const html = (0, import_react.useMemo)(() => ({ __html: scoped }), [scoped]);
1080
1110
  const say = (message) => {
1081
1111
  clearTimeout(toastTimer.current);
1082
1112
  setToast(message);
@@ -1098,10 +1128,7 @@ function DiagramViewer({ svg, svgId, source, title, labels, onClose }) {
1098
1128
  ctl.current = null;
1099
1129
  };
1100
1130
  }, []);
1101
- (0, import_react.useLayoutEffect)(() => {
1102
- const el = stage.current?.querySelector("svg");
1103
- if (el) ctl.current?.mount(el, scoped, `${ownId.current}_`);
1104
- }, [scoped]);
1131
+ (0, import_react.useLayoutEffect)(() => ctl.current?.show(scoped, `${ownId.current}_`), [scoped]);
1105
1132
  (0, import_react.useEffect)(() => {
1106
1133
  const d = dialog.current;
1107
1134
  if (!d.open) d.showModal();
@@ -1210,7 +1237,7 @@ function DiagramViewer({ svg, svgId, source, title, labels, onClose }) {
1210
1237
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "hv-btn", "aria-label": labels.close, title: `${labels.close} (Esc)`, onClick: () => dialog.current?.close(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Glyph, { d: ICONS.close }) })
1211
1238
  ] })
1212
1239
  ] }),
1213
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "hv-view", ref: viewport, tabIndex: -1, role: "group", "aria-label": title, "aria-describedby": helpId, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "hv-stage", ref: stage, dangerouslySetInnerHTML: html }) }),
1240
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "hv-view", ref: viewport, tabIndex: -1, role: "group", "aria-label": title, "aria-describedby": helpId, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "hv-stage", ref: stage }) }),
1214
1241
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("canvas", { className: "hv-mini", ref: minimap, width: 176, height: 120, hidden: !ui.minimap, "aria-hidden": "true" }),
1215
1242
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "hv-foot", children: [
1216
1243
  ui.pinned ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("ul", { className: "hv-legend", "aria-hidden": "true", children: [
@@ -1260,7 +1287,8 @@ module.exports = __toCommonJS(mermaid_diagram_exports);
1260
1287
  var import_react2 = require("react");
1261
1288
 
1262
1289
  // src/react/mermaid-config.ts
1263
- var MAX_MERMAID_SOURCE = 2e4;
1290
+ var MAX_MERMAID_SOURCE = 1024 * 1024;
1291
+ var MAX_MERMAID_EDGES = 5e3;
1264
1292
  function luminance(css) {
1265
1293
  const m = /^(rgba?)\(([^)]*)\)$|^color\(srgb ([^)]*)\)$/.exec(css.trim());
1266
1294
  if (!m) return void 0;
@@ -1317,7 +1345,7 @@ var import_jsx_runtime2 = require("react/jsx-runtime");
1317
1345
  var queue = Promise.resolve();
1318
1346
  async function renderSvg(id, source, theme) {
1319
1347
  const { default: mermaid } = await import("mermaid");
1320
- mermaid.initialize({ startOnLoad: false, securityLevel: "strict", theme, maxTextSize: MAX_MERMAID_SOURCE, suppressErrorRendering: true });
1348
+ mermaid.initialize({ startOnLoad: false, securityLevel: "strict", theme, maxTextSize: MAX_MERMAID_SOURCE, maxEdges: MAX_MERMAID_EDGES, suppressErrorRendering: true });
1321
1349
  try {
1322
1350
  return { markup: (await mermaid.render(id, stripMermaidConfig(source))).svg, id };
1323
1351
  } finally {
@@ -1325,7 +1353,7 @@ async function renderSvg(id, source, theme) {
1325
1353
  }
1326
1354
  }
1327
1355
  var THEME_ATTRS = ["data-act", "data-theme", "class"];
1328
- function MermaidDiagram({ source, title, errorText, labels = VIEWER_LABELS_EN }) {
1356
+ function MermaidDiagram({ source, title, errorText, loadingText = "Rendering the diagram", labels = VIEWER_LABELS_EN }) {
1329
1357
  const figure = (0, import_react2.useRef)(null);
1330
1358
  const trigger = (0, import_react2.useRef)(null);
1331
1359
  const captionId = (0, import_react2.useId)();
@@ -1366,7 +1394,8 @@ function MermaidDiagram({ source, title, errorText, labels = VIEWER_LABELS_EN })
1366
1394
  setOpen(true);
1367
1395
  if (!Viewer) void Promise.resolve().then(() => (init_diagram_viewer(), diagram_viewer_exports)).then((m) => setViewer(() => m.DiagramViewer), () => setOpen(false));
1368
1396
  };
1369
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("figure", { ref: figure, className: "hyle-mermaid", "data-slot-component": "Mermaid", children: [
1397
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("figure", { ref: figure, className: "hyle-mermaid", "data-slot-component": "Mermaid", ...svg === null && !failed ? { "data-state": "pending" } : {}, children: [
1398
+ near && svg === null && !failed ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "hyle-mermaid-loader", role: "status", "aria-busy": "true", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "sr-only", children: loadingText }) }) : null,
1370
1399
  svg === null ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("pre", { tabIndex: 0, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("code", { className: "language-mermaid", children: source }) }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { ref: trigger, type: "button", className: "hyle-mermaid-open", "aria-label": labels.expand, "aria-describedby": captionId, "aria-haspopup": "dialog", onClick: expand, children: [
1371
1400
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "hyle-mermaid-svg", dangerouslySetInnerHTML: html }),
1372
1401
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "hyle-mermaid-hint", "aria-hidden": "true", children: labels.expandHint })
@@ -1,40 +1,5 @@
1
1
  import * as react from 'react';
2
-
3
- /**
4
- * Every string the diagram viewer shows. Pure data, so the client component can carry the English defaults without importing
5
- * the viewer chunk, and the server passes the host's locale in (strings.ts holds fr and es, unreviewed drafts like the rest).
6
- */
7
- interface ViewerLabels {
8
- expand: string;
9
- expandHint: string;
10
- viewer: string;
11
- close: string;
12
- zoomIn: string;
13
- zoomOut: string;
14
- fit: string;
15
- actual: string;
16
- search: string;
17
- searchPlaceholder: string;
18
- noMatch: string;
19
- matchOf: string;
20
- copySource: string;
21
- downloadSvg: string;
22
- downloadPng: string;
23
- copyImage: string;
24
- pngScale: string;
25
- fullscreen: string;
26
- exitFullscreen: string;
27
- copied: string;
28
- saved: string;
29
- unavailable: string;
30
- hint: string;
31
- legendSelected: string;
32
- legendUpstream: string;
33
- legendDownstream: string;
34
- outgoing: string;
35
- tracing: string;
36
- map: string;
37
- }
2
+ import { V as ViewerLabels } from './labels-nmukKYgL.cjs';
38
3
 
39
4
  /**
40
5
  * The SDK's only client component. It receives the diagram text and presentational strings and nothing else: never a token,
@@ -47,9 +12,11 @@ interface MermaidDiagramProps {
47
12
  title: string;
48
13
  /** Shown when Mermaid cannot render the source. */
49
14
  errorText: string;
15
+ /** Accessible name of the loader shown while the diagram renders (English when omitted). */
16
+ loadingText?: string;
50
17
  /** Strings of the diagram viewer (English when omitted). */
51
18
  labels?: ViewerLabels;
52
19
  }
53
- declare function MermaidDiagram({ source, title, errorText, labels }: MermaidDiagramProps): react.JSX.Element;
20
+ declare function MermaidDiagram({ source, title, errorText, loadingText, labels }: MermaidDiagramProps): react.JSX.Element;
54
21
 
55
22
  export { MermaidDiagram, type MermaidDiagramProps };
@@ -1,40 +1,5 @@
1
1
  import * as react from 'react';
2
-
3
- /**
4
- * Every string the diagram viewer shows. Pure data, so the client component can carry the English defaults without importing
5
- * the viewer chunk, and the server passes the host's locale in (strings.ts holds fr and es, unreviewed drafts like the rest).
6
- */
7
- interface ViewerLabels {
8
- expand: string;
9
- expandHint: string;
10
- viewer: string;
11
- close: string;
12
- zoomIn: string;
13
- zoomOut: string;
14
- fit: string;
15
- actual: string;
16
- search: string;
17
- searchPlaceholder: string;
18
- noMatch: string;
19
- matchOf: string;
20
- copySource: string;
21
- downloadSvg: string;
22
- downloadPng: string;
23
- copyImage: string;
24
- pngScale: string;
25
- fullscreen: string;
26
- exitFullscreen: string;
27
- copied: string;
28
- saved: string;
29
- unavailable: string;
30
- hint: string;
31
- legendSelected: string;
32
- legendUpstream: string;
33
- legendDownstream: string;
34
- outgoing: string;
35
- tracing: string;
36
- map: string;
37
- }
2
+ import { V as ViewerLabels } from './labels-nmukKYgL.js';
38
3
 
39
4
  /**
40
5
  * The SDK's only client component. It receives the diagram text and presentational strings and nothing else: never a token,
@@ -47,9 +12,11 @@ interface MermaidDiagramProps {
47
12
  title: string;
48
13
  /** Shown when Mermaid cannot render the source. */
49
14
  errorText: string;
15
+ /** Accessible name of the loader shown while the diagram renders (English when omitted). */
16
+ loadingText?: string;
50
17
  /** Strings of the diagram viewer (English when omitted). */
51
18
  labels?: ViewerLabels;
52
19
  }
53
- declare function MermaidDiagram({ source, title, errorText, labels }: MermaidDiagramProps): react.JSX.Element;
20
+ declare function MermaidDiagram({ source, title, errorText, loadingText, labels }: MermaidDiagramProps): react.JSX.Element;
54
21
 
55
22
  export { MermaidDiagram, type MermaidDiagramProps };
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import {
3
+ MAX_MERMAID_EDGES,
3
4
  MAX_MERMAID_SOURCE,
4
5
  RENDER_TIMEOUT_MS,
5
6
  nextMermaidId,
@@ -7,7 +8,7 @@ import {
7
8
  stripMermaidConfig,
8
9
  whenNearViewport,
9
10
  withTimeout
10
- } from "./chunk-R5EMI4HQ.js";
11
+ } from "./chunk-PJMJMP66.js";
11
12
  import {
12
13
  VIEWER_LABELS_EN
13
14
  } from "./chunk-BUJFMR3M.js";
@@ -18,7 +19,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
18
19
  var queue = Promise.resolve();
19
20
  async function renderSvg(id, source, theme) {
20
21
  const { default: mermaid } = await import("mermaid");
21
- mermaid.initialize({ startOnLoad: false, securityLevel: "strict", theme, maxTextSize: MAX_MERMAID_SOURCE, suppressErrorRendering: true });
22
+ mermaid.initialize({ startOnLoad: false, securityLevel: "strict", theme, maxTextSize: MAX_MERMAID_SOURCE, maxEdges: MAX_MERMAID_EDGES, suppressErrorRendering: true });
22
23
  try {
23
24
  return { markup: (await mermaid.render(id, stripMermaidConfig(source))).svg, id };
24
25
  } finally {
@@ -26,7 +27,7 @@ async function renderSvg(id, source, theme) {
26
27
  }
27
28
  }
28
29
  var THEME_ATTRS = ["data-act", "data-theme", "class"];
29
- function MermaidDiagram({ source, title, errorText, labels = VIEWER_LABELS_EN }) {
30
+ function MermaidDiagram({ source, title, errorText, loadingText = "Rendering the diagram", labels = VIEWER_LABELS_EN }) {
30
31
  const figure = useRef(null);
31
32
  const trigger = useRef(null);
32
33
  const captionId = useId();
@@ -65,9 +66,10 @@ function MermaidDiagram({ source, title, errorText, labels = VIEWER_LABELS_EN })
65
66
  const expand = (e) => {
66
67
  if (e.target.closest("a")) return;
67
68
  setOpen(true);
68
- if (!Viewer) void import("./diagram-viewer-DYX6R63Y.js").then((m) => setViewer(() => m.DiagramViewer), () => setOpen(false));
69
+ if (!Viewer) void import("./diagram-viewer-FJPED4SN.js").then((m) => setViewer(() => m.DiagramViewer), () => setOpen(false));
69
70
  };
70
- return /* @__PURE__ */ jsxs("figure", { ref: figure, className: "hyle-mermaid", "data-slot-component": "Mermaid", children: [
71
+ return /* @__PURE__ */ jsxs("figure", { ref: figure, className: "hyle-mermaid", "data-slot-component": "Mermaid", ...svg === null && !failed ? { "data-state": "pending" } : {}, children: [
72
+ near && svg === null && !failed ? /* @__PURE__ */ jsx("span", { className: "hyle-mermaid-loader", role: "status", "aria-busy": "true", children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: loadingText }) }) : null,
71
73
  svg === null ? /* @__PURE__ */ jsx("pre", { tabIndex: 0, children: /* @__PURE__ */ jsx("code", { className: "language-mermaid", children: source }) }) : /* @__PURE__ */ jsxs("button", { ref: trigger, type: "button", className: "hyle-mermaid-open", "aria-label": labels.expand, "aria-describedby": captionId, "aria-haspopup": "dialog", onClick: expand, children: [
72
74
  /* @__PURE__ */ jsx("span", { className: "hyle-mermaid-svg", dangerouslySetInnerHTML: html }),
73
75
  /* @__PURE__ */ jsx("span", { className: "hyle-mermaid-hint", "aria-hidden": "true", children: labels.expandHint })