@tdacorp/hyle-sdk 0.21.0 → 0.22.2

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 (58) hide show
  1. package/README.md +110 -18
  2. package/dist/check-routes-bin.js +154 -42
  3. package/dist/{chunk-X2TLYM7Y.js → chunk-7T5EEJHK.js} +1 -1
  4. package/dist/chunk-DUPT6XLB.js +57 -0
  5. package/dist/{chunk-56Y24XBV.js → chunk-IW3TUD4G.js} +4 -3
  6. package/dist/{chunk-75JFLML4.js → chunk-KU7LWK4E.js} +75 -12
  7. package/dist/{chunk-K5VDLROQ.js → chunk-SFFBZFEN.js} +34 -1
  8. package/dist/{chunk-HJX57NLI.js → chunk-ZIW6FDU2.js} +246 -225
  9. package/dist/{client-LwzHwqpM.d.ts → client-BGjmEWhN.d.cts} +7 -1
  10. package/dist/{client-41fU6OY2.d.cts → client-D0LTpr3Y.d.ts} +7 -1
  11. package/dist/code-copy.cjs +4 -2
  12. package/dist/code-copy.d.cts +5 -2
  13. package/dist/code-copy.d.ts +5 -2
  14. package/dist/code-copy.js +5 -3
  15. package/dist/comments.cjs +11 -6
  16. package/dist/comments.js +11 -6
  17. package/dist/docs-enhance.cjs +7 -4
  18. package/dist/docs-enhance.d.cts +5 -3
  19. package/dist/docs-enhance.d.ts +5 -3
  20. package/dist/docs-enhance.js +8 -5
  21. package/dist/{embed-BUFRQboD.d.ts → embed-CbtsbZs3.d.cts} +4 -2
  22. package/dist/{embed-CYt-q13P.d.cts → embed-Cf_2ZR5x.d.ts} +4 -2
  23. package/dist/html.cjs +11 -6
  24. package/dist/html.d.cts +1 -1
  25. package/dist/html.d.ts +1 -1
  26. package/dist/html.js +2 -2
  27. package/dist/index.cjs +65 -12
  28. package/dist/index.d.cts +13 -11
  29. package/dist/index.d.ts +13 -11
  30. package/dist/index.js +2 -2
  31. package/dist/mermaid-diagram.cjs +46 -6
  32. package/dist/mermaid-diagram.js +15 -6
  33. package/dist/mermaid-image.cjs +4 -1
  34. package/dist/mermaid-image.js +1 -1
  35. package/dist/next.cjs +410 -241
  36. package/dist/next.d.cts +39 -17
  37. package/dist/next.d.ts +39 -17
  38. package/dist/next.js +116 -32
  39. package/dist/print-coordinator.js +1 -1
  40. package/dist/react.cjs +230 -197
  41. package/dist/react.d.cts +17 -6
  42. package/dist/react.d.ts +17 -6
  43. package/dist/react.js +5 -3
  44. package/dist/{resolve-eI1muCKL.d.cts → resolve-BnIv7aB7.d.cts} +1 -1
  45. package/dist/{resolve-BjAK0k_Y.d.ts → resolve-BysHtZ_i.d.ts} +1 -1
  46. package/dist/{sanitize-ijiWjEm9.d.cts → sanitize-BpY_AdZh.d.cts} +1 -1
  47. package/dist/{sanitize-ijiWjEm9.d.ts → sanitize-BpY_AdZh.d.ts} +1 -1
  48. package/dist/styles.css +4 -4
  49. package/dist/toc-spy.cjs +2 -1
  50. package/dist/toc-spy.js +2 -1
  51. package/dist/{types-3F0wqD-o.d.cts → types-D09Z072G.d.cts} +32 -1
  52. package/dist/{types-3F0wqD-o.d.ts → types-D09Z072G.d.ts} +32 -1
  53. package/dist/use-cache.cjs +53 -3
  54. package/dist/use-cache.d.cts +3 -3
  55. package/dist/use-cache.d.ts +3 -3
  56. package/dist/use-cache.js +3 -3
  57. package/package.json +3 -3
  58. package/dist/chunk-67IOIAVW.js +0 -35
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { H as HyleAuth, a as HyleClient } from './client-41fU6OY2.cjs';
2
- export { A as AssetOptions, b as HyleClientOptions, c as HyleCredential, d as HyleRequestInit, M as MAX_PUSH_BODY_BYTES, e as MountsOptions, P as PushEvent, f as PushEventType, g as PushPage, h as PushPost, i as PushRoute, j as PushRouteOptions, k as PushStore, R as ResolveOptions, l as ResyncOptions, m as ResyncResult, n as createHyleClient, o as createPushRoute, r as resyncPath, s as staleAfterResync } from './client-41fU6OY2.cjs';
3
- export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, D as DocumentMetaFields, E as EngageComment, b as EngageHeldComment, c as EngageListing, F as Fallback, L as ListItem, M as Mount, d as Mounts, e as MountsResult, N as NavItem, f as NavNode, g as NavTree, R as ReactionCounts, h as ReactionKind, i as Resolved, j as ResolvedArticle, k as ResolvedDisabled, l as ResolvedList, m as ResolvedNotFound, n as ResolvedRedirect, T as TocEntry, V as VoteValue } from './types-3F0wqD-o.cjs';
1
+ import { H as HyleAuth, a as HyleClient } from './client-BGjmEWhN.cjs';
2
+ export { A as AssetOptions, b as HyleClientOptions, c as HyleCredential, d as HyleRequestInit, M as MAX_PUSH_BODY_BYTES, e as MountsOptions, P as PushEvent, f as PushEventType, g as PushPage, h as PushPost, i as PushRoute, j as PushRouteOptions, k as PushStore, R as ResolveOptions, l as ResyncOptions, m as ResyncResult, n as createHyleClient, o as createPushRoute, r as resyncPath, s as staleAfterResync } from './client-BGjmEWhN.cjs';
3
+ export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, D as DocumentMetaFields, E as EngageComment, b as EngageHeldComment, c as EngageListing, F as Fallback, H as HylePreview, L as ListItem, M as Mount, d as Mounts, e as MountsResult, N as NavItem, f as NavNode, g as NavTree, R as ReactionCounts, h as ReactionKind, i as Resolved, j as ResolvedArticle, k as ResolvedDisabled, l as ResolvedList, m as ResolvedNotFound, n as ResolvedRedirect, T as ThemeRef, o as TocEntry, V as VoteValue } from './types-D09Z072G.cjs';
4
4
  export { C as CommentEvent, a as CommentEventType, R as RevalidationCallbackOptions, b as RevalidationCallbackRoute, c as RevalidationPayload, d as createRevalidationCallbackRoute, p as parseCommentEvent } from './revalidation-callback-BQl77tQR.cjs';
