@tdacorp/hyle-sdk 0.12.0 → 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 (43) hide show
  1. package/README.md +46 -12
  2. package/dist/check-routes-bin.js +31 -18
  3. package/dist/{chunk-S7PCCEHP.js → chunk-6VOHFFA5.js} +4 -3
  4. package/dist/{chunk-ZQFYH4FX.js → chunk-DMK4XQLU.js} +497 -327
  5. package/dist/{chunk-N7ZQUAGM.js → chunk-MGSUQBDW.js} +19 -7
  6. package/dist/{chunk-R5EMI4HQ.js → chunk-PJMJMP66.js} +3 -1
  7. package/dist/comments.cjs +6 -4
  8. package/dist/comments.js +6 -5
  9. package/dist/{diagram-viewer-DYX6R63Y.js → diagram-viewer-FJPED4SN.js} +46 -26
  10. package/dist/{embed-jCaSI31t.d.cts → embed-BmdwA2G9.d.cts} +51 -5
  11. package/dist/{embed-DL5QIZRJ.d.ts → embed-DNTZ2UXv.d.ts} +51 -5
  12. package/dist/index.cjs +19 -7
  13. package/dist/index.d.cts +15 -8
  14. package/dist/index.d.ts +15 -8
  15. package/dist/index.js +1 -1
  16. package/dist/labels-nmukKYgL.d.cts +37 -0
  17. package/dist/labels-nmukKYgL.d.ts +37 -0
  18. package/dist/mermaid-diagram.cjs +59 -30
  19. package/dist/mermaid-diagram.d.cts +4 -37
  20. package/dist/mermaid-diagram.d.ts +4 -37
  21. package/dist/mermaid-diagram.js +7 -5
  22. package/dist/mermaid-image.cjs +1382 -0
  23. package/dist/mermaid-image.d.cts +29 -0
  24. package/dist/mermaid-image.d.ts +29 -0
  25. package/dist/mermaid-image.js +94 -0
  26. package/dist/next.cjs +1235 -789
  27. package/dist/next.d.cts +149 -24
  28. package/dist/next.d.ts +149 -24
  29. package/dist/next.js +887 -612
  30. package/dist/react.cjs +336 -196
  31. package/dist/react.d.cts +39 -7
  32. package/dist/react.d.ts +39 -7
  33. package/dist/react.js +1 -1
  34. package/dist/{resolve-DvmuBlpO.d.ts → resolve-Ae7UFjsQ.d.ts} +5 -5
  35. package/dist/{resolve-f6IJ6SL9.d.cts → resolve-euZ4-aC9.d.cts} +5 -5
  36. package/dist/styles.css +11 -22
  37. package/dist/{types-5D6ZD0Wi.d.cts → types-Czt887Iv.d.cts} +32 -3
  38. package/dist/{types-5D6ZD0Wi.d.ts → types-Czt887Iv.d.ts} +32 -3
  39. package/dist/use-cache.cjs +1 -1
  40. package/dist/use-cache.d.cts +2 -2
  41. package/dist/use-cache.d.ts +2 -2
  42. package/dist/use-cache.js +2 -2
  43. package/package.json +1 -1
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as Resolved, M as MountsResult } from './types-5D6ZD0Wi.cjs';
2
- export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, E as EngageComment, b as EngageHeldComment, c as EngageListing, F as Fallback, L as ListItem, d as Mount, e as Mounts, N as NavItem, f as NavNode, g as NavTree, h as ResolvedArticle, i as ResolvedDisabled, j as ResolvedList, k as ResolvedNotFound, l as ResolvedRedirect, T as TocEntry } from './types-5D6ZD0Wi.cjs';
1
+ import { R as Resolved, M as MountsResult } from './types-Czt887Iv.cjs';
2
+ 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, d as Mount, e as Mounts, N as NavItem, f as NavNode, g as NavTree, h as ResolvedArticle, i as ResolvedDisabled, j as ResolvedList, k as ResolvedNotFound, l as ResolvedRedirect, T as TocEntry } from './types-Czt887Iv.cjs';
3
3
  export { R as RevalidationCallbackOptions, a as RevalidationCallbackRoute, b as RevalidationPayload, c as createRevalidationCallbackRoute } from './revalidation-callback-D7Ms_Puz.cjs';
4
4
 
5
5
  /** `next` is a Next.js fetch extension with no lib.dom type; typed structurally so this module needs no Next import. */
