@phnx-labs/artifacts-cli 0.20.0 → 0.21.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/CHANGELOG.md +13 -0
- package/dist/lib/cards.d.ts +2 -2
- package/dist/lib/cards.js +55 -9
- package/dist/lib/cards.js.map +1 -1
- package/dist/lib/charts.d.ts +44 -1
- package/dist/lib/charts.js +165 -37
- package/dist/lib/charts.js.map +1 -1
- package/dist/lib/components.d.ts +19 -0
- package/dist/lib/components.js +15 -2
- package/dist/lib/components.js.map +1 -1
- package/dist/lib/diagram.d.ts +33 -0
- package/dist/lib/diagram.js +238 -0
- package/dist/lib/diagram.js.map +1 -0
- package/dist/lib/embedded-html.d.ts +1 -1
- package/dist/lib/embedded-html.js +5 -0
- package/dist/lib/embedded-html.js.map +1 -1
- package/dist/lib/links.d.ts +23 -0
- package/dist/lib/links.js +125 -0
- package/dist/lib/links.js.map +1 -1
- package/dist/lib/render.js +57 -23
- package/dist/lib/render.js.map +1 -1
- package/dist/lib/templates.js +23 -11
- package/dist/lib/templates.js.map +1 -1
- package/dist/lib/top-band.d.ts +17 -0
- package/dist/lib/top-band.js +81 -0
- package/dist/lib/top-band.js.map +1 -0
- package/dist/lib/validate.js +93 -6
- package/dist/lib/validate.js.map +1 -1
- package/package.json +2 -1
package/dist/lib/charts.js
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import { escapeHtml } from './html.js';
|
|
2
|
-
const
|
|
3
|
-
const LABEL_WIDTH = 180;
|
|
4
|
-
const VALUE_WIDTH = 88;
|
|
5
|
-
const PLOT_X = 196;
|
|
6
|
-
const PLOT_WIDTH = CHART_WIDTH - PLOT_X - VALUE_WIDTH;
|
|
7
|
-
const ROW_HEIGHT = 42;
|
|
8
|
-
const CHART_TOP = 42;
|
|
9
|
-
const CHART_BOTTOM = 18;
|
|
2
|
+
const CHART_FENCES = ['bar-chart', 'waterfall', 'line-chart'];
|
|
10
3
|
/** Keep chart fence recognition identical anywhere Markdown tokens are consumed. */
|
|
11
|
-
export function
|
|
12
|
-
|
|
4
|
+
export function chartFenceName(info) {
|
|
5
|
+
const name = info.trim().split(/\s+/)[0];
|
|
6
|
+
return CHART_FENCES.includes(name) ? name : undefined;
|
|
13
7
|
}
|
|
14
8
|
function tableCells(line) {
|
|
15
9
|
const trimmed = line.trim().replace(/^\|/, '').replace(/\|$/, '');
|
|
16
|
-
const escapedPipe = '
|
|
10
|
+
const escapedPipe = '';
|
|
17
11
|
return trimmed
|
|
18
12
|
.replace(/\\\|/g, escapedPipe)
|
|
19
13
|
.split('|')
|
|
@@ -22,55 +16,189 @@ function tableCells(line) {
|
|
|
22
16
|
function isDivider(cells) {
|
|
23
17
|
return cells.length >= 2 && cells.every((cell) => /^:?-{3,}:?$/.test(cell));
|
|
24
18
|
}
|
|
25
|
-
function numericValue(value) {
|
|
26
|
-
const normalized = value.replace(/,/g, '').replace(/^[$£€¥]/, '').replace(/%$/, '').trim();
|
|
27
|
-
|
|
19
|
+
function numericValue(value, signed = false) {
|
|
20
|
+
const normalized = value.replace(/,/g, '').replace(/^([+−-]?)[$£€¥]/, '$1').replace(/%$/, '').replace('−', '-').trim();
|
|
21
|
+
const pattern = signed ? /^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/ : /^(?:\d+(?:\.\d+)?|\.\d+)$/;
|
|
22
|
+
if (!pattern.test(normalized))
|
|
28
23
|
return undefined;
|
|
29
24
|
const parsed = Number(normalized);
|
|
30
25
|
return Number.isFinite(parsed) ? parsed : undefined;
|
|
31
26
|
}
|
|
32
|
-
/**
|
|
33
|
-
|
|
27
|
+
/** A Markdown table's header and rows, or undefined when it is not one. */
|
|
28
|
+
function parseTable(source) {
|
|
34
29
|
const lines = source.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
35
30
|
if (lines.length < 3)
|
|
36
31
|
return undefined;
|
|
37
32
|
const header = tableCells(lines[0]);
|
|
38
33
|
const divider = tableCells(lines[1]);
|
|
39
|
-
if (header.length
|
|
34
|
+
if (header.length < 2 || divider.length !== header.length || !isDivider(divider) || header.some((cell) => !cell))
|
|
35
|
+
return undefined;
|
|
36
|
+
const rows = lines.slice(2).map(tableCells);
|
|
37
|
+
if (rows.some((row) => row.length !== header.length))
|
|
38
|
+
return undefined;
|
|
39
|
+
return { header, rows };
|
|
40
|
+
}
|
|
41
|
+
/** Parse a two-column Markdown table supplied by a `bar-chart` fence. */
|
|
42
|
+
export function parseBarChartTable(source) {
|
|
43
|
+
const table = parseTable(source);
|
|
44
|
+
if (!table || table.header.length !== 2)
|
|
40
45
|
return undefined;
|
|
41
|
-
}
|
|
42
46
|
const rows = [];
|
|
43
|
-
for (const
|
|
44
|
-
|
|
45
|
-
if (cells.length !== 2 || !cells[0] || !cells[1])
|
|
47
|
+
for (const [label, display] of table.rows) {
|
|
48
|
+
if (!label || !display)
|
|
46
49
|
return undefined;
|
|
47
|
-
const value = numericValue(
|
|
50
|
+
const value = numericValue(display);
|
|
48
51
|
if (value === undefined)
|
|
49
52
|
return undefined;
|
|
50
|
-
rows.push({ label
|
|
53
|
+
rows.push({ label, value, displayValue: display });
|
|
51
54
|
}
|
|
52
55
|
if (rows.length === 0)
|
|
53
56
|
return undefined;
|
|
54
|
-
return { labelHeading: header[0], valueHeading: header[1], rows };
|
|
57
|
+
return { labelHeading: table.header[0], valueHeading: table.header[1], rows };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A `waterfall` table: the first row is the starting amount, each later row a
|
|
61
|
+
* signed change, and a row whose label starts with `=` is a running total the
|
|
62
|
+
* renderer computes (its value cell stays empty).
|
|
63
|
+
*/
|
|
64
|
+
export function parseWaterfallTable(source) {
|
|
65
|
+
const table = parseTable(source);
|
|
66
|
+
if (!table || table.header.length !== 2 || table.rows.length < 2)
|
|
67
|
+
return undefined;
|
|
68
|
+
const currency = table.rows[0][1].match(/^[$£€¥]/)?.[0] ?? '';
|
|
69
|
+
const format = (value) => `${value < 0 ? '−' : ''}${currency}${Math.abs(value).toLocaleString('en-US', { maximumFractionDigits: 2 })}`;
|
|
70
|
+
const steps = [];
|
|
71
|
+
let running = 0;
|
|
72
|
+
for (const [index, [label, display]] of table.rows.entries()) {
|
|
73
|
+
if (!label)
|
|
74
|
+
return undefined;
|
|
75
|
+
if (label.startsWith('=')) {
|
|
76
|
+
if (index === 0 || display)
|
|
77
|
+
return undefined;
|
|
78
|
+
steps.push({ label: label.slice(1).trim(), start: 0, end: running, kind: 'total', display: format(running) });
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const value = numericValue(display, index > 0);
|
|
82
|
+
if (value === undefined)
|
|
83
|
+
return undefined;
|
|
84
|
+
if (index === 0) {
|
|
85
|
+
running = value;
|
|
86
|
+
steps.push({ label, start: 0, end: value, kind: 'base', display });
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
steps.push({ label, start: running, end: running + value, kind: value < 0 ? 'down' : 'up', display: `${value > 0 ? '+' : ''}${display.replace(/^\+/, '')}` });
|
|
90
|
+
running += value;
|
|
91
|
+
}
|
|
92
|
+
return { labelHeading: table.header[0], valueHeading: table.header[1], steps };
|
|
93
|
+
}
|
|
94
|
+
/** A `line-chart` table: the first column is the x axis, every other column a series. */
|
|
95
|
+
export function parseLineChartTable(source) {
|
|
96
|
+
const table = parseTable(source);
|
|
97
|
+
if (!table || table.rows.length < 2 || table.header.length > 6)
|
|
98
|
+
return undefined;
|
|
99
|
+
const series = table.header.slice(1).map((name, column) => ({ name, values: table.rows.map((row) => numericValue(row[column + 1], true)) }));
|
|
100
|
+
if (series.some((line) => line.values.some((value) => value === undefined)))
|
|
101
|
+
return undefined;
|
|
102
|
+
return { x: table.header[0], xs: table.rows.map((row) => row[0]), series: series };
|
|
103
|
+
}
|
|
104
|
+
/** A bar segment from `from`% to `to`% of its track, as a stretched SVG mark. */
|
|
105
|
+
function mark(from, to, fill) {
|
|
106
|
+
const x = Math.max(0, Math.min(from, to));
|
|
107
|
+
const width = Math.max(Math.abs(to - from), to === from ? 0 : 0.6);
|
|
108
|
+
return `<svg class="chart-mark" viewBox="0 0 100 10" preserveAspectRatio="none" aria-hidden="true"><rect x="${x.toFixed(2)}" y="0" width="${width.toFixed(2)}" height="10" fill="${fill}"/></svg>`;
|
|
109
|
+
}
|
|
110
|
+
function chartFigure(name, label, head, rows) {
|
|
111
|
+
return `<figure class="artifact-figure artifact-chart artifact-chart-${name}" aria-label="${escapeHtml(label)}">${head}<div class="chart-rows">${rows}</div></figure>`;
|
|
112
|
+
}
|
|
113
|
+
function invalid(name, source) {
|
|
114
|
+
return `<pre><code class="language-${name}">${escapeHtml(source)}</code></pre>`;
|
|
55
115
|
}
|
|
56
116
|
/** Render a fenced Markdown data table as a theme-aware horizontal bar chart. */
|
|
57
117
|
export function renderBarChart(source) {
|
|
58
118
|
const chart = parseBarChartTable(source);
|
|
59
119
|
if (!chart)
|
|
60
|
-
return
|
|
61
|
-
const height = CHART_TOP + chart.rows.length * ROW_HEIGHT + CHART_BOTTOM;
|
|
120
|
+
return invalid('bar-chart', source);
|
|
62
121
|
const maximum = Math.max(...chart.rows.map((row) => row.value));
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
122
|
+
const label = `${chart.valueHeading} by ${chart.labelHeading}: ${chart.rows.map((row) => `${row.label} ${row.displayValue}`).join(', ')}`;
|
|
123
|
+
const head = `<div class="chart-head"><span>${escapeHtml(chart.labelHeading)}</span><span>${escapeHtml(chart.valueHeading)}</span></div>`;
|
|
124
|
+
const rows = chart.rows.map((row) => `<div class="chart-row"><span class="chart-label">${escapeHtml(row.label)}</span><span class="chart-track">${mark(0, maximum === 0 ? 0 : (row.value / maximum) * 100, 'var(--artifact-accent)')}</span><span class="chart-value">${escapeHtml(row.displayValue)}</span></div>`).join('');
|
|
125
|
+
return chartFigure('bar', label, head, rows);
|
|
126
|
+
}
|
|
127
|
+
export function renderWaterfall(source) {
|
|
128
|
+
const chart = parseWaterfallTable(source);
|
|
129
|
+
if (!chart)
|
|
130
|
+
return invalid('waterfall', source);
|
|
131
|
+
const values = chart.steps.flatMap((step) => [step.start, step.end]);
|
|
132
|
+
const low = Math.min(0, ...values);
|
|
133
|
+
const high = Math.max(0, ...values);
|
|
134
|
+
const span = high - low || 1;
|
|
135
|
+
const at = (value) => ((value - low) / span) * 100;
|
|
136
|
+
const fill = { base: 'var(--accent-alt)', up: 'var(--artifact-accent)', down: 'var(--danger)', total: 'var(--artifact-accent)' };
|
|
137
|
+
const label = `${chart.valueHeading} by ${chart.labelHeading}: ${chart.steps.map((step) => `${step.label} ${step.display}`).join(', ')}`;
|
|
138
|
+
const head = `<div class="chart-head"><span>${escapeHtml(chart.labelHeading)}</span><span>${escapeHtml(chart.valueHeading)}</span></div>`;
|
|
139
|
+
const rows = chart.steps.map((step) => `<div class="chart-row chart-${step.kind}"><span class="chart-label">${escapeHtml(step.label)}</span><span class="chart-track">${mark(at(step.start), at(step.end), fill[step.kind])}</span><span class="chart-value">${escapeHtml(step.display)}</span></div>`).join('');
|
|
140
|
+
return chartFigure('waterfall', label, head, rows);
|
|
141
|
+
}
|
|
142
|
+
const SERIES_COLORS = ['var(--artifact-accent)', 'var(--accent-alt)', 'var(--warn)', 'var(--danger)', 'var(--muted)'];
|
|
143
|
+
export function renderLineChart(source) {
|
|
144
|
+
const chart = parseLineChartTable(source);
|
|
145
|
+
if (!chart)
|
|
146
|
+
return invalid('line-chart', source);
|
|
147
|
+
const all = chart.series.flatMap((line) => line.values);
|
|
148
|
+
const low = Math.min(0, ...all);
|
|
149
|
+
const high = Math.max(...all);
|
|
150
|
+
const span = high - low || 1;
|
|
151
|
+
const count = chart.xs.length;
|
|
152
|
+
const lines = chart.series.map((line, index) => {
|
|
153
|
+
const points = line.values.map((value, at) => `${((at / (count - 1)) * 100).toFixed(2)},${(40 - ((value - low) / span) * 40).toFixed(2)}`).join(' ');
|
|
154
|
+
return `<polyline points="${points}" fill="none" stroke="${SERIES_COLORS[index]}" stroke-width="2.5" stroke-linejoin="round" vector-effect="non-scaling-stroke"/>`;
|
|
73
155
|
}).join('');
|
|
74
|
-
|
|
156
|
+
const grid = [0, 10, 20, 30, 40].map((y) => `<line x1="0" y1="${y}" x2="100" y2="${y}" stroke="var(--line)" stroke-width="1" vector-effect="non-scaling-stroke"/>`).join('');
|
|
157
|
+
const format = (value) => value.toLocaleString('en-US', { maximumFractionDigits: 2 });
|
|
158
|
+
const ticks = [chart.xs[0], count > 2 ? chart.xs[Math.floor((count - 1) / 2)] : '', chart.xs[count - 1]];
|
|
159
|
+
const legend = chart.series.map((line, index) => `<span class="chart-key"><span class="chart-swatch" aria-hidden="true">${mark(0, 100, SERIES_COLORS[index])}</span>${escapeHtml(line.name)} <b>${escapeHtml(format(line.values[count - 1]))}</b></span>`).join('');
|
|
160
|
+
const label = `${chart.series.map((line) => `${line.name}: ${line.values.map(format).join(', ')}`).join('; ')} over ${chart.x} from ${chart.xs[0]} to ${chart.xs[count - 1]}`;
|
|
161
|
+
return `<figure class="artifact-figure artifact-chart artifact-chart-line" aria-label="${escapeHtml(label)}"><div class="chart-legend">${legend}</div><div class="chart-plot"><span class="chart-y chart-y-high">${escapeHtml(format(high))}</span><span class="chart-y chart-y-low">${escapeHtml(format(low))}</span><svg class="chart-lines" viewBox="0 0 100 40" preserveAspectRatio="none" aria-hidden="true">${grid}${lines}</svg></div><div class="chart-x">${ticks.map((tick) => `<span>${escapeHtml(tick)}</span>`).join('')}</div></figure>`;
|
|
162
|
+
}
|
|
163
|
+
export function renderChart(info, source) {
|
|
164
|
+
const name = chartFenceName(info);
|
|
165
|
+
if (name === 'bar-chart')
|
|
166
|
+
return renderBarChart(source);
|
|
167
|
+
if (name === 'waterfall')
|
|
168
|
+
return renderWaterfall(source);
|
|
169
|
+
if (name === 'line-chart')
|
|
170
|
+
return renderLineChart(source);
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
/** True when the fence holds a table its chart can draw. */
|
|
174
|
+
export function isValidChart(info, source) {
|
|
175
|
+
const name = chartFenceName(info);
|
|
176
|
+
if (name === 'bar-chart')
|
|
177
|
+
return parseBarChartTable(source) !== undefined;
|
|
178
|
+
if (name === 'waterfall')
|
|
179
|
+
return parseWaterfallTable(source) !== undefined;
|
|
180
|
+
if (name === 'line-chart')
|
|
181
|
+
return parseLineChartTable(source) !== undefined;
|
|
182
|
+
return false;
|
|
75
183
|
}
|
|
184
|
+
export const CHART_CLASSES = ['artifact-chart', 'artifact-chart-bar', 'artifact-chart-waterfall', 'artifact-chart-line', 'chart-head', 'chart-rows', 'chart-row', 'chart-label', 'chart-track', 'chart-mark', 'chart-value', 'chart-base', 'chart-up', 'chart-down', 'chart-total', 'chart-legend', 'chart-key', 'chart-swatch', 'chart-plot', 'chart-y', 'chart-y-high', 'chart-y-low', 'chart-lines', 'chart-x'];
|
|
185
|
+
export const CHART_CSS = '.artifact-chart{overflow:visible}' +
|
|
186
|
+
'.chart-head{display:flex;justify-content:space-between;gap:12px;margin-bottom:8px;color:var(--muted);font-family:var(--font-mono);font-size:11.5px;font-weight:600;letter-spacing:.06em;text-transform:uppercase}' +
|
|
187
|
+
'.chart-rows{display:grid;gap:8px}' +
|
|
188
|
+
'.chart-row{display:grid;grid-template-columns:minmax(90px,30%) minmax(0,1fr) auto;align-items:center;gap:12px}' +
|
|
189
|
+
'.chart-label{min-width:0;color:var(--text);font-size:14px;line-height:1.35;overflow-wrap:anywhere}' +
|
|
190
|
+
'.chart-track{display:block;min-width:0;border-bottom:1px solid color-mix(in srgb,var(--muted) 22%,transparent)}' +
|
|
191
|
+
'.chart-mark{display:block;width:100%;height:20px;max-width:none}' +
|
|
192
|
+
'.chart-value{min-width:3.5ch;color:var(--text);font-family:var(--font-mono);font-size:13px;font-weight:600;text-align:right;white-space:nowrap}' +
|
|
193
|
+
'.chart-total .chart-label,.chart-base .chart-label{font-weight:600}' +
|
|
194
|
+
'.chart-down .chart-value{color:var(--danger)}' +
|
|
195
|
+
'.chart-legend{display:flex;flex-wrap:wrap;gap:6px 18px;margin-bottom:10px;font-size:13px;color:var(--muted)}' +
|
|
196
|
+
'.chart-key{display:inline-flex;align-items:center;gap:6px}.chart-key b{color:var(--text);font-family:var(--font-mono);font-weight:600}' +
|
|
197
|
+
'.chart-swatch{display:inline-block;width:14px}.chart-swatch .chart-mark{height:4px}' +
|
|
198
|
+
'.chart-plot{position:relative;padding-left:52px}' +
|
|
199
|
+
'.chart-lines{display:block;width:100%;height:180px;max-width:none}' +
|
|
200
|
+
'.chart-y{position:absolute;left:0;width:46px;color:var(--muted);font-family:var(--font-mono);font-size:12px;text-align:right}' +
|
|
201
|
+
'.chart-y-high{top:-7px}.chart-y-low{bottom:-7px}' +
|
|
202
|
+
'.chart-x{display:flex;justify-content:space-between;gap:8px;margin:8px 0 0 52px;color:var(--muted);font-family:var(--font-mono);font-size:12px}' +
|
|
203
|
+
'@media(max-width:520px){.chart-row{grid-template-columns:minmax(0,1fr) auto;row-gap:2px}.chart-label{grid-column:1 / -1}.chart-lines{height:140px}}';
|
|
76
204
|
//# sourceMappingURL=charts.js.map
|
package/dist/lib/charts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"charts.js","sourceRoot":"","sources":["../../src/lib/charts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAcvC,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,MAAM,GAAG,GAAG,CAAC;AACnB,MAAM,UAAU,GAAG,WAAW,GAAG,MAAM,GAAG,WAAW,CAAC;AACtD,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB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AAC,KAAK,SAAS,CAAC;IAC5E,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;AAEnZ,MAAM,CAAC,MAAM,SAAS,GACpB,mCAAmC;IACnC,mNAAmN;IACnN,mCAAmC;IACnC,gHAAgH;IAChH,oGAAoG;IACpG,iHAAiH;IACjH,kEAAkE;IAClE,iJAAiJ;IACjJ,qEAAqE;IACrE,+CAA+C;IAC/C,8GAA8G;IAC9G,wIAAwI;IACxI,qFAAqF;IACrF,kDAAkD;IAClD,oEAAoE;IACpE,+HAA+H;IAC/H,kDAAkD;IAClD,iJAAiJ;IACjJ,qJAAqJ,CAAC"}
|
package/dist/lib/components.d.ts
CHANGED
|
@@ -171,6 +171,25 @@ export declare const COMPONENTS: ({
|
|
|
171
171
|
items: string;
|
|
172
172
|
sources: string;
|
|
173
173
|
text: string;
|
|
174
|
+
box?: undefined;
|
|
175
|
+
edge?: undefined;
|
|
176
|
+
options?: undefined;
|
|
177
|
+
};
|
|
178
|
+
example: string;
|
|
179
|
+
} | {
|
|
180
|
+
name: string;
|
|
181
|
+
purpose: string;
|
|
182
|
+
format: string;
|
|
183
|
+
fields: {
|
|
184
|
+
box: string;
|
|
185
|
+
edge: string;
|
|
186
|
+
options: string;
|
|
187
|
+
title?: undefined;
|
|
188
|
+
description?: undefined;
|
|
189
|
+
metric?: undefined;
|
|
190
|
+
items?: undefined;
|
|
191
|
+
sources?: undefined;
|
|
192
|
+
text?: undefined;
|
|
174
193
|
};
|
|
175
194
|
example: string;
|
|
176
195
|
} | {
|
package/dist/lib/components.js
CHANGED
|
@@ -4,7 +4,7 @@ import { CARD_COMPONENTS } from './cards.js';
|
|
|
4
4
|
export const COMPONENTS = [
|
|
5
5
|
{
|
|
6
6
|
name: 'explorer',
|
|
7
|
-
purpose: '
|
|
7
|
+
purpose: 'Rows a reader opens to inspect details and sources: services, modules, findings or stages. Every closed row still reads as a summary. For a flat list, use a list or a status list instead.',
|
|
8
8
|
format: 'JSON',
|
|
9
9
|
fields: {
|
|
10
10
|
title: 'Required text', description: 'Optional introductory text',
|
|
@@ -15,7 +15,20 @@ export const COMPONENTS = [
|
|
|
15
15
|
},
|
|
16
16
|
example: JSON.stringify(EXPLORER_EXAMPLE, null, 2),
|
|
17
17
|
},
|
|
18
|
-
{
|
|
18
|
+
{
|
|
19
|
+
name: 'diagram',
|
|
20
|
+
purpose: 'A system, flow or dependency drawn as boxes and arrows. You write the graph; the renderer lays it out, keeps text readable and stacks it for phones. Use it instead of hand-placed SVG.',
|
|
21
|
+
format: 'one line per box or edge',
|
|
22
|
+
fields: {
|
|
23
|
+
box: 'id: Title | detail | detail. A trailing * on the id (worker*:) highlights the box the figure is about.',
|
|
24
|
+
edge: 'a -> b : label, a <-> b for both ways, a -- b for no arrow. An id used only in an edge becomes a box titled with the id.',
|
|
25
|
+
options: 'Fence options: title="Caption" and direction=LR or direction=TB (default: whichever fits the column).',
|
|
26
|
+
},
|
|
27
|
+
example: '```diagram title="How a share is listed"\nconsole: Console | Artifacts tab sorts in browser\nworker*: share Worker | GET /__mine: 25 keys by slug\napi: rush/api | No list route\nconsole -> worker : list\nworker -> api : PUT on publish\n```',
|
|
28
|
+
},
|
|
29
|
+
{ name: 'bar-chart', purpose: 'Compare non-negative values across categories. Labels wrap at full size on a phone.', format: 'two-column Markdown table', example: '| Service | Lines |\n| --- | ---: |\n| Web | 8000 |\n| API | 5000 |' },
|
|
30
|
+
{ name: 'waterfall', purpose: 'How a starting amount becomes a result through increases and decreases. Totals are computed, so the steps always add up.', format: 'two-column Markdown table: a starting row, signed changes, and "= Label" rows with an empty value for totals', example: '| Step | Lines |\n| --- | ---: |\n| Today | 46,500 |\n| Remove arctic | -1,500 |\n| Remove drizzle | -3,100 |\n| = Target | |' },
|
|
31
|
+
{ name: 'line-chart', purpose: 'A trend over time for up to five series, with the latest value of each in the legend.', format: 'Markdown table: the first column is the x axis, each other column a numeric series', example: '| Week | API | Console |\n| --- | ---: | ---: |\n| Oct 6 | 120 | 80 |\n| Oct 13 | 180 | 95 |\n| Oct 20 | 260 | 90 |' },
|
|
19
32
|
{ name: 'excerpt', purpose: 'Verified source lines, with a highlighted range and a link pinned to the commit.', format: 'fence parameters', example: '```excerpt path=src/cli.ts lines=1-8 highlight=2-4\nWhy these lines matter.\n```' },
|
|
20
33
|
{ name: 'diff', purpose: 'Before/after code; optional disclosure for long changes.', format: 'unified diff; optional title="..." and collapsed', example: '```diff title="Status handling" collapsed\n- if (running) showTranscript();\n+ if (running || live) showTranscript();\n```' },
|
|
21
34
|
...CARD_COMPONENTS,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/lib/components.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,0FAA0F;AAC1F,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB;QACE,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/lib/components.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,0FAA0F;AAC1F,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB;QACE,IAAI,EAAE,UAAU;QAChB,OAA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,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC,OAAO,GAAG,OAAO,EAAE,CAAC,CAAC;QAC5H,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface DiagramNode {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
details: string[];
|
|
5
|
+
focus: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface DiagramEdge {
|
|
8
|
+
from: string;
|
|
9
|
+
to: string;
|
|
10
|
+
label: string;
|
|
11
|
+
arrow: 'end' | 'both' | 'none';
|
|
12
|
+
}
|
|
13
|
+
export interface DiagramData {
|
|
14
|
+
nodes: DiagramNode[];
|
|
15
|
+
edges: DiagramEdge[];
|
|
16
|
+
direction?: 'LR' | 'TB';
|
|
17
|
+
title?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function isDiagramFence(info: string): boolean;
|
|
20
|
+
/** Every ```diagram fence, for validation. */
|
|
21
|
+
export declare function diagramFences(markdown: string): Array<{
|
|
22
|
+
raw: string;
|
|
23
|
+
text: string;
|
|
24
|
+
info: string;
|
|
25
|
+
}>;
|
|
26
|
+
export declare function parseDiagram(source: string, info?: string): {
|
|
27
|
+
data?: DiagramData;
|
|
28
|
+
error?: string;
|
|
29
|
+
};
|
|
30
|
+
export declare function textWidth(text: string, size: number, bold?: boolean): number;
|
|
31
|
+
export declare function renderDiagram(info: string, source: string): string;
|
|
32
|
+
export declare const DIAGRAM_CLASSES: string[];
|
|
33
|
+
export declare const DIAGRAM_CSS: string;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `diagram` fence: an agent writes boxes and arrows as text and the
|
|
3
|
+
* renderer lays them out. Hand-placed SVG was the source of most unreadable
|
|
4
|
+
* figures in an audit of real artifacts (lines through labels, 8 px text), and
|
|
5
|
+
* no amount of guidance fixes coordinates typed by hand.
|
|
6
|
+
*
|
|
7
|
+
* ```diagram
|
|
8
|
+
* console: Console (Next.js) | Artifacts tab sorts in browser
|
|
9
|
+
* worker*: share Worker | GET /__mine: 25 R2 keys
|
|
10
|
+
* console -> worker : list
|
|
11
|
+
* worker -> r2 : read / write
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* `id: Title | detail | detail` declares a box (a trailing `*` on the id marks
|
|
15
|
+
* the box the figure is about); `a -> b : label`, `a <-> b` and `a -- b` draw
|
|
16
|
+
* edges, and an id used only in an edge becomes a box titled with that id.
|
|
17
|
+
* Layout is dagre at render time, so the page stays one self-contained file.
|
|
18
|
+
* Text is measured, wrapped and never set below 12.5 px; the figure picks the
|
|
19
|
+
* direction that fits a desktop column, and a phone gets the narrower layout
|
|
20
|
+
* at full size, scrolling sideways rather than shrinking the text.
|
|
21
|
+
*/
|
|
22
|
+
import { createHash } from 'node:crypto';
|
|
23
|
+
import dagre from '@dagrejs/dagre';
|
|
24
|
+
import { Marked } from 'marked';
|
|
25
|
+
import { escapeHtml } from './html.js';
|
|
26
|
+
const MAX_NODES = 40;
|
|
27
|
+
const TITLE_SIZE = 15;
|
|
28
|
+
const DETAIL_SIZE = 13;
|
|
29
|
+
const LABEL_SIZE = 12.5;
|
|
30
|
+
const LINE_GAP = 6;
|
|
31
|
+
const PAD_X = 16;
|
|
32
|
+
const PAD_Y = 14;
|
|
33
|
+
const MAX_TEXT_WIDTH = 220;
|
|
34
|
+
const MIN_NODE_WIDTH = 120;
|
|
35
|
+
// A desktop column is about 760 px; a figure may shrink to 85% of its size
|
|
36
|
+
// before 13 px detail text drops under 11 px. A phone column is about 340 px.
|
|
37
|
+
const DESKTOP_FIT = 760 / 0.85;
|
|
38
|
+
export function isDiagramFence(info) {
|
|
39
|
+
return info.trim().split(/\s+/)[0] === 'diagram';
|
|
40
|
+
}
|
|
41
|
+
/** Every ```diagram fence, for validation. */
|
|
42
|
+
export function diagramFences(markdown) {
|
|
43
|
+
const found = [];
|
|
44
|
+
const lexer = new Marked();
|
|
45
|
+
lexer.walkTokens(lexer.lexer(markdown), (token) => {
|
|
46
|
+
if (token.type === 'code' && isDiagramFence(token.lang ?? ''))
|
|
47
|
+
found.push({ raw: token.raw, text: token.text, info: token.lang ?? '' });
|
|
48
|
+
});
|
|
49
|
+
return found;
|
|
50
|
+
}
|
|
51
|
+
const NODE_LINE = /^([A-Za-z0-9_.-]+)(\*?)\s*:\s*(.+)$/;
|
|
52
|
+
const EDGE_LINE = /^([A-Za-z0-9_.-]+)\s*(<->|->|--)\s*([A-Za-z0-9_.-]+)\s*(?::\s*(.*))?$/;
|
|
53
|
+
export function parseDiagram(source, info = 'diagram') {
|
|
54
|
+
const direction = info.match(/\bdirection=(LR|TB)\b/i)?.[1]?.toUpperCase();
|
|
55
|
+
const title = (info.match(/\btitle="([^"]*)"/)?.[1] ?? '').trim() || undefined;
|
|
56
|
+
const nodes = new Map();
|
|
57
|
+
const edges = [];
|
|
58
|
+
const lines = source.split(/\r?\n/);
|
|
59
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
60
|
+
const line = lines[index].trim();
|
|
61
|
+
if (!line || line.startsWith('#'))
|
|
62
|
+
continue;
|
|
63
|
+
const edge = line.match(EDGE_LINE);
|
|
64
|
+
if (edge) {
|
|
65
|
+
if (edge[1] === edge[3])
|
|
66
|
+
return { error: `line ${index + 1}: "${edge[1]}" points to itself; draw a loop as two boxes or describe it in the label` };
|
|
67
|
+
edges.push({ from: edge[1], to: edge[3], label: (edge[4] ?? '').trim(), arrow: edge[2] === '<->' ? 'both' : edge[2] === '--' ? 'none' : 'end' });
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const node = line.match(NODE_LINE);
|
|
71
|
+
if (node) {
|
|
72
|
+
const [title, ...details] = node[3].split('|').map((part) => part.trim());
|
|
73
|
+
if (!title)
|
|
74
|
+
return { error: `line ${index + 1}: a box needs a title after "${node[1]}:"` };
|
|
75
|
+
if (nodes.has(node[1]))
|
|
76
|
+
return { error: `line ${index + 1}: box "${node[1]}" is declared twice` };
|
|
77
|
+
nodes.set(node[1], { id: node[1], title, details: details.filter(Boolean), focus: node[2] === '*' });
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
return { error: `line ${index + 1}: "${line}" is neither a box (id: Title | detail) nor an edge (a -> b : label)` };
|
|
81
|
+
}
|
|
82
|
+
for (const edge of edges) {
|
|
83
|
+
for (const id of [edge.from, edge.to]) {
|
|
84
|
+
if (!nodes.has(id))
|
|
85
|
+
nodes.set(id, { id, title: id, details: [], focus: false });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (!nodes.size)
|
|
89
|
+
return { error: 'the diagram is empty; declare boxes (id: Title) and edges (a -> b)' };
|
|
90
|
+
if (nodes.size > MAX_NODES)
|
|
91
|
+
return { error: `${nodes.size} boxes; keep a diagram under ${MAX_NODES} and split the rest into a second figure` };
|
|
92
|
+
return { data: { nodes: [...nodes.values()], edges, direction, title } };
|
|
93
|
+
}
|
|
94
|
+
// Advance widths as a fraction of the font size for Inter-like faces. Exact
|
|
95
|
+
// metrics need a font engine; these overestimate slightly so text never spills.
|
|
96
|
+
function charWidth(char) {
|
|
97
|
+
if (char === ' ')
|
|
98
|
+
return 0.28;
|
|
99
|
+
if (/[iIl|!.,:;'`]/.test(char))
|
|
100
|
+
return 0.3;
|
|
101
|
+
if (/[fjrt()[\]{}\-/]/.test(char))
|
|
102
|
+
return 0.4;
|
|
103
|
+
if (/[mwMW@%]/.test(char))
|
|
104
|
+
return 0.88;
|
|
105
|
+
if (/[A-Z]/.test(char))
|
|
106
|
+
return 0.7;
|
|
107
|
+
if (/[0-9]/.test(char))
|
|
108
|
+
return 0.6;
|
|
109
|
+
return 0.56;
|
|
110
|
+
}
|
|
111
|
+
export function textWidth(text, size, bold = false) {
|
|
112
|
+
let width = 0;
|
|
113
|
+
for (const char of text)
|
|
114
|
+
width += charWidth(char);
|
|
115
|
+
return width * size * (bold ? 1.06 : 1);
|
|
116
|
+
}
|
|
117
|
+
function wrap(text, size, bold, max) {
|
|
118
|
+
// A path or route wider than the line breaks after its / _ . - separators.
|
|
119
|
+
const words = text.split(/\s+/).filter(Boolean)
|
|
120
|
+
.flatMap((word) => textWidth(word, size, bold) > max ? word.split(/(?<=[/_.-])/) : [word]);
|
|
121
|
+
const lines = [];
|
|
122
|
+
let line = '';
|
|
123
|
+
for (const word of words) {
|
|
124
|
+
const joined = /[/_.-]$/.test(line);
|
|
125
|
+
const next = line ? `${line}${joined ? '' : ' '}${word}` : word;
|
|
126
|
+
if (line && textWidth(next, size, bold) > max) {
|
|
127
|
+
lines.push(line);
|
|
128
|
+
line = word;
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
line = next;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (line)
|
|
135
|
+
lines.push(line);
|
|
136
|
+
return lines.length ? lines : [''];
|
|
137
|
+
}
|
|
138
|
+
function measure(node) {
|
|
139
|
+
const titleLines = wrap(node.title, TITLE_SIZE, true, MAX_TEXT_WIDTH);
|
|
140
|
+
const detailLines = node.details.flatMap((detail) => wrap(detail, DETAIL_SIZE, false, MAX_TEXT_WIDTH));
|
|
141
|
+
const textWidthMax = Math.max(...titleLines.map((line) => textWidth(line, TITLE_SIZE, true)), ...detailLines.map((line) => textWidth(line, DETAIL_SIZE)));
|
|
142
|
+
const width = Math.max(MIN_NODE_WIDTH, Math.ceil(textWidthMax + PAD_X * 2));
|
|
143
|
+
const height = Math.ceil(PAD_Y * 2 + titleLines.length * (TITLE_SIZE + LINE_GAP) + detailLines.length * (DETAIL_SIZE + LINE_GAP) - LINE_GAP);
|
|
144
|
+
return { node, titleLines, detailLines, width, height };
|
|
145
|
+
}
|
|
146
|
+
function layout(data, boxes, direction) {
|
|
147
|
+
const graph = new dagre.graphlib.Graph({ multigraph: true });
|
|
148
|
+
graph.setGraph({ rankdir: direction, nodesep: 36, ranksep: direction === 'LR' ? 64 : 48, edgesep: 18, marginx: 2, marginy: 2 });
|
|
149
|
+
graph.setDefaultEdgeLabel(() => ({}));
|
|
150
|
+
// dagre keeps nodes in plain objects; a prefix keeps ids like `constructor` off Object.prototype.
|
|
151
|
+
const key = (id) => `n:${id}`;
|
|
152
|
+
for (const box of boxes)
|
|
153
|
+
graph.setNode(key(box.node.id), { width: box.width, height: box.height });
|
|
154
|
+
data.edges.forEach((edge, index) => {
|
|
155
|
+
const lines = edge.label ? wrap(edge.label, LABEL_SIZE, false, 180) : [];
|
|
156
|
+
const width = lines.length ? Math.ceil(Math.max(...lines.map((line) => textWidth(line, LABEL_SIZE))) + 12) : 0;
|
|
157
|
+
const height = lines.length ? lines.length * (LABEL_SIZE + 5) + 6 : 0;
|
|
158
|
+
graph.setEdge(key(edge.from), key(edge.to), { width, height, labelpos: 'c', lines }, `e${index}`);
|
|
159
|
+
});
|
|
160
|
+
dagre.layout(graph);
|
|
161
|
+
const size = graph.graph();
|
|
162
|
+
const width = Math.ceil(size.width ?? 0) + 4;
|
|
163
|
+
const height = Math.ceil(size.height ?? 0) + 4;
|
|
164
|
+
const svg = (marker, className, label) => {
|
|
165
|
+
const nodesSvg = boxes.map((box) => {
|
|
166
|
+
const { x, y } = graph.node(key(box.node.id));
|
|
167
|
+
const left = x - box.width / 2;
|
|
168
|
+
let cursor = y - box.height / 2 + PAD_Y;
|
|
169
|
+
const texts = [];
|
|
170
|
+
for (const line of box.titleLines) {
|
|
171
|
+
cursor += TITLE_SIZE;
|
|
172
|
+
texts.push(`<text class="dg-title" x="${(left + PAD_X).toFixed(1)}" y="${(cursor - 2).toFixed(1)}" font-size="${TITLE_SIZE}" font-weight="600" fill="var(--text)">${escapeHtml(line)}</text>`);
|
|
173
|
+
cursor += LINE_GAP;
|
|
174
|
+
}
|
|
175
|
+
for (const line of box.detailLines) {
|
|
176
|
+
cursor += DETAIL_SIZE;
|
|
177
|
+
texts.push(`<text class="dg-detail" x="${(left + PAD_X).toFixed(1)}" y="${(cursor - 2).toFixed(1)}" font-size="${DETAIL_SIZE}" fill="var(--muted)">${escapeHtml(line)}</text>`);
|
|
178
|
+
cursor += LINE_GAP;
|
|
179
|
+
}
|
|
180
|
+
const stroke = box.node.focus ? 'var(--accent-alt)' : 'var(--line)';
|
|
181
|
+
return `<rect x="${left.toFixed(1)}" y="${(y - box.height / 2).toFixed(1)}" width="${box.width}" height="${box.height}" rx="10" fill="var(--surface-alt)" stroke="${stroke}" stroke-width="${box.node.focus ? 2 : 1.5}"/>${texts.join('')}`;
|
|
182
|
+
}).join('');
|
|
183
|
+
const edgesSvg = data.edges.map((edge, index) => {
|
|
184
|
+
const value = graph.edge({ v: key(edge.from), w: key(edge.to), name: `e${index}` });
|
|
185
|
+
const d = value.points.map((point, at) => `${at ? 'L' : 'M'}${point.x.toFixed(1)} ${point.y.toFixed(1)}`).join('');
|
|
186
|
+
const markers = edge.arrow === 'none' ? '' : edge.arrow === 'both' ? ` marker-start="url(#${marker})" marker-end="url(#${marker})"` : ` marker-end="url(#${marker})"`;
|
|
187
|
+
const path = `<path d="${d}" fill="none" stroke="var(--muted)" stroke-width="1.5" stroke-linejoin="round"${markers}/>`;
|
|
188
|
+
if (!value.lines.length || value.x === undefined || value.y === undefined)
|
|
189
|
+
return path;
|
|
190
|
+
const top = value.y - value.height / 2;
|
|
191
|
+
const labelText = value.lines.map((line, at) => `<text class="dg-label" x="${value.x.toFixed(1)}" y="${(top + 3 + (at + 1) * (LABEL_SIZE + 5) - 4).toFixed(1)}" font-size="${LABEL_SIZE}" text-anchor="middle" fill="var(--text)">${escapeHtml(line)}</text>`).join('');
|
|
192
|
+
return `${path}<rect x="${(value.x - value.width / 2).toFixed(1)}" y="${top.toFixed(1)}" width="${value.width}" height="${value.height}" rx="4" fill="var(--surface)"/>${labelText}`;
|
|
193
|
+
}).join('');
|
|
194
|
+
const defs = `<defs><marker id="${marker}" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0 0L10 5L0 10z" fill="var(--muted)"/></marker></defs>`;
|
|
195
|
+
return `<svg class="${className}" viewBox="0 0 ${width} ${height}" width="${width}" height="${height}" role="img" aria-label="${escapeHtml(label)}" xmlns="http://www.w3.org/2000/svg">${defs}${edgesSvg}${nodesSvg}</svg>`;
|
|
196
|
+
};
|
|
197
|
+
return { direction, width, height, svg };
|
|
198
|
+
}
|
|
199
|
+
function describe(data) {
|
|
200
|
+
const name = new Map(data.nodes.map((node) => [node.id, node.title]));
|
|
201
|
+
const edges = data.edges.map((edge) => `${name.get(edge.from)} ${edge.arrow === 'both' ? '↔' : edge.arrow === 'none' ? '—' : '→'} ${name.get(edge.to)}${edge.label ? ` (${edge.label})` : ''}`);
|
|
202
|
+
return `${data.title ? `${data.title}. ` : ''}${edges.length ? edges.join('; ') : data.nodes.map((node) => node.title).join(', ')}`;
|
|
203
|
+
}
|
|
204
|
+
export function renderDiagram(info, source) {
|
|
205
|
+
const { data, error } = parseDiagram(source, info);
|
|
206
|
+
if (!data)
|
|
207
|
+
return `<p class="artifact-callout artifact-callout-danger">Invalid diagram: ${escapeHtml(error ?? '')}</p>`;
|
|
208
|
+
const boxes = data.nodes.map(measure);
|
|
209
|
+
let candidates;
|
|
210
|
+
try {
|
|
211
|
+
candidates = ['LR', 'TB'].map((direction) => layout(data, boxes, direction));
|
|
212
|
+
}
|
|
213
|
+
catch (cause) {
|
|
214
|
+
return `<p class="artifact-callout artifact-callout-danger">Invalid diagram: the layout failed (${escapeHtml(cause instanceof Error ? cause.message : String(cause))})</p>`;
|
|
215
|
+
}
|
|
216
|
+
const preferred = candidates.find((candidate) => candidate.direction === (data.direction ?? 'LR'));
|
|
217
|
+
const other = candidates.find((candidate) => candidate !== preferred);
|
|
218
|
+
// Desktop: the author's direction when it fits the column, else whichever fits.
|
|
219
|
+
const desktop = preferred.width <= DESKTOP_FIT || other.width > DESKTOP_FIT && preferred.width <= other.width ? preferred : other;
|
|
220
|
+
// Phone: the narrower layout, unscaled.
|
|
221
|
+
const phone = candidates.reduce((best, candidate) => candidate.width < best.width ? candidate : best);
|
|
222
|
+
const marker = `dg-${createHash('sha256').update(info + source).digest('hex').slice(0, 10)}`;
|
|
223
|
+
const label = describe(data);
|
|
224
|
+
const fixed = desktop.width > DESKTOP_FIT ? ' artifact-graph-fixed' : '';
|
|
225
|
+
const svgs = desktop === phone
|
|
226
|
+
? desktop.svg(marker, `artifact-graph-svg${fixed}`, label)
|
|
227
|
+
: desktop.svg(marker, `artifact-graph-svg artifact-graph-wide${fixed}`, label) + phone.svg(`${marker}-n`, 'artifact-graph-svg artifact-graph-narrow', label);
|
|
228
|
+
return `<figure class="artifact-figure artifact-graph">${svgs}${data.title ? `<figcaption>${escapeHtml(data.title)}</figcaption>` : ''}</figure>`;
|
|
229
|
+
}
|
|
230
|
+
export const DIAGRAM_CLASSES = ['artifact-graph', 'artifact-graph-svg', 'artifact-graph-wide', 'artifact-graph-narrow', 'artifact-graph-fixed', 'dg-title', 'dg-detail', 'dg-label'];
|
|
231
|
+
export const DIAGRAM_CSS = '.artifact-graph{overflow-x:auto}' +
|
|
232
|
+
'.artifact-graph svg.artifact-graph-svg{display:block;max-width:100%;height:auto;margin:0 auto}' +
|
|
233
|
+
'.artifact-graph svg.artifact-graph-fixed{max-width:none}' +
|
|
234
|
+
'.artifact-graph text{font-family:var(--font-body)}' +
|
|
235
|
+
'.artifact-graph svg.artifact-graph-narrow{display:none}' +
|
|
236
|
+
'@media(max-width:720px){.artifact-graph svg.artifact-graph-wide{display:none}.artifact-graph svg.artifact-graph-narrow{display:block}.artifact-graph svg.artifact-graph-svg{max-width:none}}' +
|
|
237
|
+
'@media print{.artifact-graph svg.artifact-graph-narrow{display:none!important}.artifact-graph svg.artifact-graph-wide{display:block!important}.artifact-graph svg.artifact-graph-svg{max-width:100%}}';
|
|
238
|
+
//# sourceMappingURL=diagram.js.map
|