@diagc/cli 1.6.0 → 1.7.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.
- package/README.md +8 -3
- package/dist/cli.js +1 -1
- package/dist/commands/tui.d.ts +1 -1
- package/dist/commands/tui.js +10 -2
- package/dist/text/ansi.js +11 -5
- package/dist/text/canvas.d.ts +9 -2
- package/dist/text/canvas.js +25 -7
- package/dist/text/dos.d.ts +69 -0
- package/dist/text/dos.js +93 -0
- package/dist/text/glyphs.d.ts +4 -3
- package/dist/text/glyphs.js +18 -2
- package/dist/text/layout.d.ts +10 -1
- package/dist/text/layout.js +10 -7
- package/dist/text/legend.js +17 -13
- package/dist/text/paint.d.ts +6 -4
- package/dist/text/paint.js +69 -17
- package/dist/text/scene.d.ts +4 -0
- package/dist/text/scene.js +10 -2
- package/dist/tui/actions.d.ts +5 -0
- package/dist/tui/actions.js +3 -0
- package/dist/tui/app.d.ts +3 -0
- package/dist/tui/app.js +18 -5
- package/dist/tui/nav.d.ts +16 -10
- package/dist/tui/nav.js +26 -4
- package/dist/tui/overview.d.ts +4 -2
- package/dist/tui/overview.js +38 -8
- package/dist/tui/screen.d.ts +10 -0
- package/dist/tui/screen.js +104 -23
- package/dist/tui/state.d.ts +12 -10
- package/dist/tui/state.js +12 -4
- package/package.json +2 -2
package/dist/tui/screen.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { serialize } from '../text/ansi.js';
|
|
2
|
+
import { BLACK, CYAN, DESKTOP, GREY, RED, SHADOW, SHADOW_REACH, WHITE } from '../text/dos.js';
|
|
2
3
|
import { UNICODE } from '../text/glyphs.js';
|
|
3
4
|
import { legendCells, legendSize } from '../text/legend.js';
|
|
4
5
|
import { subtitleOf } from '../text/vocabulary.js';
|
|
@@ -28,6 +29,7 @@ const HELP = [
|
|
|
28
29
|
['i', 'details of the box'],
|
|
29
30
|
['o', 'overview on / off'],
|
|
30
31
|
['L', 'legend on / off'],
|
|
32
|
+
['s', 'DOS style on / off'],
|
|
31
33
|
['Shift-arrows, PgUp, PgDn', 'scroll'],
|
|
32
34
|
['Home, End, mouse wheel', 'scroll'],
|
|
33
35
|
['click, double-click, drag', 'select, fold, pan'],
|
|
@@ -38,7 +40,40 @@ const HELP = [
|
|
|
38
40
|
];
|
|
39
41
|
const INVERSE = { inverse: true };
|
|
40
42
|
const DIM = { dim: true };
|
|
41
|
-
|
|
43
|
+
/** The terminal's own look: its colours, with inverse for the bars. */
|
|
44
|
+
const CLEAN = {
|
|
45
|
+
title: INVERSE,
|
|
46
|
+
status: {},
|
|
47
|
+
hint: DIM,
|
|
48
|
+
error: { fg: { ansi: 9 }, bold: true },
|
|
49
|
+
ground: {},
|
|
50
|
+
current: INVERSE,
|
|
51
|
+
panel: {},
|
|
52
|
+
rule: DIM,
|
|
53
|
+
dialog: {},
|
|
54
|
+
border: {},
|
|
55
|
+
frame: ['┌', '┐', '└', '┘', '─', '│'],
|
|
56
|
+
};
|
|
57
|
+
const BAR = { fg: BLACK, bg: GREY };
|
|
58
|
+
/** Turbo Vision's: a grey menu bar and status line over the blue desktop, the list's
|
|
59
|
+
* row and the panel a cyan window, the help a grey dialog in a double frame. */
|
|
60
|
+
const DOS = {
|
|
61
|
+
title: BAR,
|
|
62
|
+
status: BAR,
|
|
63
|
+
hint: BAR,
|
|
64
|
+
error: { ...BAR, fg: RED, bold: true },
|
|
65
|
+
ground: DESKTOP,
|
|
66
|
+
current: { fg: BLACK, bg: CYAN },
|
|
67
|
+
panel: { fg: BLACK, bg: CYAN },
|
|
68
|
+
rule: { fg: BLACK, bg: CYAN },
|
|
69
|
+
dialog: BAR,
|
|
70
|
+
border: { fg: WHITE, bg: GREY },
|
|
71
|
+
frame: ['╔', '╗', '╚', '╝', '═', '║'],
|
|
72
|
+
shadow: SHADOW,
|
|
73
|
+
ink: WHITE.rgb,
|
|
74
|
+
};
|
|
75
|
+
const chromeOf = (input) => (input.style === 'dos' ? DOS : CLEAN);
|
|
76
|
+
const blankRow = (columns, style = {}) => Array.from({ length: columns }, () => ({ ch: ' ', style }));
|
|
42
77
|
/** Before cell `i` is overwritten: if it is half of a wide character, blank the other
|
|
43
78
|
* half, so an overlay over a wide character never leaves the row a cell short or
|
|
44
79
|
* long. The canvas's `unwide`, for rows. */
|
|
@@ -129,6 +164,14 @@ function pictureShown(state, scene, size) {
|
|
|
129
164
|
export function overviewPlaceOf(state, scene, size) {
|
|
130
165
|
return pictureShown(state, scene, size) ? overviewPlace(scene.layout, canvasSize(state, size)) : undefined;
|
|
131
166
|
}
|
|
167
|
+
/** The canvas as the scroll reads it: its size, and the corner the overview's frame
|
|
168
|
+
* covers while it is on, which a selected box is kept out of and the scroll may run
|
|
169
|
+
* past the picture to uncover. `reduce` and `settle` read it. */
|
|
170
|
+
export function viewOf(state, scene, size) {
|
|
171
|
+
const canvas = canvasSize(state, size);
|
|
172
|
+
const place = state.diagram?.overview === true ? overviewPlaceOf(state, scene, size) : undefined;
|
|
173
|
+
return place === undefined ? canvas : { ...canvas, corner: { width: place.width + 2, height: place.height + 2 } };
|
|
174
|
+
}
|
|
132
175
|
/** Where the legend goes on this screen, its border included, whether or not it is on:
|
|
133
176
|
* kept off the overview while that is on. `reduce` reads the same, for clicks. */
|
|
134
177
|
export function legendPlaceOf(state, scene, size) {
|
|
@@ -160,7 +203,7 @@ export function overviewImage(state, input, size) {
|
|
|
160
203
|
const { width, height } = canvasSize(state, size);
|
|
161
204
|
const window = { scroll: d.scroll, width, height };
|
|
162
205
|
const pixels = overviewPixels(scene.layout, { ...place, cell: graphics.cell }, window, d.selected);
|
|
163
|
-
return { place, width: pixels.width, height: pixels.height, rgba: pixels.rgba(graphics.ink) };
|
|
206
|
+
return { place, width: pixels.width, height: pixels.height, rgba: pixels.rgba(chromeOf(input).ink ?? graphics.ink) };
|
|
164
207
|
}
|
|
165
208
|
function titleOf(d, model) {
|
|
166
209
|
if (model === undefined)
|
|
@@ -179,18 +222,20 @@ function titleOf(d, model) {
|
|
|
179
222
|
return parts.join(' · ');
|
|
180
223
|
}
|
|
181
224
|
function statusOf(d, input) {
|
|
225
|
+
const chrome = chromeOf(input);
|
|
182
226
|
if (d.search?.editing === true)
|
|
183
|
-
return [`/${d.search.query}_`,
|
|
227
|
+
return [`/${d.search.query}_`, chrome.status];
|
|
184
228
|
if (d.message !== undefined)
|
|
185
|
-
return [d.message.text, d.message.error ?
|
|
229
|
+
return [d.message.text, d.message.error ? chrome.error : chrome.status];
|
|
186
230
|
const node = d.selected === undefined ? undefined : input.model?.nodes.find((n) => n.id === d.selected);
|
|
187
231
|
if (node === undefined)
|
|
188
|
-
return ['arrows move · Enter fold · > go in · / search · i details · ? help · q quit',
|
|
232
|
+
return ['arrows move · Enter fold · > go in · / search · i details · ? help · q quit', chrome.hint];
|
|
189
233
|
const subtitle = printable(subtitleOf(node, input.scene?.notation));
|
|
190
234
|
const name = printable(node.name);
|
|
191
|
-
return [`${name}${subtitle === '' ? '' : ` ${subtitle}`} · Enter fold · i details · ? help`,
|
|
235
|
+
return [`${name}${subtitle === '' ? '' : ` ${subtitle}`} · Enter fold · i details · ? help`, chrome.status];
|
|
192
236
|
}
|
|
193
237
|
function drawPanel(rows, d, input, size) {
|
|
238
|
+
const { panel, rule } = chromeOf(input);
|
|
194
239
|
const beside = size.columns >= PANEL_MIN_COLUMNS;
|
|
195
240
|
const left = beside ? size.columns - PANEL_WIDTH : 0;
|
|
196
241
|
const width = beside ? PANEL_WIDTH - 3 : size.columns - 2;
|
|
@@ -200,12 +245,12 @@ function drawPanel(rows, d, input, size) {
|
|
|
200
245
|
for (let r = 1; r < size.rows - 1; r++) {
|
|
201
246
|
const row = rows[r];
|
|
202
247
|
for (let c = left; c < size.columns; c++)
|
|
203
|
-
row[c] = { ch: ' ', style:
|
|
248
|
+
row[c] = { ch: ' ', style: panel };
|
|
204
249
|
if (beside)
|
|
205
|
-
row[left] = { ch: '│', style:
|
|
250
|
+
row[left] = { ch: '│', style: rule };
|
|
206
251
|
const line = lines[r - 1];
|
|
207
252
|
if (line !== undefined)
|
|
208
|
-
write(row, left + (beside ? 2 : 1), line, { style: r === 1 ? { bold: true } :
|
|
253
|
+
write(row, left + (beside ? 2 : 1), line, { style: r === 1 ? { ...panel, bold: true } : panel });
|
|
209
254
|
}
|
|
210
255
|
}
|
|
211
256
|
/** The overview, opaque over the canvas, in a border a cell wide around `place`; blank
|
|
@@ -244,7 +289,22 @@ function drawLegend(rows, scene, place) {
|
|
|
244
289
|
cells.forEach((cell, c) => write(row, place.x + c, cell.ch, { style: cell.style }));
|
|
245
290
|
});
|
|
246
291
|
}
|
|
247
|
-
|
|
292
|
+
/** A dialog's shadow, where the chrome casts one: two columns right of `box` and a row
|
|
293
|
+
* below, as the DOS style's boxes cast theirs. */
|
|
294
|
+
function shade(rows, box, shadow) {
|
|
295
|
+
if (shadow === undefined)
|
|
296
|
+
return;
|
|
297
|
+
const [right, bottom] = [box.x + box.width, box.y + box.height];
|
|
298
|
+
for (let y = box.y + SHADOW_REACH.y; y < bottom + SHADOW_REACH.y; y++) {
|
|
299
|
+
const row = rows[y];
|
|
300
|
+
for (let x = box.x + SHADOW_REACH.x; x < right + SHADOW_REACH.x; x++) {
|
|
301
|
+
const cell = row?.[x];
|
|
302
|
+
if (cell !== undefined && (x >= right || y >= bottom))
|
|
303
|
+
row[x] = { ch: cell.ch, style: { ...cell.style, ...shadow } };
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
function drawHelp(rows, area, chrome) {
|
|
248
308
|
const keyWidth = Math.max(...HELP.map(([k]) => cellWidth(k)));
|
|
249
309
|
const lines = HELP.map(([k, what]) => `${k}${' '.repeat(keyWidth - cellWidth(k))} ${what}`);
|
|
250
310
|
const width = Math.min(area.width, Math.max(...lines.map(cellWidth)) + 4);
|
|
@@ -253,20 +313,37 @@ function drawHelp(rows, area) {
|
|
|
253
313
|
return;
|
|
254
314
|
const x = (area.width - width) >> 1;
|
|
255
315
|
const y = area.top + ((area.height - height) >> 1);
|
|
316
|
+
const [tl, tr, bl, br, across, down] = chrome.frame;
|
|
256
317
|
for (let r = 0; r < height; r++) {
|
|
257
318
|
const row = rows[y + r];
|
|
258
319
|
const edge = r === 0 || r === height - 1;
|
|
259
|
-
const [l,
|
|
260
|
-
write(row, x,
|
|
320
|
+
const [l, rt] = r === 0 ? [tl, tr] : r === height - 1 ? [bl, br] : [down, down];
|
|
321
|
+
write(row, x, l, { style: chrome.border });
|
|
322
|
+
write(row, x + 1, (edge ? across : ' ').repeat(width - 2), { style: edge ? chrome.border : chrome.dialog });
|
|
323
|
+
write(row, x + width - 1, rt, { style: chrome.border });
|
|
261
324
|
if (!edge)
|
|
262
|
-
write(row, x + 2, lines[r - 1] ?? '', { maxX: x + width - 1 });
|
|
325
|
+
write(row, x + 2, lines[r - 1] ?? '', { style: chrome.dialog, maxX: x + width - 1 });
|
|
326
|
+
}
|
|
327
|
+
write(rows[y], x + 2, ' Keys ', { style: { ...chrome.border, bold: true }, maxX: x + width - 1 });
|
|
328
|
+
shade(rows, { x, y, width, height }, chrome.shadow);
|
|
329
|
+
}
|
|
330
|
+
/** The canvas's cells that set no background of their own, laid on the chrome's ground:
|
|
331
|
+
* the picture's lies on it already, but not what lies over the picture. */
|
|
332
|
+
function onGround(rows, area, ground) {
|
|
333
|
+
if (ground.bg === undefined)
|
|
334
|
+
return;
|
|
335
|
+
for (const row of rows.slice(area.top, area.top + area.height)) {
|
|
336
|
+
row.forEach((cell, c) => {
|
|
337
|
+
if (cell.style.bg === undefined)
|
|
338
|
+
row[c] = { ch: cell.ch, style: { ...ground, ...cell.style } };
|
|
339
|
+
});
|
|
263
340
|
}
|
|
264
|
-
write(rows[y], x + 2, ' Keys ', { style: { bold: true }, maxX: x + width - 1 });
|
|
265
341
|
}
|
|
266
342
|
function composeDiagram(d, input, size, places) {
|
|
267
|
-
const
|
|
343
|
+
const chrome = chromeOf(input);
|
|
344
|
+
const rows = Array.from({ length: size.rows }, () => blankRow(size.columns, chrome.ground));
|
|
268
345
|
const area = places.canvas;
|
|
269
|
-
rows[0] = bar(size.columns, titleOf(d, input.model),
|
|
346
|
+
rows[0] = bar(size.columns, titleOf(d, input.model), chrome.title);
|
|
270
347
|
if (input.scene === undefined || input.canvas === undefined)
|
|
271
348
|
centred(rows, area, input.notice ?? 'Loading…');
|
|
272
349
|
else if (input.scene.layout.boxes.size === 0)
|
|
@@ -280,10 +357,11 @@ function composeDiagram(d, input, size, places) {
|
|
|
280
357
|
if (d.legend && places.legend !== undefined)
|
|
281
358
|
drawLegend(rows, input.scene, places.legend);
|
|
282
359
|
}
|
|
360
|
+
onGround(rows, area, chrome.ground);
|
|
283
361
|
if (d.panel && size.rows > 2)
|
|
284
362
|
drawPanel(rows, d, input, size);
|
|
285
363
|
if (d.help)
|
|
286
|
-
drawHelp(rows, area);
|
|
364
|
+
drawHelp(rows, area, chrome);
|
|
287
365
|
if (size.rows > 1) {
|
|
288
366
|
const [text, style] = statusOf(d, input);
|
|
289
367
|
rows[size.rows - 1] = bar(size.columns, fitCells(text, Math.max(0, size.columns - 2)), style);
|
|
@@ -291,9 +369,10 @@ function composeDiagram(d, input, size, places) {
|
|
|
291
369
|
return rows;
|
|
292
370
|
}
|
|
293
371
|
function composeList(state, input, size) {
|
|
294
|
-
const
|
|
372
|
+
const chrome = chromeOf(input);
|
|
373
|
+
const rows = Array.from({ length: size.rows }, () => blankRow(size.columns, chrome.ground));
|
|
295
374
|
const count = state.names.length;
|
|
296
|
-
rows[0] = bar(size.columns, `diagc · ${count} diagram${count === 1 ? '' : 's'}`,
|
|
375
|
+
rows[0] = bar(size.columns, `diagc · ${count} diagram${count === 1 ? '' : 's'}`, chrome.title);
|
|
297
376
|
const area = { top: 1, width: size.columns, height: Math.max(0, size.rows - 2) };
|
|
298
377
|
if (count === 0)
|
|
299
378
|
centred(rows, area, input.notice ?? 'No diagrams under .diagrams/src');
|
|
@@ -302,15 +381,17 @@ function composeList(state, input, size) {
|
|
|
302
381
|
for (let r = 0; r < area.height && first + r < count; r++) {
|
|
303
382
|
const current = first + r === state.index;
|
|
304
383
|
// the marker as well as the inverse bar: a terminal may show no attributes at all
|
|
305
|
-
const
|
|
384
|
+
const name = state.names[first + r];
|
|
385
|
+
const row = current ? bar(size.columns, `› ${name}`, chrome.current) : blankRow(size.columns, chrome.ground);
|
|
306
386
|
if (!current)
|
|
307
|
-
write(row, 3,
|
|
387
|
+
write(row, 3, name, { style: chrome.ground });
|
|
308
388
|
rows[area.top + r] = row;
|
|
309
389
|
}
|
|
390
|
+
onGround(rows, area, chrome.ground);
|
|
310
391
|
// with names to show, a notice is what the last pick ran into, said in the status row
|
|
311
392
|
const [status, style] = count > 0 && input.notice !== undefined
|
|
312
|
-
? [input.notice,
|
|
313
|
-
: ['Enter open · ↑↓ move · r reload · q quit',
|
|
393
|
+
? [input.notice, chrome.error]
|
|
394
|
+
: ['Enter open · ↑↓ move · s style · r reload · q quit', chrome.hint];
|
|
314
395
|
if (size.rows > 1)
|
|
315
396
|
rows[size.rows - 1] = bar(size.columns, fitCells(status, Math.max(0, size.columns - 2)), style);
|
|
316
397
|
return rows;
|
package/dist/tui/state.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type DiagramModel, type LayoutOverlay } from '@diagc/core/internal';
|
|
2
2
|
import type { CellPoint, CellRect } from '../text/canvas.js';
|
|
3
|
+
import type { TextStyle } from '../text/dos.js';
|
|
3
4
|
import { type Pins } from '../text/folds.js';
|
|
4
5
|
import type { SceneInput, Scene } from '../text/scene.js';
|
|
5
6
|
import type { UserInput } from './keys.js';
|
|
7
|
+
import { type View } from './nav.js';
|
|
6
8
|
import type { OverviewPlace } from './overview.js';
|
|
7
9
|
/** One open diagram, as the reader sees it. None of it is saved. */
|
|
8
10
|
export interface DiagramState {
|
|
@@ -53,6 +55,9 @@ export interface TuiState {
|
|
|
53
55
|
/** the list's current row */
|
|
54
56
|
index: number;
|
|
55
57
|
diagram?: DiagramState;
|
|
58
|
+
/** the style the reader picked, with `--style` or `s`, for every diagram; absent =
|
|
59
|
+
* each diagram's own */
|
|
60
|
+
style?: TextStyle;
|
|
56
61
|
}
|
|
57
62
|
/** What an event is read against: the open diagram's model and laid-out picture, the
|
|
58
63
|
* canvas's place on the screen, and when the event came (ms). */
|
|
@@ -60,16 +65,16 @@ export interface Ctx {
|
|
|
60
65
|
model?: DiagramModel;
|
|
61
66
|
overlay?: LayoutOverlay;
|
|
62
67
|
scene?: Scene;
|
|
63
|
-
/** the canvas: its first screen row
|
|
64
|
-
view: {
|
|
68
|
+
/** the canvas: its first screen row, its size and the overview's corner (`viewOf`) */
|
|
69
|
+
view: View & {
|
|
65
70
|
top: number;
|
|
66
|
-
width: number;
|
|
67
|
-
height: number;
|
|
68
71
|
};
|
|
69
72
|
/** where the overview goes on this screen, whether or not it is on */
|
|
70
73
|
overview?: OverviewPlace;
|
|
71
74
|
/** where the legend goes on this screen, its border included, whether or not it is on */
|
|
72
75
|
legend?: CellRect;
|
|
76
|
+
/** the style the diagram is drawn in; absent = the terminal's own */
|
|
77
|
+
style?: TextStyle;
|
|
73
78
|
at: number;
|
|
74
79
|
}
|
|
75
80
|
export type Effect = {
|
|
@@ -89,12 +94,9 @@ export interface Reduced {
|
|
|
89
94
|
/** A diagram as it opens, and as a plane switch reopens it: the plane's own layers and
|
|
90
95
|
* the folds its layout saved, as the published page opens it. */
|
|
91
96
|
export declare function openDiagram(name: string, model: DiagramModel, overlay: LayoutOverlay | undefined, plane?: string): DiagramState;
|
|
92
|
-
/** What to lay out for `state`. */
|
|
93
|
-
export declare function sceneInput(state: DiagramState, model: DiagramModel, overlay: LayoutOverlay | undefined): SceneInput;
|
|
97
|
+
/** What to lay out for `state`, in `style`. */
|
|
98
|
+
export declare function sceneInput(state: DiagramState, model: DiagramModel, overlay: LayoutOverlay | undefined, style?: TextStyle): SceneInput;
|
|
94
99
|
/** `state` fitted to a new picture: a selection the picture no longer draws is gone,
|
|
95
100
|
* one that asked to be followed is scrolled to, and the scroll stays on the picture. */
|
|
96
|
-
export declare function settle(state: DiagramState, scene: Scene, view:
|
|
97
|
-
width: number;
|
|
98
|
-
height: number;
|
|
99
|
-
}): DiagramState;
|
|
101
|
+
export declare function settle(state: DiagramState, scene: Scene, view: View): DiagramState;
|
|
100
102
|
export declare function reduce(state: TuiState, event: UserInput, ctx: Ctx): Reduced;
|
package/dist/tui/state.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { presetLayers } from '@diagc/core/internal';
|
|
2
2
|
import { readerPins } from '../text/folds.js';
|
|
3
|
-
import { onKey, onMouse } from './actions.js';
|
|
3
|
+
import { onKey, onMouse, otherStyle } from './actions.js';
|
|
4
4
|
import { clampScroll, follow } from './nav.js';
|
|
5
5
|
/** A diagram as it opens, and as a plane switch reopens it: the plane's own layers and
|
|
6
6
|
* the folds its layout saved, as the published page opens it. */
|
|
@@ -18,8 +18,8 @@ export function openDiagram(name, model, overlay, plane) {
|
|
|
18
18
|
legend: model.legend !== undefined,
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
/** What to lay out for `state`. */
|
|
22
|
-
export function sceneInput(state, model, overlay) {
|
|
21
|
+
/** What to lay out for `state`, in `style`. */
|
|
22
|
+
export function sceneInput(state, model, overlay, style) {
|
|
23
23
|
const root = state.path.at(-1);
|
|
24
24
|
return {
|
|
25
25
|
model,
|
|
@@ -28,6 +28,7 @@ export function sceneInput(state, model, overlay) {
|
|
|
28
28
|
...(overlay !== undefined ? { overlay } : {}),
|
|
29
29
|
...(state.plane !== undefined ? { plane: state.plane } : {}),
|
|
30
30
|
...(root !== undefined ? { root } : {}),
|
|
31
|
+
...(style !== undefined ? { style } : {}),
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
/** `state` fitted to a new picture: a selection the picture no longer draws is gone,
|
|
@@ -55,6 +56,8 @@ function reduceList(state, event) {
|
|
|
55
56
|
return stay(Math.min(last, state.index + 1));
|
|
56
57
|
if (event.name === 'r')
|
|
57
58
|
return { state, effects: [{ kind: 'reload' }] };
|
|
59
|
+
if (event.name === 's')
|
|
60
|
+
return { state: { ...state, style: otherStyle(state.style) }, effects: [] };
|
|
58
61
|
const name = state.names[state.index];
|
|
59
62
|
if (event.name === 'enter' && name !== undefined)
|
|
60
63
|
return { state, effects: [{ kind: 'open', name }] };
|
|
@@ -66,7 +69,12 @@ export function reduce(state, event, ctx) {
|
|
|
66
69
|
const { message: _cleared, ...diagram } = state.diagram;
|
|
67
70
|
const step = event.kind === 'mouse' ? onMouse(diagram, ctx, event) : onKey(diagram, ctx, event);
|
|
68
71
|
return {
|
|
69
|
-
state: {
|
|
72
|
+
state: {
|
|
73
|
+
...state,
|
|
74
|
+
diagram: step.diagram,
|
|
75
|
+
...(step.toList === true ? { screen: 'list' } : {}),
|
|
76
|
+
...(step.style !== undefined ? { style: step.style } : {}),
|
|
77
|
+
},
|
|
70
78
|
effects: step.effects,
|
|
71
79
|
};
|
|
72
80
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diagc/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.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.
|
|
48
|
+
"@diagc/core": "1.7.0"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|