@markdy/core 1.4.5 → 1.4.7

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/dist/index.js +11 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2237,9 +2237,11 @@ function layoutRadar(ast) {
2237
2237
  }
2238
2238
  function layoutNodes(ast, edges) {
2239
2239
  const dtype = diagramType(ast);
2240
+ const isAutoNarrow = (ast.meta.layoutMode === "auto" || !ast.meta.explicitDirection) && ast.meta.explicitWidth && ast.meta.width < 640;
2241
+ const isVertical = isAutoNarrow || ast.meta.direction === "TB" || ast.meta.direction === "BT";
2240
2242
  switch (dtype) {
2241
2243
  case "flowchart":
2242
- return layoutRanked(ast, edges, { forceVertical: ast.meta.direction === "TB" || ast.meta.direction === "BT" });
2244
+ return layoutRanked(ast, edges, { forceVertical: isVertical });
2243
2245
  case "tree":
2244
2246
  return layoutTree(ast, edges.some((edge) => edge.structural) ? edges.filter((edge) => edge.structural) : edges);
2245
2247
  case "sequence":
@@ -2270,9 +2272,9 @@ function layoutNodes(ast, edges) {
2270
2272
  case "nested":
2271
2273
  return layoutNested(ast);
2272
2274
  case "state":
2273
- return layoutRanked(ast, cycleSafeEdges(Object.keys(ast.nodes), edges), { forceVertical: ast.meta.direction === "TB" || ast.meta.direction === "BT" });
2275
+ return layoutRanked(ast, cycleSafeEdges(Object.keys(ast.nodes), edges), { forceVertical: isVertical });
2274
2276
  default:
2275
- return layoutRanked(ast, edges, { forceVertical: ast.meta.direction === "TB" || ast.meta.direction === "BT" });
2277
+ return layoutRanked(ast, edges, { forceVertical: isVertical });
2276
2278
  }
2277
2279
  }
2278
2280
  function computeGroupBoundaries(ast, nodes) {
@@ -2546,7 +2548,10 @@ function computeAdaptiveDimensions(ast, edges) {
2546
2548
  const nodeIds = Object.keys(ast.nodes);
2547
2549
  const nodeCount = nodeIds.length;
2548
2550
  const dtype = diagramType(ast);
2549
- const direction = ast.meta.direction ?? "LR";
2551
+ let direction = ast.meta.direction ?? "LR";
2552
+ if ((ast.meta.layoutMode === "auto" || !ast.meta.explicitDirection) && ast.meta.explicitWidth && ast.meta.width < 640) {
2553
+ direction = ast.meta.direction === "RL" || ast.meta.direction === "BT" ? "BT" : "TB";
2554
+ }
2550
2555
  const isVertical = direction === "TB" || direction === "BT";
2551
2556
  const groupCount = Object.keys(ast.groups).length;
2552
2557
  const nodeDims = nodeIds.map((id) => computeNodeDimensions(ast.nodes[id]));
@@ -3957,7 +3962,8 @@ function parse(source, opts = {}) {
3957
3962
  theme: "paper",
3958
3963
  explicitTheme: false,
3959
3964
  direction: "LR",
3960
- explicitDirection: false
3965
+ explicitDirection: false,
3966
+ layoutMode: "auto"
3961
3967
  };
3962
3968
  const styles = {};
3963
3969
  const nodes = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markdy/core",
3
- "version": "1.4.5",
3
+ "version": "1.4.7",
4
4
  "description": "Diagram-native MarkdyScript parser and compiler (auto-layout, edge routing, cue scheduling) — zero runtime dependencies.",
5
5
  "license": "MIT",
6
6
  "type": "module",