@diagc/cli 1.5.0 → 1.6.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.
Files changed (73) hide show
  1. package/assets/guide/index.md +1 -1
  2. package/assets/skill/SKILL.md +1 -1
  3. package/dist/cli/io.d.ts +5 -0
  4. package/dist/cli/io.js +4 -0
  5. package/dist/cli/parse.d.ts +7 -0
  6. package/dist/cli/parse.js +25 -0
  7. package/dist/cli/run.js +4 -0
  8. package/dist/cli.js +23 -1
  9. package/dist/commands/shared.d.ts +4 -0
  10. package/dist/commands/shared.js +13 -0
  11. package/dist/commands/show.d.ts +5 -0
  12. package/dist/commands/show.js +115 -0
  13. package/dist/commands/tui.d.ts +3 -0
  14. package/dist/commands/tui.js +36 -0
  15. package/dist/init.d.ts +1 -1
  16. package/dist/init.js +1 -1
  17. package/dist/text/accents.d.ts +9 -0
  18. package/dist/text/accents.js +83 -0
  19. package/dist/text/ansi.d.ts +28 -0
  20. package/dist/text/ansi.js +111 -0
  21. package/dist/text/braille.d.ts +28 -0
  22. package/dist/text/braille.js +58 -0
  23. package/dist/text/canvas.d.ts +65 -0
  24. package/dist/text/canvas.js +155 -0
  25. package/dist/text/content.d.ts +32 -0
  26. package/dist/text/content.js +90 -0
  27. package/dist/text/fish.d.ts +27 -0
  28. package/dist/text/fish.js +209 -0
  29. package/dist/text/folds.d.ts +14 -0
  30. package/dist/text/folds.js +45 -0
  31. package/dist/text/glyphs.d.ts +31 -0
  32. package/dist/text/glyphs.js +84 -0
  33. package/dist/text/layout.d.ts +61 -0
  34. package/dist/text/layout.js +334 -0
  35. package/dist/text/legend.d.ts +44 -0
  36. package/dist/text/legend.js +252 -0
  37. package/dist/text/paint.d.ts +25 -0
  38. package/dist/text/paint.js +208 -0
  39. package/dist/text/render.d.ts +11 -0
  40. package/dist/text/render.js +28 -0
  41. package/dist/text/scene.d.ts +40 -0
  42. package/dist/text/scene.js +50 -0
  43. package/dist/text/vocabulary.d.ts +37 -0
  44. package/dist/text/vocabulary.js +211 -0
  45. package/dist/text/width.d.ts +15 -0
  46. package/dist/text/width.js +181 -0
  47. package/dist/tui/actions.d.ts +10 -0
  48. package/dist/tui/actions.js +297 -0
  49. package/dist/tui/app.d.ts +31 -0
  50. package/dist/tui/app.js +389 -0
  51. package/dist/tui/details.d.ts +3 -0
  52. package/dist/tui/details.js +54 -0
  53. package/dist/tui/keys.d.ts +33 -0
  54. package/dist/tui/keys.js +113 -0
  55. package/dist/tui/kitty.d.ts +36 -0
  56. package/dist/tui/kitty.js +65 -0
  57. package/dist/tui/legend.d.ts +14 -0
  58. package/dist/tui/legend.js +18 -0
  59. package/dist/tui/nav.d.ts +25 -0
  60. package/dist/tui/nav.js +79 -0
  61. package/dist/tui/overview.d.ts +46 -0
  62. package/dist/tui/overview.js +115 -0
  63. package/dist/tui/pixels.d.ts +28 -0
  64. package/dist/tui/pixels.js +80 -0
  65. package/dist/tui/screen.d.ts +44 -0
  66. package/dist/tui/screen.js +335 -0
  67. package/dist/tui/state.d.ts +100 -0
  68. package/dist/tui/state.js +72 -0
  69. package/dist/tui/terminal.d.ts +21 -0
  70. package/dist/tui/terminal.js +53 -0
  71. package/dist/watch.d.ts +2 -0
  72. package/dist/watch.js +1 -0
  73. package/package.json +3 -2
