repometry 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/package.json +1 -1
- package/target/main/resources/report/json/report-v2.schema.json +13 -1
- package/target/main/resources/viewer/files.css +7 -3
- package/target/main/resources/viewer/styles.css +2 -2
- package/target/main/ts/api/git/git.d.ts +1 -0
- package/target/main/ts/api/git/git.js +12 -0
- package/target/main/ts/api/git/inspection-source.js +2 -8
- package/target/main/ts/api/git/local.d.ts +1 -1
- package/target/main/ts/api/git/local.js +39 -5
- package/target/main/ts/api/process/docker-tool-runner.d.ts +13 -0
- package/target/main/ts/api/process/docker-tool-runner.js +108 -0
- package/target/main/ts/api/process/failure.d.ts +1 -0
- package/target/main/ts/api/process/failure.js +12 -0
- package/target/main/ts/api/process/plugin.d.ts +10 -0
- package/target/main/ts/api/process/plugin.js +96 -0
- package/target/main/ts/compose/analyze-snapshot.d.ts +3 -2
- package/target/main/ts/compose/analyze-snapshot.js +82 -29
- package/target/main/ts/compose/inspect.d.ts +5 -0
- package/target/main/ts/compose/inspect.js +10 -6
- package/target/main/ts/core/engine/execute.d.ts +3 -1
- package/target/main/ts/core/engine/execute.js +14 -2
- package/target/main/ts/core/engine/operation-cache.d.ts +14 -0
- package/target/main/ts/core/engine/operation-cache.js +66 -0
- package/target/main/ts/core/engine/plan.d.ts +1 -0
- package/target/main/ts/core/engine/plan.js +22 -3
- package/target/main/ts/core/engine/plugin.d.ts +8 -1
- package/target/main/ts/core/engine/plugin.js +1 -3
- package/target/main/ts/core/engine/report-products.js +2 -13
- package/target/main/ts/core/model/clone-source.js +1 -1
- package/target/main/ts/core/model/code-structure.d.ts +3 -0
- package/target/main/ts/core/model/code-structure.js +4 -1
- package/target/main/ts/core/model/finding-ignore.js +1 -1
- package/target/main/ts/core/model/finding.js +1 -1
- package/target/main/ts/core/model/line-coverage.d.ts +5 -1
- package/target/main/ts/core/model/line-coverage.js +14 -11
- package/target/main/ts/core/model/measurement.js +1 -1
- package/target/main/ts/core/model/plugin-data.d.ts +2 -0
- package/target/main/ts/core/model/plugin-data.js +15 -1
- package/target/main/ts/core/model/quality-summary.js +1 -1
- package/target/main/ts/core/model/scanner-import.js +1 -1
- package/target/main/ts/core/model/snapshot.d.ts +1 -0
- package/target/main/ts/core/model/snapshot.js +5 -1
- package/target/main/ts/core/model/source.d.ts +3 -0
- package/target/main/ts/core/model/source.js +15 -0
- package/target/main/ts/core/ports/tool-runner.d.ts +18 -0
- package/target/main/ts/core/ports/tool-runner.js +2 -0
- package/target/main/ts/plugin.d.ts +7 -1
- package/target/main/ts/plugin.js +3 -1
- package/target/main/ts/plugins/coverage/coverage.d.ts +5 -2
- package/target/main/ts/plugins/coverage/coverage.js +35 -10
- package/target/main/ts/plugins/language-js/function-facts.d.ts +1 -0
- package/target/main/ts/plugins/language-js/function-facts.js +30 -4
- package/target/main/ts/report/html/app/viewer-chart-bars.d.ts +11 -0
- package/target/main/ts/report/html/app/viewer-chart-bars.js +54 -0
- package/target/main/ts/report/html/app/viewer-chart-label.d.ts +15 -0
- package/target/main/ts/report/html/app/viewer-chart-label.js +43 -0
- package/target/main/ts/report/html/app/viewer-chart-line.d.ts +24 -0
- package/target/main/ts/report/html/app/viewer-chart-line.js +89 -0
- package/target/main/ts/report/html/app/viewer-chart-points.d.ts +49 -0
- package/target/main/ts/report/html/app/viewer-chart-points.js +74 -0
- package/target/main/ts/report/html/app/viewer-chart-scale.d.ts +21 -0
- package/target/main/ts/report/html/app/viewer-chart-scale.js +93 -0
- package/target/main/ts/report/html/app/viewer-chart-svg.d.ts +28 -0
- package/target/main/ts/report/html/app/viewer-chart-svg.js +41 -0
- package/target/main/ts/report/html/app/viewer-chart-time.d.ts +26 -0
- package/target/main/ts/report/html/app/viewer-chart-time.js +150 -0
- package/target/main/ts/report/html/app/viewer-chart-tip.d.ts +4 -0
- package/target/main/ts/report/html/app/viewer-chart-tip.js +210 -0
- package/target/main/ts/report/html/app/viewer-chart-x.d.ts +12 -0
- package/target/main/ts/report/html/app/viewer-chart-x.js +50 -0
- package/target/main/ts/report/html/app/viewer-chart.d.ts +4 -98
- package/target/main/ts/report/html/app/viewer-chart.js +16 -677
- package/target/main/ts/report/html/app/viewer-code-map.d.ts +27 -0
- package/target/main/ts/report/html/app/viewer-code-map.js +175 -0
- package/target/main/ts/report/html/app/viewer-columns.d.ts +38 -0
- package/target/main/ts/report/html/app/viewer-columns.js +92 -0
- package/target/main/ts/report/html/app/viewer-commit-picker.d.ts +12 -0
- package/target/main/ts/report/html/app/viewer-commit-picker.js +229 -0
- package/target/main/ts/report/html/app/viewer-commits.d.ts +5 -9
- package/target/main/ts/report/html/app/viewer-commits.js +17 -216
- package/target/main/ts/report/html/app/viewer-controls.d.ts +43 -0
- package/target/main/ts/report/html/app/viewer-controls.js +141 -0
- package/target/main/ts/report/html/app/viewer-copy.d.ts +17 -0
- package/target/main/ts/report/html/app/viewer-copy.js +64 -0
- package/target/main/ts/report/html/app/viewer-diagnostics.d.ts +4 -0
- package/target/main/ts/report/html/app/viewer-diagnostics.js +60 -0
- package/target/main/ts/report/html/app/viewer-dom.d.ts +27 -0
- package/target/main/ts/report/html/app/viewer-dom.js +99 -0
- package/target/main/ts/report/html/app/viewer-file-aside.d.ts +19 -0
- package/target/main/ts/report/html/app/viewer-file-aside.js +124 -0
- package/target/main/ts/report/html/app/viewer-file-figures.d.ts +15 -0
- package/target/main/ts/report/html/app/viewer-file-figures.js +60 -0
- package/target/main/ts/report/html/app/viewer-file-source.d.ts +7 -0
- package/target/main/ts/report/html/app/viewer-file-source.js +119 -0
- package/target/main/ts/report/html/app/viewer-files.d.ts +2 -118
- package/target/main/ts/report/html/app/viewer-files.js +24 -2184
- package/target/main/ts/report/html/app/viewer-filter.d.ts +3 -51
- package/target/main/ts/report/html/app/viewer-filter.js +111 -450
- package/target/main/ts/report/html/app/viewer-hotspots.d.ts +4 -0
- package/target/main/ts/report/html/app/viewer-hotspots.js +131 -0
- package/target/main/ts/report/html/app/viewer-inspection.d.ts +69 -0
- package/target/main/ts/report/html/app/viewer-inspection.js +36 -0
- package/target/main/ts/report/html/app/viewer-issue-group.d.ts +27 -0
- package/target/main/ts/report/html/app/viewer-issue-group.js +174 -0
- package/target/main/ts/report/html/app/viewer-issues.d.ts +4 -0
- package/target/main/ts/report/html/app/viewer-issues.js +173 -0
- package/target/main/ts/report/html/app/viewer-language-bar.d.ts +9 -0
- package/target/main/ts/report/html/app/viewer-language-bar.js +72 -0
- package/target/main/ts/report/html/app/viewer-languages.d.ts +27 -0
- package/target/main/ts/report/html/app/viewer-languages.js +93 -0
- package/target/main/ts/report/html/app/viewer-layout.d.ts +14 -0
- package/target/main/ts/report/html/app/viewer-layout.js +134 -0
- package/target/main/ts/report/html/app/viewer-line-coverage.d.ts +47 -0
- package/target/main/ts/report/html/app/viewer-line-coverage.js +121 -0
- package/target/main/ts/report/html/app/viewer-locations.d.ts +16 -0
- package/target/main/ts/report/html/app/viewer-locations.js +31 -0
- package/target/main/ts/report/html/app/viewer-map-scale.d.ts +26 -0
- package/target/main/ts/report/html/app/viewer-map-scale.js +147 -0
- package/target/main/ts/report/html/app/viewer-map-shape.d.ts +42 -0
- package/target/main/ts/report/html/app/viewer-map-shape.js +102 -0
- package/target/main/ts/report/html/app/viewer-metric-format.d.ts +23 -0
- package/target/main/ts/report/html/app/viewer-metric-format.js +93 -0
- package/target/main/ts/report/html/app/viewer-metric-registry.d.ts +0 -20
- package/target/main/ts/report/html/app/viewer-metric-registry.js +0 -77
- package/target/main/ts/report/html/app/viewer-metrics-view.d.ts +4 -0
- package/target/main/ts/report/html/app/viewer-metrics-view.js +162 -0
- package/target/main/ts/report/html/app/viewer-metrics.d.ts +6 -1
- package/target/main/ts/report/html/app/viewer-metrics.js +53 -35
- package/target/main/ts/report/html/app/viewer-overview-cards.d.ts +12 -0
- package/target/main/ts/report/html/app/viewer-overview-cards.js +112 -0
- package/target/main/ts/report/html/app/viewer-overview-hotspots.d.ts +9 -0
- package/target/main/ts/report/html/app/viewer-overview-hotspots.js +173 -0
- package/target/main/ts/report/html/app/viewer-overview-lead.d.ts +12 -0
- package/target/main/ts/report/html/app/viewer-overview-lead.js +116 -0
- package/target/main/ts/report/html/app/viewer-profile-badges.d.ts +11 -0
- package/target/main/ts/report/html/app/viewer-profile-badges.js +119 -0
- package/target/main/ts/report/html/app/viewer-profile-table.d.ts +29 -0
- package/target/main/ts/report/html/app/viewer-profile-table.js +124 -0
- package/target/main/ts/report/html/app/viewer-profile.d.ts +2 -6
- package/target/main/ts/report/html/app/viewer-profile.js +6 -248
- package/target/main/ts/report/html/app/viewer-pull-sections.d.ts +4 -0
- package/target/main/ts/report/html/app/viewer-pull-sections.js +118 -0
- package/target/main/ts/report/html/app/viewer-pull-trend.d.ts +5 -0
- package/target/main/ts/report/html/app/viewer-pull-trend.js +63 -0
- package/target/main/ts/report/html/app/viewer-pulls.d.ts +0 -1
- package/target/main/ts/report/html/app/viewer-pulls.js +28 -178
- package/target/main/ts/report/html/app/viewer-query-field.d.ts +19 -0
- package/target/main/ts/report/html/app/viewer-query-field.js +203 -0
- package/target/main/ts/report/html/app/viewer-route.d.ts +34 -0
- package/target/main/ts/report/html/app/viewer-route.js +55 -0
- package/target/main/ts/report/html/app/viewer-shell.d.ts +20 -0
- package/target/main/ts/report/html/app/viewer-shell.js +116 -0
- package/target/main/ts/report/html/app/viewer-source-view.d.ts +49 -0
- package/target/main/ts/report/html/app/viewer-source-view.js +150 -0
- package/target/main/ts/report/html/app/viewer-source.d.ts +0 -84
- package/target/main/ts/report/html/app/viewer-source.js +7 -363
- package/target/main/ts/report/html/app/viewer-suggest.d.ts +13 -0
- package/target/main/ts/report/html/app/viewer-suggest.js +91 -0
- package/target/main/ts/report/html/app/viewer-sunburst.d.ts +5 -0
- package/target/main/ts/report/html/app/viewer-sunburst.js +40 -0
- package/target/main/ts/report/html/app/viewer-table-cells.d.ts +25 -0
- package/target/main/ts/report/html/app/viewer-table-cells.js +129 -0
- package/target/main/ts/report/html/app/viewer-table-rows.d.ts +54 -0
- package/target/main/ts/report/html/app/viewer-table-rows.js +95 -0
- package/target/main/ts/report/html/app/viewer-tokenizer.d.ts +16 -0
- package/target/main/ts/report/html/app/viewer-tokenizer.js +192 -0
- package/target/main/ts/report/html/app/viewer-totals.d.ts +14 -0
- package/target/main/ts/report/html/app/viewer-totals.js +89 -0
- package/target/main/ts/report/html/app/viewer-treemap.d.ts +24 -0
- package/target/main/ts/report/html/app/viewer-treemap.js +112 -0
- package/target/main/ts/report/html/app/viewer-trend-data.d.ts +49 -0
- package/target/main/ts/report/html/app/viewer-trend-data.js +105 -0
- package/target/main/ts/report/html/app/viewer-trend-nav.d.ts +5 -0
- package/target/main/ts/report/html/app/viewer-trend-nav.js +85 -0
- package/target/main/ts/report/html/app/viewer-trend-points.d.ts +30 -0
- package/target/main/ts/report/html/app/viewer-trend-points.js +128 -0
- package/target/main/ts/report/html/app/viewer-trend-series.d.ts +26 -0
- package/target/main/ts/report/html/app/viewer-trend-series.js +98 -0
- package/target/main/ts/report/html/app/viewer-trends.d.ts +2 -70
- package/target/main/ts/report/html/app/viewer-trends.js +41 -392
- package/target/main/ts/report/html/app/viewer.js +152 -663
- package/target/main/ts/report/html/site/badges.js +41 -18
- package/target/main/ts/report/json/store/local-store.js +2 -12
- package/target/main/ts/report/json/store/operation-cache.d.ts +8 -0
- package/target/main/ts/report/json/store/operation-cache.js +32 -0
- package/target/main/ts/report/json/store/replace-file.d.ts +1 -0
- package/target/main/ts/report/json/store/replace-file.js +14 -0
- package/target/main/ts/report.d.ts +1 -0
- package/target/main/ts/report.js +1 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { element } from './viewer-dom.js';
|
|
1
2
|
const shown = 50;
|
|
2
3
|
const day = new Intl.DateTimeFormat(undefined, { day: 'numeric', month: 'short', year: 'numeric' });
|
|
3
|
-
const dayTime = new Intl.DateTimeFormat(undefined, { day: 'numeric', month: 'short', year: 'numeric', hour: '2-digit', minute: '2-digit' });
|
|
4
|
+
export const dayTime = new Intl.DateTimeFormat(undefined, { day: 'numeric', month: 'short', year: 'numeric', hour: '2-digit', minute: '2-digit' });
|
|
4
5
|
export function commitIndex(entries) {
|
|
5
6
|
return entries.map(entry => {
|
|
6
7
|
const time = when(entry);
|
|
@@ -31,199 +32,6 @@ export function searchCommits(index, query, limit = shown) {
|
|
|
31
32
|
}
|
|
32
33
|
return { matches: [...exact, ...rest].slice(0, limit), total };
|
|
33
34
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Renders the picker into the slot; picking a commit calls back with its SHA. The branch, when the configuration names
|
|
36
|
-
* one, heads the field: the commits are that branch's history.
|
|
37
|
-
*/
|
|
38
|
-
export function createCommitPicker(slot, entries, pick, branch) {
|
|
39
|
-
const index = commitIndex(entries);
|
|
40
|
-
const bySha = new Map(entries.map(entry => [entry.sha, entry]));
|
|
41
|
-
const searchable = entries.some(entry => entry.subject || entry.author || entry.tags?.length);
|
|
42
|
-
let current = entries[0].sha;
|
|
43
|
-
let active = 0;
|
|
44
|
-
let matches = [];
|
|
45
|
-
// One control: the field shows the selected commit and, once focused, takes the search; the list opens attached
|
|
46
|
-
// under it, inside the same frame.
|
|
47
|
-
const field = element('div', 'commit-field');
|
|
48
|
-
const input = element('input', 'commit-search');
|
|
49
|
-
input.type = 'text';
|
|
50
|
-
input.autocomplete = 'off';
|
|
51
|
-
input.spellcheck = false;
|
|
52
|
-
input.placeholder = searchable ? 'Message, tag, author, date or hash' : 'Hash or date';
|
|
53
|
-
input.setAttribute('role', 'combobox');
|
|
54
|
-
input.setAttribute('aria-autocomplete', 'list');
|
|
55
|
-
input.setAttribute('aria-expanded', 'false');
|
|
56
|
-
const shown = element('span', 'commit-current');
|
|
57
|
-
shown.setAttribute('aria-hidden', 'true');
|
|
58
|
-
// The selected commit is drawn over the empty input, so both share one box after the branch.
|
|
59
|
-
const entry = element('span', 'commit-entry');
|
|
60
|
-
entry.append(input, shown);
|
|
61
|
-
if (branch) {
|
|
62
|
-
const name = element('span', 'commit-branch', branch);
|
|
63
|
-
name.title = `Branch ${branch}`;
|
|
64
|
-
name.setAttribute('aria-hidden', 'true');
|
|
65
|
-
field.append(name);
|
|
66
|
-
}
|
|
67
|
-
field.append(entry);
|
|
68
|
-
const popover = element('div', 'commit-popover');
|
|
69
|
-
popover.hidden = true;
|
|
70
|
-
const list = element('ul', 'commit-options');
|
|
71
|
-
list.id = 'commit-options';
|
|
72
|
-
list.setAttribute('role', 'listbox');
|
|
73
|
-
list.setAttribute('aria-label', 'Commits');
|
|
74
|
-
input.setAttribute('aria-controls', list.id);
|
|
75
|
-
const status = element('p', 'commit-status');
|
|
76
|
-
status.setAttribute('aria-live', 'polite');
|
|
77
|
-
popover.append(list, status);
|
|
78
|
-
slot.replaceChildren(field, popover);
|
|
79
|
-
function label() {
|
|
80
|
-
const entry = bySha.get(current);
|
|
81
|
-
const time = when(entry);
|
|
82
|
-
shown.replaceChildren(element('span', 'commit-hash', entry.sha.slice(0, 7)), element('span', 'commit-current-text', entry.subject ?? (time === null ? '' : dayTime.format(new Date(time)))));
|
|
83
|
-
field.title = [entry.sha, entry.subject].filter(Boolean).join('\n');
|
|
84
|
-
input.setAttribute('aria-label', `${branch ? `Branch ${branch}, commit` : 'Commit'} ${entry.sha.slice(0, 7)}${entry.subject ? `: ${entry.subject}` : ''}. Type to search commits`);
|
|
85
|
-
}
|
|
86
|
-
function update() {
|
|
87
|
-
const result = searchCommits(index, input.value);
|
|
88
|
-
matches = result.matches;
|
|
89
|
-
active = Math.max(0, matches.findIndex(match => match.entry.sha === current));
|
|
90
|
-
if (input.value.trim())
|
|
91
|
-
active = 0;
|
|
92
|
-
const words = input.value.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
|
93
|
-
list.replaceChildren(...matches.map((match, position) => option(match.entry, position, words)));
|
|
94
|
-
status.textContent = result.total === 0 ? `No commits match “${input.value.trim()}”`
|
|
95
|
-
: result.total > matches.length ? `${matches.length} of ${result.total.toLocaleString()} ${input.value.trim() ? 'matches' : 'commits'} · type to narrow`
|
|
96
|
-
: `${result.total.toLocaleString()} ${result.total === 1 ? 'commit' : 'commits'}${branch && !input.value.trim() ? ` on ${branch}` : ''}`;
|
|
97
|
-
highlight();
|
|
98
|
-
}
|
|
99
|
-
function option(entry, position, words) {
|
|
100
|
-
const item = element('li', 'commit-option');
|
|
101
|
-
item.id = `commit-option-${position}`;
|
|
102
|
-
item.setAttribute('role', 'option');
|
|
103
|
-
item.setAttribute('aria-selected', String(entry.sha === current));
|
|
104
|
-
const time = when(entry);
|
|
105
|
-
const head = element('span', 'commit-option-head');
|
|
106
|
-
head.append(marked('span', 'commit-hash', entry.sha.slice(0, 7), words, true), marked('span', 'commit-subject', entry.subject ?? (time === null ? '' : dayTime.format(new Date(time))), words));
|
|
107
|
-
item.append(head);
|
|
108
|
-
// The second line names who and when, then the tags: two fit, the rest fold into a count, and the tags the
|
|
109
|
-
// search found come first. The email appears only when the search found it.
|
|
110
|
-
const author = authorLabel(entry.author, words);
|
|
111
|
-
const meta = [author, entry.subject && time !== null ? dayTime.format(new Date(time)) : null].filter(Boolean).join(' · ');
|
|
112
|
-
const tags = [...entry.tags ?? []].sort((a, b) => Number(hit(b, words)) - Number(hit(a, words)));
|
|
113
|
-
if (meta || tags.length) {
|
|
114
|
-
const line = element('span', 'commit-option-meta');
|
|
115
|
-
line.append(marked('span', 'commit-meta', meta, words));
|
|
116
|
-
for (const tag of tags.slice(0, 2))
|
|
117
|
-
line.append(marked('span', 'commit-tag', tag, words));
|
|
118
|
-
if (tags.length > 2) {
|
|
119
|
-
const more = element('span', 'commit-tag commit-tag-more', `+${tags.length - 2}`);
|
|
120
|
-
more.title = tags.slice(2).join('\n');
|
|
121
|
-
line.append(more);
|
|
122
|
-
}
|
|
123
|
-
item.append(line);
|
|
124
|
-
}
|
|
125
|
-
item.addEventListener('mousedown', event => event.preventDefault());
|
|
126
|
-
item.addEventListener('click', () => choose(entry.sha));
|
|
127
|
-
item.addEventListener('mousemove', () => { if (active !== position) {
|
|
128
|
-
active = position;
|
|
129
|
-
highlight();
|
|
130
|
-
} });
|
|
131
|
-
return item;
|
|
132
|
-
}
|
|
133
|
-
function highlight() {
|
|
134
|
-
for (const [position, item] of [...list.children].entries())
|
|
135
|
-
item.classList.toggle('active', position === active);
|
|
136
|
-
const item = list.children[active];
|
|
137
|
-
if (item) {
|
|
138
|
-
input.setAttribute('aria-activedescendant', item.id);
|
|
139
|
-
item.scrollIntoView({ block: 'nearest' });
|
|
140
|
-
}
|
|
141
|
-
else
|
|
142
|
-
input.removeAttribute('aria-activedescendant');
|
|
143
|
-
}
|
|
144
|
-
const isOpen = () => !popover.hidden;
|
|
145
|
-
function open() {
|
|
146
|
-
if (isOpen())
|
|
147
|
-
return;
|
|
148
|
-
popover.hidden = false;
|
|
149
|
-
slot.classList.add('open');
|
|
150
|
-
input.setAttribute('aria-expanded', 'true');
|
|
151
|
-
update();
|
|
152
|
-
document.addEventListener('pointerdown', outside, true);
|
|
153
|
-
}
|
|
154
|
-
function close() {
|
|
155
|
-
if (!isOpen())
|
|
156
|
-
return;
|
|
157
|
-
popover.hidden = true;
|
|
158
|
-
slot.classList.remove('open');
|
|
159
|
-
input.setAttribute('aria-expanded', 'false');
|
|
160
|
-
input.removeAttribute('aria-activedescendant');
|
|
161
|
-
input.value = '';
|
|
162
|
-
document.removeEventListener('pointerdown', outside, true);
|
|
163
|
-
}
|
|
164
|
-
function outside(event) {
|
|
165
|
-
if (!slot.contains(event.target))
|
|
166
|
-
close();
|
|
167
|
-
}
|
|
168
|
-
function choose(sha) {
|
|
169
|
-
close();
|
|
170
|
-
input.blur();
|
|
171
|
-
if (sha !== current)
|
|
172
|
-
pick(sha);
|
|
173
|
-
}
|
|
174
|
-
field.addEventListener('pointerdown', event => {
|
|
175
|
-
if (event.target !== input)
|
|
176
|
-
event.preventDefault();
|
|
177
|
-
input.focus();
|
|
178
|
-
open();
|
|
179
|
-
});
|
|
180
|
-
input.addEventListener('focus', open);
|
|
181
|
-
input.addEventListener('blur', () => { if (!slot.matches(':hover'))
|
|
182
|
-
close(); });
|
|
183
|
-
input.addEventListener('input', () => isOpen() ? update() : open());
|
|
184
|
-
input.addEventListener('keydown', event => {
|
|
185
|
-
const last = matches.length - 1;
|
|
186
|
-
if (!isOpen() && (event.key === 'ArrowDown' || event.key === 'ArrowUp' || event.key === 'Enter')) {
|
|
187
|
-
event.preventDefault();
|
|
188
|
-
open();
|
|
189
|
-
}
|
|
190
|
-
else if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
191
|
-
event.preventDefault();
|
|
192
|
-
active = last < 0 ? 0 : (active + (event.key === 'ArrowDown' ? 1 : -1) + matches.length) % matches.length;
|
|
193
|
-
highlight();
|
|
194
|
-
}
|
|
195
|
-
else if (event.key === 'PageDown' || event.key === 'PageUp') {
|
|
196
|
-
event.preventDefault();
|
|
197
|
-
active = Math.min(last, Math.max(0, active + (event.key === 'PageDown' ? 8 : -8)));
|
|
198
|
-
highlight();
|
|
199
|
-
}
|
|
200
|
-
else if (event.key === 'Enter') {
|
|
201
|
-
event.preventDefault();
|
|
202
|
-
const match = matches[active];
|
|
203
|
-
if (match)
|
|
204
|
-
choose(match.entry.sha);
|
|
205
|
-
}
|
|
206
|
-
else if (event.key === 'Escape' && isOpen()) {
|
|
207
|
-
event.preventDefault();
|
|
208
|
-
close();
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
label();
|
|
212
|
-
return {
|
|
213
|
-
set(sha) {
|
|
214
|
-
if (!bySha.has(sha))
|
|
215
|
-
return;
|
|
216
|
-
current = sha;
|
|
217
|
-
label();
|
|
218
|
-
},
|
|
219
|
-
get hidden() { return slot.hidden === true; },
|
|
220
|
-
set hidden(value) {
|
|
221
|
-
if (value)
|
|
222
|
-
close();
|
|
223
|
-
slot.hidden = value;
|
|
224
|
-
},
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
35
|
/**
|
|
228
36
|
* How a commit's author reads in the list: the name, with the email only when the search found the email and not the
|
|
229
37
|
* name. A history without emails carries the name alone, and then it is the name alone; nothing reads as missing.
|
|
@@ -233,31 +41,32 @@ export function authorLabel(author, words) {
|
|
|
233
41
|
return null;
|
|
234
42
|
return author.email && hit(author.email, words) && !hit(author.name, words) ? `${author.name} <${author.email}>` : author.name;
|
|
235
43
|
}
|
|
236
|
-
function hit(text, words) {
|
|
44
|
+
export function hit(text, words) {
|
|
237
45
|
const lower = text.toLowerCase();
|
|
238
46
|
return words.some(word => lower.includes(word));
|
|
239
47
|
}
|
|
240
|
-
function when(entry) {
|
|
48
|
+
export function when(entry) {
|
|
241
49
|
const time = Date.parse(entry.committedAt ?? entry.generatedAt);
|
|
242
50
|
return Number.isFinite(time) ? time : null;
|
|
243
51
|
}
|
|
244
|
-
/**
|
|
245
|
-
function
|
|
246
|
-
const node = element(tag, className);
|
|
247
|
-
const lower = text.toLowerCase();
|
|
52
|
+
/** Where the typed words stand in the text, in order; a hash is matched only from its start. */
|
|
53
|
+
function wordRanges(lower, words, prefixOnly) {
|
|
248
54
|
const ranges = [];
|
|
249
55
|
for (const word of words) {
|
|
250
|
-
if (prefixOnly) {
|
|
251
|
-
|
|
252
|
-
ranges.push([
|
|
253
|
-
continue;
|
|
56
|
+
if (!prefixOnly) {
|
|
57
|
+
for (let at = lower.indexOf(word); at >= 0; at = lower.indexOf(word, at + word.length))
|
|
58
|
+
ranges.push([at, at + word.length]);
|
|
254
59
|
}
|
|
255
|
-
|
|
256
|
-
ranges.push([
|
|
60
|
+
else if (lower.startsWith(word))
|
|
61
|
+
ranges.push([0, word.length]);
|
|
257
62
|
}
|
|
258
|
-
ranges.sort((a, b) => a[0] - b[0]);
|
|
63
|
+
return ranges.sort((a, b) => a[0] - b[0]);
|
|
64
|
+
}
|
|
65
|
+
/** Text with the typed words marked; a hash is marked only from its start, as it is matched. */
|
|
66
|
+
export function marked(tag, className, text, words, prefixOnly = false) {
|
|
67
|
+
const node = element(tag, className);
|
|
259
68
|
let cursor = 0;
|
|
260
|
-
for (const [start, end] of
|
|
69
|
+
for (const [start, end] of wordRanges(text.toLowerCase(), words, prefixOnly)) {
|
|
261
70
|
if (end <= cursor)
|
|
262
71
|
continue;
|
|
263
72
|
const from = Math.max(start, cursor);
|
|
@@ -270,11 +79,3 @@ function marked(tag, className, text, words, prefixOnly = false) {
|
|
|
270
79
|
node.append(text.slice(cursor));
|
|
271
80
|
return node;
|
|
272
81
|
}
|
|
273
|
-
function element(tag, className, text) {
|
|
274
|
-
const node = document.createElement(tag);
|
|
275
|
-
if (className)
|
|
276
|
-
node.className = className;
|
|
277
|
-
if (text !== undefined)
|
|
278
|
-
node.textContent = text;
|
|
279
|
-
return node;
|
|
280
|
-
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare function searchField(text: string, placeholder: string): {
|
|
2
|
+
label: HTMLLabelElement;
|
|
3
|
+
input: HTMLInputElement;
|
|
4
|
+
};
|
|
5
|
+
/** Two or three exclusive views as one segmented switch; the pressed segment is the current view. */
|
|
6
|
+
export declare function segmented(text: string, options: readonly (readonly [string, string])[], selected: string, change: (value: string) => void): HTMLElement;
|
|
7
|
+
/** Presses the segment with this name, as a click on it would look, without running its change. */
|
|
8
|
+
export declare function pressSegment(group: HTMLElement, name: string): void;
|
|
9
|
+
/** A details menu that closes on a click elsewhere or on Escape, as a menu does. */
|
|
10
|
+
export declare function dismissible(menu: HTMLDetailsElement): void;
|
|
11
|
+
/** What a multiple choice's button says: all, up to two names, or how many are chosen. */
|
|
12
|
+
export declare function chosenLabel(chosen: readonly string[], all: string, plural: string): string;
|
|
13
|
+
/** What a multiple choice is called, what it says with nothing ticked, and what it counts with many. */
|
|
14
|
+
export interface ChoiceNames {
|
|
15
|
+
readonly text: string;
|
|
16
|
+
readonly all: string;
|
|
17
|
+
readonly plural: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A dropdown of checkboxes: none ticked means all. The button names what is chosen, so the filter reads at a glance;
|
|
21
|
+
* each option carries its count. It hides itself when there is nothing to choose between.
|
|
22
|
+
*/
|
|
23
|
+
export declare function multiChoice({ text, all, plural }: ChoiceNames, options: readonly (readonly [string, string, number])[], change: () => void, initial?: Iterable<string>): {
|
|
24
|
+
element: HTMLDetailsElement;
|
|
25
|
+
values: Set<string>;
|
|
26
|
+
};
|
|
27
|
+
export declare function choice(text: string, options: readonly (readonly [string, string])[], selected: string): {
|
|
28
|
+
label: HTMLLabelElement;
|
|
29
|
+
select: HTMLSelectElement;
|
|
30
|
+
};
|
|
31
|
+
/** A select's options: the catch-all first, then each distinct value by its label. */
|
|
32
|
+
export declare function choices<T extends string>(first: string, values: readonly T[], labels?: Readonly<Partial<Record<T, string>>>): [string, string][];
|
|
33
|
+
export declare function navigationButtons(label: string, previous: () => void, next: () => void): {
|
|
34
|
+
section: HTMLElement;
|
|
35
|
+
update: (page: number, pages: number) => void;
|
|
36
|
+
};
|
|
37
|
+
/** A paged list's state: its buttons, and the page they move, rendered again on each move. */
|
|
38
|
+
export declare function pager(label: string, render: () => void): {
|
|
39
|
+
page: number;
|
|
40
|
+
} & {
|
|
41
|
+
section: HTMLElement;
|
|
42
|
+
update: (page: number, pages: number) => void;
|
|
43
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { collator, count, element } from './viewer-dom.js';
|
|
2
|
+
export function searchField(text, placeholder) {
|
|
3
|
+
const label = element('label', 'fx-field');
|
|
4
|
+
label.append(element('span', 'fx-field-text', text));
|
|
5
|
+
const input = element('input');
|
|
6
|
+
input.type = 'search';
|
|
7
|
+
input.placeholder = placeholder;
|
|
8
|
+
input.spellcheck = false;
|
|
9
|
+
label.append(input);
|
|
10
|
+
return { label, input };
|
|
11
|
+
}
|
|
12
|
+
/** Two or three exclusive views as one segmented switch; the pressed segment is the current view. */
|
|
13
|
+
export function segmented(text, options, selected, change) {
|
|
14
|
+
const group = element('div', 'fx-segmented');
|
|
15
|
+
group.setAttribute('role', 'group');
|
|
16
|
+
group.setAttribute('aria-label', text);
|
|
17
|
+
const buttons = options.map(([value, name]) => {
|
|
18
|
+
const button = element('button', '', name);
|
|
19
|
+
button.type = 'button';
|
|
20
|
+
button.setAttribute('aria-pressed', String(value === selected));
|
|
21
|
+
button.addEventListener('click', () => {
|
|
22
|
+
for (const other of buttons)
|
|
23
|
+
other.setAttribute('aria-pressed', String(other === button));
|
|
24
|
+
change(value);
|
|
25
|
+
});
|
|
26
|
+
return button;
|
|
27
|
+
});
|
|
28
|
+
group.append(...buttons);
|
|
29
|
+
return group;
|
|
30
|
+
}
|
|
31
|
+
/** Presses the segment with this name, as a click on it would look, without running its change. */
|
|
32
|
+
export function pressSegment(group, name) {
|
|
33
|
+
group.querySelectorAll('button').forEach(button => button.setAttribute('aria-pressed', String(button.textContent === name)));
|
|
34
|
+
}
|
|
35
|
+
/** A details menu that closes on a click elsewhere or on Escape, as a menu does. */
|
|
36
|
+
export function dismissible(menu) {
|
|
37
|
+
const close = (event) => {
|
|
38
|
+
const key = event instanceof KeyboardEvent;
|
|
39
|
+
if (key ? event.key !== 'Escape' : menu.contains(event.target))
|
|
40
|
+
return;
|
|
41
|
+
if (menu.open && key)
|
|
42
|
+
menu.querySelector('summary')?.focus();
|
|
43
|
+
menu.open = false;
|
|
44
|
+
};
|
|
45
|
+
menu.addEventListener('toggle', () => {
|
|
46
|
+
const listen = menu.open ? document.addEventListener.bind(document) : document.removeEventListener.bind(document);
|
|
47
|
+
listen('pointerdown', close, true);
|
|
48
|
+
listen('keydown', close);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/** What a multiple choice's button says: all, up to two names, or how many are chosen. */
|
|
52
|
+
export function chosenLabel(chosen, all, plural) {
|
|
53
|
+
if (chosen.length === 0)
|
|
54
|
+
return all;
|
|
55
|
+
// Two choices read by name, so a filtered view says what it holds; more read as a count.
|
|
56
|
+
return chosen.length <= 2 ? chosen.join(', ') : `${chosen.length} ${plural}`;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A dropdown of checkboxes: none ticked means all. The button names what is chosen, so the filter reads at a glance;
|
|
60
|
+
* each option carries its count. It hides itself when there is nothing to choose between.
|
|
61
|
+
*/
|
|
62
|
+
export function multiChoice({ text, all, plural }, options, change, initial = []) {
|
|
63
|
+
const offered = new Set(options.map(([value]) => value));
|
|
64
|
+
const values = new Set([...initial].filter(value => offered.has(value)));
|
|
65
|
+
const menu = element('details', 'fx-columns fx-multi');
|
|
66
|
+
menu.hidden = options.length < 2;
|
|
67
|
+
const summary = element('summary', '', all);
|
|
68
|
+
summary.setAttribute('aria-label', `${text}: ${all}`);
|
|
69
|
+
const list = element('div', 'fx-column-toggles');
|
|
70
|
+
list.setAttribute('role', 'group');
|
|
71
|
+
list.setAttribute('aria-label', text);
|
|
72
|
+
function label() {
|
|
73
|
+
const chosen = options.filter(([value]) => values.has(value)).map(([, name]) => name);
|
|
74
|
+
summary.textContent = chosenLabel(chosen, all, plural);
|
|
75
|
+
summary.title = chosen.join(', ');
|
|
76
|
+
summary.setAttribute('aria-label', `${text}: ${chosen.length ? chosen.join(', ') : all}`);
|
|
77
|
+
menu.classList.toggle('fx-multi-active', chosen.length > 0);
|
|
78
|
+
}
|
|
79
|
+
for (const [value, name, total] of options) {
|
|
80
|
+
const row = element('label', 'fx-column-toggle');
|
|
81
|
+
const box = element('input');
|
|
82
|
+
box.type = 'checkbox';
|
|
83
|
+
box.value = value;
|
|
84
|
+
box.checked = values.has(value);
|
|
85
|
+
box.addEventListener('change', () => {
|
|
86
|
+
if (box.checked)
|
|
87
|
+
values.add(value);
|
|
88
|
+
else
|
|
89
|
+
values.delete(value);
|
|
90
|
+
label();
|
|
91
|
+
change();
|
|
92
|
+
});
|
|
93
|
+
row.append(box, element('span', 'fx-multi-name', name), element('span', 'fx-multi-count', total.toLocaleString()));
|
|
94
|
+
list.append(row);
|
|
95
|
+
}
|
|
96
|
+
menu.append(summary, list);
|
|
97
|
+
dismissible(menu);
|
|
98
|
+
label();
|
|
99
|
+
return { element: menu, values };
|
|
100
|
+
}
|
|
101
|
+
export function choice(text, options, selected) {
|
|
102
|
+
const label = element('label', 'fx-field');
|
|
103
|
+
label.append(element('span', 'fx-field-text', text));
|
|
104
|
+
const select = element('select');
|
|
105
|
+
for (const [value, name] of options) {
|
|
106
|
+
const option = element('option', '', name);
|
|
107
|
+
option.value = value;
|
|
108
|
+
select.append(option);
|
|
109
|
+
}
|
|
110
|
+
select.value = selected;
|
|
111
|
+
label.append(select);
|
|
112
|
+
return { label, select };
|
|
113
|
+
}
|
|
114
|
+
/** A select's options: the catch-all first, then each distinct value by its label. */
|
|
115
|
+
export function choices(first, values, labels) {
|
|
116
|
+
const unique = [...new Set(values)].map(value => [value, labels?.[value] ?? value]);
|
|
117
|
+
return [['', first], ...unique.sort((a, b) => collator.compare(a[1], b[1]))];
|
|
118
|
+
}
|
|
119
|
+
export function navigationButtons(label, previous, next) {
|
|
120
|
+
const section = element('nav', 'fx-page-buttons');
|
|
121
|
+
section.setAttribute('aria-label', label);
|
|
122
|
+
const back = element('button', 'button', 'Previous');
|
|
123
|
+
const forward = element('button', 'button', 'Next');
|
|
124
|
+
back.type = forward.type = 'button';
|
|
125
|
+
back.addEventListener('click', previous);
|
|
126
|
+
forward.addEventListener('click', next);
|
|
127
|
+
const pageLabel = element('span', 'fx-note');
|
|
128
|
+
pageLabel.setAttribute('aria-live', 'polite');
|
|
129
|
+
section.append(back, pageLabel, forward);
|
|
130
|
+
return { section, update: (page, pages) => {
|
|
131
|
+
back.disabled = page === 0;
|
|
132
|
+
forward.disabled = page + 1 >= pages;
|
|
133
|
+
pageLabel.textContent = `${count(page + 1)} of ${count(pages)}`;
|
|
134
|
+
} };
|
|
135
|
+
}
|
|
136
|
+
/** A paged list's state: its buttons, and the page they move, rendered again on each move. */
|
|
137
|
+
export function pager(label, render) {
|
|
138
|
+
const state = { page: 0 };
|
|
139
|
+
const buttons = navigationButtons(label, () => { state.page--; render(); }, () => { state.page++; render(); });
|
|
140
|
+
return Object.assign(state, buttons);
|
|
141
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface CopyFeedback {
|
|
2
|
+
/** The text is on the clipboard; the button shows its check until `reset`. */
|
|
3
|
+
copied(): void;
|
|
4
|
+
reset(): void;
|
|
5
|
+
/** The browser refused the clipboard: the reader copies by hand. */
|
|
6
|
+
refused(): void;
|
|
7
|
+
}
|
|
8
|
+
/** Copies the text on each click, with a check that fades after a moment, or the fallback the browser leaves. */
|
|
9
|
+
export declare function copyOnClick(button: HTMLButtonElement, text: () => string, feedback: CopyFeedback): void;
|
|
10
|
+
/**
|
|
11
|
+
* Copies a file's path from the repository root. Where the browser refuses the clipboard, `show` puts the path on the
|
|
12
|
+
* page and it is selected, for the reader's own copy shortcut.
|
|
13
|
+
*/
|
|
14
|
+
export declare function copyPathButton(path: string, show: () => HTMLElement): HTMLButtonElement;
|
|
15
|
+
/** The common copy glyph, two offset sheets, with the check it turns into once copied. */
|
|
16
|
+
export declare function copyIcon(): SVGSVGElement;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { element, svgElement } from './viewer-dom.js';
|
|
2
|
+
/** Copies the text on each click, with a check that fades after a moment, or the fallback the browser leaves. */
|
|
3
|
+
export function copyOnClick(button, text, feedback) {
|
|
4
|
+
let timer;
|
|
5
|
+
button.addEventListener('click', async () => {
|
|
6
|
+
clearTimeout(timer);
|
|
7
|
+
try {
|
|
8
|
+
if (!navigator.clipboard)
|
|
9
|
+
throw new Error('Clipboard unavailable');
|
|
10
|
+
await navigator.clipboard.writeText(text());
|
|
11
|
+
button.classList.add('fx-copied');
|
|
12
|
+
feedback.copied();
|
|
13
|
+
timer = setTimeout(() => {
|
|
14
|
+
button.classList.remove('fx-copied');
|
|
15
|
+
feedback.reset();
|
|
16
|
+
}, 1500);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
feedback.refused();
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Copies a file's path from the repository root. Where the browser refuses the clipboard, `show` puts the path on the
|
|
25
|
+
* page and it is selected, for the reader's own copy shortcut.
|
|
26
|
+
*/
|
|
27
|
+
export function copyPathButton(path, show) {
|
|
28
|
+
const label = 'Copy path';
|
|
29
|
+
const copy = element('button', 'fx-copy fx-copy-inline');
|
|
30
|
+
copy.type = 'button';
|
|
31
|
+
copy.title = `${label}: ${path}`;
|
|
32
|
+
copy.setAttribute('aria-label', label);
|
|
33
|
+
copy.append(copyIcon());
|
|
34
|
+
const status = element('span', 'visually-hidden');
|
|
35
|
+
status.setAttribute('role', 'status');
|
|
36
|
+
copy.append(status);
|
|
37
|
+
copyOnClick(copy, () => path, {
|
|
38
|
+
copied: () => { status.textContent = 'Path copied'; },
|
|
39
|
+
reset: () => { status.textContent = ''; },
|
|
40
|
+
refused: () => {
|
|
41
|
+
window.getSelection()?.selectAllChildren(show());
|
|
42
|
+
status.textContent = 'Path selected. Press your copy shortcut.';
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
return copy;
|
|
46
|
+
}
|
|
47
|
+
/** The common copy glyph, two offset sheets, with the check it turns into once copied. */
|
|
48
|
+
export function copyIcon() {
|
|
49
|
+
const svg = svgElement('svg');
|
|
50
|
+
svg.setAttribute('viewBox', '0 0 16 16');
|
|
51
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
52
|
+
const shapes = [
|
|
53
|
+
['rect', { class: 'fx-copy-sheets', x: '5.5', y: '5.5', width: '8', height: '8', rx: '1.5' }],
|
|
54
|
+
['path', { class: 'fx-copy-sheets', d: 'M10.5 3.5v-.5A1.5 1.5 0 0 0 9 1.5H3A1.5 1.5 0 0 0 1.5 3v6A1.5 1.5 0 0 0 3 10.5h.5' }],
|
|
55
|
+
['path', { class: 'fx-copy-check', d: 'M3 8.5l3 3 7-7' }],
|
|
56
|
+
];
|
|
57
|
+
for (const [tag, attributes] of shapes) {
|
|
58
|
+
const shape = svgElement(tag);
|
|
59
|
+
for (const [name, value] of Object.entries(attributes))
|
|
60
|
+
shape.setAttribute(name, value);
|
|
61
|
+
svg.append(shape);
|
|
62
|
+
}
|
|
63
|
+
return svg;
|
|
64
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { InspectionDetails } from '../../json/wire/inspection-details-model.js';
|
|
2
|
+
import type { Navigation } from './viewer-inspection.js';
|
|
3
|
+
/** The Diagnostics page: what the analysis could not do, filtered by a search, an operation and a state. */
|
|
4
|
+
export declare function diagnosticsView(details: InspectionDetails, navigation: Navigation): HTMLElement;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { choice, choices, navigationButtons, searchField } from './viewer-controls.js';
|
|
2
|
+
import { contains, element, link, quantity } from './viewer-dom.js';
|
|
3
|
+
import { fileHref } from './viewer-file-figures.js';
|
|
4
|
+
import { pageSize } from './viewer-inspection.js';
|
|
5
|
+
const diagnosticStates = { failed: 'Failed', blocked: 'Blocked', partial: 'Partial' };
|
|
6
|
+
function diagnosticItem(row, navigation, files) {
|
|
7
|
+
const item = element('li');
|
|
8
|
+
const heading = element('div', 'fx-event-heading');
|
|
9
|
+
const state = element('span', 'fx-state', diagnosticStates[row.state]);
|
|
10
|
+
state.dataset.state = row.state;
|
|
11
|
+
heading.append(element('code', 'fx-path', row.operation), state);
|
|
12
|
+
item.append(heading, element('p', '', row.message));
|
|
13
|
+
if (row.path)
|
|
14
|
+
item.append(files.has(row.path) ? link(fileHref(navigation, row.path), row.path, 'fx-inline-link') : element('code', 'fx-path', row.path));
|
|
15
|
+
return item;
|
|
16
|
+
}
|
|
17
|
+
/** The Diagnostics page: what the analysis could not do, filtered by a search, an operation and a state. */
|
|
18
|
+
export function diagnosticsView(details, navigation) {
|
|
19
|
+
const { diagnostics, metrics } = details;
|
|
20
|
+
const view = element('section', 'fx-view panel fx-events');
|
|
21
|
+
const path = navigation.file;
|
|
22
|
+
const scoped = path ? diagnostics.filter(row => row.path === path) : diagnostics;
|
|
23
|
+
if (path) {
|
|
24
|
+
const scope = element('div', 'fx-file-heading');
|
|
25
|
+
scope.append(element('code', 'fx-path', path), link(navigation.href('diagnostics'), 'All diagnostics', 'fx-inline-link'));
|
|
26
|
+
view.append(scope);
|
|
27
|
+
}
|
|
28
|
+
if (!scoped.length) {
|
|
29
|
+
view.append(element('p', 'fx-note', path ? 'No analysis diagnostics for this file.' : 'No analysis diagnostics for this commit.'));
|
|
30
|
+
return view;
|
|
31
|
+
}
|
|
32
|
+
const search = searchField('Search diagnostics', 'Operation, path or message');
|
|
33
|
+
const operation = choice('Operation', choices('All operations', scoped.map(row => row.operation)), '');
|
|
34
|
+
const state = choice('State', choices('All states', scoped.map(row => row.state), diagnosticStates), '');
|
|
35
|
+
const tools = element('div', 'fx-tools');
|
|
36
|
+
tools.append(search.label, operation.label, state.label);
|
|
37
|
+
const result = element('p', 'fx-note fx-results');
|
|
38
|
+
result.setAttribute('aria-live', 'polite');
|
|
39
|
+
const events = element('ul', 'fx-event-list');
|
|
40
|
+
const nav = navigationButtons('Diagnostic pages', () => { page--; render(); }, () => { page++; render(); });
|
|
41
|
+
view.append(tools, result, events, nav.section);
|
|
42
|
+
const files = new Set(metrics.files.map(entry => entry.path));
|
|
43
|
+
let page = 0;
|
|
44
|
+
const picked = (select, value) => !select.value || select.value === value;
|
|
45
|
+
function render() {
|
|
46
|
+
const query = search.input.value.trim().toLowerCase();
|
|
47
|
+
const matches = scoped.filter(row => picked(state.select, row.state) && picked(operation.select, row.operation)
|
|
48
|
+
&& contains(query, [row.operation, row.path, row.message]));
|
|
49
|
+
result.textContent = matches.length ? quantity(matches.length, 'diagnostic') : 'No diagnostics match these filters.';
|
|
50
|
+
events.replaceChildren(...matches.slice(page * pageSize, (page + 1) * pageSize).map(row => diagnosticItem(row, navigation, files)));
|
|
51
|
+
nav.section.hidden = matches.length <= pageSize;
|
|
52
|
+
nav.update(page, Math.ceil(matches.length / pageSize));
|
|
53
|
+
}
|
|
54
|
+
const reset = () => { page = 0; render(); };
|
|
55
|
+
search.input.addEventListener('input', reset);
|
|
56
|
+
operation.select.addEventListener('change', reset);
|
|
57
|
+
state.select.addEventListener('change', reset);
|
|
58
|
+
render();
|
|
59
|
+
return view;
|
|
60
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** The DOM building blocks every page of the viewer shares. */
|
|
2
|
+
/** Paths compare as people read them: numbers by value, so file10 follows file9. */
|
|
3
|
+
export declare const collator: Intl.Collator;
|
|
4
|
+
export declare function element<K extends keyof HTMLElementTagNameMap>(tag: K, className?: string, text?: string): HTMLElementTagNameMap[K];
|
|
5
|
+
export declare function svgElement<K extends keyof SVGElementTagNameMap>(tag: K): SVGElementTagNameMap[K];
|
|
6
|
+
export declare function link(href: string, label: string, className?: string): HTMLAnchorElement;
|
|
7
|
+
/** A link that opens another site in a new tab, without handing it this page. */
|
|
8
|
+
export declare function externalLink(href: string, label: string, className?: string): HTMLAnchorElement;
|
|
9
|
+
/** One row of a description list, with a quieter line of context under the value. */
|
|
10
|
+
export declare function fact(label: string, value: string, context?: string): HTMLElement;
|
|
11
|
+
/** A table that scrolls on its own, named so the region can be found and scrolled from the keyboard. */
|
|
12
|
+
export declare function scrollableTable(table: HTMLTableElement, label: string): HTMLElement;
|
|
13
|
+
export declare function count(value: number | null | undefined): string;
|
|
14
|
+
export declare function percent(value: number): string;
|
|
15
|
+
export declare function quantity(amount: number, noun: string): string;
|
|
16
|
+
export declare function parentPath(path: string): string;
|
|
17
|
+
export declare function basename(path: string): string;
|
|
18
|
+
export declare function inside(path: string, directory: string): boolean;
|
|
19
|
+
/** Whether any of the strings holds the lowercased query; an empty query holds everywhere. */
|
|
20
|
+
export declare function contains(query: string, strings: readonly (string | undefined)[]): boolean;
|
|
21
|
+
/** Storage that a private window or a blocked site refuses: reads fall back, writes are forgotten. */
|
|
22
|
+
export declare function stored(storage: () => Storage, key: string): string | null;
|
|
23
|
+
export declare function store(storage: () => Storage, key: string, value: string | null): void;
|
|
24
|
+
/** An element of the page by its id; the page's own markup holds every id the viewer asks for. */
|
|
25
|
+
export declare function byId(id: string): HTMLElement;
|
|
26
|
+
/** A quiet status line in place of a container's content: loading, empty, or failed. */
|
|
27
|
+
export declare function notice(container: HTMLElement, text: string): void;
|