@venizia/vulcan 0.4.8 → 0.4.9-1
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/base/extensions/vulcan-guards.ts +48 -41
- package/base/hooks/antigravity-guards.ts +4 -3
- package/base/hooks/codex-guards.ts +17 -6
- package/base/hooks/guard-git.ts +8 -8
- package/base/hooks/guard-manifest.ts +5 -5
- package/base/hooks/guard-outside.ts +8 -8
- package/base/hooks/guard-package.ts +6 -6
- package/base/hooks/guard-remote-hosts.ts +14 -9
- package/base/hooks/guard-scripting.ts +6 -6
- package/base/hooks/guard-writes.ts +20 -11
- package/base/hooks/post-tool.ts +4 -3
- package/base/hooks/prompt-submit.ts +4 -3
- package/base/hooks/session-start.ts +5 -3
- package/base/hooks/stop.ts +4 -3
- package/base/hooks/subagent-start.ts +2 -2
- package/base/make/vulcan.mk +1 -4
- package/base/skills/build-a-feature/SKILL.md +1 -1
- package/base/skills/docs-update/SKILL.md +11 -5
- package/base/skills/docs-update/evals/evals.json +1 -1
- package/base/skills/docs-writing/SKILL.md +1 -1
- package/base/skills/plan-a-change/references/spec-card.md +1 -1
- package/base/skills/ship/SKILL.md +1 -1
- package/base/skills/visualize-work/SKILL.md +29 -6
- package/base/skills/visualize-work/references/spec.md +16 -5
- package/package.json +5 -6
- package/src/agents/atlas-block.ts +43 -43
- package/src/agents/codex-hooks.ts +55 -52
- package/src/agents/common/types.ts +1 -1
- package/src/agents/detect.ts +19 -16
- package/src/agents/exclude.ts +97 -98
- package/src/agents/hooks-json.ts +41 -43
- package/src/agents/local.ts +46 -43
- package/src/agents/prompt.ts +45 -42
- package/src/agents/render.ts +203 -201
- package/src/agents/resolve.ts +133 -134
- package/src/agents/table.ts +12 -8
- package/src/cli.ts +3 -1
- package/src/commands/add.command.ts +2 -2
- package/src/commands/agents.command.ts +11 -17
- package/src/commands/clean.command.ts +6 -6
- package/src/commands/doctor.command.ts +6 -4
- package/src/commands/help.command.ts +11 -9
- package/src/commands/init.command.ts +14 -8
- package/src/commands/preset.command.ts +2 -2
- package/src/commands/profile.command.ts +43 -50
- package/src/commands/sync.command.ts +109 -111
- package/src/commands/upgrade.command.ts +85 -78
- package/src/commands/visualize.command.ts +20 -5
- package/src/commands/x.command.ts +55 -50
- package/src/common/format.ts +23 -21
- package/src/common/index.ts +2 -0
- package/src/common/json.ts +8 -5
- package/src/common/layout-folder.ts +96 -111
- package/src/common/paths.ts +14 -12
- package/src/common/record.ts +7 -0
- package/src/common/text.ts +7 -0
- package/src/config/common/constants.ts +13 -1
- package/src/config/common/types.ts +8 -1
- package/src/config/loader.ts +53 -48
- package/src/config/packages.ts +17 -11
- package/src/config/schema.ts +54 -7
- package/src/create/add-app.ts +604 -493
- package/src/create/add-lib.ts +249 -242
- package/src/create/bunfig.ts +26 -23
- package/src/create/checks.ts +36 -34
- package/src/create/common/constants.ts +1 -0
- package/src/create/common/failure.ts +10 -0
- package/src/create/common/index.ts +2 -0
- package/src/create/common/preset-path.ts +11 -0
- package/src/create/common/types.ts +7 -2
- package/src/create/diff.ts +21 -23
- package/src/create/dockerignore.ts +26 -24
- package/src/create/files.ts +7 -5
- package/src/create/init-monorepo.ts +78 -80
- package/src/create/lib-preset.ts +62 -61
- package/src/create/manifest-json.ts +10 -4
- package/src/create/names.ts +217 -210
- package/src/create/next.ts +27 -24
- package/src/create/plan.ts +15 -12
- package/src/create/preset-diff.ts +415 -240
- package/src/create/preset-menu.ts +40 -34
- package/src/create/preset.ts +207 -194
- package/src/create/process.ts +80 -71
- package/src/create/scratch.ts +49 -48
- package/src/create/workspace.ts +423 -398
- package/src/doctor/checks.ts +1069 -998
- package/src/doctor/makefile.ts +17 -13
- package/src/doctor/runner.ts +88 -116
- package/src/doctor/skills.ts +97 -95
- package/src/doctor/tags.ts +44 -41
- package/src/hooks/codex-patch.ts +27 -24
- package/src/hooks/command-view.ts +44 -39
- package/src/hooks/common/constants.ts +0 -3
- package/src/hooks/common/types.ts +15 -1
- package/src/hooks/decision.ts +38 -42
- package/src/hooks/guard-git.ts +52 -50
- package/src/hooks/guard-manifest.ts +58 -55
- package/src/hooks/guard-outside.ts +109 -88
- package/src/hooks/guard-package.ts +86 -77
- package/src/hooks/guard-scripting.ts +20 -15
- package/src/hooks/guard-writes.ts +169 -111
- package/src/hooks/owner-reply.ts +128 -128
- package/src/hooks/post-tool.ts +94 -93
- package/src/hooks/project-guards.ts +93 -55
- package/src/hooks/project-tmp.ts +27 -24
- package/src/hooks/remote-hosts.ts +157 -149
- package/src/hooks/session-digest.ts +99 -95
- package/src/hooks/shell.ts +519 -500
- package/src/hooks/subagent-card.ts +11 -7
- package/src/hooks/trusted-scripts.ts +158 -80
- package/src/init/common/types.ts +1 -1
- package/src/init/scaffold.ts +137 -134
- package/src/local/clean.ts +39 -37
- package/src/local/format.ts +21 -17
- package/src/local/scan.ts +146 -140
- package/src/manifest/render.ts +127 -112
- package/src/owner/card.ts +51 -46
- package/src/owner/profile.ts +100 -96
- package/src/owner/reply-switch.ts +9 -6
- package/src/owner/shape.ts +72 -70
- package/src/owner/survey.ts +175 -164
- package/src/owner/view.ts +62 -59
- package/src/owner/violations.ts +119 -123
- package/src/router.ts +4 -1
- package/src/rules/base.ts +15 -11
- package/src/rules/common/types.ts +1 -1
- package/src/rules/parser.ts +39 -32
- package/src/rules/slots.ts +8 -6
- package/src/signals/claims.ts +30 -28
- package/src/signals/classify.ts +36 -33
- package/src/signals/loop.ts +39 -37
- package/src/signals/state.ts +80 -85
- package/src/skills/frontmatter.ts +28 -28
- package/src/sync/agent-files.ts +217 -199
- package/src/sync/agent-removal.ts +62 -68
- package/src/sync/atlas-block.ts +45 -43
- package/src/sync/base-rules.ts +32 -30
- package/src/sync/claude-launch.ts +74 -37
- package/src/sync/common/constants.ts +4 -0
- package/src/sync/common/index.ts +1 -0
- package/src/sync/common/symlink.ts +9 -0
- package/src/sync/common/types.ts +2 -2
- package/src/sync/exclude.ts +77 -69
- package/src/sync/local-choice.ts +50 -47
- package/src/sync/planner.ts +64 -68
- package/src/sync/prune.ts +52 -48
- package/src/sync/settings.ts +167 -168
- package/src/ui/capability.ts +12 -7
- package/src/ui/keyboard.ts +35 -33
- package/src/ui/prompt.ts +81 -77
- package/src/visualize/assets.ts +379 -195
- package/src/visualize/charts.ts +188 -176
- package/src/visualize/compare-css.ts +31 -0
- package/src/visualize/compare-render.ts +196 -0
- package/src/visualize/compare-schema.ts +81 -0
- package/src/visualize/compare-validate.ts +126 -0
- package/src/visualize/constants.ts +29 -3
- package/src/visualize/diagrams.ts +189 -174
- package/src/visualize/gate.ts +136 -0
- package/src/visualize/grid-span.ts +34 -0
- package/src/visualize/icons.ts +9 -4
- package/src/visualize/index.ts +2 -0
- package/src/visualize/kinds-css.ts +54 -0
- package/src/visualize/kinds-render.ts +698 -0
- package/src/visualize/kinds-schema.ts +148 -0
- package/src/visualize/kinds-validate.ts +186 -0
- package/src/visualize/labels-vi.ts +109 -0
- package/src/visualize/labels.ts +53 -0
- package/src/visualize/layout.ts +112 -92
- package/src/visualize/page.ts +140 -114
- package/src/visualize/render.ts +158 -114
- package/src/visualize/schema.ts +21 -1
- package/src/visualize/sections.ts +401 -309
- package/src/visualize/sources.ts +270 -0
- package/src/visualize/theme.ts +474 -0
- package/src/visualize/validate.ts +15 -5
- package/src/wiki/anchors.ts +39 -37
- package/src/wiki/command.ts +4 -4
- package/src/wiki/source-links.ts +49 -49
|
@@ -1,56 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SpecCharts } from './charts.ts';
|
|
2
2
|
import { ChangeKinds, MinimapStates, NodeStates } from './constants.ts';
|
|
3
3
|
import type { TChangeKind, TChrome } from './constants.ts';
|
|
4
|
-
import {
|
|
4
|
+
import { SpecDiagrams } from './diagrams.ts';
|
|
5
5
|
import type { IDrawing } from './diagrams.ts';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { GridSpans } from './grid-span.ts';
|
|
7
|
+
import { IconSet } from './icons.ts';
|
|
8
|
+
import { FigureLayout } from './layout.ts';
|
|
8
9
|
import type { TVisualizeSpec } from './schema.ts';
|
|
10
|
+
import { SourceRefs } from './sources.ts';
|
|
9
11
|
|
|
10
12
|
/** What every section needs: the spec, the page's words, and the widths of the figures that must give way to a list on a phone. */
|
|
11
13
|
export interface ISectionContext {
|
|
12
14
|
spec: TVisualizeSpec;
|
|
13
15
|
chrome: TChrome;
|
|
14
16
|
fits: Set<number>;
|
|
17
|
+
/** The row spans the page uses (see `GridSpans`). */
|
|
18
|
+
spans: Set<number>;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
|
-
const escaped = (value: string): string => escapeText({ value });
|
|
18
|
-
|
|
19
|
-
/** The word of a state in the page's language. */
|
|
20
|
-
export const stateWord = (opts: { chrome: TChrome; state: string }): string => {
|
|
21
|
-
const key = MinimapStates.keyOf(opts.state) as keyof TChrome['minimapStates'];
|
|
22
|
-
|
|
23
|
-
return opts.chrome.minimapStates[key] ?? opts.state;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/** A state as an icon and a word. */
|
|
27
|
-
export const chip = (opts: {
|
|
28
|
-
chrome: TChrome;
|
|
29
|
-
state: string;
|
|
30
|
-
size?: number;
|
|
31
|
-
label?: string;
|
|
32
|
-
}): string =>
|
|
33
|
-
`<span class="chip c-${NodeStates.toneOf(opts.state)}">${stateIcon({ state: opts.state, size: opts.size ?? 16 })}<span>${escaped(opts.label ?? stateWord(opts))}</span></span>`;
|
|
34
|
-
|
|
35
|
-
export const section = (opts: {
|
|
36
|
-
id: string;
|
|
37
|
-
title: string;
|
|
38
|
-
body: string;
|
|
39
|
-
extra?: string;
|
|
40
|
-
}): string =>
|
|
41
|
-
`<section class="sec${opts.extra === undefined ? '' : ` ${opts.extra}`}" id="${opts.id}" data-slide><h2 class="lab">${escaped(opts.title)}</h2>${opts.body}</section>`;
|
|
42
|
-
|
|
43
|
-
/** A drawing in its frame; below the width where its text would pass 12 px the list takes its place. */
|
|
44
|
-
export const figure = (opts: { ctx: ISectionContext; drawing: IDrawing }): string => {
|
|
45
|
-
const width = Math.round(opts.drawing.width);
|
|
46
|
-
|
|
47
|
-
opts.ctx.fits.add(width);
|
|
48
|
-
|
|
49
|
-
return `<div class="fig f${width}">${opts.drawing.svg}</div>${opts.drawing.fallback}`;
|
|
50
|
-
};
|
|
21
|
+
const escaped = (value: string): string => FigureLayout.escapeText({ value });
|
|
51
22
|
|
|
52
23
|
/** JSON for a `<script type="application/json">`: nothing in it can close the tag or start a comment. */
|
|
53
|
-
|
|
24
|
+
const jsonForScript = (opts: { value: unknown }): string =>
|
|
54
25
|
JSON.stringify(opts.value)
|
|
55
26
|
.replaceAll('<', '\\u003c')
|
|
56
27
|
.replaceAll('>', '\\u003e')
|
|
@@ -58,313 +29,434 @@ export const jsonForScript = (opts: { value: unknown }): string =>
|
|
|
58
29
|
.replaceAll('
', '\\u2028')
|
|
59
30
|
.replaceAll('
', '\\u2029');
|
|
60
31
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
32
|
+
/** One variant of an arrow as a short line, drawn with the same rules as the arrows of the figure. */
|
|
33
|
+
const variantSwatch = (opts: { variant: string }): string =>
|
|
34
|
+
`<svg class="lg" viewBox="0 0 44 12" aria-hidden="true"><g class="edge ${escaped(opts.variant)}"><path d="M0 6H44"/></g></svg>`;
|
|
64
35
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
36
|
+
const dots = (opts: { score: number }): string =>
|
|
37
|
+
`<span class="dots" role="img" aria-label="${opts.score} / 5">${Array.from({ length: 5 }, (_, index) => `<i${index < opts.score ? ' class="on"' : ''}></i>`).join('')}</span>`;
|
|
68
38
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const variants = [...new Set(flow.edges.map((edge) => edge.variant ?? 'main'))];
|
|
72
|
-
const states = [
|
|
73
|
-
...new Set(flow.nodes.flatMap((node) => (node.state === undefined ? [] : [node.state]))),
|
|
74
|
-
];
|
|
75
|
-
const steps = flow.steps;
|
|
76
|
-
const controls = [
|
|
77
|
-
flow.edges.length > 0
|
|
78
|
-
? `<button id="play" type="button" aria-pressed="false" data-play="${escaped(chrome.play)}" data-pause="${escaped(chrome.pause)}">${escaped(chrome.play)}</button>`
|
|
79
|
-
: '',
|
|
80
|
-
steps.length > 0
|
|
81
|
-
? `<button id="prev" type="button">${escaped(chrome.previous)}</button><button id="next" type="button">${escaped(chrome.following)}</button><button id="all" type="button">${escaped(chrome.allSteps)}</button>`
|
|
82
|
-
: '',
|
|
83
|
-
].join('');
|
|
84
|
-
|
|
85
|
-
opts.ctx.fits.add(width);
|
|
86
|
-
|
|
87
|
-
// The figure, its phone list, then the controls: a sibling order the page CSS relies on to swap the figure for the list.
|
|
88
|
-
return section({
|
|
89
|
-
id: 'flow',
|
|
90
|
-
title: chrome.flow,
|
|
91
|
-
body: `<div class="fig f${width}">${renderFigure({ flow })}</div>${renderPathList({ flow })}<div class="bar">${controls}</div><p id="detail" aria-live="polite">${escaped(chrome.detailHint)}</p>${
|
|
92
|
-
steps.length > 0 ? `<p id="stepnote" aria-live="polite"></p>` : ''
|
|
93
|
-
}<div class="legend">${states.map((state) => chip({ chrome, state })).join('')}${kinds.map((kind) => `<span>${escaped(kind)}</span>`).join('')}${variants.map((variant) => `<span>${escaped(variant)}</span>`).join('')}</div>${
|
|
94
|
-
steps.length > 0
|
|
95
|
-
? `<ol class="steps-note">${steps.map((step) => `<li><b>${escaped(step.title)}</b> - ${escaped(step.note)}</li>`).join('')}</ol><script type="application/json" id="steps">${jsonForScript({ value: steps })}</script>`
|
|
96
|
-
: ''
|
|
97
|
-
}`,
|
|
98
|
-
});
|
|
99
|
-
};
|
|
39
|
+
const table = (opts: { head: string[]; rows: string[][] }): string =>
|
|
40
|
+
`<div class="tw"><table class="stack"><thead><tr>${opts.head.map((cell) => `<th>${escaped(cell)}</th>`).join('')}</tr></thead><tbody>${opts.rows.map((row) => `<tr>${row.join('')}</tr>`).join('')}</tbody></table></div>`;
|
|
100
41
|
|
|
101
|
-
|
|
102
|
-
|
|
42
|
+
const cell = (opts: { value: string; label?: string; tag?: boolean }): string =>
|
|
43
|
+
`<td${opts.tag === true ? ' class="tag"' : ''}${opts.label === undefined ? '' : ` data-label="${escaped(opts.label)}"`}>${escaped(opts.value)}</td>`;
|
|
103
44
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
45
|
+
export class SpecSections {
|
|
46
|
+
/** The word of a state in the page's language. */
|
|
47
|
+
static stateWord(opts: { chrome: TChrome; state: string }): string {
|
|
48
|
+
const key = MinimapStates.keyOf(opts.state) as keyof TChrome['minimapStates'];
|
|
107
49
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
title: opts.ctx.chrome.architecture,
|
|
111
|
-
body: figure({
|
|
112
|
-
ctx: opts.ctx,
|
|
113
|
-
drawing: renderArchitecture({ architecture, chrome: opts.ctx.chrome }),
|
|
114
|
-
}),
|
|
115
|
-
});
|
|
116
|
-
};
|
|
50
|
+
return opts.chrome.minimapStates[key] ?? opts.state;
|
|
51
|
+
}
|
|
117
52
|
|
|
118
|
-
|
|
119
|
-
|
|
53
|
+
/** A state as an icon and a word. */
|
|
54
|
+
static chip(opts: { chrome: TChrome; state: string; size?: number; label?: string }): string {
|
|
55
|
+
return `<span class="chip c-${NodeStates.toneOf(opts.state)}">${SpecCharts.stateIcon({ state: opts.state, size: opts.size ?? 16 })}<span>${escaped(opts.label ?? SpecSections.stateWord(opts))}</span></span>`;
|
|
56
|
+
}
|
|
120
57
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
58
|
+
/** The in-page links of the top bar: the parts that exist, in the order of the page. */
|
|
59
|
+
static sectionLinks(opts: {
|
|
60
|
+
spec: TVisualizeSpec;
|
|
61
|
+
chrome: TChrome;
|
|
62
|
+
}): { id: string; title: string }[] {
|
|
63
|
+
const { spec, chrome } = opts;
|
|
64
|
+
const parts: [boolean, string, string][] = [
|
|
65
|
+
[spec.flow !== undefined, 'flow', chrome.flow],
|
|
66
|
+
[spec.minimap !== undefined, 'minimap', chrome.minimap],
|
|
67
|
+
[spec.strip !== undefined, 'next', chrome.next],
|
|
68
|
+
[spec.architecture !== undefined, 'architecture', chrome.architecture],
|
|
69
|
+
[spec.compare !== undefined, 'compare', chrome.compareView],
|
|
70
|
+
[spec.sequence !== undefined, 'sequence', chrome.sequence],
|
|
71
|
+
[spec.lifecycle !== undefined, 'lifecycle', chrome.lifecycle],
|
|
72
|
+
[spec.tree !== undefined, 'tree', chrome.tree],
|
|
73
|
+
[spec.comparison !== undefined, 'comparison', chrome.comparison],
|
|
74
|
+
[spec.ideaMap !== undefined, 'idea-map', chrome.ideaMap],
|
|
75
|
+
[spec.explainer !== undefined, 'explainer', chrome.explainer],
|
|
76
|
+
[spec.timeline !== undefined, 'timeline', chrome.timeline],
|
|
77
|
+
[spec.findings !== undefined, 'findings', chrome.findings],
|
|
78
|
+
[spec.beforeAfter !== undefined, 'before-after', `${chrome.before} / ${chrome.after}`],
|
|
79
|
+
[spec.decisionRecord !== undefined, 'decision-record', chrome.decisionRecord],
|
|
80
|
+
[spec.decisions !== undefined, 'decisions', chrome.decisions],
|
|
81
|
+
[spec.evidence !== undefined, 'evidence', chrome.evidence],
|
|
82
|
+
[spec.risks !== undefined, 'risks', chrome.risks],
|
|
83
|
+
[spec.log !== undefined, 'log', chrome.log],
|
|
84
|
+
[spec.terms !== undefined, 'terms', chrome.terms],
|
|
85
|
+
[SourceRefs.entries({ spec, chrome }).length > 0, 'sources', chrome.sources],
|
|
86
|
+
[spec.links !== undefined, 'links', chrome.links],
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
return parts.filter(([exists]) => exists).map(([, id, title]) => ({ id, title }));
|
|
90
|
+
}
|
|
124
91
|
|
|
125
|
-
|
|
126
|
-
|
|
92
|
+
/**
|
|
93
|
+
* The flow lives in the hero: the figure on the slab, its phone list, the legend, then the steps to press and the
|
|
94
|
+
* line that says what is picked. Without script the steps are a plain list with their text.
|
|
95
|
+
*/
|
|
96
|
+
static flow(opts: { ctx: ISectionContext }): string {
|
|
97
|
+
const { flow } = opts.ctx.spec;
|
|
98
|
+
const { chrome } = opts.ctx;
|
|
99
|
+
|
|
100
|
+
if (flow === undefined) {
|
|
101
|
+
return '';
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const width = FigureLayout.figureWidth({ cols: FigureLayout.columnsOf({ flow }) });
|
|
105
|
+
const kinds = [...new Set(flow.nodes.map((node) => node.kind ?? 'step'))];
|
|
106
|
+
const variants = [...new Set(flow.edges.map((edge) => edge.variant ?? 'main'))];
|
|
107
|
+
const states = [
|
|
108
|
+
...new Set(flow.nodes.flatMap((node) => (node.state === undefined ? [] : [node.state]))),
|
|
109
|
+
];
|
|
110
|
+
const steps = flow.steps;
|
|
111
|
+
const legend = [
|
|
112
|
+
...states.map((state) => `<li>${SpecSections.chip({ chrome, state })}</li>`),
|
|
113
|
+
...(kinds.length > 1 ? kinds.map((kind) => `<li>${escaped(kind)}</li>`) : []),
|
|
114
|
+
...(variants.length > 1
|
|
115
|
+
? variants.map(
|
|
116
|
+
(variant) => `<li>${variantSwatch({ variant })}<span>${escaped(variant)}</span></li>`,
|
|
117
|
+
)
|
|
118
|
+
: []),
|
|
119
|
+
];
|
|
120
|
+
const play =
|
|
121
|
+
flow.edges.length > 0
|
|
122
|
+
? `<button class="btn" id="play" type="button" aria-pressed="false" data-play="${escaped(chrome.play)}" data-pause="${escaped(chrome.pause)}">${escaped(chrome.play)}</button>`
|
|
123
|
+
: '';
|
|
124
|
+
const all =
|
|
125
|
+
steps.length > 0
|
|
126
|
+
? `<button class="btn" id="all" type="button" hidden>${escaped(chrome.allSteps)}</button>`
|
|
127
|
+
: '';
|
|
128
|
+
|
|
129
|
+
opts.ctx.fits.add(width);
|
|
130
|
+
|
|
131
|
+
// A box that has a source says it in its detail line: on hover, and in the phone list.
|
|
132
|
+
const shown = {
|
|
133
|
+
...flow,
|
|
134
|
+
nodes: flow.nodes.map((node) =>
|
|
135
|
+
node.source === undefined
|
|
136
|
+
? node
|
|
137
|
+
: {
|
|
138
|
+
...node,
|
|
139
|
+
detail: SourceRefs.withSource({
|
|
140
|
+
text: node.detail ?? node.sublabel,
|
|
141
|
+
source: node.source,
|
|
142
|
+
}),
|
|
143
|
+
},
|
|
144
|
+
),
|
|
145
|
+
};
|
|
146
|
+
// The script reads the step's note whole: its source goes after it there, and in the markup it is its own element.
|
|
147
|
+
const stepsJson = steps.map((step) =>
|
|
148
|
+
step.source === undefined
|
|
149
|
+
? step
|
|
150
|
+
: {
|
|
151
|
+
title: step.title,
|
|
152
|
+
note: SourceRefs.withSource({ text: step.note, source: step.source }),
|
|
153
|
+
nodes: step.nodes,
|
|
154
|
+
edges: step.edges,
|
|
155
|
+
},
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
// The figure, its phone list, the legend, then the steps: a sibling order the page CSS relies on to swap the figure for the list.
|
|
159
|
+
return `<figure class="figure" id="flow"><p class="lab">${escaped(chrome.flow)}</p><div class="fig f${width}">${FigureLayout.render({ flow: shown })}</div>${FigureLayout.renderPathList({ flow: shown })}${
|
|
160
|
+
legend.length === 0 ? '' : `<ul class="legend">${legend.join('')}</ul>`
|
|
161
|
+
}${
|
|
162
|
+
steps.length > 0
|
|
163
|
+
? `<ol class="steps">${steps.map((step, index) => `<li><button type="button" aria-pressed="false"><b>${escaped(step.title)}</b><span>${index + 1} / ${steps.length}</span></button><p class="explain">${escaped(step.note)}${step.source === undefined ? '' : ` ${SourceRefs.html({ source: step.source })}`}</p></li>`).join('')}</ol>`
|
|
164
|
+
: ''
|
|
165
|
+
}<div class="say js-only"><p id="say" aria-live="polite">${escaped(chrome.detailHint)}</p><div class="ctl">${play}${all}</div></div>${
|
|
166
|
+
steps.length > 0
|
|
167
|
+
? `<script type="application/json" id="steps">${jsonForScript({ value: stepsJson })}</script>`
|
|
168
|
+
: ''
|
|
169
|
+
}</figure>`;
|
|
127
170
|
}
|
|
128
171
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
.
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
title: chrome.comparison,
|
|
145
|
-
body: `<div class="card chart"><p class="lab">${escaped(chrome.total)}, ${escaped(chrome.outOf)} ${max}</p>${renderTotals({ names: comparison.options.map((option) => option.name), totals, best, max, chrome })}</div><div class="opts n${comparison.options.length}">${cards}</div>${comparison.note === undefined ? '' : `<p class="note">${iconSvg({ name: 'info', size: 16 })} ${escaped(comparison.note)}</p>`}`,
|
|
146
|
-
});
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
export const ideaMapSection = (opts: { ctx: ISectionContext }): string => {
|
|
150
|
-
const { ideaMap } = opts.ctx.spec;
|
|
151
|
-
|
|
152
|
-
return ideaMap === undefined
|
|
153
|
-
? ''
|
|
154
|
-
: section({
|
|
155
|
-
id: 'idea-map',
|
|
156
|
-
title: opts.ctx.chrome.ideaMap,
|
|
157
|
-
body: renderIdeaMap({ map: ideaMap }),
|
|
158
|
-
});
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
export const explainerSection = (opts: { ctx: ISectionContext }): string => {
|
|
162
|
-
const { explainer } = opts.ctx.spec;
|
|
163
|
-
|
|
164
|
-
if (explainer === undefined) {
|
|
165
|
-
return '';
|
|
172
|
+
static architecture(opts: { ctx: ISectionContext }): string {
|
|
173
|
+
const { architecture } = opts.ctx.spec;
|
|
174
|
+
|
|
175
|
+
if (architecture === undefined) {
|
|
176
|
+
return '';
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return SpecSections.section({
|
|
180
|
+
id: 'architecture',
|
|
181
|
+
title: opts.ctx.chrome.architecture,
|
|
182
|
+
body: SpecSections.figure({
|
|
183
|
+
ctx: opts.ctx,
|
|
184
|
+
drawing: SpecDiagrams.renderArchitecture({ architecture, chrome: opts.ctx.chrome }),
|
|
185
|
+
}),
|
|
186
|
+
});
|
|
166
187
|
}
|
|
167
188
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
189
|
+
static comparison(opts: { ctx: ISectionContext }): string {
|
|
190
|
+
const { comparison } = opts.ctx.spec;
|
|
191
|
+
const { chrome } = opts.ctx;
|
|
192
|
+
|
|
193
|
+
if (comparison === undefined) {
|
|
194
|
+
return '';
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const totals = comparison.options.map((option) =>
|
|
198
|
+
option.scores.reduce((sum, score) => sum + score, 0),
|
|
199
|
+
);
|
|
200
|
+
const marked = comparison.options.findIndex((option) => option.recommended === true);
|
|
201
|
+
const best = marked === -1 ? totals.indexOf(Math.max(...totals)) : marked;
|
|
202
|
+
const max = comparison.criteria.length * 5;
|
|
203
|
+
const { spans } = opts.ctx;
|
|
204
|
+
// Every card spans the same rows of the grid: the badge slot (only when some option is recommended), the total, the
|
|
205
|
+
// title, the line (only when some option has one), each criterion, then the most pros and the most cons of any option.
|
|
206
|
+
const hasBadge = comparison.options.some((option) => option.recommended === true);
|
|
207
|
+
const hasLine = comparison.options.some((option) => option.line !== undefined);
|
|
208
|
+
const mostPros = Math.max(0, ...comparison.options.map((option) => (option.pros ?? []).length));
|
|
209
|
+
const mostCons = Math.max(0, ...comparison.options.map((option) => (option.cons ?? []).length));
|
|
210
|
+
const rows =
|
|
211
|
+
(hasBadge ? 1 : 0) + 2 + (hasLine ? 1 : 0) + comparison.criteria.length + mostPros + mostCons;
|
|
212
|
+
const proRow = (row: { icon: string; word: string; text: string; kind: string }): string =>
|
|
213
|
+
`<li class="${row.kind}">${IconSet.iconSvg({ name: row.icon, size: 16 })}<span><span class="vh">${escaped(row.word)}: </span>${escaped(row.text)}</span></li>`;
|
|
214
|
+
const cards = comparison.options
|
|
172
215
|
.map(
|
|
173
|
-
(
|
|
174
|
-
`<
|
|
216
|
+
(option, index) =>
|
|
217
|
+
`<article class="opt${option.recommended === true ? ' rec' : ''} ${GridSpans.classOf({ count: rows, spans })}">${hasBadge ? `<span class="tag-slot">${option.recommended === true ? `<span class="tag">${escaped(chrome.recommended)}</span>` : ''}</span>` : ''}<p class="tot">${totals[index]}<small> ${escaped(chrome.outOf)} ${max}</small></p><h3>${escaped(option.name)}</h3>${hasLine ? `<p class="ln">${option.line === undefined ? '' : escaped(option.line)}</p>` : ''}<div class="crit ${GridSpans.classOf({ count: comparison.criteria.length, spans })}">${comparison.criteria.map((criterion, i) => `<div><span>${escaped(criterion)}</span>${dots({ score: option.scores[i] ?? 0 })}</div>`).join('')}</div>${mostPros === 0 ? '' : `<ul class="pc proslist ${GridSpans.classOf({ count: mostPros, spans })}">${(option.pros ?? []).map((pro) => proRow({ icon: 'plus', word: chrome.pros, text: pro, kind: 'p' })).join('')}</ul>`}${mostCons === 0 ? '' : `<ul class="pc conslist ${GridSpans.classOf({ count: mostCons, spans })}">${(option.cons ?? []).map((con) => proRow({ icon: 'minus', word: chrome.cons, text: con, kind: 'c' })).join('')}</ul>`}</article>`,
|
|
175
218
|
)
|
|
176
|
-
.join('')
|
|
177
|
-
|
|
178
|
-
|
|
219
|
+
.join('');
|
|
220
|
+
|
|
221
|
+
return SpecSections.section({
|
|
222
|
+
id: 'comparison',
|
|
223
|
+
title: chrome.comparison,
|
|
224
|
+
body: `<div class="ranks"><p class="lab">${escaped(chrome.total)}, ${escaped(chrome.outOf)} ${max}</p>${SpecCharts.renderTotals({ names: comparison.options.map((option) => option.name), totals, best, max, chrome })}</div><div class="opts n${comparison.options.length}">${cards}</div>${comparison.note === undefined ? '' : `<p class="note">${IconSet.iconSvg({ name: 'info', size: 16 })} ${escaped(comparison.note)}</p>`}`,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
static ideaMap(opts: { ctx: ISectionContext }): string {
|
|
229
|
+
const { ideaMap } = opts.ctx.spec;
|
|
179
230
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
231
|
+
return ideaMap === undefined
|
|
232
|
+
? ''
|
|
233
|
+
: SpecSections.section({
|
|
234
|
+
id: 'idea-map',
|
|
235
|
+
title: opts.ctx.chrome.ideaMap,
|
|
236
|
+
body: SpecDiagrams.renderIdeaMap({ map: ideaMap, spans: opts.ctx.spans }),
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
static explainer(opts: { ctx: ISectionContext }): string {
|
|
241
|
+
const { explainer } = opts.ctx.spec;
|
|
242
|
+
|
|
243
|
+
if (explainer === undefined) {
|
|
244
|
+
return '';
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return SpecSections.section({
|
|
248
|
+
id: 'explainer',
|
|
249
|
+
title: opts.ctx.chrome.explainer,
|
|
250
|
+
body: `<ol class="ex">${explainer.steps
|
|
251
|
+
.map(
|
|
252
|
+
(step, index) =>
|
|
253
|
+
`<li class="estep"><span class="no">${index + 1}</span><div class="sb"><h3>${escaped(step.title)}</h3><p>${escaped(step.text)}</p></div>${step.diagram === undefined ? '' : `<div class="dg">${SpecSections.figure({ ctx: opts.ctx, drawing: SpecDiagrams.render({ diagram: step.diagram }) })}</div>`}</li>`,
|
|
254
|
+
)
|
|
255
|
+
.join('')}</ol>`,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
183
258
|
|
|
184
|
-
|
|
185
|
-
|
|
259
|
+
static timeline(opts: { ctx: ISectionContext }): string {
|
|
260
|
+
const { timeline } = opts.ctx.spec;
|
|
261
|
+
const { chrome } = opts.ctx;
|
|
262
|
+
|
|
263
|
+
if (timeline === undefined) {
|
|
264
|
+
return '';
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return SpecSections.section({
|
|
268
|
+
id: 'timeline',
|
|
269
|
+
title: chrome.timeline,
|
|
270
|
+
body: `<ol class="tl">${timeline.items
|
|
271
|
+
.map(
|
|
272
|
+
(item) =>
|
|
273
|
+
`<li class="c-${item.state === undefined ? 'mut' : NodeStates.toneOf(item.state)}"><span class="dot">${item.state === undefined ? '' : SpecCharts.stateIcon({ state: item.state, size: 18 })}</span><time>${escaped(item.date)}</time><h3>${escaped(item.title)}</h3>${item.state === undefined ? '' : `<span class="vh">${escaped(SpecSections.stateWord({ chrome, state: item.state }))}</span>`}${item.text === undefined ? '' : `<p>${escaped(item.text)}</p>`}</li>`,
|
|
274
|
+
)
|
|
275
|
+
.join('')}</ol>`,
|
|
276
|
+
});
|
|
186
277
|
}
|
|
187
278
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
279
|
+
/** Big numbers as fields: a tint and an icon for a state, plain for a number that is only a number. */
|
|
280
|
+
static tilesHtml(opts: {
|
|
281
|
+
tiles: { value: string; label: string; state?: string }[];
|
|
282
|
+
chrome: TChrome;
|
|
283
|
+
}): string {
|
|
284
|
+
return `<ul class="tiles" aria-label="${escaped(opts.chrome.findings)}">${opts.tiles
|
|
192
285
|
.map(
|
|
193
|
-
(
|
|
194
|
-
`<li class="
|
|
286
|
+
(tile) =>
|
|
287
|
+
`<li class="tile${tile.state === undefined ? '' : ` c-${NodeStates.toneOf(tile.state)}`}">${tile.state === undefined ? '' : SpecCharts.stateIcon({ state: tile.state, size: 22 })}<span class="n">${escaped(tile.value)}</span><span class="l">${escaped(tile.label)}</span>${tile.state === undefined ? '' : `<span class="vh">${escaped(SpecSections.stateWord({ chrome: opts.chrome, state: tile.state }))}</span>`}</li>`,
|
|
195
288
|
)
|
|
196
|
-
.join('')}</
|
|
197
|
-
});
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
export const tilesHtml = (opts: {
|
|
201
|
-
tiles: { value: string; label: string; state?: string }[];
|
|
202
|
-
chrome: TChrome;
|
|
203
|
-
}): string =>
|
|
204
|
-
`<ul class="tiles" aria-label="${escaped(opts.chrome.findings)}">${opts.tiles
|
|
205
|
-
.map(
|
|
206
|
-
(tile) =>
|
|
207
|
-
`<li class="tile${tile.state === undefined ? '' : ` c-${NodeStates.toneOf(tile.state)}`}">${tile.state === undefined ? '' : stateIcon({ state: tile.state, size: 22 })}<span class="n">${escaped(tile.value)}</span><span class="l">${escaped(tile.label)}</span>${tile.state === undefined ? '' : `<span class="vh">${escaped(stateWord({ chrome: opts.chrome, state: tile.state }))}</span>`}</li>`,
|
|
208
|
-
)
|
|
209
|
-
.join('')}</ul>`;
|
|
210
|
-
|
|
211
|
-
export const findingsSection = (opts: { ctx: ISectionContext }): string => {
|
|
212
|
-
const { findings } = opts.ctx.spec;
|
|
213
|
-
const { chrome } = opts.ctx;
|
|
214
|
-
|
|
215
|
-
if (findings === undefined) {
|
|
216
|
-
return '';
|
|
289
|
+
.join('')}</ul>`;
|
|
217
290
|
}
|
|
218
291
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
body: `${findings.numbers === undefined ? '' : tilesHtml({ tiles: findings.numbers, chrome })}${findings.charts === undefined ? '' : `<div class="charts">${findings.charts.map((chart) => renderChart({ chart, chrome })).join('')}</div>`}${findings.callouts === undefined ? '' : `<ul class="callouts">${findings.callouts.map((callout) => `<li class="callout c-${callout.state === undefined ? 'info' : NodeStates.toneOf(callout.state)}">${stateIcon({ state: callout.state ?? 'info', size: 22 })}<p>${callout.state === undefined ? '' : `<span class="vh">${escaped(stateWord({ chrome, state: callout.state }))}: </span>`}${escaped(callout.text)}</p></li>`).join('')}</ul>`}`,
|
|
223
|
-
});
|
|
224
|
-
};
|
|
292
|
+
static findings(opts: { ctx: ISectionContext }): string {
|
|
293
|
+
const { findings } = opts.ctx.spec;
|
|
294
|
+
const { chrome } = opts.ctx;
|
|
225
295
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
296
|
+
if (findings === undefined) {
|
|
297
|
+
return '';
|
|
298
|
+
}
|
|
229
299
|
|
|
230
|
-
|
|
231
|
-
|
|
300
|
+
return SpecSections.section({
|
|
301
|
+
id: 'findings',
|
|
302
|
+
title: chrome.findings,
|
|
303
|
+
body: `${findings.numbers === undefined ? '' : SpecSections.tilesHtml({ tiles: findings.numbers, chrome })}${findings.charts === undefined ? '' : `<div class="charts">${findings.charts.map((chart) => SpecCharts.render({ chart, chrome })).join('')}</div>`}${findings.callouts === undefined ? '' : `<ul class="callouts">${findings.callouts.map((callout) => `<li class="callout c-${callout.state === undefined ? 'info' : NodeStates.toneOf(callout.state)}">${SpecCharts.stateIcon({ state: callout.state ?? 'info', size: 22 })}<p>${callout.state === undefined ? '' : `<span class="vh">${escaped(SpecSections.stateWord({ chrome, state: callout.state }))}: </span>`}${escaped(callout.text)}</p></li>`).join('')}</ul>`}`,
|
|
304
|
+
});
|
|
232
305
|
}
|
|
233
306
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
307
|
+
static beforeAfter(opts: { ctx: ISectionContext }): string {
|
|
308
|
+
const { beforeAfter } = opts.ctx.spec;
|
|
309
|
+
const { chrome } = opts.ctx;
|
|
310
|
+
|
|
311
|
+
if (beforeAfter === undefined) {
|
|
312
|
+
return '';
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
const side = (given: {
|
|
316
|
+
title: string;
|
|
317
|
+
items: { text: string; change?: string }[];
|
|
318
|
+
kind: TChangeKind;
|
|
319
|
+
}): string =>
|
|
320
|
+
`<section class="ba"><h3>${escaped(given.title)}</h3><ul>${given.items
|
|
321
|
+
.map((item) =>
|
|
322
|
+
item.change === given.kind
|
|
323
|
+
? `<li class="${given.kind === ChangeKinds.ADDED ? 'add' : 'del'}">${IconSet.iconSvg({ name: given.kind === ChangeKinds.ADDED ? 'plus' : 'minus', size: 16 })}<span><b class="wd">${escaped(given.kind === ChangeKinds.ADDED ? chrome.added : chrome.removed)}</b><span class="tx">${escaped(item.text)}</span></span></li>`
|
|
324
|
+
: `<li class="same">${IconSet.iconSvg({ name: 'minus', size: 16 })}<span>${escaped(item.text)}</span></li>`,
|
|
325
|
+
)
|
|
326
|
+
.join('')}</ul></section>`;
|
|
327
|
+
|
|
328
|
+
return SpecSections.section({
|
|
329
|
+
id: 'before-after',
|
|
330
|
+
title: `${chrome.before} / ${chrome.after}`,
|
|
331
|
+
body: `<div class="diff">${side({ ...beforeAfter.before, kind: ChangeKinds.REMOVED })}${side({ ...beforeAfter.after, kind: ChangeKinds.ADDED })}</div>`,
|
|
332
|
+
});
|
|
333
|
+
}
|
|
253
334
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
335
|
+
static decisionRecord(opts: { ctx: ISectionContext }): string {
|
|
336
|
+
const { decisionRecord } = opts.ctx.spec;
|
|
337
|
+
const { chrome } = opts.ctx;
|
|
338
|
+
|
|
339
|
+
if (decisionRecord === undefined) {
|
|
340
|
+
return '';
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// Every option spans the same rows: the badge slot (when one is chosen), the title and the summary.
|
|
344
|
+
const hasChosen = decisionRecord.options.some((option) => option.chosen === true);
|
|
345
|
+
const recordRows = (hasChosen ? 1 : 0) + 2;
|
|
346
|
+
|
|
347
|
+
return SpecSections.section({
|
|
348
|
+
id: 'decision-record',
|
|
349
|
+
title: chrome.decisionRecord,
|
|
350
|
+
body: `<div class="dr"><div><p class="lab">${escaped(chrome.context)}</p><p class="ctx">${escaped(decisionRecord.context)}</p></div><div><p class="lab">${escaped(chrome.optionsConsidered)}</p><div class="opts n${decisionRecord.options.length}">${decisionRecord.options
|
|
351
|
+
.map(
|
|
352
|
+
(option) =>
|
|
353
|
+
`<article class="opt${option.chosen === true ? ' rec' : ''} ${GridSpans.classOf({ count: recordRows, spans: opts.ctx.spans })}">${hasChosen ? `<span class="tag-slot">${option.chosen === true ? `<span class="tag">${escaped(chrome.chosen)}</span>` : ''}</span>` : ''}<h3>${escaped(option.name)}</h3><p class="ln">${escaped(option.summary)}</p></article>`,
|
|
354
|
+
)
|
|
355
|
+
.join(
|
|
356
|
+
'',
|
|
357
|
+
)}</div></div><blockquote class="pull">${IconSet.iconSvg({ name: 'quote', size: 36 })}<p class="lab">${escaped(chrome.decision)}</p><p class="big">${escaped(decisionRecord.decision)}</p></blockquote><div><p class="lab">${escaped(chrome.consequences)}</p><ul class="cons">${decisionRecord.consequences.map((consequence) => `<li>${IconSet.iconSvg({ name: 'check', size: 18 })}<span>${escaped(consequence)}</span></li>`).join('')}</ul></div></div>`,
|
|
358
|
+
});
|
|
359
|
+
}
|
|
257
360
|
|
|
258
|
-
|
|
259
|
-
|
|
361
|
+
static decisions(opts: { ctx: ISectionContext }): string {
|
|
362
|
+
const { decisions } = opts.ctx.spec;
|
|
363
|
+
const { chrome } = opts.ctx;
|
|
364
|
+
|
|
365
|
+
if (decisions === undefined) {
|
|
366
|
+
return '';
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
return SpecSections.section({
|
|
370
|
+
id: 'decisions',
|
|
371
|
+
title: chrome.decisions,
|
|
372
|
+
body: `<ol class="qs">${decisions
|
|
373
|
+
.map(
|
|
374
|
+
(item) =>
|
|
375
|
+
`<li class="q"><div><h3>${escaped(item.question)}</h3><p class="chg"><span class="lab">${escaped(chrome.changesClaim)}</span>${escaped(item.changes)}</p></div><div class="rec"><b>${escaped(chrome.recommended)}</b><strong>${escaped(item.recommended)}</strong></div></li>`,
|
|
376
|
+
)
|
|
377
|
+
.join('')}</ol>`,
|
|
378
|
+
});
|
|
260
379
|
}
|
|
261
380
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
381
|
+
static evidence(opts: { ctx: ISectionContext }): string {
|
|
382
|
+
const { evidence } = opts.ctx.spec;
|
|
383
|
+
const { chrome } = opts.ctx;
|
|
384
|
+
|
|
385
|
+
if (evidence === undefined) {
|
|
386
|
+
return '';
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
return SpecSections.section({
|
|
390
|
+
id: 'evidence',
|
|
391
|
+
title: chrome.evidence,
|
|
392
|
+
body: `<ul class="ledger">${evidence
|
|
393
|
+
.map((row) => {
|
|
394
|
+
const word =
|
|
395
|
+
chrome.evidenceLabels[row.label as keyof TChrome['evidenceLabels']] ?? row.label;
|
|
396
|
+
|
|
397
|
+
return `<li class="ev"><span class="badge ev-${escaped(row.label)}">${IconSet.iconSvg({ name: row.label, size: 16 })}${escaped(word)}</span><span class="cl"><b>${escaped(row.claim)}</b><span class="pr">${escaped(row.probe)}</span></span><span class="rs">${escaped(row.result)}</span></li>`;
|
|
398
|
+
})
|
|
399
|
+
.join('')}</ul>`,
|
|
400
|
+
});
|
|
282
401
|
}
|
|
283
402
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
403
|
+
static risks(opts: { ctx: ISectionContext }): string {
|
|
404
|
+
const { risks } = opts.ctx.spec;
|
|
405
|
+
const { chrome } = opts.ctx;
|
|
406
|
+
|
|
407
|
+
if (risks === undefined) {
|
|
408
|
+
return '';
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
return SpecSections.section({
|
|
412
|
+
id: 'risks',
|
|
413
|
+
title: chrome.risks,
|
|
414
|
+
body: table({
|
|
415
|
+
head: [chrome.risk, chrome.impact, chrome.fallback],
|
|
416
|
+
rows: risks.map((row) => [
|
|
417
|
+
cell({ value: row.risk, label: chrome.risk }),
|
|
418
|
+
cell({ value: row.impact, label: chrome.impact }),
|
|
419
|
+
cell({ value: row.fallback, label: chrome.fallback }),
|
|
420
|
+
]),
|
|
421
|
+
}),
|
|
422
|
+
});
|
|
423
|
+
}
|
|
295
424
|
|
|
296
|
-
|
|
297
|
-
|
|
425
|
+
static log(opts: { ctx: ISectionContext }): string {
|
|
426
|
+
const { log } = opts.ctx.spec;
|
|
298
427
|
|
|
299
|
-
|
|
300
|
-
|
|
428
|
+
return log === undefined
|
|
429
|
+
? ''
|
|
430
|
+
: SpecSections.section({
|
|
431
|
+
id: 'log',
|
|
432
|
+
title: opts.ctx.chrome.log,
|
|
433
|
+
body: `<ul class="log">${log.map((row) => `<li><time>${escaped(row.date)}</time><span>${escaped(row.text)}</span></li>`).join('')}</ul>`,
|
|
434
|
+
});
|
|
435
|
+
}
|
|
301
436
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
const { chrome } = opts.ctx;
|
|
437
|
+
static links(opts: { ctx: ISectionContext }): string {
|
|
438
|
+
const { links } = opts.ctx.spec;
|
|
305
439
|
|
|
306
|
-
|
|
307
|
-
|
|
440
|
+
return links === undefined
|
|
441
|
+
? ''
|
|
442
|
+
: SpecSections.section({
|
|
443
|
+
id: 'links',
|
|
444
|
+
title: opts.ctx.chrome.links,
|
|
445
|
+
body: `<ul class="links">${links.map((link) => `<li><a href="${escaped(link.href)}" rel="noopener noreferrer"><span>${escaped(link.label)}</span>${IconSet.iconSvg({ name: 'arrow', size: 18 })}</a></li>`).join('')}</ul>`,
|
|
446
|
+
});
|
|
308
447
|
}
|
|
309
448
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
body: `<ul class="evs">${evidence
|
|
314
|
-
.map((row) => {
|
|
315
|
-
const word =
|
|
316
|
-
chrome.evidenceLabels[row.label as keyof TChrome['evidenceLabels']] ?? row.label;
|
|
317
|
-
|
|
318
|
-
return `<li class="ev"><span class="badge ev-${escaped(row.label)}">${iconSvg({ name: row.label, size: 15 })}${escaped(word)}</span><b>${escaped(row.claim)}</b><span class="pr">${escaped(row.probe)}</span><span class="rs">${escaped(row.result)}</span></li>`;
|
|
319
|
-
})
|
|
320
|
-
.join('')}</ul>`,
|
|
321
|
-
});
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
export const risksSection = (opts: { ctx: ISectionContext }): string => {
|
|
325
|
-
const { risks } = opts.ctx.spec;
|
|
326
|
-
const { chrome } = opts.ctx;
|
|
327
|
-
|
|
328
|
-
if (risks === undefined) {
|
|
329
|
-
return '';
|
|
449
|
+
/** A part of the page: its title, then its body, each part a slide of its own. */
|
|
450
|
+
static section(opts: { id: string; title: string; body: string; extra?: string }): string {
|
|
451
|
+
return `<section class="part${opts.extra === undefined ? '' : ` ${opts.extra}`}" id="${opts.id}" data-slide><div class="wrap"><h2 class="sh">${escaped(opts.title)}</h2>${opts.body}</div></section>`;
|
|
330
452
|
}
|
|
331
453
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
]),
|
|
342
|
-
}),
|
|
343
|
-
});
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
export const logSection = (opts: { ctx: ISectionContext }): string => {
|
|
347
|
-
const { log } = opts.ctx.spec;
|
|
348
|
-
|
|
349
|
-
return log === undefined
|
|
350
|
-
? ''
|
|
351
|
-
: section({
|
|
352
|
-
id: 'log',
|
|
353
|
-
title: opts.ctx.chrome.log,
|
|
354
|
-
body: `<ul class="log">${log.map((row) => `<li><time>${escaped(row.date)}</time><span>${escaped(row.text)}</span></li>`).join('')}</ul>`,
|
|
355
|
-
});
|
|
356
|
-
};
|
|
357
|
-
|
|
358
|
-
export const linksSection = (opts: { ctx: ISectionContext }): string => {
|
|
359
|
-
const { links } = opts.ctx.spec;
|
|
360
|
-
|
|
361
|
-
return links === undefined
|
|
362
|
-
? ''
|
|
363
|
-
: section({
|
|
364
|
-
id: 'links',
|
|
365
|
-
title: opts.ctx.chrome.links,
|
|
366
|
-
body: `<ul class="links">${links.map((link) => `<li><a href="${escaped(link.href)}" rel="noopener noreferrer">${escaped(link.label)}</a></li>`).join('')}</ul>`,
|
|
367
|
-
});
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
export { formatNumber };
|
|
454
|
+
/** A drawing in a dark window; below the width where its text would pass 12 px the list takes its place. */
|
|
455
|
+
static figure(opts: { ctx: ISectionContext; drawing: IDrawing }): string {
|
|
456
|
+
const width = Math.round(opts.drawing.width);
|
|
457
|
+
|
|
458
|
+
opts.ctx.fits.add(width);
|
|
459
|
+
|
|
460
|
+
return `<div class="win"><div class="fig f${width}">${opts.drawing.svg}</div>${opts.drawing.fallback}</div>`;
|
|
461
|
+
}
|
|
462
|
+
}
|