@@ -0,0 +1,211 @@
1
+ import { GIT_NOTATION, GIT_STAGE_TYPE, isActivityChrome, isPlanRole, } from '@diagc/core/internal';
2
+ const box = (label, extra = {}) => ({
3
+ shape: 'box',
4
+ ...(label !== undefined ? { label } : {}),
5
+ ...extra,
6
+ });
7
+ const shaped = (shape, label, extra = {}) => ({
8
+ shape,
9
+ ...(label !== undefined ? { label } : {}),
10
+ ...extra,
11
+ });
12
+ const dashed = { dashed: true };
13
+ const open = { neverFolds: true };
14
+ /** One entry per type the renderer styles, in its order. */
15
+ export const TYPE_LOOKS = {
16
+ system: box(undefined, dashed),
17
+ platform: box(undefined, dashed),
18
+ service: box(),
19
+ database: shaped('cylinder'),
20
+ 'aws-rds': shaped('cylinder'),
21
+ table: shaped('cylinder'),
22
+ 'db-table': shaped('table'),
23
+ queue: shaped('rounded'),
24
+ infra: shaped('hexagon'),
25
+ person: shaped('rounded'),
26
+ team: shaped('rounded'),
27
+ comment: shaped('rounded'),
28
+ 'c4-person': box('[Person]'),
29
+ 'c4-person-external': box('[Person]'),
30
+ 'c4-system': box('[Software System]'),
31
+ 'c4-system-external': box('[Software System]'),
32
+ 'c4-enterprise-boundary': box('[Enterprise]', dashed),
33
+ 'c4-system-boundary': box('[System]', dashed),
34
+ 'c4-group': box('[Group]', dashed),
35
+ 'c4-container': box('[Container]'),
36
+ 'c4-container-external': box('[Container]'),
37
+ 'c4-container-web': box('[Container]'),
38
+ 'c4-container-spa': box('[Container]'),
39
+ 'c4-container-mobile': box('[Container]'),
40
+ 'c4-container-desktop': box('[Container]'),
41
+ 'c4-container-api': box('[Container]'),
42
+ 'c4-container-function': box('[Container]'),
43
+ 'c4-container-cli': box('[Container]'),
44
+ 'c4-container-db': shaped('cylinder', '[Container]'),
45
+ 'c4-container-blob': shaped('cylinder', '[Container]'),
46
+ 'c4-container-search': shaped('cylinder', '[Container]'),
47
+ 'c4-container-queue': shaped('rounded', '[Container]'),
48
+ 'c4-container-boundary': box('[Container]', dashed),
49
+ 'c4-component': box('[Component]'),
50
+ 'c4-component-external': box('[Component]'),
51
+ 'c4-component-db': shaped('cylinder', '[Component]'),
52
+ 'c4-component-queue': shaped('rounded', '[Component]'),
53
+ 'c4-deployment-node': box('[Deployment Node]', dashed),
54
+ 'c4-infrastructure-node': shaped('hexagon', '[Infrastructure Node]'),
55
+ 'c4-container-instance': box('[Container Instance]'),
56
+ 'c4-class': box('[Class]'),
57
+ 'c4-interface': box('[Interface]', dashed),
58
+ 'c4-enum': box('[Enumeration]'),
59
+ 'aws-group': box(''),
60
+ 'aws-account': box(''),
61
+ 'aws-cloud': box(''),
62
+ 'aws-vpc': box(''),
63
+ 'aws-region': box('', dashed),
64
+ 'aws-auto-scaling-group': box('', dashed),
65
+ 'aws-az': box('', dashed),
66
+ 'aws-subnet-public': box(''),
67
+ 'aws-subnet-private': box(''),
68
+ 'activity-frame': box(undefined, open),
69
+ 'activity-lane': box(undefined, open),
70
+ 'activity-region': box(undefined, { ...dashed, ...open, legend: 'Interruptible region' }),
71
+ 'activity-action': shaped('rounded', '', { legend: 'Action' }),
72
+ 'activity-decision': shaped('diamond', '', { legend: 'Decision / merge' }),
73
+ 'activity-bar': shaped('bar', '', { legend: 'Fork / join' }),
74
+ 'activity-start': shaped('dot', '', { legend: 'Start' }),
75
+ 'activity-end': shaped('dot', '', { legend: 'End' }),
76
+ 'activity-send': box('', { legend: 'Send signal' }),
77
+ 'activity-receive': box('', { legend: 'Receive signal' }),
78
+ 'activity-object': box('', { legend: 'Object' }),
79
+ 'activity-note': shaped('note', ''),
80
+ 'so-decision': shaped('rounded', ''),
81
+ 'so-consequence-positive': shaped('rounded', ''),
82
+ 'so-consequence-negative': shaped('rounded', ''),
83
+ 'so-consequence-neutral': shaped('rounded', ''),
84
+ 'fb-effect': box(''),
85
+ 'fb-category': box(''),
86
+ 'fb-cause': box(''),
87
+ 'deploy-environment': box('[Environment]', { legend: 'Environment' }),
88
+ 'deploy-region': box('[Region]', { legend: 'Region' }),
89
+ 'deploy-zone': box('[Availability zone]', { ...dashed, legend: 'Availability zone' }),
90
+ 'deploy-network': box('[Network]', { legend: 'Network' }),
91
+ 'deploy-subnet-public': box('[Public subnet]', { legend: 'Public subnet' }),
92
+ 'deploy-subnet-private': box('[Private subnet]', { legend: 'Private subnet' }),
93
+ 'deploy-cluster': box('[Cluster]', { ...dashed, legend: 'Cluster' }),
94
+ 'deploy-host': box('[Host]'),
95
+ 'deploy-service': shaped('rounded', '[Service]'),
96
+ 'deploy-database': shaped('cylinder', '[Database]'),
97
+ 'deploy-queue': shaped('rounded', '[Queue]'),
98
+ 'deploy-storage': shaped('cylinder', '[Storage]'),
99
+ 'deploy-load-balancer': shaped('hexagon', '[Load balancer]'),
100
+ 'deploy-gateway': shaped('hexagon', '[Gateway]'),
101
+ 'deploy-firewall': box('[Firewall]'),
102
+ 'deploy-internet': shaped('rounded', '[External network]', dashed),
103
+ 'tm-entity': box('', { legend: 'External entity' }),
104
+ 'tm-process': shaped('rounded', '', { legend: 'Process' }),
105
+ 'tm-store': shaped('cylinder', '', { legend: 'Data store' }),
106
+ 'tm-boundary': box('', { ...dashed, ...open, legend: 'Trust boundary' }),
107
+ 'plan-zone': shaped('rounded', '', { legend: 'Zone' }),
108
+ 'plan-event': shaped('diamond', '', { legend: 'Event' }),
109
+ };
110
+ const solid = { line: 'solid', end: 'arrow' };
111
+ /** One entry per kind the renderer styles, in its order. */
112
+ export const KIND_LOOKS = {
113
+ sync: solid,
114
+ async: { line: 'dashed', end: 'arrow' },
115
+ reads: solid,
116
+ writes: { line: 'heavy', end: 'arrow' },
117
+ 'hosted-on': { line: 'dashed', end: 'arrow' },
118
+ flow: solid,
119
+ mixed: { line: 'heavy', end: 'arrow' },
120
+ fk: { line: 'solid', end: 'one', start: 'many', legend: 'Foreign key: many to one' },
121
+ control: { ...solid, legend: 'Control flow' },
122
+ 'object-flow': { line: 'dashed', end: 'arrow', legend: 'Object flow' },
123
+ interrupt: { ...solid, legend: 'Interrupt' },
124
+ 'note-link': { line: 'dashed', end: 'none', legend: 'Note link' },
125
+ influence: solid,
126
+ network: solid,
127
+ 'leads-to': solid,
128
+ 'cause-of': solid,
129
+ 'data-flow': { ...solid, legend: 'Data flow' },
130
+ owns: { ...solid, legend: 'Owns' },
131
+ executes: { ...solid, legend: 'Executes' },
132
+ checks: { ...solid, legend: 'Checks' },
133
+ };
134
+ // What a notation's profile changes (packages/renderer/src/notations.ts). Not pinned
135
+ // by the test: the profiles are code, not tables, and these are the few looks a
136
+ // terminal can show — C4's person shape and colours, deployment's solid node, git's
137
+ // round commits and headless dashed links.
138
+ const C4_COLOURS = {
139
+ 'c4-person': '#08427b',
140
+ 'c4-person-external': '#999999',
141
+ 'c4-system': '#1168bd',
142
+ 'c4-system-external': '#999999',
143
+ 'c4-container-external': '#999999',
144
+ 'c4-component': '#85bbf0',
145
+ 'c4-component-db': '#85bbf0',
146
+ 'c4-component-queue': '#85bbf0',
147
+ 'c4-component-external': '#999999',
148
+ ...Object.fromEntries(['', '-web', '-spa', '-mobile', '-desktop', '-api', '-function', '-cli', '-db', '-blob', '-search', '-queue'].map((suffix) => [`c4-container${suffix}`, '#438dd5'])),
149
+ };
150
+ const NOTATION_TYPES = {
151
+ c4: Object.fromEntries(Object.entries(C4_COLOURS).map(([type, accent]) => [
152
+ type,
153
+ { ...TYPE_LOOKS[type], accent, ...(type.startsWith('c4-person') ? { shape: 'rounded' } : {}) },
154
+ ])),
155
+ deployment: { 'c4-deployment-node': box('[Deployment Node]') },
156
+ // a commit is a dot and a branch a lane in the browser: neither prints its type
157
+ [GIT_NOTATION]: { commit: shaped('dot', ''), branch: box('', open), [GIT_STAGE_TYPE]: box('') },
158
+ plan: { 'plan-zone': { ...TYPE_LOOKS['plan-zone'], ...open } },
159
+ };
160
+ const NOTATION_KINDS = {
161
+ [GIT_NOTATION]: {
162
+ commit: { line: 'dashed', end: 'none' },
163
+ branch: { line: 'dashed', end: 'none' },
164
+ merge: { line: 'dashed', end: 'none' },
165
+ },
166
+ };
167
+ export function typeLook(type, notation) {
168
+ if (type === undefined)
169
+ return { shape: 'box' };
170
+ const own = notation !== undefined ? NOTATION_TYPES[notation]?.[type] : undefined;
171
+ return own ?? TYPE_LOOKS[type] ?? { shape: 'box' };
172
+ }
173
+ export function kindLook(edge, notation) {
174
+ const own = notation !== undefined ? NOTATION_KINDS[notation]?.[edge.kind] : undefined;
175
+ const base = own ?? KIND_LOOKS[edge.kind] ?? solid;
176
+ const style = edge.style;
177
+ if (style === undefined)
178
+ return base;
179
+ const line = style.line === 'dashed' || style.line === 'dotted'
180
+ ? 'dashed'
181
+ : (style.width ?? 0) >= 2.5
182
+ ? 'heavy'
183
+ : style.line === 'solid'
184
+ ? 'solid'
185
+ : base.line;
186
+ return { ...base, line, ...(style.end !== undefined ? { end: style.end } : {}) };
187
+ }
188
+ /** Kinds a notation never draws as lines: a plan's roles become chips on the zone. */
189
+ export function hidesKind(kind, notation) {
190
+ return notation === 'plan' && isPlanRole(kind);
191
+ }
192
+ /** The renderer's `typeSubtitle`: `[Container]` + `Java` → `[Container: Java]`. An
193
+ * empty label stays empty, so a glyph type's technology cannot resurrect it. */
194
+ function typeSubtitle(label, technology) {
195
+ if (technology === undefined || label === '')
196
+ return label;
197
+ return label.endsWith(']') ? `${label.slice(0, -1)}: ${technology}]` : `${label}: ${technology}`;
198
+ }
199
+ /** The subtitle a box prints under its name, as the renderer prints it: the type's
200
+ * label, or the raw type id for a type without one; `''` for none. */
201
+ export function subtitleOf(node, notation) {
202
+ // The activity frame, lanes and regions are drawn as bodies of their own, which
203
+ // print the name alone; their registry entries carry no label only because they
204
+ // are never drawn as a plain box.
205
+ if (node.type === undefined || isActivityChrome(node.type))
206
+ return '';
207
+ return typeSubtitle(typeLook(node.type, notation).label ?? node.type, node.technology);
208
+ }
209
+ export function neverFolds(node, notation) {
210
+ return typeLook(node.type, notation).neverFolds === true;
211
+ }
@@ -0,0 +1,15 @@
1
+ /** A C0 or C1 control character, or DEL: a terminal acts on one (a line break, an
2
+ * escape) instead of drawing it. */
3
+ export declare const isControl: (cp: number) => boolean;
4
+ /** `text` with every control character a space: what a name, a label or a description
5
+ * may hold (a line break typed in the studio, a tab) and a terminal must not be sent. */
6
+ export declare function printable(text: string): string;
7
+ /** The cells one code point takes: 0 for a mark, a joiner or a control character. */
8
+ export declare function charWidth(cp: number): 0 | 1 | 2;
9
+ /** The cells `text` takes in a terminal. */
10
+ export declare function cellWidth(text: string): number;
11
+ /** `text` cut to `max` cells, ending in `ellipsis` (one cell) when anything was cut. */
12
+ export declare function fitCells(text: string, max: number, ellipsis?: string): string;
13
+ /** `text` wrapped at spaces into lines of at most `max` cells; a word wider than a
14
+ * line is split. Empty text is one empty line, so a box always has a title row. */
15
+ export declare function wrapCells(text: string, max: number): string[];
@@ -0,0 +1,181 @@
1
+ // How many terminal cells text takes. A box is drawn to the width of its name, so a
2
+ // name measured in characters instead of cells pushes the right border of every row
3
+ // that holds a wide character out of line with the rows that do not.
4
+ //
5
+ // Measured per code point, which is what a terminal does short of joining emoji
6
+ // sequences (a ZWJ sequence draws as one glyph on some terminals and as its parts on
7
+ // others; counting the parts keeps the frame wide enough on both).
8
+ // [first, last] code points drawn two cells wide: East Asian Wide and Fullwidth, and
9
+ // the emoji drawn in emoji presentation by default.
10
+ const WIDE = [
11
+ [0x1100, 0x115f],
12
+ [0x231a, 0x231b],
13
+ [0x2329, 0x232a],
14
+ [0x23e9, 0x23ec],
15
+ [0x23f0, 0x23f0],
16
+ [0x23f3, 0x23f3],
17
+ [0x25fd, 0x25fe],
18
+ [0x2614, 0x2615],
19
+ [0x2648, 0x2653],
20
+ [0x267f, 0x267f],
21
+ [0x2693, 0x2693],
22
+ [0x26a1, 0x26a1],
23
+ [0x26aa, 0x26ab],
24
+ [0x26bd, 0x26be],
25
+ [0x26c4, 0x26c5],
26
+ [0x26ce, 0x26ce],
27
+ [0x26d4, 0x26d4],
28
+ [0x26ea, 0x26ea],
29
+ [0x26f2, 0x26f3],
30
+ [0x26f5, 0x26f5],
31
+ [0x26fa, 0x26fa],
32
+ [0x26fd, 0x26fd],
33
+ [0x2705, 0x2705],
34
+ [0x270a, 0x270b],
35
+ [0x2728, 0x2728],
36
+ [0x274c, 0x274c],
37
+ [0x274e, 0x274e],
38
+ [0x2753, 0x2755],
39
+ [0x2757, 0x2757],
40
+ [0x2795, 0x2797],
41
+ [0x27b0, 0x27b0],
42
+ [0x27bf, 0x27bf],
43
+ [0x2b1b, 0x2b1c],
44
+ [0x2b50, 0x2b50],
45
+ [0x2b55, 0x2b55],
46
+ [0x2e80, 0x303e],
47
+ [0x3041, 0x33ff],
48
+ [0x3400, 0x4dbf],
49
+ [0x4e00, 0x9fff],
50
+ [0xa000, 0xa4cf],
51
+ [0xa960, 0xa97f],
52
+ [0xac00, 0xd7a3],
53
+ [0xf900, 0xfaff],
54
+ [0xfe10, 0xfe19],
55
+ [0xfe30, 0xfe6f],
56
+ [0xff00, 0xff60],
57
+ [0xffe0, 0xffe6],
58
+ [0x1f004, 0x1f004],
59
+ [0x1f0cf, 0x1f0cf],
60
+ [0x1f18e, 0x1f18e],
61
+ [0x1f191, 0x1f19a],
62
+ [0x1f200, 0x1f251],
63
+ [0x1f300, 0x1f64f],
64
+ [0x1f680, 0x1f6ff],
65
+ [0x1f7e0, 0x1f7eb],
66
+ [0x1f900, 0x1f9ff],
67
+ [0x1fa70, 0x1faff],
68
+ [0x20000, 0x3fffd],
69
+ ];
70
+ // [first, last] code points that take no cell of their own: combining marks, which
71
+ // draw over the character before them, and the invisible joiners and selectors.
72
+ const ZERO = [
73
+ [0x0300, 0x036f],
74
+ [0x0483, 0x0489],
75
+ [0x0591, 0x05bd],
76
+ [0x1ab0, 0x1aff],
77
+ [0x1dc0, 0x1dff],
78
+ [0x200b, 0x200f],
79
+ [0x2060, 0x2064],
80
+ [0x20d0, 0x20ff],
81
+ [0xfe00, 0xfe0f],
82
+ [0xfe20, 0xfe2f],
83
+ [0xfeff, 0xfeff],
84
+ [0xe0100, 0xe01ef],
85
+ ];
86
+ function inRanges(cp, ranges) {
87
+ // Binary search: both tables are sorted and disjoint.
88
+ let lo = 0;
89
+ let hi = ranges.length - 1;
90
+ while (lo <= hi) {
91
+ const mid = (lo + hi) >> 1;
92
+ const [first, last] = ranges[mid];
93
+ if (cp < first)
94
+ hi = mid - 1;
95
+ else if (cp > last)
96
+ lo = mid + 1;
97
+ else
98
+ return true;
99
+ }
100
+ return false;
101
+ }
102
+ /** A C0 or C1 control character, or DEL: a terminal acts on one (a line break, an
103
+ * escape) instead of drawing it. */
104
+ export const isControl = (cp) => cp < 0x20 || (cp >= 0x7f && cp < 0xa0);
105
+ /** `text` with every control character a space: what a name, a label or a description
106
+ * may hold (a line break typed in the studio, a tab) and a terminal must not be sent. */
107
+ export function printable(text) {
108
+ let out = '';
109
+ for (const ch of text)
110
+ out += isControl(ch.codePointAt(0)) ? ' ' : ch;
111
+ return out;
112
+ }
113
+ /** The cells one code point takes: 0 for a mark, a joiner or a control character. */
114
+ export function charWidth(cp) {
115
+ if (cp < 0x20 || (cp >= 0x7f && cp < 0xa0))
116
+ return 0;
117
+ if (inRanges(cp, ZERO))
118
+ return 0;
119
+ return inRanges(cp, WIDE) ? 2 : 1;
120
+ }
121
+ /** The cells `text` takes in a terminal. */
122
+ export function cellWidth(text) {
123
+ let width = 0;
124
+ for (const ch of text)
125
+ width += charWidth(ch.codePointAt(0));
126
+ return width;
127
+ }
128
+ /** `text` cut to `max` cells, ending in `ellipsis` (one cell) when anything was cut. */
129
+ export function fitCells(text, max, ellipsis = '…') {
130
+ if (cellWidth(text) <= max)
131
+ return text;
132
+ if (max <= 0)
133
+ return '';
134
+ let out = '';
135
+ let width = 0;
136
+ for (const ch of text) {
137
+ const w = charWidth(ch.codePointAt(0));
138
+ if (width + w > max - 1)
139
+ break;
140
+ out += ch;
141
+ width += w;
142
+ }
143
+ return `${out}${ellipsis}`;
144
+ }
145
+ /** A word wider than `max`, in pieces of at most `max` cells. */
146
+ function splitWord(word, max) {
147
+ const pieces = [];
148
+ let piece = '';
149
+ let width = 0;
150
+ for (const ch of word) {
151
+ const w = charWidth(ch.codePointAt(0));
152
+ if (width + w > max && piece !== '') {
153
+ pieces.push(piece);
154
+ piece = '';
155
+ width = 0;
156
+ }
157
+ piece += ch;
158
+ width += w;
159
+ }
160
+ pieces.push(piece);
161
+ return pieces;
162
+ }
163
+ /** `text` wrapped at spaces into lines of at most `max` cells; a word wider than a
164
+ * line is split. Empty text is one empty line, so a box always has a title row. */
165
+ export function wrapCells(text, max) {
166
+ const lines = [];
167
+ let line = '';
168
+ for (const word of text.split(' ').filter((w) => w !== '')) {
169
+ for (const piece of cellWidth(word) > max ? splitWord(word, max) : [word]) {
170
+ const joined = line === '' ? piece : `${line} ${piece}`;
171
+ if (cellWidth(joined) <= max)
172
+ line = joined;
173
+ else {
174
+ lines.push(line);
175
+ line = piece;
176
+ }
177
+ }
178
+ }
179
+ lines.push(line);
180
+ return lines;
181
+ }
@@ -0,0 +1,10 @@
1
+ import type { Key, Mouse } from './keys.js';
2
+ import { type Ctx, type DiagramState, type Effect } from './state.js';
3
+ export interface Step {
4
+ diagram: DiagramState;
5
+ effects: Effect[];
6
+ /** back to the list of diagrams */
7
+ toList?: boolean;
8
+ }
9
+ export declare function onKey(d: DiagramState, ctx: Ctx, key: Key): Step;
10
+ export declare function onMouse(d: DiagramState, ctx: Ctx, mouse: Mouse): Step;