@chatpanel/events 0.12.0 → 0.12.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.
Files changed (2) hide show
  1. package/flowchart.js +13 -2
  2. package/package.json +1 -1
package/flowchart.js CHANGED
@@ -312,12 +312,23 @@ function styleFor(id, graph, rankIdx) {
312
312
  * Mermaid flowchart text → a complete SVG document string, or null if it isn't a flowchart
313
313
  * this renderer handles (the caller then keeps the code block).
314
314
  */
315
- export function renderFlowchartSvg(text, { padding = 18, maxWidth = 1400 } = {}) {
315
+ export function renderFlowchartSvg(text, { padding = 18, maxWidth = 1400, autoFlip = true } = {}) {
316
316
  const graph = parseFlowchart(text);
317
317
  if (!graph) return null;
318
- const L = layoutFlowchart(graph);
318
+ let L = layoutFlowchart(graph);
319
319
  if (!L.boxes.size) return null;
320
320
 
321
+ // A broad tree laid out top-down (one root, six categories, ~28 leaves) becomes a 3000px
322
+ // strip that is unreadable in a side panel. When a chart comes out far wider than it is
323
+ // tall, lay it out left-to-right instead: the same graph, but the wide rank stacks
324
+ // vertically and every label stays legible at fit-width. Purely a presentation choice —
325
+ // the Code view always shows what the model actually wrote.
326
+ if (autoFlip) {
327
+ const aspect = L.width / Math.max(1, L.height);
328
+ if (aspect > 2.2 && !L.horizontal) L = layoutFlowchart(graph, { dir: 'LR' });
329
+ else if (aspect < 0.25 && L.horizontal) L = layoutFlowchart(graph, { dir: 'TB' });
330
+ }
331
+
321
332
  const W = Math.min(maxWidth, Math.ceil(L.width + padding * 2));
322
333
  const H = Math.ceil(L.height + padding * 2);
323
334
  const out = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatpanel/events",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "The canonical ChatPanel event-log and capability contracts \u2014 typed durable facts, clock-free deterministic linearization, schema upcasting, and the invariants the replay harness asserts. Pure, dependency-free ESM shared by the ChatPanel extension, gateway and bridge.",
5
5
  "type": "module",
6
6
  "main": "index.js",