@@ -27,7 +27,7 @@ interface ResolveOptions {
27
27
  /** The site path as a visitor sees it, including the workspace's path prefix. Sent as a query parameter, so it is encoded once. */
28
28
  readonly path: string;
29
29
  readonly locale?: string;
30
- readonly format?: "hast" | "html";
30
+ readonly format?: "hast" | "html" | "md";
31
31
  /** "tree" adds the whole section's navigation (`article.nav`); the docs layout asks for it. An older hyle ignores it. */
32
32
  readonly nav?: "tree";
33
33
  readonly cursor?: string;
@@ -155,8 +155,17 @@ declare class DeliveryDedupe {
155
155
  interface PublicationPath {
156
156
  /** The publication's canonical site path, for example "/learn/hello". */
157
157
  readonly path: string;
158
- /** ISO 8601 `published_at` (the list endpoint carries no `updated_at`). */
158
+ /** ISO 8601 `published_at`. */
159
159
  readonly publishedAt: string;
160
+ /** ISO 8601 `updated_at`, when the server sends it. */
161
+ readonly updatedAt?: string;
162
+ /** The translation group, itself included, as site paths per locale; only when the server sends it. */
163
+ readonly alternates?: readonly {
164
+ readonly locale: string;
165
+ readonly path: string;
166
+ }[];
167
+ readonly title: string;
168
+ readonly description: string | null;
160
169
  }
161
170
  interface PublicationPaths {
162
171
  readonly paths: PublicationPath[];
@@ -168,16 +177,14 @@ interface ListPublicationPathsOptions {
168
177
  readonly client: Pick<HyleClient, "resolve">;
169
178
  /** The mount prefix, "" or "/learn": the same value as `basePath` of `hylePage`. */
170
179
  readonly basePath: string;
171
- /** Section slugs to list besides the default section, whose index is `basePath` itself. A section's index is `basePath/<slug>`. */
172
- readonly sections?: readonly string[];
173
180
  readonly locale?: string;
174
181
  /** Pages fetched per index (default 20, of 100 items each), so a workspace larger than 2000 per section is truncated. */
175
182
  readonly maxPages?: number;
176
183
  }
177
184
  /**
178
185
  * Every published page under a mount, for a sitemap. The contract has no "list everything" endpoint, so this pages the list
179
- * result at each section index (`limit` 100, following `next_cursor`) up to `maxPages` per index. Only the default section and
180
- * the listed `sections` are covered. Never throws: on any error it returns what it collected with `complete: false`, so the caller decides whether a partial listing is acceptable.
186
+ * result at each section index (`limit` 100, following `next_cursor`) up to `maxPages` per index. Only the mount's own section
187
+ * (its index is `basePath`) is covered: every section is its own mount. Never throws: on any error it returns what it collected with `complete: false`, so the caller decides whether a partial listing is acceptable.
181
188
  */
182
189
  declare function listPublicationPaths(options: ListPublicationPathsOptions): Promise<PublicationPaths>;
183
190
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as Resolved, M as MountsResult } from './types-5D6ZD0Wi.js';
2
- export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, E as EngageComment, b as EngageHeldComment, c as EngageListing, F as Fallback, L as ListItem, d as Mount, e as Mounts, N as NavItem, f as NavNode, g as NavTree, h as ResolvedArticle, i as ResolvedDisabled, j as ResolvedList, k as ResolvedNotFound, l as ResolvedRedirect, T as TocEntry } from './types-5D6ZD0Wi.js';
1
+ import { R as Resolved, M as MountsResult } from './types-Czt887Iv.js';
2
+ 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, d as Mount, e as Mounts, N as NavItem, f as NavNode, g as NavTree, h as ResolvedArticle, i as ResolvedDisabled, j as ResolvedList, k as ResolvedNotFound, l as ResolvedRedirect, T as TocEntry } from './types-Czt887Iv.js';
3
3
  export { R as RevalidationCallbackOptions, a as RevalidationCallbackRoute, b as RevalidationPayload, c as createRevalidationCallbackRoute } from './revalidation-callback-D7Ms_Puz.js';
4
4
 
5
5
  /** `next` is a Next.js fetch extension with no lib.dom type; typed structurally so this module needs no Next import. */
