@diagc/cli 1.7.0 → 1.8.0

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.
@@ -1,9 +1,10 @@
1
- import { activeNotation, buildHierarchy, compileView, defined, defaultLayoutDirection, FISHBONE_NOTATION, layoutPlaneKey, presetLayers, } from '@diagc/core/internal';
1
+ import { activeNotation, buildHierarchy, compileView, defined, defaultLayoutDirection, FISHBONE_NOTATION, GIT_NOTATION, layoutPlaneKey, presetLayers, } from '@diagc/core/internal';
2
2
  import { notationAccents } from './accents.js';
3
3
  import { boxText, edgeText } from './content.js';
4
4
  import { SHADOW_REACH } from './dos.js';
5
5
  import { fishCells } from './fish.js';
6
6
  import { withNeverFolds } from './folds.js';
7
+ import { gitCells } from './git.js';
7
8
  import { layoutCells } from './layout.js';
8
9
  import { legendOf } from './legend.js';
9
10
  import { hidesKind } from './vocabulary.js';
@@ -45,10 +46,13 @@ export async function buildScene(input, glyphs) {
45
46
  for (const root of view.roots)
46
47
  walk(root, undefined);
47
48
  const labels = new Map(view.layoutEdges.map((e) => [e.id, edgeText(e, glyphs)]));
48
- // A fishbone is the fish, as on the page, whatever way the plane's settings say to flow.
49
+ // A fishbone is the fish and a git graph its lanes, whatever way the plane's
50
+ // settings say to flow.
49
51
  const laid = notation === FISHBONE_NOTATION
50
52
  ? fishCells(model, view, boxes)
51
- : await layoutCells(view, boxes, flowOf(input), labels);
53
+ : notation === GIT_NOTATION
54
+ ? gitCells(model, view, boxes, defined({ plane, across: input.horizontal }))
55
+ : await layoutCells(view, boxes, flowOf(input), labels);
52
56
  const room = input.style === 'dos' && laid.boxes.size > 0;
53
57
  const layout = room ? { ...laid, width: laid.width + SHADOW_REACH.x, height: laid.height + SHADOW_REACH.y } : laid;
54
58
  const accents = notationAccents(model, plane, notation, view.edges);
@@ -1,3 +1,4 @@
1
+ import { GIT_NOTATION } from '@diagc/core/internal';
1
2
  import { neverFolds } from '../text/vocabulary.js';
2
3
  import { onLegend } from './legend.js';
3
4
  import { clampScroll, follow, hitTest, nearest, readingOrder } from './nav.js';
@@ -89,8 +90,18 @@ function switchPlane(d, ctx, step) {
89
90
  const at = Math.max(0, planes.findIndex((p) => p.id === (d.plane ?? planes[0].id)));
90
91
  const plane = planes[(at + step + planes.length) % planes.length];
91
92
  // what the reader has open or shut stays as it was; the view is the new plane's
92
- const { panel, overview, legend } = d;
93
- return relayout({ ...openDiagram(d.name, ctx.model, ctx.overlay, plane.id), panel, overview, legend });
93
+ const { panel, overview, legend, horizontal } = d;
94
+ const kept = { panel, overview, legend, ...(horizontal === true ? { horizontal } : {}) };
95
+ return relayout({ ...openDiagram(d.name, ctx.model, ctx.overlay, plane.id), ...kept });
96
+ }
97
+ /** A git graph turned across the screen, or back down it, the selection kept in view;
98
+ * anything else says it does not turn, or the key would seem to do nothing. */
99
+ function turnGit(d, ctx) {
100
+ if (ctx.scene?.notation !== GIT_NOTATION)
101
+ return say(d, 'only a git graph turns across the screen');
102
+ const { horizontal, ...rest } = d;
103
+ const turned = horizontal === true ? rest : { ...rest, horizontal: true };
104
+ return relayout({ ...turned, scroll: { x: 0, y: 0 }, ...(d.selected !== undefined ? { follow: true } : {}) });
94
105
  }
95
106
  function toggleLayer(d, ctx, n) {
96
107
  const layer = ctx.model?.layers[n - 1];
@@ -218,6 +229,7 @@ const KEYS = {
218
229
  i: (d) => stay({ ...d, panel: !d.panel }),
219
230
  o: (d, ctx) => toggleOverview(d, ctx),
220
231
  L: (d, ctx) => toggleLegend(d, ctx),
232
+ H: (d, ctx) => turnGit(d, ctx),
221
233
  '?': (d) => stay({ ...d, help: !d.help }),
222
234
  s: (d, ctx) => ({ diagram: d, effects: [{ kind: 'relayout' }], style: otherStyle(ctx.style) }),
223
235
  r: (d) => ({ diagram: d, effects: [{ kind: 'reload' }] }),
@@ -29,6 +29,7 @@ const HELP = [
29
29
  ['i', 'details of the box'],
30
30
  ['o', 'overview on / off'],
31
31
  ['L', 'legend on / off'],
32
+ ['H', 'a git graph across / down'],
32
33
  ['s', 'DOS style on / off'],
33
34
  ['Shift-arrows, PgUp, PgDn', 'scroll'],
34
35
  ['Home, End, mouse wheel', 'scroll'],
@@ -47,6 +47,8 @@ export interface DiagramState {
47
47
  };
48
48
  /** scroll the selection into view once the layout it waits for arrives (`settle`) */
49
49
  follow?: boolean;
50
+ /** a git graph turned across the screen (`H`); absent = down it */
51
+ horizontal?: true;
50
52
  }
51
53
  export interface TuiState {
52
54
  screen: 'list' | 'diagram';
package/dist/tui/state.js CHANGED
@@ -29,6 +29,7 @@ export function sceneInput(state, model, overlay, style) {
29
29
  ...(state.plane !== undefined ? { plane: state.plane } : {}),
30
30
  ...(root !== undefined ? { root } : {}),
31
31
  ...(style !== undefined ? { style } : {}),
32
+ ...(state.horizontal === true ? { horizontal: true } : {}),
32
33
  };
33
34
  }
34
35
  /** `state` fitted to a new picture: a selection the picture no longer draws is gone,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagc/cli",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Author software-architecture diagrams as code, compile them to a validated model, edit them in a local studio, and publish pages and images.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "author": "Bogdan Frankovskyi",
@@ -45,7 +45,7 @@
45
45
  "fast-glob": "^3.3.0",
46
46
  "jiti": "^2.0.0",
47
47
  "playwright-core": "^1.62.0",
48
- "@diagc/core": "1.7.0"
48
+ "@diagc/core": "1.8.0"
49
49
  },
50
50
  "publishConfig": {
51
51
  "access": "public"