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.
@@ -2429,7 +2429,7 @@ var init_claude_registry = __esm(() => {
2429
2429
  });
2430
2430
 
2431
2431
  // ../../packages/core/src/version.ts
2432
- var NEGOTIUM_VERSION = "0.3.1";
2432
+ var NEGOTIUM_VERSION = "0.3.2";
2433
2433
 
2434
2434
  // ../../packages/core/src/agents/codex-native-multi-agent.ts
2435
2435
  import { spawn as spawn2 } from "child_process";
@@ -14814,11 +14814,58 @@ function buildMermaidHtml(code, theme, scriptUrl = MERMAID_BROWSER_ASSET_RELATIV
14814
14814
  <script data-otium-mermaid-runtime src="${safeScriptUrl}"></script>
14815
14815
  <script>
14816
14816
  (async () => {
14817
+ // An unrendered document reports itself in more than one voice: Mermaid's
14818
+ // own 0x0 guard, and the browser refusing geometry on a path that was
14819
+ // never laid out. Both mean the same thing, so both are worth one retry
14820
+ // and, if it still fails, the same explanation.
14821
+ const unrendered = (error) => {
14822
+ const message = String(error && error.message ? error.message : error);
14823
+ return message.indexOf("not in render tree") !== -1 || message.indexOf("path is empty") !== -1;
14824
+ };
14817
14825
  try {
14818
14826
  const runtime = globalThis.mermaid;
14819
14827
  if (!runtime) throw new Error("Mermaid renderer failed to load.");
14820
14828
  runtime.initialize({ startOnLoad: false, securityLevel: "strict", theme: ${safeTheme} });
14821
- await runtime.run({ querySelector: ".mermaid" });
14829
+ const host = document.querySelector(".mermaid");
14830
+ // Mermaid sizes every label by appending a probe <svg> to the body and
14831
+ // reading getBBox(), and it throws "svg element not in render tree" the
14832
+ // moment that comes back 0x0. That is what a hidden panel looks like from
14833
+ // in here: the document exists but nothing is in the render tree, so the
14834
+ // measurement has no geometry to report. Ask the same question Mermaid
14835
+ // will ask, and only start once it has an answer.
14836
+ const measurable = () => {
14837
+ const probe = document.createElementNS("http://www.w3.org/2000/svg", "svg");
14838
+ const text = document.createElementNS("http://www.w3.org/2000/svg", "text");
14839
+ text.textContent = "M";
14840
+ probe.appendChild(text);
14841
+ document.body.appendChild(probe);
14842
+ let box = { width: 0, height: 0 };
14843
+ try { box = text.getBBox(); } catch (ignored) {}
14844
+ probe.remove();
14845
+ return box.width > 0 || box.height > 0;
14846
+ };
14847
+ // requestAnimationFrame is the right clock here: a hidden document stops
14848
+ // being animated, so this waits without spinning and resumes on the frame
14849
+ // the panel is shown. The cap counts rendered frames, not wall time.
14850
+ const waitUntilMeasurable = async (maxFrames) => {
14851
+ for (let frame = 0; frame < maxFrames; frame += 1) {
14852
+ if (measurable()) return true;
14853
+ await new Promise((next) => requestAnimationFrame(next));
14854
+ }
14855
+ return measurable();
14856
+ };
14857
+ await waitUntilMeasurable(600);
14858
+ try {
14859
+ await runtime.run({ querySelector: ".mermaid" });
14860
+ } catch (firstAttempt) {
14861
+ if (!unrendered(firstAttempt)) throw firstAttempt;
14862
+ // The panel can be hidden again between the probe and the real measure.
14863
+ // Clear the marker Mermaid leaves behind so the retry is not skipped as
14864
+ // already done, then wait for the render tree once more.
14865
+ host.removeAttribute("data-processed");
14866
+ await waitUntilMeasurable(600);
14867
+ await runtime.run({ querySelector: ".mermaid" });
14868
+ }
14822
14869
  const viewport = document.querySelector(".viewport");
14823
14870
  const svg = document.querySelector(".mermaid svg");
14824
14871
  const value = document.querySelector(".zoom-value");
@@ -14854,6 +14901,8 @@ function buildMermaidHtml(code, theme, scriptUrl = MERMAID_BROWSER_ASSET_RELATIV
14854
14901
  // for a syntax error that does not exist. Say what actually moves it.
14855
14902
  const note = raw.indexOf("Could not find a suitable point") !== -1
14856
14903
  ? "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."
14904
+ : unrendered(error)
14905
+ ? "The panel stayed hidden long enough that there was never a laid-out page to measure the diagram against. Reopening the panel renders it."
14857
14906
  : "This diagram could not be rendered.";
14858
14907
  document.querySelector(".viewport").innerHTML =
14859
14908
  '<div class="failure"><p>' + escape(note) +
@@ -18947,4 +18996,4 @@ export {
18947
18996
  DEFAULT_SELF_CONFIG_PRODUCT
18948
18997
  };
18949
18998
 
18950
- //# debugId=04D3635C24297EC864756E2164756E21
18999
+ //# debugId=F55519AD891B254F64756E2164756E21