@venizia/vulcan 0.4.9-0 → 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 +2 -2
- package/base/hooks/codex-guards.ts +15 -5
- package/base/hooks/guard-git.ts +8 -8
- package/base/hooks/guard-manifest.ts +4 -5
- package/base/hooks/guard-outside.ts +8 -8
- package/base/hooks/guard-package.ts +5 -6
- package/base/hooks/guard-remote-hosts.ts +6 -7
- package/base/hooks/guard-scripting.ts +5 -6
- package/base/hooks/guard-writes.ts +8 -9
- package/base/hooks/post-tool.ts +2 -2
- package/base/hooks/prompt-submit.ts +2 -2
- package/base/hooks/session-start.ts +3 -3
- package/base/hooks/stop.ts +2 -2
- package/base/hooks/subagent-start.ts +2 -2
- package/base/skills/visualize-work/SKILL.md +9 -0
- package/package.json +3 -3
- package/src/agents/atlas-block.ts +43 -43
- package/src/agents/codex-hooks.ts +45 -43
- package/src/agents/detect.ts +19 -16
- package/src/agents/exclude.ts +96 -97
- package/src/agents/hooks-json.ts +38 -36
- package/src/agents/local.ts +46 -43
- package/src/agents/prompt.ts +45 -42
- package/src/agents/render.ts +201 -195
- package/src/agents/resolve.ts +133 -134
- package/src/agents/table.ts +12 -8
- 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 +4 -4
- package/src/commands/init.command.ts +12 -8
- package/src/commands/preset.command.ts +2 -2
- package/src/commands/profile.command.ts +42 -49
- package/src/commands/sync.command.ts +109 -111
- package/src/commands/upgrade.command.ts +80 -75
- package/src/commands/visualize.command.ts +7 -13
- package/src/commands/x.command.ts +55 -50
- package/src/common/format.ts +23 -21
- package/src/common/json.ts +8 -5
- package/src/common/layout-folder.ts +94 -91
- package/src/common/paths.ts +14 -12
- package/src/config/loader.ts +52 -49
- package/src/config/packages.ts +14 -11
- package/src/config/schema.ts +3 -3
- package/src/create/add-app.ts +519 -509
- package/src/create/add-lib.ts +237 -240
- package/src/create/bunfig.ts +26 -23
- package/src/create/checks.ts +36 -34
- 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 +75 -80
- package/src/create/lib-preset.ts +59 -63
- package/src/create/manifest-json.ts +10 -4
- package/src/create/names.ts +217 -210
- package/src/create/next.ts +26 -23
- package/src/create/plan.ts +15 -12
- package/src/create/preset-diff.ts +301 -303
- package/src/create/preset-menu.ts +38 -32
- package/src/create/preset.ts +202 -197
- package/src/create/process.ts +79 -72
- package/src/create/scratch.ts +48 -49
- package/src/create/workspace.ts +404 -396
- package/src/doctor/checks.ts +1027 -1014
- package/src/doctor/makefile.ts +17 -13
- package/src/doctor/runner.ts +88 -118
- package/src/doctor/skills.ts +97 -95
- package/src/doctor/tags.ts +42 -37
- package/src/hooks/codex-patch.ts +25 -22
- package/src/hooks/command-view.ts +44 -39
- package/src/hooks/decision.ts +37 -37
- package/src/hooks/guard-git.ts +51 -49
- package/src/hooks/guard-manifest.ts +58 -55
- package/src/hooks/guard-outside.ts +93 -91
- package/src/hooks/guard-package.ts +82 -79
- package/src/hooks/guard-scripting.ts +19 -14
- package/src/hooks/guard-writes.ts +154 -149
- package/src/hooks/owner-reply.ts +127 -127
- package/src/hooks/post-tool.ts +94 -93
- package/src/hooks/project-guards.ts +65 -62
- package/src/hooks/project-tmp.ts +27 -24
- package/src/hooks/remote-hosts.ts +153 -130
- package/src/hooks/session-digest.ts +98 -101
- package/src/hooks/shell.ts +509 -499
- package/src/hooks/subagent-card.ts +11 -7
- package/src/hooks/trusted-scripts.ts +106 -104
- package/src/init/scaffold.ts +135 -132
- package/src/local/clean.ts +38 -36
- package/src/local/format.ts +21 -17
- package/src/local/scan.ts +144 -138
- package/src/manifest/render.ts +110 -104
- package/src/owner/card.ts +51 -46
- package/src/owner/profile.ts +99 -93
- package/src/owner/reply-switch.ts +9 -6
- package/src/owner/shape.ts +71 -69
- package/src/owner/survey.ts +173 -171
- package/src/owner/view.ts +62 -59
- package/src/owner/violations.ts +119 -123
- package/src/rules/base.ts +15 -11
- 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 +79 -81
- package/src/skills/frontmatter.ts +28 -28
- package/src/sync/agent-files.ts +217 -199
- package/src/sync/agent-removal.ts +56 -59
- package/src/sync/atlas-block.ts +45 -43
- package/src/sync/base-rules.ts +32 -30
- package/src/sync/claude-launch.ts +36 -34
- package/src/sync/exclude.ts +77 -69
- package/src/sync/local-choice.ts +50 -47
- package/src/sync/planner.ts +59 -61
- package/src/sync/prune.ts +52 -48
- package/src/sync/settings.ts +166 -167
- package/src/ui/capability.ts +12 -7
- package/src/ui/keyboard.ts +38 -38
- package/src/ui/prompt.ts +79 -77
- package/src/visualize/assets.ts +33 -24
- package/src/visualize/charts.ts +179 -176
- package/src/visualize/compare-css.ts +3 -2
- package/src/visualize/compare-render.ts +9 -7
- package/src/visualize/diagrams.ts +189 -174
- package/src/visualize/grid-span.ts +34 -0
- package/src/visualize/icons.ts +7 -5
- package/src/visualize/kinds-render.ts +50 -45
- package/src/visualize/kinds-validate.ts +12 -10
- package/src/visualize/labels.ts +21 -17
- package/src/visualize/layout.ts +112 -97
- package/src/visualize/page.ts +92 -104
- package/src/visualize/render.ts +143 -140
- package/src/visualize/sections.ts +395 -384
- package/src/visualize/sources.ts +2 -2
- package/src/visualize/theme.ts +12 -10
- package/src/visualize/validate.ts +13 -9
- package/src/wiki/anchors.ts +38 -36
- package/src/wiki/command.ts +4 -4
- package/src/wiki/source-links.ts +46 -44
|
@@ -1,10 +1,11 @@
|
|
|
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';
|
|
9
10
|
import { SourceRefs } from './sources.ts';
|
|
10
11
|
|
|
@@ -13,77 +14,11 @@ export interface ISectionContext {
|
|
|
13
14
|
spec: TVisualizeSpec;
|
|
14
15
|
chrome: TChrome;
|
|
15
16
|
fits: Set<number>;
|
|
17
|
+
/** The row spans the page uses (see `GridSpans`). */
|
|
18
|
+
spans: Set<number>;
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
const escaped = (value: string): string => escapeText({ value });
|
|
19
|
-
|
|
20
|
-
/** The word of a state in the page's language. */
|
|
21
|
-
export const stateWord = (opts: { chrome: TChrome; state: string }): string => {
|
|
22
|
-
const key = MinimapStates.keyOf(opts.state) as keyof TChrome['minimapStates'];
|
|
23
|
-
|
|
24
|
-
return opts.chrome.minimapStates[key] ?? opts.state;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
/** A state as an icon and a word. */
|
|
28
|
-
export const chip = (opts: {
|
|
29
|
-
chrome: TChrome;
|
|
30
|
-
state: string;
|
|
31
|
-
size?: number;
|
|
32
|
-
label?: string;
|
|
33
|
-
}): string =>
|
|
34
|
-
`<span class="chip c-${NodeStates.toneOf(opts.state)}">${stateIcon({ state: opts.state, size: opts.size ?? 16 })}<span>${escaped(opts.label ?? stateWord(opts))}</span></span>`;
|
|
35
|
-
|
|
36
|
-
/** A part of the page: its title, then its body, each part a slide of its own. */
|
|
37
|
-
export const section = (opts: {
|
|
38
|
-
id: string;
|
|
39
|
-
title: string;
|
|
40
|
-
body: string;
|
|
41
|
-
extra?: string;
|
|
42
|
-
}): string =>
|
|
43
|
-
`<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>`;
|
|
44
|
-
|
|
45
|
-
/** The in-page links of the top bar: the parts that exist, in the order of the page. */
|
|
46
|
-
export const sectionLinks = (opts: {
|
|
47
|
-
spec: TVisualizeSpec;
|
|
48
|
-
chrome: TChrome;
|
|
49
|
-
}): { id: string; title: string }[] => {
|
|
50
|
-
const { spec, chrome } = opts;
|
|
51
|
-
const parts: [boolean, string, string][] = [
|
|
52
|
-
[spec.flow !== undefined, 'flow', chrome.flow],
|
|
53
|
-
[spec.minimap !== undefined, 'minimap', chrome.minimap],
|
|
54
|
-
[spec.strip !== undefined, 'next', chrome.next],
|
|
55
|
-
[spec.architecture !== undefined, 'architecture', chrome.architecture],
|
|
56
|
-
[spec.compare !== undefined, 'compare', chrome.compareView],
|
|
57
|
-
[spec.sequence !== undefined, 'sequence', chrome.sequence],
|
|
58
|
-
[spec.lifecycle !== undefined, 'lifecycle', chrome.lifecycle],
|
|
59
|
-
[spec.tree !== undefined, 'tree', chrome.tree],
|
|
60
|
-
[spec.comparison !== undefined, 'comparison', chrome.comparison],
|
|
61
|
-
[spec.ideaMap !== undefined, 'idea-map', chrome.ideaMap],
|
|
62
|
-
[spec.explainer !== undefined, 'explainer', chrome.explainer],
|
|
63
|
-
[spec.timeline !== undefined, 'timeline', chrome.timeline],
|
|
64
|
-
[spec.findings !== undefined, 'findings', chrome.findings],
|
|
65
|
-
[spec.beforeAfter !== undefined, 'before-after', `${chrome.before} / ${chrome.after}`],
|
|
66
|
-
[spec.decisionRecord !== undefined, 'decision-record', chrome.decisionRecord],
|
|
67
|
-
[spec.decisions !== undefined, 'decisions', chrome.decisions],
|
|
68
|
-
[spec.evidence !== undefined, 'evidence', chrome.evidence],
|
|
69
|
-
[spec.risks !== undefined, 'risks', chrome.risks],
|
|
70
|
-
[spec.log !== undefined, 'log', chrome.log],
|
|
71
|
-
[spec.terms !== undefined, 'terms', chrome.terms],
|
|
72
|
-
[SourceRefs.entries({ spec, chrome }).length > 0, 'sources', chrome.sources],
|
|
73
|
-
[spec.links !== undefined, 'links', chrome.links],
|
|
74
|
-
];
|
|
75
|
-
|
|
76
|
-
return parts.filter(([exists]) => exists).map(([, id, title]) => ({ id, title }));
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
/** A drawing in a dark window; below the width where its text would pass 12 px the list takes its place. */
|
|
80
|
-
export const figure = (opts: { ctx: ISectionContext; drawing: IDrawing }): string => {
|
|
81
|
-
const width = Math.round(opts.drawing.width);
|
|
82
|
-
|
|
83
|
-
opts.ctx.fits.add(width);
|
|
84
|
-
|
|
85
|
-
return `<div class="win"><div class="fig f${width}">${opts.drawing.svg}</div>${opts.drawing.fallback}</div>`;
|
|
86
|
-
};
|
|
21
|
+
const escaped = (value: string): string => FigureLayout.escapeText({ value });
|
|
87
22
|
|
|
88
23
|
/** JSON for a `<script type="application/json">`: nothing in it can close the tag or start a comment. */
|
|
89
24
|
const jsonForScript = (opts: { value: unknown }): string =>
|
|
@@ -98,354 +33,430 @@ const jsonForScript = (opts: { value: unknown }): string =>
|
|
|
98
33
|
const variantSwatch = (opts: { variant: string }): string =>
|
|
99
34
|
`<svg class="lg" viewBox="0 0 44 12" aria-hidden="true"><g class="edge ${escaped(opts.variant)}"><path d="M0 6H44"/></g></svg>`;
|
|
100
35
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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>`;
|
|
38
|
+
|
|
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>`;
|
|
41
|
+
|
|
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>`;
|
|
44
|
+
|
|
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'];
|
|
108
49
|
|
|
109
|
-
|
|
110
|
-
return '';
|
|
50
|
+
return opts.chrome.minimapStates[key] ?? opts.state;
|
|
111
51
|
}
|
|
112
52
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
+
}
|
|
57
|
+
|
|
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
|
+
}
|
|
91
|
+
|
|
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
|
|
146
150
|
: {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}),
|
|
151
|
+
title: step.title,
|
|
152
|
+
note: SourceRefs.withSource({ text: step.note, source: step.source }),
|
|
153
|
+
nodes: step.nodes,
|
|
154
|
+
edges: step.edges,
|
|
152
155
|
},
|
|
153
|
-
)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
// 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.
|
|
168
|
-
return `<figure class="figure" id="flow"><p class="lab">${escaped(chrome.flow)}</p><div class="fig f${width}">${renderFigure({ flow: shown })}</div>${renderPathList({ flow: shown })}${
|
|
169
|
-
legend.length === 0 ? '' : `<ul class="legend">${legend.join('')}</ul>`
|
|
170
|
-
}${
|
|
171
|
-
steps.length > 0
|
|
172
|
-
? `<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>`
|
|
173
|
-
: ''
|
|
174
|
-
}<div class="say js-only"><p id="say" aria-live="polite">${escaped(chrome.detailHint)}</p><div class="ctl">${play}${all}</div></div>${
|
|
175
|
-
steps.length > 0
|
|
176
|
-
? `<script type="application/json" id="steps">${jsonForScript({ value: stepsJson })}</script>`
|
|
177
|
-
: ''
|
|
178
|
-
}</figure>`;
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
export const architectureSection = (opts: { ctx: ISectionContext }): string => {
|
|
182
|
-
const { architecture } = opts.ctx.spec;
|
|
183
|
-
|
|
184
|
-
if (architecture === undefined) {
|
|
185
|
-
return '';
|
|
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>`;
|
|
186
170
|
}
|
|
187
171
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
+
});
|
|
187
|
+
}
|
|
200
188
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
|
215
|
+
.map(
|
|
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>`,
|
|
218
|
+
)
|
|
219
|
+
.join('');
|
|
204
220
|
|
|
205
|
-
|
|
206
|
-
|
|
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
|
+
});
|
|
207
226
|
}
|
|
208
227
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
)
|
|
220
|
-
.join('');
|
|
221
|
-
|
|
222
|
-
return section({
|
|
223
|
-
id: 'comparison',
|
|
224
|
-
title: chrome.comparison,
|
|
225
|
-
body: `<div class="ranks"><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>`}`,
|
|
226
|
-
});
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
export const ideaMapSection = (opts: { ctx: ISectionContext }): string => {
|
|
230
|
-
const { ideaMap } = opts.ctx.spec;
|
|
231
|
-
|
|
232
|
-
return ideaMap === undefined
|
|
233
|
-
? ''
|
|
234
|
-
: section({
|
|
235
|
-
id: 'idea-map',
|
|
236
|
-
title: opts.ctx.chrome.ideaMap,
|
|
237
|
-
body: renderIdeaMap({ map: ideaMap }),
|
|
238
|
-
});
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
export const explainerSection = (opts: { ctx: ISectionContext }): string => {
|
|
242
|
-
const { explainer } = opts.ctx.spec;
|
|
243
|
-
|
|
244
|
-
if (explainer === undefined) {
|
|
245
|
-
return '';
|
|
228
|
+
static ideaMap(opts: { ctx: ISectionContext }): string {
|
|
229
|
+
const { ideaMap } = opts.ctx.spec;
|
|
230
|
+
|
|
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
|
+
});
|
|
246
238
|
}
|
|
247
239
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
title: opts.ctx.chrome.explainer,
|
|
251
|
-
body: `<ol class="ex">${explainer.steps
|
|
252
|
-
.map(
|
|
253
|
-
(step, index) =>
|
|
254
|
-
`<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">${figure({ ctx: opts.ctx, drawing: renderDiagram({ diagram: step.diagram }) })}</div>`}</li>`,
|
|
255
|
-
)
|
|
256
|
-
.join('')}</ol>`,
|
|
257
|
-
});
|
|
258
|
-
};
|
|
240
|
+
static explainer(opts: { ctx: ISectionContext }): string {
|
|
241
|
+
const { explainer } = opts.ctx.spec;
|
|
259
242
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
243
|
+
if (explainer === undefined) {
|
|
244
|
+
return '';
|
|
245
|
+
}
|
|
263
246
|
|
|
264
|
-
|
|
265
|
-
|
|
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
|
+
});
|
|
266
257
|
}
|
|
267
258
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
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
|
+
});
|
|
277
|
+
}
|
|
278
|
+
|
|
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
|
|
272
285
|
.map(
|
|
273
|
-
(
|
|
274
|
-
`<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>`,
|
|
275
288
|
)
|
|
276
|
-
.join('')}</
|
|
277
|
-
});
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
/** Big numbers as fields: a tint and an icon for a state, plain for a number that is only a number. */
|
|
281
|
-
export const tilesHtml = (opts: {
|
|
282
|
-
tiles: { value: string; label: string; state?: string }[];
|
|
283
|
-
chrome: TChrome;
|
|
284
|
-
}): string =>
|
|
285
|
-
`<ul class="tiles" aria-label="${escaped(opts.chrome.findings)}">${opts.tiles
|
|
286
|
-
.map(
|
|
287
|
-
(tile) =>
|
|
288
|
-
`<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>`,
|
|
289
|
-
)
|
|
290
|
-
.join('')}</ul>`;
|
|
291
|
-
|
|
292
|
-
export const findingsSection = (opts: { ctx: ISectionContext }): string => {
|
|
293
|
-
const { findings } = opts.ctx.spec;
|
|
294
|
-
const { chrome } = opts.ctx;
|
|
295
|
-
|
|
296
|
-
if (findings === undefined) {
|
|
297
|
-
return '';
|
|
289
|
+
.join('')}</ul>`;
|
|
298
290
|
}
|
|
299
291
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
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>`}`,
|
|
304
|
-
});
|
|
305
|
-
};
|
|
292
|
+
static findings(opts: { ctx: ISectionContext }): string {
|
|
293
|
+
const { findings } = opts.ctx.spec;
|
|
294
|
+
const { chrome } = opts.ctx;
|
|
306
295
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
296
|
+
if (findings === undefined) {
|
|
297
|
+
return '';
|
|
298
|
+
}
|
|
310
299
|
|
|
311
|
-
|
|
312
|
-
|
|
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
|
+
});
|
|
313
305
|
}
|
|
314
306
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
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
327
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
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
|
+
}
|
|
334
334
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
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
|
+
}
|
|
338
360
|
|
|
339
|
-
|
|
340
|
-
|
|
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
|
+
});
|
|
341
379
|
}
|
|
342
380
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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
|
+
});
|
|
363
401
|
}
|
|
364
402
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
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
|
+
}
|
|
376
424
|
|
|
377
|
-
|
|
378
|
-
|
|
425
|
+
static log(opts: { ctx: ISectionContext }): string {
|
|
426
|
+
const { log } = opts.ctx.spec;
|
|
379
427
|
|
|
380
|
-
|
|
381
|
-
|
|
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
|
+
}
|
|
382
436
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
const { chrome } = opts.ctx;
|
|
437
|
+
static links(opts: { ctx: ISectionContext }): string {
|
|
438
|
+
const { links } = opts.ctx.spec;
|
|
386
439
|
|
|
387
|
-
|
|
388
|
-
|
|
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
|
+
});
|
|
389
447
|
}
|
|
390
448
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
body: `<ul class="ledger">${evidence
|
|
395
|
-
.map((row) => {
|
|
396
|
-
const word =
|
|
397
|
-
chrome.evidenceLabels[row.label as keyof TChrome['evidenceLabels']] ?? row.label;
|
|
398
|
-
|
|
399
|
-
return `<li class="ev"><span class="badge ev-${escaped(row.label)}">${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>`;
|
|
400
|
-
})
|
|
401
|
-
.join('')}</ul>`,
|
|
402
|
-
});
|
|
403
|
-
};
|
|
404
|
-
|
|
405
|
-
export const risksSection = (opts: { ctx: ISectionContext }): string => {
|
|
406
|
-
const { risks } = opts.ctx.spec;
|
|
407
|
-
const { chrome } = opts.ctx;
|
|
408
|
-
|
|
409
|
-
if (risks === undefined) {
|
|
410
|
-
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>`;
|
|
411
452
|
}
|
|
412
453
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
]),
|
|
423
|
-
}),
|
|
424
|
-
});
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
export const logSection = (opts: { ctx: ISectionContext }): string => {
|
|
428
|
-
const { log } = opts.ctx.spec;
|
|
429
|
-
|
|
430
|
-
return log === undefined
|
|
431
|
-
? ''
|
|
432
|
-
: section({
|
|
433
|
-
id: 'log',
|
|
434
|
-
title: opts.ctx.chrome.log,
|
|
435
|
-
body: `<ul class="log">${log.map((row) => `<li><time>${escaped(row.date)}</time><span>${escaped(row.text)}</span></li>`).join('')}</ul>`,
|
|
436
|
-
});
|
|
437
|
-
};
|
|
438
|
-
|
|
439
|
-
export const linksSection = (opts: { ctx: ISectionContext }): string => {
|
|
440
|
-
const { links } = opts.ctx.spec;
|
|
441
|
-
|
|
442
|
-
return links === undefined
|
|
443
|
-
? ''
|
|
444
|
-
: section({
|
|
445
|
-
id: 'links',
|
|
446
|
-
title: opts.ctx.chrome.links,
|
|
447
|
-
body: `<ul class="links">${links.map((link) => `<li><a href="${escaped(link.href)}" rel="noopener noreferrer"><span>${escaped(link.label)}</span>${iconSvg({ name: 'arrow', size: 18 })}</a></li>`).join('')}</ul>`,
|
|
448
|
-
});
|
|
449
|
-
};
|
|
450
|
-
|
|
451
|
-
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
|
+
}
|