negotium 0.3.1 → 0.3.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.
@@ -1017,7 +1017,7 @@ var init_claude_registry = __esm(() => {
1017
1017
  });
1018
1018
 
1019
1019
  // ../../packages/core/src/version.ts
1020
- var NEGOTIUM_VERSION = "0.3.1";
1020
+ var NEGOTIUM_VERSION = "0.3.2";
1021
1021
 
1022
1022
  // ../../packages/core/src/agents/codex-native-multi-agent.ts
1023
1023
  import { spawn as spawn2 } from "child_process";
@@ -14837,11 +14837,58 @@ function buildMermaidHtml(code, theme, scriptUrl = MERMAID_BROWSER_ASSET_RELATIV
14837
14837
  <script data-otium-mermaid-runtime src="${safeScriptUrl}"></script>
14838
14838
  <script>
14839
14839
  (async () => {
14840
+ // An unrendered document reports itself in more than one voice: Mermaid's
14841
+ // own 0x0 guard, and the browser refusing geometry on a path that was
14842
+ // never laid out. Both mean the same thing, so both are worth one retry
14843
+ // and, if it still fails, the same explanation.
14844
+ const unrendered = (error) => {
14845
+ const message = String(error && error.message ? error.message : error);
14846
+ return message.indexOf("not in render tree") !== -1 || message.indexOf("path is empty") !== -1;
14847
+ };
14840
14848
  try {
14841
14849
  const runtime = globalThis.mermaid;
14842
14850
  if (!runtime) throw new Error("Mermaid renderer failed to load.");
14843
14851
  runtime.initialize({ startOnLoad: false, securityLevel: "strict", theme: ${safeTheme} });
14844
- await runtime.run({ querySelector: ".mermaid" });
14852
+ const host = document.querySelector(".mermaid");
14853
+ // Mermaid sizes every label by appending a probe <svg> to the body and
14854
+ // reading getBBox(), and it throws "svg element not in render tree" the
14855
+ // moment that comes back 0x0. That is what a hidden panel looks like from
14856
+ // in here: the document exists but nothing is in the render tree, so the
14857
+ // measurement has no geometry to report. Ask the same question Mermaid
14858
+ // will ask, and only start once it has an answer.
14859
+ const measurable = () => {
14860
+ const probe = document.createElementNS("http://www.w3.org/2000/svg", "svg");
14861
+ const text = document.createElementNS("http://www.w3.org/2000/svg", "text");
14862
+ text.textContent = "M";
14863
+ probe.appendChild(text);
14864
+ document.body.appendChild(probe);
14865
+ let box = { width: 0, height: 0 };
14866
+ try { box = text.getBBox(); } catch (ignored) {}
14867
+ probe.remove();
14868
+ return box.width > 0 || box.height > 0;
14869
+ };
14870
+ // requestAnimationFrame is the right clock here: a hidden document stops
14871
+ // being animated, so this waits without spinning and resumes on the frame
14872
+ // the panel is shown. The cap counts rendered frames, not wall time.
14873
+ const waitUntilMeasurable = async (maxFrames) => {
14874
+ for (let frame = 0; frame < maxFrames; frame += 1) {
14875
+ if (measurable()) return true;
14876
+ await new Promise((next) => requestAnimationFrame(next));
14877
+ }
14878
+ return measurable();
14879
+ };
14880
+ await waitUntilMeasurable(600);
14881
+ try {
14882
+ await runtime.run({ querySelector: ".mermaid" });
14883
+ } catch (firstAttempt) {
14884
+ if (!unrendered(firstAttempt)) throw firstAttempt;
14885
+ // The panel can be hidden again between the probe and the real measure.
14886
+ // Clear the marker Mermaid leaves behind so the retry is not skipped as
14887
+ // already done, then wait for the render tree once more.
14888
+ host.removeAttribute("data-processed");
14889
+ await waitUntilMeasurable(600);
14890
+ await runtime.run({ querySelector: ".mermaid" });
14891
+ }
14845
14892
  const viewport = document.querySelector(".viewport");
14846
14893
  const svg = document.querySelector(".mermaid svg");
14847
14894
  const value = document.querySelector(".zoom-value");
@@ -14877,6 +14924,8 @@ function buildMermaidHtml(code, theme, scriptUrl = MERMAID_BROWSER_ASSET_RELATIV
14877
14924
  // for a syntax error that does not exist. Say what actually moves it.
14878
14925
  const note = raw.indexOf("Could not find a suitable point") !== -1
14879
14926
  ? "Two nodes ended up too close together for Mermaid to fit a label on the edge between them. Renaming a node, adding another, or setting an explicit direction usually spreads the layout enough to render."
14927
+ : unrendered(error)
14928
+ ? "The panel stayed hidden long enough that there was never a laid-out page to measure the diagram against. Reopening the panel renders it."
14880
14929
  : "This diagram could not be rendered.";
14881
14930
  document.querySelector(".viewport").innerHTML =
14882
14931
  '<div class="failure"><p>' + escape(note) +
@@ -21489,4 +21538,4 @@ export {
21489
21538
  createAgentHealthMcpServer
21490
21539
  };
21491
21540
 
21492
- //# debugId=68312E6A48CAB76C64756E2164756E21
21541
+ //# debugId=A4B482066B2CF06D64756E2164756E21