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.
Files changed (190) hide show
  1. package/README.md +4 -0
  2. package/package.json +1 -1
  3. package/target/main/resources/report/json/report-v2.schema.json +13 -1
  4. package/target/main/resources/viewer/files.css +7 -3
  5. package/target/main/resources/viewer/styles.css +2 -2
  6. package/target/main/ts/api/git/git.d.ts +1 -0
  7. package/target/main/ts/api/git/git.js +12 -0
  8. package/target/main/ts/api/git/inspection-source.js +2 -8
  9. package/target/main/ts/api/git/local.d.ts +1 -1
  10. package/target/main/ts/api/git/local.js +39 -5
  11. package/target/main/ts/api/process/docker-tool-runner.d.ts +13 -0
  12. package/target/main/ts/api/process/docker-tool-runner.js +108 -0
  13. package/target/main/ts/api/process/failure.d.ts +1 -0
  14. package/target/main/ts/api/process/failure.js +12 -0
  15. package/target/main/ts/api/process/plugin.d.ts +10 -0
  16. package/target/main/ts/api/process/plugin.js +96 -0
  17. package/target/main/ts/compose/analyze-snapshot.d.ts +3 -2
  18. package/target/main/ts/compose/analyze-snapshot.js +82 -29
  19. package/target/main/ts/compose/inspect.d.ts +5 -0
  20. package/target/main/ts/compose/inspect.js +10 -6
  21. package/target/main/ts/core/engine/execute.d.ts +3 -1
  22. package/target/main/ts/core/engine/execute.js +14 -2
  23. package/target/main/ts/core/engine/operation-cache.d.ts +14 -0
  24. package/target/main/ts/core/engine/operation-cache.js +66 -0
  25. package/target/main/ts/core/engine/plan.d.ts +1 -0
  26. package/target/main/ts/core/engine/plan.js +22 -3
  27. package/target/main/ts/core/engine/plugin.d.ts +8 -1
  28. package/target/main/ts/core/engine/plugin.js +1 -3
  29. package/target/main/ts/core/engine/report-products.js +2 -13
  30. package/target/main/ts/core/model/clone-source.js +1 -1
  31. package/target/main/ts/core/model/code-structure.d.ts +3 -0
  32. package/target/main/ts/core/model/code-structure.js +4 -1
  33. package/target/main/ts/core/model/finding-ignore.js +1 -1
  34. package/target/main/ts/core/model/finding.js +1 -1
  35. package/target/main/ts/core/model/line-coverage.d.ts +5 -1
  36. package/target/main/ts/core/model/line-coverage.js +14 -11
  37. package/target/main/ts/core/model/measurement.js +1 -1
  38. package/target/main/ts/core/model/plugin-data.d.ts +2 -0
  39. package/target/main/ts/core/model/plugin-data.js +15 -1
  40. package/target/main/ts/core/model/quality-summary.js +1 -1
  41. package/target/main/ts/core/model/scanner-import.js +1 -1
  42. package/target/main/ts/core/model/snapshot.d.ts +1 -0
  43. package/target/main/ts/core/model/snapshot.js +5 -1
  44. package/target/main/ts/core/model/source.d.ts +3 -0
  45. package/target/main/ts/core/model/source.js +15 -0
  46. package/target/main/ts/core/ports/tool-runner.d.ts +18 -0
  47. package/target/main/ts/core/ports/tool-runner.js +2 -0
  48. package/target/main/ts/plugin.d.ts +7 -1
  49. package/target/main/ts/plugin.js +3 -1
  50. package/target/main/ts/plugins/coverage/coverage.d.ts +5 -2
  51. package/target/main/ts/plugins/coverage/coverage.js +35 -10
  52. package/target/main/ts/plugins/language-js/function-facts.d.ts +1 -0
  53. package/target/main/ts/plugins/language-js/function-facts.js +30 -4
  54. package/target/main/ts/report/html/app/viewer-chart-bars.d.ts +11 -0
  55. package/target/main/ts/report/html/app/viewer-chart-bars.js +54 -0
  56. package/target/main/ts/report/html/app/viewer-chart-label.d.ts +15 -0
  57. package/target/main/ts/report/html/app/viewer-chart-label.js +43 -0
  58. package/target/main/ts/report/html/app/viewer-chart-line.d.ts +24 -0
  59. package/target/main/ts/report/html/app/viewer-chart-line.js +89 -0
  60. package/target/main/ts/report/html/app/viewer-chart-points.d.ts +49 -0
  61. package/target/main/ts/report/html/app/viewer-chart-points.js +74 -0
  62. package/target/main/ts/report/html/app/viewer-chart-scale.d.ts +21 -0
  63. package/target/main/ts/report/html/app/viewer-chart-scale.js +93 -0
  64. package/target/main/ts/report/html/app/viewer-chart-svg.d.ts +28 -0
  65. package/target/main/ts/report/html/app/viewer-chart-svg.js +41 -0
  66. package/target/main/ts/report/html/app/viewer-chart-time.d.ts +26 -0
  67. package/target/main/ts/report/html/app/viewer-chart-time.js +150 -0
  68. package/target/main/ts/report/html/app/viewer-chart-tip.d.ts +4 -0
  69. package/target/main/ts/report/html/app/viewer-chart-tip.js +210 -0
  70. package/target/main/ts/report/html/app/viewer-chart-x.d.ts +12 -0
  71. package/target/main/ts/report/html/app/viewer-chart-x.js +50 -0
  72. package/target/main/ts/report/html/app/viewer-chart.d.ts +4 -98
  73. package/target/main/ts/report/html/app/viewer-chart.js +16 -677
  74. package/target/main/ts/report/html/app/viewer-code-map.d.ts +27 -0
  75. package/target/main/ts/report/html/app/viewer-code-map.js +175 -0
  76. package/target/main/ts/report/html/app/viewer-columns.d.ts +38 -0
  77. package/target/main/ts/report/html/app/viewer-columns.js +92 -0
  78. package/target/main/ts/report/html/app/viewer-commit-picker.d.ts +12 -0
  79. package/target/main/ts/report/html/app/viewer-commit-picker.js +229 -0
  80. package/target/main/ts/report/html/app/viewer-commits.d.ts +5 -9
  81. package/target/main/ts/report/html/app/viewer-commits.js +17 -216
  82. package/target/main/ts/report/html/app/viewer-controls.d.ts +43 -0
  83. package/target/main/ts/report/html/app/viewer-controls.js +141 -0
  84. package/target/main/ts/report/html/app/viewer-copy.d.ts +17 -0
  85. package/target/main/ts/report/html/app/viewer-copy.js +64 -0
  86. package/target/main/ts/report/html/app/viewer-diagnostics.d.ts +4 -0
  87. package/target/main/ts/report/html/app/viewer-diagnostics.js +60 -0
  88. package/target/main/ts/report/html/app/viewer-dom.d.ts +27 -0
  89. package/target/main/ts/report/html/app/viewer-dom.js +99 -0
  90. package/target/main/ts/report/html/app/viewer-file-aside.d.ts +19 -0
  91. package/target/main/ts/report/html/app/viewer-file-aside.js +124 -0
  92. package/target/main/ts/report/html/app/viewer-file-figures.d.ts +15 -0
  93. package/target/main/ts/report/html/app/viewer-file-figures.js +60 -0
  94. package/target/main/ts/report/html/app/viewer-file-source.d.ts +7 -0
  95. package/target/main/ts/report/html/app/viewer-file-source.js +119 -0
  96. package/target/main/ts/report/html/app/viewer-files.d.ts +2 -118
  97. package/target/main/ts/report/html/app/viewer-files.js +24 -2184
  98. package/target/main/ts/report/html/app/viewer-filter.d.ts +3 -51
  99. package/target/main/ts/report/html/app/viewer-filter.js +111 -450
  100. package/target/main/ts/report/html/app/viewer-hotspots.d.ts +4 -0
  101. package/target/main/ts/report/html/app/viewer-hotspots.js +131 -0
  102. package/target/main/ts/report/html/app/viewer-inspection.d.ts +69 -0
  103. package/target/main/ts/report/html/app/viewer-inspection.js +36 -0
  104. package/target/main/ts/report/html/app/viewer-issue-group.d.ts +27 -0
  105. package/target/main/ts/report/html/app/viewer-issue-group.js +174 -0
  106. package/target/main/ts/report/html/app/viewer-issues.d.ts +4 -0
  107. package/target/main/ts/report/html/app/viewer-issues.js +173 -0
  108. package/target/main/ts/report/html/app/viewer-language-bar.d.ts +9 -0
  109. package/target/main/ts/report/html/app/viewer-language-bar.js +72 -0
  110. package/target/main/ts/report/html/app/viewer-languages.d.ts +27 -0
  111. package/target/main/ts/report/html/app/viewer-languages.js +93 -0
  112. package/target/main/ts/report/html/app/viewer-layout.d.ts +14 -0
  113. package/target/main/ts/report/html/app/viewer-layout.js +134 -0
  114. package/target/main/ts/report/html/app/viewer-line-coverage.d.ts +47 -0
  115. package/target/main/ts/report/html/app/viewer-line-coverage.js +121 -0
  116. package/target/main/ts/report/html/app/viewer-locations.d.ts +16 -0
  117. package/target/main/ts/report/html/app/viewer-locations.js +31 -0
  118. package/target/main/ts/report/html/app/viewer-map-scale.d.ts +26 -0
  119. package/target/main/ts/report/html/app/viewer-map-scale.js +147 -0
  120. package/target/main/ts/report/html/app/viewer-map-shape.d.ts +42 -0
  121. package/target/main/ts/report/html/app/viewer-map-shape.js +102 -0
  122. package/target/main/ts/report/html/app/viewer-metric-format.d.ts +23 -0
  123. package/target/main/ts/report/html/app/viewer-metric-format.js +93 -0
  124. package/target/main/ts/report/html/app/viewer-metric-registry.d.ts +0 -20
  125. package/target/main/ts/report/html/app/viewer-metric-registry.js +0 -77
  126. package/target/main/ts/report/html/app/viewer-metrics-view.d.ts +4 -0
  127. package/target/main/ts/report/html/app/viewer-metrics-view.js +162 -0
  128. package/target/main/ts/report/html/app/viewer-metrics.d.ts +6 -1
  129. package/target/main/ts/report/html/app/viewer-metrics.js +53 -35
  130. package/target/main/ts/report/html/app/viewer-overview-cards.d.ts +12 -0
  131. package/target/main/ts/report/html/app/viewer-overview-cards.js +112 -0
  132. package/target/main/ts/report/html/app/viewer-overview-hotspots.d.ts +9 -0
  133. package/target/main/ts/report/html/app/viewer-overview-hotspots.js +173 -0
  134. package/target/main/ts/report/html/app/viewer-overview-lead.d.ts +12 -0
  135. package/target/main/ts/report/html/app/viewer-overview-lead.js +116 -0
  136. package/target/main/ts/report/html/app/viewer-profile-badges.d.ts +11 -0
  137. package/target/main/ts/report/html/app/viewer-profile-badges.js +119 -0
  138. package/target/main/ts/report/html/app/viewer-profile-table.d.ts +29 -0
  139. package/target/main/ts/report/html/app/viewer-profile-table.js +124 -0
  140. package/target/main/ts/report/html/app/viewer-profile.d.ts +2 -6
  141. package/target/main/ts/report/html/app/viewer-profile.js +6 -248
  142. package/target/main/ts/report/html/app/viewer-pull-sections.d.ts +4 -0
  143. package/target/main/ts/report/html/app/viewer-pull-sections.js +118 -0
  144. package/target/main/ts/report/html/app/viewer-pull-trend.d.ts +5 -0
  145. package/target/main/ts/report/html/app/viewer-pull-trend.js +63 -0
  146. package/target/main/ts/report/html/app/viewer-pulls.d.ts +0 -1
  147. package/target/main/ts/report/html/app/viewer-pulls.js +28 -178
  148. package/target/main/ts/report/html/app/viewer-query-field.d.ts +19 -0
  149. package/target/main/ts/report/html/app/viewer-query-field.js +203 -0
  150. package/target/main/ts/report/html/app/viewer-route.d.ts +34 -0
  151. package/target/main/ts/report/html/app/viewer-route.js +55 -0
  152. package/target/main/ts/report/html/app/viewer-shell.d.ts +20 -0
  153. package/target/main/ts/report/html/app/viewer-shell.js +116 -0
  154. package/target/main/ts/report/html/app/viewer-source-view.d.ts +49 -0
  155. package/target/main/ts/report/html/app/viewer-source-view.js +150 -0
  156. package/target/main/ts/report/html/app/viewer-source.d.ts +0 -84
  157. package/target/main/ts/report/html/app/viewer-source.js +7 -363
  158. package/target/main/ts/report/html/app/viewer-suggest.d.ts +13 -0
  159. package/target/main/ts/report/html/app/viewer-suggest.js +91 -0
  160. package/target/main/ts/report/html/app/viewer-sunburst.d.ts +5 -0
  161. package/target/main/ts/report/html/app/viewer-sunburst.js +40 -0
  162. package/target/main/ts/report/html/app/viewer-table-cells.d.ts +25 -0
  163. package/target/main/ts/report/html/app/viewer-table-cells.js +129 -0
  164. package/target/main/ts/report/html/app/viewer-table-rows.d.ts +54 -0
  165. package/target/main/ts/report/html/app/viewer-table-rows.js +95 -0
  166. package/target/main/ts/report/html/app/viewer-tokenizer.d.ts +16 -0
  167. package/target/main/ts/report/html/app/viewer-tokenizer.js +192 -0
  168. package/target/main/ts/report/html/app/viewer-totals.d.ts +14 -0
  169. package/target/main/ts/report/html/app/viewer-totals.js +89 -0
  170. package/target/main/ts/report/html/app/viewer-treemap.d.ts +24 -0
  171. package/target/main/ts/report/html/app/viewer-treemap.js +112 -0
  172. package/target/main/ts/report/html/app/viewer-trend-data.d.ts +49 -0
  173. package/target/main/ts/report/html/app/viewer-trend-data.js +105 -0
  174. package/target/main/ts/report/html/app/viewer-trend-nav.d.ts +5 -0
  175. package/target/main/ts/report/html/app/viewer-trend-nav.js +85 -0
  176. package/target/main/ts/report/html/app/viewer-trend-points.d.ts +30 -0
  177. package/target/main/ts/report/html/app/viewer-trend-points.js +128 -0
  178. package/target/main/ts/report/html/app/viewer-trend-series.d.ts +26 -0
  179. package/target/main/ts/report/html/app/viewer-trend-series.js +98 -0
  180. package/target/main/ts/report/html/app/viewer-trends.d.ts +2 -70
  181. package/target/main/ts/report/html/app/viewer-trends.js +41 -392
  182. package/target/main/ts/report/html/app/viewer.js +152 -663
  183. package/target/main/ts/report/html/site/badges.js +41 -18
  184. package/target/main/ts/report/json/store/local-store.js +2 -12
  185. package/target/main/ts/report/json/store/operation-cache.d.ts +8 -0
  186. package/target/main/ts/report/json/store/operation-cache.js +32 -0
  187. package/target/main/ts/report/json/store/replace-file.d.ts +1 -0
  188. package/target/main/ts/report/json/store/replace-file.js +14 -0
  189. package/target/main/ts/report.d.ts +1 -0
  190. package/target/main/ts/report.js +1 -0