@@ -27,7 +27,7 @@ interface ResolveOptions {
27
27
  /** The site path as a visitor sees it, including the workspace's path prefix. Sent as a query parameter, so it is encoded once. */
28
28
  readonly path: string;
29
29
  readonly locale?: string;
30
- readonly format?: "hast" | "html";
30
+ readonly format?: "hast" | "html" | "md";
31
31
  /** "tree" adds the whole section's navigation (`article.nav`); the docs layout asks for it. An older hyle ignores it. */
32
32
  readonly nav?: "tree";
33
33
  readonly cursor?: string;
@@ -155,8 +155,17 @@ declare class DeliveryDedupe {
155
155
  interface PublicationPath {
156
156
  /** The publication's canonical site path, for example "/learn/hello". */
157
157
  readonly path: string;
158
- /** ISO 8601 `published_at` (the list endpoint carries no `updated_at`). */
158
+ /** ISO 8601 `published_at`. */
159
159
  readonly publishedAt: string;
160
+ /** ISO 8601 `updated_at`, when the server sends it. */
161
+ readonly updatedAt?: string;
162
+ /** The translation group, itself included, as site paths per locale; only when the server sends it. */
163
+ readonly alternates?: readonly {
164
+ readonly locale: string;
165
+ readonly path: string;
166
+ }[];
167
+ readonly title: string;
168
+ readonly description: string | null;
160
169
  }
161
170
  interface PublicationPaths {
162
171
  readonly paths: PublicationPath[];
@@ -168,16 +177,14 @@ interface ListPublicationPathsOptions {
168
177
  readonly client: Pick<HyleClient, "resolve">;
169
178
  /** The mount prefix, "" or "/learn": the same value as `basePath` of `hylePage`. */
170
179
  readonly basePath: string;
171
- /** Section slugs to list besides the default section, whose index is `basePath` itself. A section's index is `basePath/<slug>`. */
172
- readonly sections?: readonly string[];
173
180
  readonly locale?: string;
174
181
  /** Pages fetched per index (default 20, of 100 items each), so a workspace larger than 2000 per section is truncated. */
175
182
  readonly maxPages?: number;
176
183
  }
177
184
  /**
178
185
  * Every published page under a mount, for a sitemap. The contract has no "list everything" endpoint, so this pages the list
179
- * result at each section index (`limit` 100, following `next_cursor`) up to `maxPages` per index. Only the default section and
180
- * the listed `sections` are covered. Never throws: on any error it returns what it collected with `complete: false`, so the caller decides whether a partial listing is acceptable.
186
+ * result at each section index (`limit` 100, following `next_cursor`) up to `maxPages` per index. Only the mount's own section
187
+ * (its index is `basePath`) is covered: every section is its own mount. Never throws: on any error it returns what it collected with `complete: false`, so the caller decides whether a partial listing is acceptable.
181
188
  */
182
189
  declare function listPublicationPaths(options: ListPublicationPathsOptions): Promise<PublicationPaths>;
183
190
 
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  routeMatches,
19
19
  syncHostReserved,
20
20
  verifyHyleSignature
21
- } from "./chunk-N7ZQUAGM.js";
21
+ } from "./chunk-MGSUQBDW.js";
22
22
  import "./chunk-67IOIAVW.js";
23
23
  export {
24
24
  CACHE_TAG_PATTERN,
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Every string the diagram viewer shows. Pure data, so the client component can carry the English defaults without importing
3
+ * the viewer chunk, and the server passes the host's locale in (strings.ts holds fr and es, unreviewed drafts like the rest).
4
+ */
5
+ interface ViewerLabels {
6
+ expand: string;
7
+ expandHint: string;
8
+ viewer: string;
9
+ close: string;
10
+ zoomIn: string;
11
+ zoomOut: string;
12
+ fit: string;
13
+ actual: string;
14
+ search: string;
15
+ searchPlaceholder: string;
16
+ noMatch: string;
17
+ matchOf: string;
18
+ copySource: string;
19
+ downloadSvg: string;
20
+ downloadPng: string;
21
+ copyImage: string;
22
+ pngScale: string;
23
+ fullscreen: string;
24
+ exitFullscreen: string;
25
+ copied: string;
26
+ saved: string;
27
+ unavailable: string;
28
+ hint: string;
29
+ legendSelected: string;
30
+ legendUpstream: string;
31
+ legendDownstream: string;
32
+ outgoing: string;
33
+ tracing: string;
34
+ map: string;
35
+ }
36
+
37
+ export type { ViewerLabels as V };
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Every string the diagram viewer shows. Pure data, so the client component can carry the English defaults without importing
3
+ * the viewer chunk, and the server passes the host's locale in (strings.ts holds fr and es, unreviewed drafts like the rest).
4
+ */
5
+ interface ViewerLabels {
6
+ expand: string;
7
+ expandHint: string;
8
+ viewer: string;
9
+ close: string;
10
+ zoomIn: string;
11
+ zoomOut: string;
12
+ fit: string;
13
+ actual: string;
14
+ search: string;
15
+ searchPlaceholder: string;
16
+ noMatch: string;
17
+ matchOf: string;
18
+ copySource: string;
19
+ downloadSvg: string;
20
+ downloadPng: string;
21
+ copyImage: string;
22
+ pngScale: string;
23
+ fullscreen: string;
24
+ exitFullscreen: string;
25
+ copied: string;
26
+ saved: string;
27
+ unavailable: string;
28
+ hint: string;
29
+ legendSelected: string;
30
+ legendUpstream: string;
31
+ legendDownstream: string;
32
+ outgoing: string;
33
+ tracing: string;
34
+ map: string;
35
+ }
36
+
37
+ export type { ViewerLabels as V };
@@ -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 })