5
5
 
6
6
  declare class Cp1ClientError extends Error {
@@ -11,26 +11,29 @@ declare class Cp1ClientError extends Error {
11
11
  constructor(code: string, message: string, status: number, requestId: string, details?: Record<string, unknown>);
12
12
  }
13
13
 
14
- type HostSyncInput = {
14
+ /** Where a build writes to hyle's control surface, and as whom. */
15
+ type ControlTarget = {
15
16
  /** hyle's origin. */
16
17
  readonly baseUrl: string;
17
18
  /** The workspace to write, from `client.mounts()`; the credential must be granted on it. */
18
19
  readonly workspaceId: string;
19
- /** The host's complete list of reserved paths (a replace). */
20
- readonly paths: readonly string[];
21
20
  readonly host: string;
22
21
  readonly buildId: string;
23
22
  readonly fetch?: typeof fetch;
24
23
  readonly timeoutMs?: number;
25
24
  readonly allowInsecureHttp?: boolean;
26
25
  } & ({
27
- /** A CONTROL credential (hyle_tc_...) holding hyle.workspace.manage on the workspace. Never a target (read) token. */
26
+ /** A CONTROL credential (hyle_tc_...) holding the route's permission on the workspace. Never a target (read) token. */
28
27
  readonly token: string;
29
28
  readonly auth?: never;
30
29
  } | {
31
30
  readonly auth: HyleAuth;
32
31
  readonly token?: never;
33
32
  });
33
+ type HostSyncInput = ControlTarget & {
34
+ /** The host's complete list of reserved paths (a replace). */
35
+ readonly paths: readonly string[];
36
+ };
34
37
  interface HostSyncResult {
35
38
  /** What hyle stored: sorted, de-duplicated. */
36
39
  readonly paths: readonly string[];
@@ -44,10 +47,9 @@ interface HostSyncResult {
44
47
  };
45
48
  }
46
49
  /**
47
- * Reports the host's reserved paths to hyle (ADR 0016): `PUT /cp1/control/workspace/host-reserved-paths`. Idempotent (resending the
48
- * same list changes nothing), so a retry or a repeated deploy is safe; the random Idempotency-Key only satisfies the control
49
- * surface's mutation rule. Throws `TypeError` before any request for a wrong token kind or an insecure URL, and `Cp1ClientError`
50
- * for anything hyle answers or the network does.
50
+ * Reports the host's reserved paths to hyle (ADR 0016): `PUT /cp1/control/workspace/host-reserved-paths`, with
51
+ * hyle.workspace.sync_host. Idempotent (resending the same list changes nothing), so a retry or a
52
+ * repeated deploy is safe. Throws as `put` describes.
51
53
  */
52
54
  declare function syncHostReserved(input: HostSyncInput): Promise<HostSyncResult>;
53
55
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { H as HyleAuth, a as HyleClient } from './client-LwzHwqpM.js';
2
- export { A as AssetOptions, b as HyleClientOptions, c as HyleCredential, d as HyleRequestInit, M as MAX_PUSH_BODY_BYTES, e as MountsOptions, P as PushEvent, f as PushEventType, g as PushPage, h as PushPost, i as PushRoute, j as PushRouteOptions, k as PushStore, R as ResolveOptions, l as ResyncOptions, m as ResyncResult, n as createHyleClient, o as createPushRoute, r as resyncPath, s as staleAfterResync } from './client-LwzHwqpM.js';
3
- export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, D as DocumentMetaFields, E as EngageComment, b as EngageHeldComment, c as EngageListing, F as Fallback, L as ListItem, M as Mount, d as Mounts, e as MountsResult, N as NavItem, f as NavNode, g as NavTree, R as ReactionCounts, h as ReactionKind, i as Resolved, j as ResolvedArticle, k as ResolvedDisabled, l as ResolvedList, m as ResolvedNotFound, n as ResolvedRedirect, T as TocEntry, V as VoteValue } from './types-3F0wqD-o.js';
1
+ import { H as HyleAuth, a as HyleClient } from './client-D0LTpr3Y.js';
2
+ export { A as AssetOptions, b as HyleClientOptions, c as HyleCredential, d as HyleRequestInit, M as MAX_PUSH_BODY_BYTES, e as MountsOptions, P as PushEvent, f as PushEventType, g as PushPage, h as PushPost, i as PushRoute, j as PushRouteOptions, k as PushStore, R as ResolveOptions, l as ResyncOptions, m as ResyncResult, n as createHyleClient, o as createPushRoute, r as resyncPath, s as staleAfterResync } from './client-D0LTpr3Y.js';
3
+ export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, D as DocumentMetaFields, E as EngageComment, b as EngageHeldComment, c as EngageListing, F as Fallback, H as HylePreview, L as ListItem, M as Mount, d as Mounts, e as MountsResult, N as NavItem, f as NavNode, g as NavTree, R as ReactionCounts, h as ReactionKind, i as Resolved, j as ResolvedArticle, k as ResolvedDisabled, l as ResolvedList, m as ResolvedNotFound, n as ResolvedRedirect, T as ThemeRef, o as TocEntry, V as VoteValue } from './types-D09Z072G.js';
4
4
  export { C as CommentEvent, a as CommentEventType, R as RevalidationCallbackOptions, b as RevalidationCallbackRoute, c as RevalidationPayload, d as createRevalidationCallbackRoute, p as parseCommentEvent } from './revalidation-callback-BQl77tQR.js';
