executable-stories-react 0.16.0 → 0.17.1

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.
@@ -1747,7 +1747,7 @@ function ReportSpanGraph() {
1747
1747
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("h2", { id: "es-span-graph-heading", className: "text-base font-semibold text-foreground", children: "Architecture, as it ran" }),
1748
1748
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: "mt-1 text-sm text-muted-foreground", children: "Derived from this run\u2019s traces. Every component was named by a span while a scenario ran, so nothing here is inferred from the code. Instrumented, exercised paths only: a component no scenario reaches does not appear." }),
1749
1749
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DocMermaid, { entry: { kind: "mermaid", phase: "static", code } }),
1750
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("table", { className: "mt-2 w-full text-left text-sm", children: [
1750
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("table", { className: "mt-2 w-full border-collapse text-left text-sm", children: [
1751
1751
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("caption", { className: "sr-only", children: "Each component and the scenarios that exercised it" }),
1752
1752
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("tr", { className: "text-xs text-muted-foreground", children: [
1753
1753
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("th", { scope: "col", className: "py-1 pr-4 font-medium", children: "Component" }),
@@ -1760,7 +1760,7 @@ function ReportSpanGraph() {
1760
1760
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(MarkBadge, { node })
1761
1761
  ] }),
1762
1762
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("td", { className: "py-1.5 pr-4 text-xs text-muted-foreground", children: LANE_LABEL[node.kind] }),
1763
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("td", { className: "py-1.5", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("ul", { className: "flex flex-col gap-0.5", children: node.scenarioIds.map((id) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("a", { href: `#${id}`, className: "text-xs underline underline-offset-2", children: titleById.get(id) ?? id }) }, id)) }) })
1763
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("td", { className: "py-1.5", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("ul", { className: "flex flex-col gap-0.5", children: node.scenarioIds.map((id) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("a", { href: `#${id}`, className: "text-xs text-link underline underline-offset-2 hover:text-foreground", children: titleById.get(id) ?? id }) }, id)) }) })
1764
1764
  ] }, node.id)) })
1765
1765
  ] })
1766
1766
  ] });
@@ -2720,7 +2720,7 @@ function ReportShare({
2720
2720
  "a",
2721
2721
  {
2722
2722
  className: "text-xs underline underline-offset-2",
2723
- href: "https://executablestories.com/guides/sharing-reports/",
2723
+ href: "https://docs.executablestories.com/guides/sharing-reports/",
2724
2724
  target: "_blank",
2725
2725
  rel: "noreferrer",
2726
2726
  children: "How sharing works"
@@ -2907,18 +2907,36 @@ function TocContent({ onNavigate }) {
2907
2907
  [report]
2908
2908
  );
2909
2909
  (0, import_react19.useEffect)(() => {
2910
- if (typeof IntersectionObserver === "undefined") return;
2910
+ if (typeof window === "undefined") return;
2911
2911
  const els = scenarioIds.map((id) => document.getElementById(id)).filter((el) => el !== null);
2912
2912
  if (els.length === 0) return;
2913
- const observer = new IntersectionObserver(
2914
- (entries) => {
2915
- const visible = entries.filter((e) => e.isIntersecting).sort((a, b) => a.boundingClientRect.top - b.boundingClientRect.top);
2916
- if (visible[0]) setActiveId(visible[0].target.id);
2917
- },
2918
- { rootMargin: "-8% 0px -80% 0px" }
2919
- );
2920
- els.forEach((el) => observer.observe(el));
2921
- return () => observer.disconnect();
2913
+ let frame = 0;
2914
+ const update = () => {
2915
+ frame = 0;
2916
+ const atBottom = window.scrollY + window.innerHeight >= document.documentElement.scrollHeight - 2;
2917
+ const line = atBottom ? window.innerHeight : window.innerHeight * 0.2;
2918
+ let active = els[0];
2919
+ let best = -Infinity;
2920
+ for (const el of els) {
2921
+ const top = el.getBoundingClientRect().top;
2922
+ if (top <= line && top > best) {
2923
+ best = top;
2924
+ active = el;
2925
+ }
2926
+ }
2927
+ setActiveId(active.id);
2928
+ };
2929
+ const onScroll = () => {
2930
+ if (frame === 0) frame = requestAnimationFrame(update);
2931
+ };
2932
+ update();
2933
+ window.addEventListener("scroll", onScroll, { passive: true });
2934
+ window.addEventListener("resize", onScroll);
2935
+ return () => {
2936
+ window.removeEventListener("scroll", onScroll);
2937
+ window.removeEventListener("resize", onScroll);
2938
+ if (frame !== 0) cancelAnimationFrame(frame);
2939
+ };
2922
2940
  }, [scenarioIds]);
2923
2941
  if (report.features.length === 0) return null;
2924
2942
  return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("ul", { className: "flex list-none flex-col gap-4 pl-0", children: report.features.map((feature) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("li", { children: [
@@ -3458,6 +3476,7 @@ function ReportInteractiveView({
3458
3476
  staleAfterDays = 7,
3459
3477
  scenarioHistory,
3460
3478
  share = false,
3479
+ architecture = false,
3461
3480
  shareCommand
3462
3481
  }) {
3463
3482
  const [urlState, setUrlState] = useUrlState();
@@ -3668,7 +3687,7 @@ function ReportInteractiveView({
3668
3687
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ReportSummary, {}),
3669
3688
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ReportMeta, {})
3670
3689
  ] }),
3671
- /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ReportSpanGraph, {}),
3690
+ architecture ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ReportSpanGraph, {}) : null,
3672
3691
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
3673
3692
  ReportFreshness,
3674
3693
  {
@@ -3824,7 +3843,10 @@ function MermaidView({ entry, load }) {
3824
3843
  mermaid.initialize({
3825
3844
  startOnLoad: false,
3826
3845
  securityLevel: "strict",
3827
- theme: prefersDark(ref.current) ? "dark" : "default"
3846
+ // "neutral" in light: the same theme the static, no-JS render uses
3847
+ // in ssr-entry, so a diagram keeps its colours when the island takes
3848
+ // over.
3849
+ theme: prefersDark(ref.current) ? "dark" : "neutral"
3828
3850
  });
3829
3851
  await mermaid.parse(entry.code);
3830
3852
  const id = `es-mermaid-${Math.random().toString(36).slice(2)}`;
@@ -3883,7 +3905,7 @@ function MermaidView({ entry, load }) {
3883
3905
  // src/interactive/island-renderers.tsx
3884
3906
  var import_jsx_runtime55 = require("react/jsx-runtime");
3885
3907
  var HLJS_ESM = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/es/highlight.min.js";
3886
- var MERMAID_ESM = "https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs";
3908
+ var MERMAID_ESM = "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs";
3887
3909
  function cachedCdnModule(url) {
3888
3910
  let loader;
3889
3911
  return () => {