executable-stories-react 0.16.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.
@@ -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
  ] });
@@ -2907,18 +2907,42 @@ 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
+ let firstId = null;
2921
+ let firstTop = Infinity;
2922
+ for (const el of els) {
2923
+ const top = el.getBoundingClientRect().top;
2924
+ if (top <= line && top > best) {
2925
+ best = top;
2926
+ active = el;
2927
+ }
2928
+ if (top < firstTop) {
2929
+ firstTop = top;
2930
+ firstId = el.id;
2931
+ }
2932
+ }
2933
+ setActiveId(best === -Infinity ? firstId : active.id);
2934
+ };
2935
+ const onScroll = () => {
2936
+ if (frame === 0) frame = requestAnimationFrame(update);
2937
+ };
2938
+ update();
2939
+ window.addEventListener("scroll", onScroll, { passive: true });
2940
+ window.addEventListener("resize", onScroll);
2941
+ return () => {
2942
+ window.removeEventListener("scroll", onScroll);
2943
+ window.removeEventListener("resize", onScroll);
2944
+ if (frame !== 0) cancelAnimationFrame(frame);
2945
+ };
2922
2946
  }, [scenarioIds]);
2923
2947
  if (report.features.length === 0) return null;
2924
2948
  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 +3482,7 @@ function ReportInteractiveView({
3458
3482
  staleAfterDays = 7,
3459
3483
  scenarioHistory,
3460
3484
  share = false,
3485
+ architecture = false,
3461
3486
  shareCommand
3462
3487
  }) {
3463
3488
  const [urlState, setUrlState] = useUrlState();
@@ -3668,7 +3693,7 @@ function ReportInteractiveView({
3668
3693
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ReportSummary, {}),
3669
3694
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ReportMeta, {})
3670
3695
  ] }),
3671
- /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ReportSpanGraph, {}),
3696
+ architecture ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ReportSpanGraph, {}) : null,
3672
3697
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
3673
3698
  ReportFreshness,
3674
3699
  {
@@ -3824,7 +3849,10 @@ function MermaidView({ entry, load }) {
3824
3849
  mermaid.initialize({
3825
3850
  startOnLoad: false,
3826
3851
  securityLevel: "strict",
3827
- theme: prefersDark(ref.current) ? "dark" : "default"
3852
+ // "neutral" in light: the same theme the static, no-JS render uses
3853
+ // in ssr-entry, so a diagram keeps its colours when the island takes
3854
+ // over.
3855
+ theme: prefersDark(ref.current) ? "dark" : "neutral"
3828
3856
  });
3829
3857
  await mermaid.parse(entry.code);
3830
3858
  const id = `es-mermaid-${Math.random().toString(36).slice(2)}`;
@@ -3883,7 +3911,7 @@ function MermaidView({ entry, load }) {
3883
3911
  // src/interactive/island-renderers.tsx
3884
3912
  var import_jsx_runtime55 = require("react/jsx-runtime");
3885
3913
  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";
3914
+ var MERMAID_ESM = "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs";
3887
3915
  function cachedCdnModule(url) {
3888
3916
  let loader;
3889
3917
  return () => {