5
5
 
6
6
  declare class Cp1ClientError extends Error {
@@ -11,26 +11,29 @@ declare class Cp1ClientError extends Error {
11
11
  constructor(code: string, message: string, status: number, requestId: string, details?: Record<string, unknown>);
12
12
  }
13
13
 
14
- type HostSyncInput = {
14
+ /** Where a build writes to hyle's control surface, and as whom. */
15
+ type ControlTarget = {
15
16
  /** hyle's origin. */
16
17
  readonly baseUrl: string;
17
18
  /** The workspace to write, from `client.mounts()`; the credential must be granted on it. */
18
19
  readonly workspaceId: string;
19
- /** The host's complete list of reserved paths (a replace). */
20
- readonly paths: readonly string[];
21
20
  readonly host: string;
22
21
  readonly buildId: string;
23
22
  readonly fetch?: typeof fetch;
24
23
  readonly timeoutMs?: number;
25
24
  readonly allowInsecureHttp?: boolean;
26
25
  } & ({
27
- /** A CONTROL credential (hyle_tc_...) holding hyle.workspace.manage on the workspace. Never a target (read) token. */
26
+ /** A CONTROL credential (hyle_tc_...) holding the route's permission on the workspace. Never a target (read) token. */
28
27
  readonly token: string;
29
28
  readonly auth?: never;
30
29
  } | {
31
30
  readonly auth: HyleAuth;
32
31
  readonly token?: never;
33
32
  });
33
+ type HostSyncInput = ControlTarget & {
34
+ /** The host's complete list of reserved paths (a replace). */
35
+ readonly paths: readonly string[];
36
+ };
34
37
  interface HostSyncResult {
35
38
  /** What hyle stored: sorted, de-duplicated. */
36
39
  readonly paths: readonly string[];
@@ -44,10 +47,9 @@ interface HostSyncResult {
44
47
  };
45
48
  }
46
49
  /**
47
- * Reports the host's reserved paths to hyle (ADR 0016): `PUT /cp1/control/workspace/host-reserved-paths`. Idempotent (resending the
48
- * same list changes nothing), so a retry or a repeated deploy is safe; the random Idempotency-Key only satisfies the control
49
- * surface's mutation rule. Throws `TypeError` before any request for a wrong token kind or an insecure URL, and `Cp1ClientError`
50
- * for anything hyle answers or the network does.
50
+ * Reports the host's reserved paths to hyle (ADR 0016): `PUT /cp1/control/workspace/host-reserved-paths`, with
51
+ * hyle.workspace.sync_host. Idempotent (resending the same list changes nothing), so a retry or a
52
+ * repeated deploy is safe. Throws as `put` describes.
51
53
  */
52
54
  declare function syncHostReserved(input: HostSyncInput): Promise<HostSyncResult>;
53
55
 
package/dist/index.js CHANGED
@@ -23,8 +23,8 @@ import {
23
23
  staleAfterResync,
24
24
  syncHostReserved,
25
25
  verifyHyleSignature
26
- } from "./chunk-75JFLML4.js";
27
- import "./chunk-67IOIAVW.js";
26
+ } from "./chunk-KU7LWK4E.js";
27
+ import "./chunk-DUPT6XLB.js";
28
28
  export {
29
29
  CACHE_TAG_PATTERN,
30
30
  Cp1ClientError,
@@ -1375,6 +1375,37 @@ var AUTO_RENDER_GROUPS = 25;
1375
1375
  var CLAMP_LINES = 12;
1376
1376
  var isClampedSource = (source) => source.trimEnd().split("\n").length > CLAMP_LINES;
1377
1377
  var DARK_VARIABLES = { edgeLabelBackground: "#333333" };
1378
+ var DIAGRAM_COLOUR_ROLES = ["bg", "node", "node-text", "node-border", "line", "accent", "muted"];
1379
+ var THEME_COLOUR = /^(?:#[0-9a-f]{6}(?:[0-9a-f]{2})?|transparent)$/;
1380
+ function diagramThemeVariables(colours, dark) {
1381
+ const [bg, node, text, border, line, accent, muted] = colours;
1382
+ return {
1383
+ darkMode: dark,
1384
+ background: bg,
1385
+ primaryColor: node,
1386
+ primaryTextColor: text,
1387
+ primaryBorderColor: border,
1388
+ secondaryColor: bg,
1389
+ secondaryTextColor: text,
1390
+ secondaryBorderColor: muted,
1391
+ tertiaryColor: bg,
1392
+ tertiaryTextColor: text,
1393
+ tertiaryBorderColor: muted,
1394
+ lineColor: line,
1395
+ textColor: text,
1396
+ titleColor: text,
1397
+ edgeLabelBackground: bg,
1398
+ clusterBkg: bg,
1399
+ clusterBorder: muted,
1400
+ noteBkgColor: bg,
1401
+ noteTextColor: text,
1402
+ noteBorderColor: accent,
1403
+ activationBorderColor: accent,
1404
+ actorLineColor: muted,
1405
+ signalColor: line,
1406
+ signalTextColor: text
1407
+ };
1408
+ }
1378
1409
  var COLOR = /^(rgba?|oklab|oklch|lab|lch)\(([^)]*)\)$|^color\(srgb ([^)]*)\)$/;
1379
1410
  function isDark(css) {
1380
1411
  const m = COLOR.exec(css.trim());
@@ -1397,7 +1428,8 @@ function watchPageTheme(el, onTheme) {
1397
1428
  const scheme = window.matchMedia("(prefers-color-scheme: dark)");
1398
1429
  const update = () => {
1399
1430
  const style = getComputedStyle(el);
1400
- onTheme(pickMermaidTheme(style.backgroundColor, scheme.matches, style.colorScheme));
1431
+ const colours = DIAGRAM_COLOUR_ROLES.map((role) => style.getPropertyValue(`--hyle-diagram-${role}`).trim());
1432
+ onTheme(pickMermaidTheme(style.backgroundColor, scheme.matches, style.colorScheme), colours.every((c) => THEME_COLOUR.test(c)) ? colours.join(" ") : "");
1401
1433
  };
1402
1434
  update();
1403
1435
  const observer = new MutationObserver(update);
@@ -1511,13 +1543,14 @@ var DiagramBoundary = class extends import_react2.Component {
1511
1543
  };
1512
1544
  var queue = Promise.resolve();
1513
1545
  var afterPaint = () => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve())));