@@ -1,21 +1,24 @@
1
- import { isRecord } from '../engine/plugin.js';
1
+ import { isRecord } from './plugin-data.js';
2
+ import { isMergedLineRanges } from './source.js';
2
3
  export const lcovLines = {
3
4
  id: 'repometry.lcov-lines/v1',
4
- accepts: (value) => isRecord(value) && Object.values(value).every(file => isRecord(file) && isMerged(file.covered) && isMerged(file.uncovered) &&
5
- (file.partial === undefined || isMerged(file.partial)) && (file.hits === undefined || isMergedHits(file.hits))),
5
+ accepts: (value) => isRecord(value) && Object.values(value).every(file => isRecord(file) && isMergedLineRanges(file.covered) && isMergedLineRanges(file.uncovered)
6
+ && (file.partial === undefined || isMergedLineRanges(file.partial)) && (file.hits === undefined || isMergedHits(file.hits))
7
+ && (file.functionCalls === undefined || isOrderedCallCounts(file.functionCalls))
8
+ && (file.functionBodies === undefined || isMergedLineRanges(file.functionBodies))),
6
9
  };
7
- function isMerged(value) {
10
+ function isOrderedCallCounts(value) {
8
11
  if (!Array.isArray(value))
9
12
  return false;
10
- let previous = -1;
11
- for (const range of value) {
12
- if (!Array.isArray(range) || range.length !== 2)
13
+ let previous = 1;
14
+ for (const call of value) {
15
+ if (!Array.isArray(call) || call.length !== 2)
13
16
  return false;
14
- const [first, last] = range;
15
- if (typeof first !== 'number' || typeof last !== 'number' || !Number.isSafeInteger(first)
16
- || !Number.isSafeInteger(last) || first <= previous + 1 || last < first)
17
+ const [line, count] = call;
18
+ if (typeof line !== 'number' || typeof count !== 'number' || !Number.isSafeInteger(line) || !Number.isSafeInteger(count)
19
+ || line < previous || count < 0)
17
20
  return false;
18
- previous = last;
21
+ previous = line;
19
22
  }
20
23
  return true;
21
24
  }
@@ -1,4 +1,4 @@
1
- import { isRecord } from '../engine/plugin.js';
1
+ import { isRecord } from './plugin-data.js';
2
2
  export const definitions = {
3
3
  lines: 'repometry.physical-lines/v1',
4
4
  functions: 'repometry.functions/v1',
@@ -3,6 +3,8 @@ import type { InventoryFile } from './source.js';
3
3
  export type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
4
4
  readonly [key: string]: JsonValue;
5
5
  };
6
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
7
+ export declare function isJsonValue(value: unknown, depth?: number): value is JsonValue;
6
8
  export interface PersistedProduct {
7
9
  readonly operation: string;
8
10
  readonly path?: string;
@@ -1 +1,15 @@
1
- export {};
1
+ export function isRecord(value) {
2
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
3
+ }
4
+ export function isJsonValue(value, depth = 0) {
5
+ if (depth > 512)
6
+ return false;
7
+ if (value === null || typeof value === 'boolean' || typeof value === 'string')
8
+ return true;
9
+ if (typeof value === 'number')
10
+ return Number.isFinite(value);
11
+ if (Array.isArray(value))
12
+ return value.every(item => isJsonValue(item, depth + 1));
13
+ return isRecord(value) && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null)
14
+ && Object.values(value).every(item => isJsonValue(item, depth + 1));
15
+ }
@@ -1,4 +1,4 @@
1
- import { isRecord } from '../engine/plugin.js';
1
+ import { isRecord } from './plugin-data.js';
2
2
  import { definitions } from './measurement.js';
3
3
  export const debtModel = { name: 'basic-cocomo-organic', scale: 2.4, exponent: 1.05, minutesPerPersonMonth: 9600 };
4
4
  export function qualitySummary(report) {
@@ -1,4 +1,4 @@
1
- import { isRecord } from '../engine/plugin.js';
1
+ import { isRecord } from './plugin-data.js';
2
2
  import { findingCategories } from './finding.js';
3
3
  /** Keep scanner identity in profile comparisons while dropping the per-snapshot inputs and counts. */
4
4
  export function findingImportMethods(value) {
@@ -2,6 +2,7 @@ import type { DataContract } from '../engine/plugin.js';
2
2
  import type { SourceFile, SourceSnapshot } from './source.js';
3
3
  export type { Subject, SourceFile, SourceSnapshot } from './source.js';
4
4
  export declare const sourceFile: DataContract<SourceFile>;
5
+ export declare const sourceFiles: DataContract<readonly SourceFile[]>;
5
6
  export declare const sourceDirectoriesExcluded: readonly ['.git', '.repometry', 'node_modules', 'target'];
6
7
  export declare const sourceExtensions: readonly ['.js', '.mjs', '.cjs', '.jsx', '.ts', '.mts', '.cts', '.tsx'];
7
8
  export declare function isSourcePath(path: string): boolean;
@@ -1,10 +1,14 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { extname } from 'node:path';
3
- import { isRecord } from '../engine/plugin.js';
3
+ import { isRecord } from './plugin-data.js';
4
4
  export const sourceFile = {
5
5
  id: 'repometry.source-file/v1',
6
6
  accepts: (value) => isRecord(value) && typeof value.path === 'string' && value.bytes instanceof Uint8Array,
7
7
  };
8
+ export const sourceFiles = {
9
+ id: 'repometry.source-files/v1',
10
+ accepts: (value) => Array.isArray(value) && value.every(sourceFile.accepts),
11
+ };
8
12
  export const sourceDirectoriesExcluded = ['.git', '.repometry', 'node_modules', 'target'];
9
13
  export const sourceExtensions = ['.js', '.mjs', '.cjs', '.jsx', '.ts', '.mts', '.cts', '.tsx'];
10
14
  const excluded = new Set(sourceDirectoriesExcluded);
@@ -9,6 +9,9 @@ export interface SourceFile {
9
9
  readonly path: string;
10
10
  readonly bytes: Uint8Array;
11
11
  }
12
+ /** A 1-based inclusive range in source text. */
13
+ export type SourceLineRange = readonly [first: number, last: number];
14
+ export declare function isMergedLineRanges(value: unknown): value is readonly SourceLineRange[];
12
15
  export declare const maxClaimedFileBytes: number;
13
16
  export declare function isClaimedText(bytes: Uint8Array): boolean;
14
17
  export interface InventoryFile {
@@ -1,3 +1,18 @@
1
+ export function isMergedLineRanges(value) {
2
+ if (!Array.isArray(value))
3
+ return false;
4
+ let previous = -1;
5
+ for (const range of value) {
6
+ if (!Array.isArray(range) || range.length !== 2)
7
+ return false;
8
+ const [first, last] = range;
9
+ if (typeof first !== 'number' || typeof last !== 'number' || !Number.isSafeInteger(first)
10
+ || !Number.isSafeInteger(last) || first <= previous + 1 || last < first)
11
+ return false;
12
+ previous = last;
13
+ }
14
+ return true;
15
+ }
1
16
  export const maxClaimedFileBytes = 1024 * 1024;
2
17
  export function isClaimedText(bytes) {
3
18
  return bytes.byteLength <= maxClaimedFileBytes && !bytes.subarray(0, 8192).includes(0);
@@ -0,0 +1,18 @@
1
+ import type { SourceFile } from '../model/source.js';
2
+ export interface ToolInvocation {
3
+ readonly argv: readonly string[];
4
+ readonly files: readonly SourceFile[];
5
+ readonly stdin?: Uint8Array;
6
+ readonly timeoutMs: number;
7
+ readonly maxOutputBytes: number;
8
+ }
9
+ export interface ToolResult {
10
+ readonly exitCode: number;
11
+ readonly stdout: Uint8Array;
12
+ readonly stderr: Uint8Array;
13
+ }
14
+ export interface ToolRunner {
15
+ readonly network: 'none';
16
+ readonly implementation?: string;
17
+ run(invocation: ToolInvocation): Promise<ToolResult>;
18
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tool-runner.js.map
@@ -1,14 +1,20 @@
1
1
  export { pluginApi } from './core/engine/plugin.js';
2
2
  export type { DataContract, InspectionInputs, Operation, Plugin, PluginConfigSchema, Product, RuleDescriptor } from './core/engine/plugin.js';
3
3
  export type { FileClaims, LegacyPlugin, MetricDescriptor, MetricScope, PluginKind, ProductDeclaration } from './core/engine/plugin.js';
4
+ export type { OperationCache, OperationCacheOptions } from './core/engine/operation-cache.js';
4
5
  export { codeStructure } from './core/model/code-structure.js';
5
6
  export type { CodeStructure, FunctionComplexity, StructuralCheck, StructuralObservation } from './core/model/code-structure.js';
6
7
  export type { Candidate, CloneSource } from './core/model/clone-source.js';
7
- export { sourceFile } from './core/model/snapshot.js';
8
+ export { sourceFile, sourceFiles } from './core/model/snapshot.js';
8
9
  export type { InventoryFile, SourceFile, SourceSnapshot } from './core/model/source.js';
9
10
  export { measurements } from './core/model/measurement.js';
10
11
  export type { Measurement } from './core/model/measurement.js';
11
12
  export { findingResult } from './core/model/finding.js';
12
13
  export type { Finding, FindingResult } from './core/model/finding.js';
13
14
  export type { SourceContext, SourcePlugin, SourceProvider } from './core/ports/source-provider.js';
15
+ export type { ToolInvocation, ToolResult, ToolRunner } from './core/ports/tool-runner.js';
16
+ export { DockerToolRunner } from './api/process/docker-tool-runner.js';
17
+ export type { DockerToolLimits } from './api/process/docker-tool-runner.js';
18
+ export { processPlugin, processPluginProtocol } from './api/process/plugin.js';
19
+ export type { ProcessOperation, ProcessPluginManifest } from './api/process/plugin.js';
14
20
  export type { SourceLocator } from './core/model/source-locator.js';
@@ -1,6 +1,8 @@
1
1
  export { pluginApi } from './core/engine/plugin.js';
2
2
  export { codeStructure } from './core/model/code-structure.js';
3
- export { sourceFile } from './core/model/snapshot.js';
3
+ export { sourceFile, sourceFiles } from './core/model/snapshot.js';
4
4
  export { measurements } from './core/model/measurement.js';
5
5
  export { findingResult } from './core/model/finding.js';
6
+ export { DockerToolRunner } from './api/process/docker-tool-runner.js';
7
+ export { processPlugin, processPluginProtocol } from './api/process/plugin.js';
6
8
  //# sourceMappingURL=plugin.js.map
@@ -1,11 +1,13 @@
1
1
  import type { DataContract, Plugin } from '../../core/engine/plugin.js';
2
2
  import type { Measurement } from '../../core/model/measurement.js';
3
- import type { LineCoverage } from '../../core/model/line-coverage.js';
3
+ import type { FunctionCallCount, LineCoverage } from '../../core/model/line-coverage.js';
4
+ import type { SourceLineRange } from '../../core/model/source.js';
4
5
  export interface CoverageInput {
5
6
  readonly text: string;
6
7
  readonly root: string;
7
8
  readonly sourceLines: ReadonlyMap<string, number>;
8
9
  readonly codeLines?: ReadonlyMap<string, ReadonlySet<number>>;
10
+ readonly functionBodies?: ReadonlyMap<string, readonly SourceLineRange[]>;
9
11
  readonly excludes?: (path: string) => boolean;
10
12
  }
11
13
  interface CoverageResult {
@@ -22,7 +24,8 @@ export declare const coverage: Plugin;
22
24
  export declare function mapCoverage({ text, root, sourceLines, codeLines, excludes }: CoverageInput): {
23
25
  files: Map<string, Map<number, number>>;
24
26
  branches: Map<string, Map<string, number>>;
25
- functions: Map<string, Map<string, boolean>>;
27
+ functions: Map<string, Map<string, number>>;
28
+ functionCalls: Map<string, readonly FunctionCallCount[]>;
26
29
  gaps: Map<string, string>;
27
30
  };
28
31
  export {};
@@ -9,6 +9,7 @@ export const lcovInput = {
9
9
  accepts: (value) => isRecord(value) && typeof value.text === 'string'
10
10
  && typeof value.root === 'string' && value.sourceLines instanceof Map
11
11
  && (value.codeLines === undefined || value.codeLines instanceof Map)
12
+ && (value.functionBodies === undefined || value.functionBodies instanceof Map)
12
13
  && (value.excludes === undefined || typeof value.excludes === 'function'),
13
14
  };
14
15
  export const coverageResult = {
@@ -37,7 +38,8 @@ export const coverage = {
37
38
  { id: definitions.coverableFunctions, label: 'Measured functions', unit: 'count', scope: 'file', aggregate: 'sum', better: 'none', group: 'Coverage' },
38
39
  ] }, { contract: lcovLines.id, persistence: 'report',
39
40
  schema: { ...reportSchema.$defs.lcovLines,
40
- $defs: { lcovLineRanges: reportSchema.$defs.lcovLineRanges, lcovHitRuns: reportSchema.$defs.lcovHitRuns } } }],
41
+ $defs: { lcovLineRanges: reportSchema.$defs.lcovLineRanges, lcovHitRuns: reportSchema.$defs.lcovHitRuns,
42
+ lcovFunctionCalls: reportSchema.$defs.lcovFunctionCalls } } }],
41
43
  operations: [{
42
44
  id: 'import',
43
45
  role: 'inspection',
@@ -55,7 +57,7 @@ export const coverage = {
55
57
  export function mapCoverage({ text, root, sourceLines, codeLines, excludes }) {
56
58
  const files = new Map();
57
59
  // Branches by line, block and branch. Functions by name and its occurrence in the record: tools such as c8 repeat a
58
- // name for different functions and list FNDA in FN order. Several reports merge by any hit.
60
+ // name for different functions and list FNDA in FN order.
59
61
  const branches = new Map();
60
62
  const declared = new Map();
61
63
  const called = new Map();
@@ -111,7 +113,7 @@ export function mapCoverage({ text, root, sourceLines, codeLines, excludes }) {
111
113
  if (ignored || !files.has(active))
112
114
  continue;
113
115
  const branch = /^BRDA:([1-9]\d*),([^,]+),([^,]+),(\d+|-)$/.exec(line);
114
- const declaration = /^FN:[1-9]\d*(?:,[1-9]\d*)?,(.+)$/.exec(line);
116
+ const declaration = /^FN:([1-9]\d*)(?:,[1-9]\d*)?,(.+)$/.exec(line);
115
117
  const call = /^FNDA:(\d+),(.+)$/.exec(line);
116
118
  if (branch) {
117
119
  const taken = branch[4] === '-' ? 0 : Number(branch[4]);
@@ -121,12 +123,19 @@ export function mapCoverage({ text, root, sourceLines, codeLines, excludes }) {
121
123
  branches.set(active, file);
122
124
  }
123
125
  else if (declaration) {
124
- declared.set(active, (declared.get(active) ?? new Set()).add(occurrence(occurrences.declared, declaration[1])));
126
+ const number = Number(declaration[1]);
127
+ if (!Number.isSafeInteger(number))
128
+ throw new Error(`Invalid LCOV function line at line ${index + 1}`);
129
+ const key = occurrence(occurrences.declared, declaration[2]);
130
+ const file = declared.get(active) ?? new Map();
131
+ if (!file.has(key))
132
+ file.set(key, number);
133
+ declared.set(active, file);
125
134
  }
126
135
  else if (call) {
127
136
  const key = occurrence(occurrences.called, call[2]);
128
137
  const file = called.get(active) ?? new Map();
129
- file.set(key, (file.get(key) ?? false) || Number(call[1]) > 0);
138
+ addHits(file, key, Number(call[1]), index + 1);
130
139
  called.set(active, file);
131
140
  }
132
141
  else {
@@ -143,8 +152,21 @@ export function mapCoverage({ text, root, sourceLines, codeLines, excludes }) {
143
152
  throw new Error('Unterminated LCOV source record');
144
153
  if (!sawSource && text.trim() !== '')
145
154
  throw new Error('LCOV contains no source records');
146
- const functions = new Map([...declared].map(([path, names]) => [path, new Map([...names].map(name => [name, called.get(path)?.get(name) ?? false]))]));
147
- return { files, branches, functions, gaps };
155
+ const functions = new Map();
156
+ const functionCalls = new Map();
157
+ for (const [path, declarations] of declared) {
158
+ const hits = called.get(path);
159
+ functions.set(path, new Map([...declarations.keys()].map(key => [key, hits?.get(key) ?? 0])));
160
+ const counts = [];
161
+ for (const [key, first] of declarations) {
162
+ const count = hits?.get(key);
163
+ if (count !== undefined && first <= sourceLines.get(path))
164
+ counts.push([first, count]);
165
+ }
166
+ if (counts.length)
167
+ functionCalls.set(path, counts.sort(([left], [right]) => left - right));
168
+ }
169
+ return { files, branches, functions, functionCalls, gaps };
148
170
  }
149
171
  function addHits(hits, key, count, record) {
150
172
  const total = (hits.get(key) ?? 0) + count;
@@ -153,7 +175,7 @@ function addHits(hits, key, count, record) {
153
175
  hits.set(key, total);
154
176
  }
155
177
  function importCoverage(input) {
156
- const { files, branches, functions, gaps } = mapCoverage(input);
178
+ const { files, branches, functions, functionCalls, gaps } = mapCoverage(input);
157
179
  const rows = [];
158
180
  const lineCoverage = [];
159
181
  let totalCovered = 0;
@@ -166,11 +188,14 @@ function importCoverage(input) {
166
188
  (hit ? hitLines : missedLines).push(line);
167
189
  const partialHits = partiallyCoveredLines(branches.get(path), input.sourceLines.get(path), input.codeLines?.get(path));
168
190
  const partial = mergedRanges([...partialHits.keys()]);
169
- if (hits.size || partial.length) {
191
+ const calls = functionCalls.get(path);
192
+ const bodies = input.functionBodies?.get(path);
193
+ if (hits.size || partial.length || calls !== undefined) {
170
194
  // A BRDA-only partial line has at least as many hits as its most frequently taken branch.
171
195
  const measured = new Map([...partialHits, ...hits]);
172
196
  lineCoverage.push([path, { covered: mergedRanges(hitLines), uncovered: mergedRanges(missedLines),
173
- ...(partial.length ? { partial } : {}), hits: mergedHits(measured) }]);
197
+ ...(partial.length ? { partial } : {}), hits: mergedHits(measured),
198
+ ...(calls === undefined ? {} : { functionCalls: calls }), ...(bodies === undefined ? {} : { functionBodies: bodies }) }]);
174
199
  }
175
200
  const covered = hitLines.length;
176
201
  totalCovered += covered;
@@ -3,6 +3,7 @@ import type { FunctionComplexity } from '../../core/model/code-structure.js';
3
3
  export declare function functionFacts(ast: Node): {
4
4
  functions: number;
5
5
  cyclomaticFunctions: FunctionComplexity[];
6
+ functionBodies: [number, number][];
6
7
  };
7
8
  export declare function children(node: Node): Iterable<Node>;
8
9
  export declare function functionName(node: BabelFunction): string;
@@ -1,13 +1,20 @@
1
- import { VISITOR_KEYS, isFunction, isIdentifier, isStringLiteral } from '@babel/types';
1
+ import { VISITOR_KEYS, isBlockStatement, isFunction, isIdentifier, isStringLiteral } from '@babel/types';
2
2
  const decisionNodes = new Set(['IfStatement', 'ConditionalExpression', 'ForStatement', 'ForInStatement', 'ForOfStatement',
3
3
  'WhileStatement', 'DoWhileStatement', 'CatchClause', 'LogicalExpression']);
4
4
  export function functionFacts(ast) {
5
5
  let functions = 0;
6
- walk(ast, node => { if (isFunction(node) && node.body)
7
- functions++; });
6
+ const bodyRanges = [];
7
+ walk(ast, node => {
8
+ if (!isFunction(node) || !node.body)
9
+ return;
10
+ functions++;
11
+ const range = bodyRange(node.body);
12
+ if (range)
13
+ bodyRanges.push(range);
14
+ });
8
15
  const cyclomaticFunctions = [];
9
16
  visit(ast, undefined);
10
- return { functions, cyclomaticFunctions };
17
+ return { functions, cyclomaticFunctions, functionBodies: mergeBodyRanges(bodyRanges) };
11
18
  function visit(node, frame) {
12
19
  if (isFunction(node) && node.body) {
13
20
  const own = { value: 1 };
@@ -26,6 +33,25 @@ export function functionFacts(ast) {
26
33
  visit(child, frame);
27
34
  }
28
35
  }
36
+ function bodyRange(body) {
37
+ if (!isBlockStatement(body))
38
+ return body.loc ? [body.loc.start.line, body.loc.end.line] : undefined;
39
+ const first = body.directives[0] ?? body.body[0];
40
+ const last = body.body.at(-1) ?? body.directives.at(-1);
41
+ if (first?.loc && last?.loc)
42
+ return [first.loc.start.line, last.loc.end.line];
43
+ }
44
+ function mergeBodyRanges(ranges) {
45
+ const merged = [];
46
+ for (const [first, last] of ranges.sort(([left], [right]) => left - right)) {
47
+ const previous = merged.at(-1);
48
+ if (previous && first <= previous[1] + 1)
49
+ previous[1] = Math.max(previous[1], last);
50
+ else
51
+ merged.push([first, last]);
52
+ }
53
+ return merged;
54
+ }
29
55
  export function* children(node) {
30
56
  const properties = node;
31
57
  for (const key of VISITOR_KEYS[node.type] ?? []) {
@@ -0,0 +1,11 @@
1
+ import type { ChartPoint } from './viewer-chart-points.js';
2
+ import type { Layout } from './viewer-chart-svg.js';
3
+ export interface BarOptions {
4
+ readonly format: (value: number) => string;
5
+ readonly compact: boolean;
6
+ /** Positive values are bad news (for example, added debt). */
7
+ readonly upIsWorse: boolean;
8
+ /** Round tick values to this unit, as for line charts. */
9
+ readonly tickUnit?: number | undefined;
10
+ }
11
+ export declare function barChart(svg: SVGSVGElement, layout: Layout, points: readonly ChartPoint[], options: BarOptions): void;
@@ -0,0 +1,54 @@
1
+ import { markBoundaries, measuredValues, pointLink } from './viewer-chart-points.js';
2
+ import { yAxis } from './viewer-chart-scale.js';
3
+ import { centredText, line, setAttributes, svgNode } from './viewer-chart-svg.js';
4
+ import { placeX } from './viewer-chart-x.js';
5
+ /** The room beside a bar: the distance to the nearer neighbour. */
6
+ function room(x, count, index) {
7
+ const before = index > 0 ? x(index) - x(index - 1) : Infinity;
8
+ const after = index < count - 1 ? x(index + 1) - x(index) : Infinity;
9
+ return Math.min(before, after);
10
+ }
11
+ /** A bar from zero to the value, labelled where the label fits or the commit is the selected one. */
12
+ function bar({ points, x, y, format, upIsWorse }, index, width, space) {
13
+ const point = points[index];
14
+ const value = point.value;
15
+ const worse = upIsWorse ? value > 0 : value < 0;
16
+ const rect = svgNode('rect', `tc-bar ${worse ? 'tc-bar-worse' : 'tc-bar-better'}${point.current ? ' tc-bar-current' : ''}`);
17
+ setAttributes(rect, { x: x(index) - width / 2, y: Math.min(y(value), y(0)), width, height: Math.max(1, Math.abs(y(value) - y(0))) });
18
+ if (!point.current && format(value).length * 7.6 >= space)
19
+ return [rect];
20
+ const at = value > 0 ? y(value) - 7 : y(value) + 16;
21
+ return [rect, centredText(format(value), point.current ? 'tc-value tc-value-current' : 'tc-value', x(index), at)];
22
+ }
23
+ /** A point's marks: its bar, a flat mark for no change, or a tick on the zero line where nothing was measured. */
24
+ function barMarks(context, index) {
25
+ const { points, x, y } = context;
26
+ const value = points[index].value;
27
+ const space = room(x, points.length, index);
28
+ const width = Math.max(2, Math.min(28, Number.isFinite(space) ? space * .62 : 28));
29
+ const cx = x(index);
30
+ if (value === null)
31
+ return [line('tc-missing-mark', { x1: cx, x2: cx, y1: y(0) - 3.5, y2: y(0) + 3.5 })];
32
+ if (value === 0)
33
+ return [line('tc-zero-mark', { x1: cx - width / 2, x2: cx + width / 2, y1: y(0), y2: y(0) })];
34
+ return bar(context, index, width, space);
35
+ }
36
+ export function barChart(svg, layout, points, options) {
37
+ svg.classList.add('tc-bars');
38
+ const y = yAxis(svg, layout, { values: measuredValues(points.map(point => point.value)), ratio: false, count: options.compact ? 3 : 4,
39
+ format: options.format, tickUnit: options.tickUnit ?? 1, zero: true });
40
+ placeX(svg, layout, points);
41
+ markBoundaries(svg, layout, points);
42
+ const x = (index) => layout.xs[index];
43
+ layout.ys = points.map(point => point.value === null ? null : y(point.value));
44
+ // In a long history the zero line already says "no change" and "not measured"; only bars that moved are drawn.
45
+ const dense = layout.xs.some((at, index) => index > 0 && at - layout.xs[index - 1] < 7);
46
+ const context = { ...options, points, x, y };
47
+ for (const [index, point] of points.entries()) {
48
+ const link = pointLink(point, index);
49
+ const quiet = !point.current && !point.value;
50
+ if (!dense || !quiet)
51
+ link.append(...barMarks(context, index));
52
+ svg.append(link);
53
+ }
54
+ }
@@ -0,0 +1,15 @@
1
+ import type { ChartPoint } from './viewer-chart-points.js';
2
+ export interface LabelContext {
3
+ readonly points: readonly ChartPoint[];
4
+ readonly x: (index: number) => number;
5
+ readonly y: (value: number) => number;
6
+ readonly format: (value: number) => string;
7
+ /** The y of the plot's bottom edge. */
8
+ readonly axis: number;
9
+ }
10
+ /**
11
+ * The value of the labelled point. A flag on this point or one just beside it takes the space above, so the value
12
+ * moves left of the pole; a label pushed far from its point would sit on the line, so it goes under the point instead,
13
+ * where a flag never is.
14
+ */
15
+ export declare function valueLabel(context: LabelContext, index: number): SVGTextElement;
@@ -0,0 +1,43 @@
1
+ import { text } from './viewer-chart-svg.js';
2
+ /** The x of every flag whose pole and pennant a label between `left` and `anchor` at `top` would cover. */
3
+ function flagsCrossed({ points, x, y }, left, anchor, top) {
4
+ return points.flatMap((other, at) => {
5
+ if (!other.flag || other.value === null)
6
+ return [];
7
+ const foot = y(other.value) - 4;
8
+ const across = x(at) >= left && x(at) <= anchor + 11;
9
+ return across && top > foot - 22 && top - 14 < foot ? [x(at)] : [];
10
+ });
11
+ }
12
+ /** The label runs left from its anchor; it steps left of every flag it would cross, so it never covers one. */
13
+ function clearOfFlags(context, start, top, width) {
14
+ let anchor = start;
15
+ let poles = [];
16
+ for (let pass = 0; pass < 4; pass += 1) {
17
+ const crossed = flagsCrossed(context, anchor - width - 4, anchor, top);
18
+ if (!crossed.length || Math.min(...crossed) - 7 >= anchor)
19
+ break;
20
+ poles = crossed;
21
+ anchor = Math.min(...crossed) - 7;
22
+ }
23
+ return { anchor, poles };
24
+ }
25
+ /**
26
+ * The value of the labelled point. A flag on this point or one just beside it takes the space above, so the value
27
+ * moves left of the pole; a label pushed far from its point would sit on the line, so it goes under the point instead,
28
+ * where a flag never is.
29
+ */
30
+ export function valueLabel(context, index) {
31
+ const { points, x, y, format, axis } = context;
32
+ const point = points[index];
33
+ const value = point.value;
34
+ const last = index === points.length - 1;
35
+ const top = y(value) - 11;
36
+ const cleared = clearOfFlags(context, x(index), top, format(value).length * 7.2);
37
+ const below = x(index) - cleared.anchor > 40 && y(value) + 22 <= axis;
38
+ const anchor = below ? x(index) + (last ? 4 : 0) : cleared.anchor;
39
+ const label = text(format(value), point.current ? 'tc-value tc-value-current' : 'tc-value', anchor, below ? y(value) + 21 : top);
40
+ const flush = (cleared.poles.length > 0 && !below) || (last && points.length > 1);
41
+ label.setAttribute('text-anchor', flush ? 'end' : 'middle');
42
+ return label;
43
+ }
@@ -0,0 +1,24 @@
1
+ import type { ChartPoint } from './viewer-chart-points.js';
2
+ import type { Layout } from './viewer-chart-svg.js';
3
+ export interface ChartOptions {
4
+ readonly format: (value: number) => string;
5
+ /** Values are ratios within [0, 1]. */
6
+ readonly ratio: boolean;
7
+ readonly compact: boolean;
8
+ /** Ticks fall on whole multiples of this unit, for example 60 to tick minutes in whole hours. */
9
+ readonly tickUnit?: number;
10
+ /** Label the selected point's value; off where the page already shows it next to the chart. */
11
+ readonly labelCurrent?: boolean;
12
+ /** Overall height in pixels, where the layout needs the chart to fill a given space. */
13
+ readonly height?: number | undefined;
14
+ /** A second series drawn as a grey line behind the first, on its own scale labelled at the right edge. */
15
+ readonly secondary?: SecondarySeries | undefined;
16
+ }
17
+ export interface SecondarySeries {
18
+ /** One value per point, in the same order. */
19
+ readonly values: readonly (number | null)[];
20
+ readonly format: (value: number) => string;
21
+ /** Ticks fall on whole multiples of this unit, as for the main series. */
22
+ readonly tickUnit?: number;
23
+ }
24
+ export declare function lineChart(svg: SVGSVGElement, layout: Layout, points: readonly ChartPoint[], { format, ratio, compact, tickUnit, labelCurrent, secondary }: ChartOptions): void;
@@ -0,0 +1,89 @@
1
+ import { valueLabel } from './viewer-chart-label.js';
2
+ import { flagMark, markBoundaries, measuredValues, pointLink, segments, stepPath } from './viewer-chart-points.js';
3
+ import { niceStep, yAxis } from './viewer-chart-scale.js';
4
+ import { line, setAttributes, svgNode } from './viewer-chart-svg.js';
5
+ import { placeX } from './viewer-chart-x.js';
6
+ /**
7
+ * The second scale starts at zero and shares the main grid lines: each line carries one round value of each. Its top
8
+ * is known once the main axis has settled how many lines there are.
9
+ */
10
+ function secondScale(secondary) {
11
+ const values = measuredValues(secondary.values);
12
+ const scale = { high: 0, labels: undefined };
13
+ if (!values.length)
14
+ return scale;
15
+ scale.labels = ticks => {
16
+ const unit = secondary.tickUnit ?? 1;
17
+ const step = niceStep(Math.max(...values, 0) / unit / Math.max(1, ticks - 1)) * unit;
18
+ scale.high = step * (ticks - 1);
19
+ return Array.from({ length: ticks }, (_, index) => index === 0 ? '0' : secondary.format(step * index));
20
+ };
21
+ return scale;
22
+ }
23
+ function drawSecondary(svg, layout, secondary, high, x) {
24
+ const y = (value) => layout.top + layout.plotHeight - value / high * layout.plotHeight;
25
+ for (const segment of segments(secondary.values)) {
26
+ const path = svgNode('path', 'tc-line tc-line-secondary');
27
+ path.setAttribute('d', stepPath(segment, index => secondary.values[index], x, y));
28
+ svg.append(path);
29
+ }
30
+ }
31
+ /**
32
+ * A dot per commit is noise once commits sit close together: the line carries the curve, and a dot marks only what
33
+ * says something (the selected and the last commit, flags, and a measurement with no neighbour to draw a line to).
34
+ * Hover and the keyboard move one dot along the line instead. Only a short, sparse series keeps a dot per commit.
35
+ */
36
+ function marked(points, index, sparse) {
37
+ const point = points[index];
38
+ if (sparse || point.current || index === points.length - 1)
39
+ return true;
40
+ if (point.flag || point.boundary)
41
+ return true;
42
+ return point.value !== null && points[index - 1]?.value == null && points[index + 1]?.value == null;
43
+ }
44
+ function pointMarks(point, cx, cy) {
45
+ const dot = svgNode('circle', point.current ? 'tc-dot tc-dot-current' : 'tc-dot');
46
+ if (point.partial)
47
+ dot.classList.add('tc-dot-partial');
48
+ setAttributes(dot, { cx, cy, r: point.current ? 5 : 3.5 });
49
+ return point.flag ? [flagMark(point.flag, cx, cy), dot] : [dot];
50
+ }
51
+ /** Each marked point's dot, flag or gap mark, and the one value the chart labels. */
52
+ function drawMarks(svg, layout, points, { format, labelCurrent, y }) {
53
+ const x = (index) => layout.xs[index];
54
+ const axis = layout.top + layout.plotHeight;
55
+ const sparse = points.length <= 12 && layout.xs.every((at, index) => index === 0 || at - layout.xs[index - 1] >= 24);
56
+ // One value is labelled: the selected commit's, or the last one when the selection is off the chart.
57
+ const selectedIndex = points.findIndex(point => point.current && point.value !== null);
58
+ const labelled = labelCurrent && selectedIndex >= 0 ? selectedIndex : points.length - 1;
59
+ const context = { points, x, y, format, axis };
60
+ for (const [index, point] of points.entries()) {
61
+ if (!marked(points, index, sparse))
62
+ continue;
63
+ const link = pointLink(point, index);
64
+ if (point.value === null)
65
+ link.append(line('tc-missing-mark', { x1: x(index), x2: x(index), y1: axis - 7, y2: axis }));
66
+ else
67
+ link.append(...pointMarks(point, x(index), y(point.value)));
68
+ if (point.value !== null && index === labelled)
69
+ link.append(valueLabel(context, index));
70
+ svg.append(link);
71
+ }
72
+ }
73
+ export function lineChart(svg, layout, points, { format, ratio, compact, tickUnit = 1, labelCurrent = true, secondary }) {
74
+ const second = secondary && secondScale(secondary);
75
+ const y = yAxis(svg, layout, { values: measuredValues(points.map(point => point.value)), ratio, count: compact ? 3 : 4, format, tickUnit,
76
+ zero: false, rightLabels: second?.labels });
77
+ placeX(svg, layout, points);
78
+ const x = (index) => layout.xs[index];
79
+ markBoundaries(svg, layout, points);
80
+ if (secondary && second.high > 0)
81
+ drawSecondary(svg, layout, secondary, second.high, x);
82
+ for (const segment of segments(points.map(point => point.value))) {
83
+ const path = svgNode('path', 'tc-line');
84
+ path.setAttribute('d', stepPath(segment, index => points[index].value, x, y));
85
+ svg.append(path);
86
+ }
87
+ layout.ys = points.map(point => point.value === null ? null : y(point.value));
88
+ drawMarks(svg, layout, points, { format, labelCurrent, y });
89
+ }