repometry 0.4.2 → 0.6.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 +36 -14
- package/package.json +1 -1
- package/target/main/resources/report/json/comparison-v1.schema.json +6 -6
- package/target/main/resources/report/json/file-metrics-v1.schema.json +7 -6
- package/target/main/resources/report/json/pull-review-v1.schema.json +5 -5
- package/target/main/resources/report/json/report-v2.schema.json +210 -11
- package/target/main/resources/report/json/repository-summary-v1.schema.json +161 -14
- package/target/main/resources/report/json/viewer-inspection-v1.schema.json +518 -6
- package/target/main/resources/viewer/styles.css +7 -2
- package/target/main/ts/api/git/changes.d.ts +1 -1
- package/target/main/ts/api/git/changes.js +3 -3
- package/target/main/ts/api/git/commit-metadata.js +6 -4
- package/target/main/ts/api/git/git.d.ts +2 -1
- package/target/main/ts/api/git/git.js +16 -4
- package/target/main/ts/api/git/inspection-source.d.ts +1 -1
- package/target/main/ts/api/git/inspection-source.js +4 -10
- package/target/main/ts/api/git/local.d.ts +1 -1
- package/target/main/ts/api/git/local.js +41 -7
- 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/api/worker/remote-executor.d.ts +1 -1
- package/target/main/ts/api/worker/remote-executor.js +2 -2
- package/target/main/ts/api/worker/worker-protocol.d.ts +2 -2
- package/target/main/ts/api/worker/worker-protocol.js +8 -8
- package/target/main/ts/api/worker/worker.d.ts +1 -1
- package/target/main/ts/api/worker/worker.js +4 -4
- package/target/main/ts/cli/main.js +4 -3
- package/target/main/ts/cli/reporting.d.ts +1 -1
- package/target/main/ts/cli/reporting.js +1 -1
- package/target/main/ts/compose/analysis-files.d.ts +13 -0
- package/target/main/ts/compose/analysis-files.js +95 -0
- package/target/main/ts/compose/analysis-imports.d.ts +7 -0
- package/target/main/ts/compose/analysis-imports.js +34 -0
- package/target/main/ts/compose/analysis-report.d.ts +5 -0
- package/target/main/ts/compose/analysis-report.js +78 -0
- package/target/main/ts/compose/analysis-repository.d.ts +6 -0
- package/target/main/ts/compose/analysis-repository.js +61 -0
- package/target/main/ts/compose/analysis-results.d.ts +38 -0
- package/target/main/ts/compose/analysis-results.js +78 -0
- package/target/main/ts/compose/analysis-sources.d.ts +73 -0
- package/target/main/ts/compose/analysis-sources.js +47 -0
- package/target/main/ts/compose/analyze-snapshot.d.ts +3 -2
- package/target/main/ts/compose/analyze-snapshot.js +19 -197
- package/target/main/ts/compose/diff-coverage.d.ts +2 -0
- package/target/main/ts/compose/diff-coverage.js +6 -4
- package/target/main/ts/compose/inspect.d.ts +5 -0
- package/target/main/ts/compose/inspect.js +14 -7
- package/target/main/ts/compose/languages.d.ts +29 -0
- package/target/main/ts/compose/languages.js +87 -0
- package/target/main/ts/compose/sources.js +14 -12
- 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/manifest.d.ts +2 -2
- package/target/main/ts/core/engine/manifest.js +25 -5
- 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 +3 -4
- package/target/main/ts/core/engine/plan.js +28 -11
- package/target/main/ts/core/engine/plugin.d.ts +10 -2
- 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.d.ts +1 -0
- package/target/main/ts/core/model/clone-source.js +2 -1
- package/target/main/ts/core/model/code-structure.d.ts +5 -0
- package/target/main/ts/core/model/code-structure.js +10 -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/language.d.ts +10 -0
- package/target/main/ts/core/model/language.js +6 -0
- 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.d.ts +7 -6
- package/target/main/ts/core/model/measurement.js +18 -7
- package/target/main/ts/core/model/plugin-data.d.ts +5 -0
- package/target/main/ts/core/model/plugin-data.js +15 -1
- package/target/main/ts/core/model/quality-summary.js +6 -5
- package/target/main/ts/core/model/report.d.ts +1 -2
- package/target/main/ts/core/model/report.js +0 -1
- package/target/main/ts/core/model/scanner-import.js +1 -1
- package/target/main/ts/core/model/snapshot.d.ts +1 -2
- package/target/main/ts/core/model/snapshot.js +5 -7
- 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/core/usecases/compare.js +61 -17
- package/target/main/ts/core/usecases/inspect.js +2 -2
- package/target/main/ts/plugin.d.ts +10 -3
- package/target/main/ts/plugin.js +4 -2
- 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/duplication/duplication.js +10 -4
- package/target/main/ts/plugins/language-js/babel-provider.js +8 -2
- package/target/main/ts/plugins/language-js/extensions.d.ts +3 -0
- package/target/main/ts/plugins/language-js/extensions.js +4 -0
- 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/plugins/language-js/js-security.js +3 -2
- 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-data.d.ts +1 -1
- package/target/main/ts/report/html/app/viewer-data.js +2 -29
- 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 +7 -84
- 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 +118 -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 -365
- 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 +54 -0
- package/target/main/ts/report/html/app/viewer-trend-data.js +109 -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/export-site.d.ts +3 -4
- package/target/main/ts/report/html/site/export-site.js +24 -41
- package/target/main/ts/report/html/site/exported-server.js +2 -1
- package/target/main/ts/report/html/site/local-server.d.ts +1 -1
- package/target/main/ts/report/html/site/local-server.js +13 -19
- package/target/main/ts/report/html/site/projects.js +8 -17
- package/target/main/ts/report/json/projections/commit-summary.d.ts +2 -2
- package/target/main/ts/report/json/projections/commit-summary.js +18 -19
- package/target/main/ts/report/json/projections/file-metrics.js +31 -24
- package/target/main/ts/report/json/projections/inspection-context.js +10 -1
- package/target/main/ts/report/json/projections/inspection-details.d.ts +1 -1
- package/target/main/ts/report/json/projections/inspection-details.js +2 -2
- package/target/main/ts/report/json/projections/metric-values.d.ts +1 -0
- package/target/main/ts/report/json/projections/metric-values.js +15 -5
- 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/pull-review-store.js +1 -2
- 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/json/validation/report.d.ts +1 -1
- package/target/main/ts/report/json/validation/report.js +10 -8
- package/target/main/ts/report/json/validation/summary-validation.js +1 -3
- package/target/main/ts/report/json/wire/file-metrics-model.d.ts +2 -0
- package/target/main/ts/report/json/wire/inspection-details-model.d.ts +0 -5
- package/target/main/ts/report/json/wire/public-history-model.d.ts +0 -6
- package/target/main/ts/report/json/wire/public-history-model.js +0 -1
- package/target/main/ts/report.d.ts +3 -3
- package/target/main/ts/report.js +2 -2
- package/target/main/resources/report/json/inspection-context-v1.schema.json +0 -172
- package/target/main/resources/report/json/public-history-v1.schema.json +0 -50
- package/target/main/resources/report/json/quality-history-v1.schema.json +0 -51
- package/target/main/resources/report/json/report-v1.schema.json +0 -65
- package/target/main/resources/report/json/viewer-details-v1.schema.json +0 -346
- package/target/main/ts/report/json/projections/public-history.d.ts +0 -4
- package/target/main/ts/report/json/projections/public-history.js +0 -17
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { flagIcon } from './viewer-chart-points.js';
|
|
2
|
+
import { setAttributes, svgNode } from './viewer-chart-svg.js';
|
|
3
|
+
const flagNotes = { best: 'Best of the shown inspections', worst: 'Worst of the shown inspections' };
|
|
4
|
+
/** The card scrolls, so a cluster lists its commits whole up to a bound a hand can still scroll through. */
|
|
5
|
+
const listed = 50;
|
|
6
|
+
function span(className, content) {
|
|
7
|
+
const node = document.createElement('span');
|
|
8
|
+
node.className = className;
|
|
9
|
+
node.textContent = content;
|
|
10
|
+
return node;
|
|
11
|
+
}
|
|
12
|
+
/** The value, and its change where it says something: in a cluster an unchanged value goes without saying. */
|
|
13
|
+
function valueLine(point, brief) {
|
|
14
|
+
const value = span('tc-tip-value', point.tip.value);
|
|
15
|
+
const change = point.tip.change;
|
|
16
|
+
if (!change || (brief && change.direction === 'same'))
|
|
17
|
+
return value;
|
|
18
|
+
const node = span('tc-tip-change', change.text);
|
|
19
|
+
node.dataset.direction = change.direction;
|
|
20
|
+
value.append(' ', node);
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
/** Each card opens its commit: in a cluster the card is how one of several commits at a point is picked. */
|
|
24
|
+
function card(point, brief) {
|
|
25
|
+
const entry = document.createElement(point.href ? 'a' : 'div');
|
|
26
|
+
entry.className = 'tc-tip-entry';
|
|
27
|
+
if (entry instanceof HTMLAnchorElement)
|
|
28
|
+
entry.href = point.href;
|
|
29
|
+
const heading = document.createElement('strong');
|
|
30
|
+
heading.textContent = point.tip.heading;
|
|
31
|
+
const commit = document.createElement('code');
|
|
32
|
+
commit.textContent = point.tip.commit;
|
|
33
|
+
entry.append(heading, commit);
|
|
34
|
+
if (point.tip.subject)
|
|
35
|
+
entry.append(span('tc-tip-subject', point.tip.subject));
|
|
36
|
+
entry.append(valueLine(point, brief));
|
|
37
|
+
if (point.flag) {
|
|
38
|
+
const flag = document.createElement('span');
|
|
39
|
+
flag.className = 'tc-tip-flag';
|
|
40
|
+
flag.append(flagIcon(point.flag), flagNotes[point.flag]);
|
|
41
|
+
entry.append(flag);
|
|
42
|
+
}
|
|
43
|
+
entry.append(...point.tip.notes.map(note => span('tc-tip-note', note)));
|
|
44
|
+
return entry;
|
|
45
|
+
}
|
|
46
|
+
/** Marks closer than a few pixels overlap, so the card lists every commit under the pointer, newest first. */
|
|
47
|
+
function fillTip(tip, points, layout, x) {
|
|
48
|
+
const cluster = points.flatMap((_, other) => Math.abs(layout.xs[other] - x) < 4 ? [other] : []).reverse();
|
|
49
|
+
tip.replaceChildren(...cluster.slice(0, listed).map(member => card(points[member], cluster.length > 1)));
|
|
50
|
+
if (cluster.length > listed)
|
|
51
|
+
tip.append(span('tc-tip-note', `${cluster.length - listed} more commits at this point`));
|
|
52
|
+
tip.scrollTop = 0;
|
|
53
|
+
// Only a card of several commits takes the pointer; a single card stays out of the way of scanning along the chart.
|
|
54
|
+
tip.classList.toggle('tc-tip-held', cluster.length > 1);
|
|
55
|
+
tip.hidden = false;
|
|
56
|
+
}
|
|
57
|
+
/** The card keeps the side it opened on while it fits, so it does not jump across the pointer heading for it. */
|
|
58
|
+
function placeTip(tip, svg, layout, mark, side) {
|
|
59
|
+
const { x, y: markY } = mark;
|
|
60
|
+
const scale = svg.getBoundingClientRect().width / Math.max(1, layout.width) || 1;
|
|
61
|
+
const width = tip.offsetWidth;
|
|
62
|
+
const room = svg.clientWidth || layout.width;
|
|
63
|
+
const right = x * scale + 14;
|
|
64
|
+
const leftSide = x * scale - 14 - width;
|
|
65
|
+
const keepsLeft = side === 'left' && leftSide >= 0;
|
|
66
|
+
const next = !keepsLeft && right + width <= room ? 'right' : 'left';
|
|
67
|
+
tip.style.left = `${Math.max(0, next === 'right' ? right : leftSide)}px`;
|
|
68
|
+
const bottom = layout.top * scale + layout.plotHeight * scale - tip.offsetHeight;
|
|
69
|
+
tip.style.top = `${Math.max(0, Math.min((markY ?? layout.top + layout.plotHeight) * scale - tip.offsetHeight / 2, bottom))}px`;
|
|
70
|
+
return next;
|
|
71
|
+
}
|
|
72
|
+
/** Marks the point as active, and puts the hover dot on it where the point draws no dot of its own. */
|
|
73
|
+
function highlight(svg, pointer, layout, index) {
|
|
74
|
+
svg.querySelectorAll('.tc-point.is-active').forEach(node => node.classList.remove('is-active'));
|
|
75
|
+
const own = svg.querySelector(`.tc-point[data-index="${index}"]`);
|
|
76
|
+
own?.classList.add('is-active');
|
|
77
|
+
const markY = layout.ys[index];
|
|
78
|
+
if (markY == null || own?.querySelector('.tc-dot') || svg.classList.contains('tc-bars')) {
|
|
79
|
+
pointer.setAttribute('visibility', 'hidden');
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
setAttributes(pointer, { cx: layout.xs[index], cy: markY });
|
|
83
|
+
pointer.setAttribute('visibility', 'visible');
|
|
84
|
+
}
|
|
85
|
+
/** The point nearest the pointer; the later point on ties, so the newest of a cluster is reachable. */
|
|
86
|
+
function nearestPoint(svg, layout, clientX) {
|
|
87
|
+
const box = svg.getBoundingClientRect();
|
|
88
|
+
const px = (clientX - box.left) * (layout.width / Math.max(1, box.width));
|
|
89
|
+
let best = 0;
|
|
90
|
+
for (const [index, position] of layout.xs.entries()) {
|
|
91
|
+
if (Math.abs(position - px) <= Math.abs(layout.xs[best] - px))
|
|
92
|
+
best = index;
|
|
93
|
+
}
|
|
94
|
+
return best;
|
|
95
|
+
}
|
|
96
|
+
/** Whether the pointer is on its way to a held card: moving towards it and not there yet. */
|
|
97
|
+
function headingForCard(tip, side, dx, clientX) {
|
|
98
|
+
if (tip.hidden || !tip.classList.contains('tc-tip-held'))
|
|
99
|
+
return false;
|
|
100
|
+
const box = tip.getBoundingClientRect();
|
|
101
|
+
return side === 'right' ? dx > 0 && clientX < box.left : dx < 0 && clientX > box.right;
|
|
102
|
+
}
|
|
103
|
+
const keySteps = new Map([
|
|
104
|
+
['ArrowLeft', (from) => Math.max(0, from - 1)],
|
|
105
|
+
['ArrowRight', (from, last) => Math.min(last, from + 1)],
|
|
106
|
+
['Home', () => 0],
|
|
107
|
+
['End', (_, last) => last],
|
|
108
|
+
]);
|
|
109
|
+
function guideLine(svg) {
|
|
110
|
+
const guide = svgNode('line', 'tc-guide');
|
|
111
|
+
guide.setAttribute('visibility', 'hidden');
|
|
112
|
+
svg.insertBefore(guide, svg.firstChild);
|
|
113
|
+
return guide;
|
|
114
|
+
}
|
|
115
|
+
/** One dot follows the pointer or the keyboard along the line, so the chart needs no element per commit. */
|
|
116
|
+
function hoverDot(svg) {
|
|
117
|
+
const pointer = svgNode('circle', 'tc-dot tc-hover-dot');
|
|
118
|
+
pointer.setAttribute('r', '4.5');
|
|
119
|
+
pointer.setAttribute('visibility', 'hidden');
|
|
120
|
+
svg.append(pointer);
|
|
121
|
+
return pointer;
|
|
122
|
+
}
|
|
123
|
+
/** One hover card for the whole chart: the point nearest the pointer, or the focused one. */
|
|
124
|
+
export function interact(svg, tip, layout, points) {
|
|
125
|
+
if (points.length === 0)
|
|
126
|
+
return;
|
|
127
|
+
const guide = guideLine(svg);
|
|
128
|
+
const pointer = hoverDot(svg);
|
|
129
|
+
const state = {
|
|
130
|
+
active: -1, side: null, pending: undefined, lastX: 0
|
|
131
|
+
};
|
|
132
|
+
const show = (index) => {
|
|
133
|
+
if (index === state.active)
|
|
134
|
+
return;
|
|
135
|
+
state.active = index;
|
|
136
|
+
const x = layout.xs[index];
|
|
137
|
+
setAttributes(guide, { x1: x, x2: x, y1: layout.top - 6, y2: layout.top + layout.plotHeight });
|
|
138
|
+
guide.setAttribute('visibility', 'visible');
|
|
139
|
+
highlight(svg, pointer, layout, index);
|
|
140
|
+
fillTip(tip, points, layout, x);
|
|
141
|
+
state.side = placeTip(tip, svg, layout, { x, y: layout.ys[index] }, state.side);
|
|
142
|
+
};
|
|
143
|
+
const hide = () => {
|
|
144
|
+
clearTimeout(state.pending);
|
|
145
|
+
state.side = null;
|
|
146
|
+
state.active = -1;
|
|
147
|
+
tip.hidden = true;
|
|
148
|
+
guide.setAttribute('visibility', 'hidden');
|
|
149
|
+
pointer.setAttribute('visibility', 'hidden');
|
|
150
|
+
svg.querySelectorAll('.tc-point.is-active').forEach(node => node.classList.remove('is-active'));
|
|
151
|
+
};
|
|
152
|
+
// A pointer heading for the card may cross other commits on the way. While it moves towards the card, the switch
|
|
153
|
+
// waits a moment; reaching the card keeps it, so its commits can be scrolled and picked.
|
|
154
|
+
svg.addEventListener('pointermove', event => {
|
|
155
|
+
const candidate = nearestPoint(svg, layout, event.clientX);
|
|
156
|
+
const dx = event.clientX - state.lastX;
|
|
157
|
+
state.lastX = event.clientX;
|
|
158
|
+
clearTimeout(state.pending);
|
|
159
|
+
if (candidate === state.active)
|
|
160
|
+
return;
|
|
161
|
+
if (headingForCard(tip, state.side, dx, event.clientX))
|
|
162
|
+
state.pending = setTimeout(() => show(candidate), 220);
|
|
163
|
+
else
|
|
164
|
+
show(candidate);
|
|
165
|
+
});
|
|
166
|
+
svg.addEventListener('pointerleave', event => {
|
|
167
|
+
if (!tip.contains(event.relatedTarget))
|
|
168
|
+
hide();
|
|
169
|
+
});
|
|
170
|
+
tip.addEventListener('pointerenter', () => clearTimeout(state.pending));
|
|
171
|
+
tip.addEventListener('pointerleave', event => {
|
|
172
|
+
if (!svg.contains(event.relatedTarget))
|
|
173
|
+
hide();
|
|
174
|
+
});
|
|
175
|
+
svg.addEventListener('click', event => {
|
|
176
|
+
if (event.target.closest('.tc-point'))
|
|
177
|
+
return;
|
|
178
|
+
const href = points[nearestPoint(svg, layout, event.clientX)]?.href;
|
|
179
|
+
if (href)
|
|
180
|
+
location.assign(href);
|
|
181
|
+
});
|
|
182
|
+
svg.addEventListener('focusin', event => {
|
|
183
|
+
const index = Number(event.target.closest('.tc-point')?.dataset.index);
|
|
184
|
+
if (Number.isInteger(index))
|
|
185
|
+
show(index);
|
|
186
|
+
});
|
|
187
|
+
svg.addEventListener('focusout', hide);
|
|
188
|
+
// The chart itself takes focus: arrows step through commits, Home and End jump to the ends, Enter opens the commit.
|
|
189
|
+
svg.tabIndex = 0;
|
|
190
|
+
svg.setAttribute('aria-keyshortcuts', 'ArrowLeft ArrowRight Home End Enter');
|
|
191
|
+
svg.setAttribute('aria-label', `${points.length} ${points.length === 1 ? 'commit' : 'commits'}; arrow keys move between them, Enter opens one`);
|
|
192
|
+
svg.addEventListener('focus', () => {
|
|
193
|
+
const current = points.findIndex(point => point.current);
|
|
194
|
+
show(current >= 0 ? current : points.length - 1);
|
|
195
|
+
});
|
|
196
|
+
svg.addEventListener('keydown', event => {
|
|
197
|
+
const last = points.length - 1;
|
|
198
|
+
const step = keySteps.get(event.key);
|
|
199
|
+
if (step) {
|
|
200
|
+
event.preventDefault();
|
|
201
|
+
const next = step(state.active < 0 ? last : state.active, last);
|
|
202
|
+
state.active = -1;
|
|
203
|
+
show(next);
|
|
204
|
+
}
|
|
205
|
+
else if (event.key === 'Enter' && state.active >= 0) {
|
|
206
|
+
event.preventDefault();
|
|
207
|
+
location.assign(points[state.active].href);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Layout } from './viewer-chart-svg.js';
|
|
2
|
+
interface Placed {
|
|
3
|
+
readonly label: string;
|
|
4
|
+
readonly time: number | null;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Positions points on the x axis and draws it. When every point has a commit time the axis is time: equal periods take
|
|
8
|
+
* equal width, and the ticks step by one calendar period (a day, a week, a month, a quarter, a year) chosen to fit the
|
|
9
|
+
* width. Without times the points stand evenly in order under their own labels.
|
|
10
|
+
*/
|
|
11
|
+
export declare function placeX(svg: SVGSVGElement, layout: Layout, points: readonly Placed[]): void;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { centredText, clampLabel, inset, line } from './viewer-chart-svg.js';
|
|
2
|
+
import { axisLabels, timeTicks } from './viewer-chart-time.js';
|
|
3
|
+
/** Equal periods take equal width; the ticks step by one calendar period chosen to fit the width. */
|
|
4
|
+
function placeTimed(svg, layout, times, from, span) {
|
|
5
|
+
const axis = layout.top + layout.plotHeight;
|
|
6
|
+
const low = Math.min(...times);
|
|
7
|
+
const high = Math.max(...times);
|
|
8
|
+
const at = (time) => high === low ? from + span / 2 : from + (time - low) / (high - low) * span;
|
|
9
|
+
layout.xs = times.map(at);
|
|
10
|
+
if (high === low)
|
|
11
|
+
return;
|
|
12
|
+
const ticks = timeTicks(low, high, span);
|
|
13
|
+
for (const tick of ticks)
|
|
14
|
+
svg.append(line('tc-xtick', { x1: at(tick.time), x2: at(tick.time), y1: axis, y2: axis + 4 }));
|
|
15
|
+
for (const label of axisLabels(ticks.map(tick => ({ time: tick.time, x: at(tick.time) })), ticks[0]?.unit ?? 'day', layout)) {
|
|
16
|
+
svg.append(centredText(label.label, 'tc-label', label.at, layout.height - 9));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Whether an ordered point keeps its label: every so many points, and always the last, which the one before yields to. */
|
|
20
|
+
function labelled(index, every, last) {
|
|
21
|
+
if (index === last)
|
|
22
|
+
return true;
|
|
23
|
+
return index % every === 0 && last - index >= every;
|
|
24
|
+
}
|
|
25
|
+
/** Without times the points stand evenly in order under their own labels, as many labels as fit. */
|
|
26
|
+
function placeOrdered(svg, layout, points, from, span) {
|
|
27
|
+
const step = points.length > 1 ? span / (points.length - 1) : 0;
|
|
28
|
+
layout.xs = points.map((_, index) => points.length > 1 ? from + index * step : from + span / 2);
|
|
29
|
+
const labelWidth = Math.max(...points.map(point => point.label.length)) * 7.6 + 10;
|
|
30
|
+
const every = step > 0 ? Math.max(1, Math.ceil(labelWidth / step)) : 1;
|
|
31
|
+
for (const [index, point] of points.entries()) {
|
|
32
|
+
if (!labelled(index, every, points.length - 1))
|
|
33
|
+
continue;
|
|
34
|
+
svg.append(centredText(point.label, 'tc-label', clampLabel(layout.xs[index], point.label, layout), layout.height - 9));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Positions points on the x axis and draws it. When every point has a commit time the axis is time: equal periods take
|
|
39
|
+
* equal width, and the ticks step by one calendar period (a day, a week, a month, a quarter, a year) chosen to fit the
|
|
40
|
+
* width. Without times the points stand evenly in order under their own labels.
|
|
41
|
+
*/
|
|
42
|
+
export function placeX(svg, layout, points) {
|
|
43
|
+
const from = layout.left + inset;
|
|
44
|
+
const span = Math.max(1, layout.plotWidth - inset * 2);
|
|
45
|
+
const times = points.map(point => point.time);
|
|
46
|
+
if (points.length > 0 && times.every((time) => time !== null))
|
|
47
|
+
placeTimed(svg, layout, times, from, span);
|
|
48
|
+
else
|
|
49
|
+
placeOrdered(svg, layout, points, from, span);
|
|
50
|
+
}
|
|
@@ -1,101 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
readonly label: string;
|
|
6
|
-
/** Accessible name of the point. */
|
|
7
|
-
readonly title: string;
|
|
8
|
-
readonly href: string;
|
|
9
|
-
readonly current: boolean;
|
|
10
|
-
readonly partial: boolean;
|
|
11
|
-
readonly boundary?: ProfileBoundary | null;
|
|
12
|
-
/** Commit time in milliseconds; the x axis is a time scale when every point has one. */
|
|
13
|
-
readonly time: number | null;
|
|
14
|
-
/** Hover card lines: a heading, then details. */
|
|
15
|
-
readonly tip: ChartTip;
|
|
16
|
-
/** A green flag on the best value of the series, a red one at half-mast on the worst. */
|
|
17
|
-
readonly flag?: 'best' | 'worst' | undefined;
|
|
18
|
-
}
|
|
19
|
-
export interface ChartTip {
|
|
20
|
-
readonly heading: string;
|
|
21
|
-
readonly commit: string;
|
|
22
|
-
/** The commit's message, first line: what the chart's step was. */
|
|
23
|
-
readonly subject?: string;
|
|
24
|
-
readonly value: string;
|
|
25
|
-
readonly change?: {
|
|
26
|
-
readonly text: string;
|
|
27
|
-
readonly direction: string;
|
|
28
|
-
} | null;
|
|
29
|
-
readonly notes: readonly string[];
|
|
30
|
-
}
|
|
31
|
-
export interface ChartOptions {
|
|
32
|
-
readonly format: (value: number) => string;
|
|
33
|
-
/** Values are ratios within [0, 1]. */
|
|
34
|
-
readonly ratio: boolean;
|
|
35
|
-
readonly compact: boolean;
|
|
36
|
-
/** Ticks fall on whole multiples of this unit, for example 60 to tick minutes in whole hours. */
|
|
37
|
-
readonly tickUnit?: number;
|
|
38
|
-
/** Label the selected point's value; off where the page already shows it next to the chart. */
|
|
39
|
-
readonly labelCurrent?: boolean;
|
|
40
|
-
/** Overall height in pixels, where the layout needs the chart to fill a given space. */
|
|
41
|
-
readonly height?: number | undefined;
|
|
42
|
-
/** A second series drawn as a grey line behind the first, on its own scale labelled at the right edge. */
|
|
43
|
-
readonly secondary?: SecondarySeries | undefined;
|
|
44
|
-
}
|
|
45
|
-
export interface SecondarySeries {
|
|
46
|
-
/** One value per point, in the same order. */
|
|
47
|
-
readonly values: readonly (number | null)[];
|
|
48
|
-
readonly format: (value: number) => string;
|
|
49
|
-
/** Ticks fall on whole multiples of this unit, as for the main series. */
|
|
50
|
-
readonly tickUnit?: number;
|
|
51
|
-
}
|
|
1
|
+
import type { BarOptions } from './viewer-chart-bars.js';
|
|
2
|
+
import type { ChartOptions } from './viewer-chart-line.js';
|
|
3
|
+
import type { ChartPoint } from './viewer-chart-points.js';
|
|
4
|
+
export type { ChartPoint } from './viewer-chart-points.js';
|
|
52
5
|
export declare function renderLineChart(container: HTMLElement, points: readonly ChartPoint[], options: ChartOptions): void;
|
|
53
|
-
export interface BarOptions {
|
|
54
|
-
readonly format: (value: number) => string;
|
|
55
|
-
readonly compact: boolean;
|
|
56
|
-
/** Positive values are bad news (for example, added debt). */
|
|
57
|
-
readonly upIsWorse: boolean;
|
|
58
|
-
/** Round tick values to this unit, as for line charts. */
|
|
59
|
-
readonly tickUnit?: number | undefined;
|
|
60
|
-
}
|
|
61
6
|
/** Diverging bars around zero, one per point; a point without a value gets a mark on the zero line. */
|
|
62
7
|
export declare function renderBarChart(container: HTMLElement, points: readonly ChartPoint[], options: BarOptions): void;
|
|
63
|
-
interface Layout {
|
|
64
|
-
readonly width: number;
|
|
65
|
-
readonly height: number;
|
|
66
|
-
readonly top: number;
|
|
67
|
-
readonly plotHeight: number;
|
|
68
|
-
left: number;
|
|
69
|
-
plotWidth: number;
|
|
70
|
-
/** Horizontal position of each point. */
|
|
71
|
-
xs: number[];
|
|
72
|
-
/** Y of each point's mark, for the hover card. */
|
|
73
|
-
ys: (number | null)[];
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Labels for ticks in time order. Each names its own unit, and the coarser units join it only where they change:
|
|
77
|
-
* Jul 2023, Nov, Dec, Jan 2024, Feb; 30 Jun, 1 Jul, 2; 23:00, 1 Jul, 01:00. The first tick always carries them.
|
|
78
|
-
*/
|
|
79
|
-
export declare function tickLabels(times: readonly number[], unit: TickUnit): string[];
|
|
80
|
-
/**
|
|
81
|
-
* The labels under the ticks. Which ticks keep a label is settled first: one that would sit far off its tick at the
|
|
82
|
-
* edge, or touch the label before it, keeps only its mark. Only then are the labels written, so the first label shown
|
|
83
|
-
* carries the coarser units, and every later one carries them only where they change.
|
|
84
|
-
*/
|
|
85
|
-
export declare function axisLabels(ticks: readonly {
|
|
86
|
-
time: number;
|
|
87
|
-
x: number;
|
|
88
|
-
}[], unit: TickUnit, layout: Layout): {
|
|
89
|
-
at: number;
|
|
90
|
-
label: string;
|
|
91
|
-
}[];
|
|
92
|
-
interface TimeTick {
|
|
93
|
-
readonly time: number;
|
|
94
|
-
readonly label: string;
|
|
95
|
-
readonly unit: TickUnit;
|
|
96
|
-
}
|
|
97
|
-
export type TickUnit = 'minute' | 'hour' | 'day' | 'month' | 'year';
|
|
98
|
-
/** Calendar-aligned ticks between two times, as many as fit the width without overlapping labels. */
|
|
99
|
-
export declare function timeTicks(start: number, end: number, width: number): TimeTick[];
|
|
100
|
-
export declare function niceTicks(values: readonly number[], ratio: boolean, count: number): number[];
|
|
101
|
-
export {};
|