@qe-mcp/server-ena 0.1.4 → 0.1.5

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 (2) hide show
  1. package/package.json +1 -1
  2. package/server.js +17 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qe-mcp/server-ena",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "MCP server for Epistemic Network Analysis — WASM backend, zero Python dependency",
5
5
  "type": "module",
6
6
  "main": "server.js",
package/server.js CHANGED
@@ -303,7 +303,23 @@ async function renderSVG(modelData, opts = {}) {
303
303
  if (!svgHtml.includes('xmlns=')) {
304
304
  svgHtml = svgHtml.replace('<svg', '<svg xmlns="http://www.w3.org/2000/svg"');
305
305
  }
306
- return svgHtml;
306
+ return withWhiteBackground(svgHtml);
307
+ }
308
+
309
+ // The qeviz SVG has a transparent background, which makes the plot invisible in
310
+ // dark-mode viewers. Insert an opaque white rect as the first child (behind all
311
+ // content), sized to the SVG's viewBox so it covers the full canvas.
312
+ function withWhiteBackground(svgHtml) {
313
+ const openTagMatch = svgHtml.match(/<svg[^>]*>/);
314
+ if (!openTagMatch) return svgHtml;
315
+ const openTag = openTagMatch[0];
316
+
317
+ const vb = openTag.match(/viewBox\s*=\s*["']\s*([-\d.]+)\s+([-\d.]+)\s+([-\d.]+)\s+([-\d.]+)\s*["']/);
318
+ const rect = vb
319
+ ? `<rect x="${vb[1]}" y="${vb[2]}" width="${vb[3]}" height="${vb[4]}" fill="#ffffff"/>`
320
+ : `<rect x="0" y="0" width="100%" height="100%" fill="#ffffff"/>`;
321
+
322
+ return svgHtml.replace(openTag, openTag + rect);
307
323
  }
308
324
 
309
325
  // ── Model / accumulation cache ────────────────────────────────────────────────