1514
- async function renderSvg(id, source, theme, onSvg, stillWanted) {
1546
+ async function renderSvg(id, source, theme, colours, onSvg, stillWanted) {
1515
1547
  const { default: mermaid } = await import("mermaid");
1516
1548
  if (stillWanted) {
1517
1549
  await afterPaint();
1518
1550
  if (!stillWanted()) return;
1519
1551
  }
1520
- mermaid.initialize({ startOnLoad: false, securityLevel: "strict", theme, ...theme === "dark" ? { themeVariables: DARK_VARIABLES } : {}, maxTextSize: MAX_MERMAID_SOURCE, maxEdges: MAX_MERMAID_EDGES, suppressErrorRendering: true });
1552
+ const look = colours ? { theme: "base", themeVariables: diagramThemeVariables(colours.split(" "), theme === "dark") } : { theme, ...theme === "dark" ? { themeVariables: DARK_VARIABLES } : {} };
1553
+ mermaid.initialize({ startOnLoad: false, securityLevel: "strict", ...look, maxTextSize: MAX_MERMAID_SOURCE, maxEdges: MAX_MERMAID_EDGES, suppressErrorRendering: true });
1521
1554
  const drawing = mermaid.render(id, stripMermaidConfig(source)).then((out) => onSvg({ markup: out.svg, id, theme })).finally(() => document.getElementById(`d${id}`)?.remove());
1522
1555
  await withTimeout(drawing, RENDER_TIMEOUT_MS);
1523
1556
  }
@@ -1533,6 +1566,7 @@ function Diagram({ source, title, errorText, loadingText = "Rendering the diagra
1533
1566
  const [Viewer, setViewer] = (0, import_react2.useState)(null);
1534
1567
  const [viewerFailed, setViewerFailed] = (0, import_react2.useState)(false);
1535
1568
  const [theme, setTheme] = (0, import_react2.useState)(null);
1569
+ const [colours, setColours] = (0, import_react2.useState)("");
1536
1570
  const [near, setNear] = (0, import_react2.useState)(false);
1537
1571
  const [svg, setSvg] = (0, import_react2.useState)(null);
1538
1572
  const [failed, setFailed] = (0, import_react2.useState)(false);
@@ -1543,7 +1577,13 @@ function Diagram({ source, title, errorText, loadingText = "Rendering the diagra
1543
1577
  const refocus = (0, import_react2.useRef)(false);
1544
1578
  const allowed = !large || asked;
1545
1579
  const clamped = large && isClampedSource(source);
1546
- (0, import_react2.useEffect)(() => figure.current ? watchPageTheme(figure.current, setTheme) : void 0, []);
1580
+ (0, import_react2.useEffect)(() => {
1581
+ if (!figure.current) return void 0;
1582
+ return watchPageTheme(figure.current, (next, themed) => {
1583
+ setTheme(next);
1584
+ setColours(themed);
1585
+ });
1586
+ }, []);
1547
1587
  (0, import_react2.useEffect)(() => figure.current ? whenNearViewport(figure.current, () => setNear(true)) : void 0, []);
1548
1588
  (0, import_react2.useEffect)(() => {
1549
1589
  const toPrint = window.matchMedia("print");
@@ -1597,13 +1637,13 @@ function Diagram({ source, title, errorText, loadingText = "Rendering the diagra
1597
1637
  setSvg(out);
1598
1638
  setFailed(false);
1599
1639
  };
1600
- queue = queue.then(() => current ? renderSvg(id, source, theme, show, large && !shown.current ? () => current : void 0) : void 0).catch(() => {
1640
+ queue = queue.then(() => current ? renderSvg(id, source, theme, colours, show, large && !shown.current ? () => current : void 0) : void 0).catch(() => {
1601
1641
  if (current) setFailed(true);
1602
1642
  });
1603
1643
  return () => {
1604
1644
  current = false;
1605
1645
  };
1606
- }, [source, theme, wanted, attempt, large]);
1646
+ }, [source, theme, colours, wanted, attempt, large]);
1607
1647
  (0, import_react2.useEffect)(() => {
1608
1648
  if (!refocus.current || svg === null && !failed) return;
1609
1649
  refocus.current = false;
@@ -5,6 +5,7 @@ import {
5
5
  MAX_MERMAID_SOURCE,
6
6
  RENDER_TIMEOUT_MS,
7
7
  afterFullscreen,
8
+ diagramThemeVariables,
8
9
  isClampedSource,
9
10
  isLargeDiagram,
10
11
  nextMermaidId,
@@ -12,7 +13,7 @@ import {
12
13
  watchPageTheme,
13
14
  whenNearViewport,
14
15
  withTimeout
15
- } from "./chunk-K5VDLROQ.js";
16
+ } from "./chunk-SFFBZFEN.js";
16
17
  import {
17
18
  VIEWER_LABELS_EN
18
19
  } from "./chunk-QVYQM5R2.js";
@@ -62,13 +63,14 @@ var DiagramBoundary = class extends Component {
62
63
  };
63
64
  var queue = Promise.resolve();
64
65
  var afterPaint = () => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve())));
65
- async function renderSvg(id, source, theme, onSvg, stillWanted) {
66
+ async function renderSvg(id, source, theme, colours, onSvg, stillWanted) {
66
67
  const { default: mermaid } = await import("mermaid");
67
68
  if (stillWanted) {
68
69
  await afterPaint();
69
70
  if (!stillWanted()) return;
70
71
  }
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 look = colours ? { theme: "base", themeVariables: diagramThemeVariables(colours.split(" "), theme === "dark") } : { theme, ...theme === "dark" ? { themeVariables: DARK_VARIABLES } : {} };
73
+ mermaid.initialize({ startOnLoad: false, securityLevel: "strict", ...look, maxTextSize: MAX_MERMAID_SOURCE, maxEdges: MAX_MERMAID_EDGES, suppressErrorRendering: true });
72
74
  const drawing = mermaid.render(id, stripMermaidConfig(source)).then((out) => onSvg({ markup: out.svg, id, theme })).finally(() => document.getElementById(`d${id}`)?.remove());
73
75
  await withTimeout(drawing, RENDER_TIMEOUT_MS);
74
76
  }
@@ -84,6 +86,7 @@ function Diagram({ source, title, errorText, loadingText = "Rendering the diagra
84
86
  const [Viewer, setViewer] = useState(null);
85
87
  const [viewerFailed, setViewerFailed] = useState(false);
86
88
  const [theme, setTheme] = useState(null);
89
+ const [colours, setColours] = useState("");
87
90
  const [near, setNear] = useState(false);
88
91
  const [svg, setSvg] = useState(null);
89
92
  const [failed, setFailed] = useState(false);
@@ -94,7 +97,13 @@ function Diagram({ source, title, errorText, loadingText = "Rendering the diagra
94
97
  const refocus = useRef(false);
95
98
  const allowed = !large || asked;
96
99
  const clamped = large && isClampedSource(source);
97
- useEffect(() => figure.current ? watchPageTheme(figure.current, setTheme) : void 0, []);
100
+ useEffect(() => {
101
+ if (!figure.current) return void 0;
102
+ return watchPageTheme(figure.current, (next, themed) => {
103
+ setTheme(next);
104
+ setColours(themed);
105
+ });
106
+ }, []);
98
107
  useEffect(() => figure.current ? whenNearViewport(figure.current, () => setNear(true)) : void 0, []);
99
108
  useEffect(() => {
100
109
  const toPrint = window.matchMedia("print");
@@ -148,13 +157,13 @@ function Diagram({ source, title, errorText, loadingText = "Rendering the diagra
148
157
  setSvg(out);
149
158
  setFailed(false);
150
159
  };
151
- queue = queue.then(() => current ? renderSvg(id, source, theme, show, large && !shown.current ? () => current : void 0) : void 0).catch(() => {
160
+ queue = queue.then(() => current ? renderSvg(id, source, theme, colours, show, large && !shown.current ? () => current : void 0) : void 0).catch(() => {
152
161
  if (current) setFailed(true);
153
162
  });
154
163
  return () => {
155
164
  current = false;
156
165
  };
157
- }, [source, theme, wanted, attempt, large]);
166
+ }, [source, theme, colours, wanted, attempt, large]);
158
167
  useEffect(() => {
159
168
  if (!refocus.current || svg === null && !failed) return;
160
169
  refocus.current = false;
@@ -1329,6 +1329,8 @@ var import_react2 = require("react");
1329
1329
 
1330
1330
  // src/react/mermaid-config.ts
1331
1331
  var MAX_MERMAID_SOURCE = 1024 * 1024;
1332
+ var DIAGRAM_COLOUR_ROLES = ["bg", "node", "node-text", "node-border", "line", "accent", "muted"];
1333
+ var THEME_COLOUR = /^(?:#[0-9a-f]{6}(?:[0-9a-f]{2})?|transparent)$/;
1332
1334
  var COLOR = /^(rgba?|oklab|oklch|lab|lch)\(([^)]*)\)$|^color\(srgb ([^)]*)\)$/;
1333
1335
  function isDark(css) {
1334
1336
  const m = COLOR.exec(css.trim());
@@ -1351,7 +1353,8 @@ function watchPageTheme(el, onTheme) {
1351
1353
  const scheme = window.matchMedia("(prefers-color-scheme: dark)");
1352
1354
  const update = () => {
1353
1355
  const style = getComputedStyle(el);
1354
- onTheme(pickMermaidTheme(style.backgroundColor, scheme.matches, style.colorScheme));
1356
+ const colours = DIAGRAM_COLOUR_ROLES.map((role) => style.getPropertyValue(`--hyle-diagram-${role}`).trim());
1357
+ onTheme(pickMermaidTheme(style.backgroundColor, scheme.matches, style.colorScheme), colours.every((c) => THEME_COLOUR.test(c)) ? colours.join(" ") : "");
1355
1358
  };
1356
1359
  update();
1357
1360
  const observer = new MutationObserver(update);
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  afterFullscreen,
4
4
  watchPageTheme
5
- } from "./chunk-K5VDLROQ.js";
5
+ } from "./chunk-SFFBZFEN.js";
6
6
  import {
7
7
  VIEWER_LABELS_EN
8
8
  } from "./chunk-QVYQM5R2.js";