@testivai/witness 2.4.0 → 2.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.
Files changed (106) hide show
  1. package/README.md +9 -2
  2. package/dist/baselines/store.d.ts +31 -0
  3. package/dist/baselines/store.d.ts.map +1 -1
  4. package/dist/baselines/store.js +38 -1
  5. package/dist/baselines/store.js.map +1 -1
  6. package/dist/bin/testivai.js +2 -0
  7. package/dist/bin/testivai.js.map +1 -1
  8. package/dist/capture/element-map.d.ts +23 -2
  9. package/dist/capture/element-map.d.ts.map +1 -1
  10. package/dist/capture/element-map.js +102 -4
  11. package/dist/capture/element-map.js.map +1 -1
  12. package/dist/capture/environment.d.ts +243 -0
  13. package/dist/capture/environment.d.ts.map +1 -0
  14. package/dist/capture/environment.js +403 -0
  15. package/dist/capture/environment.js.map +1 -0
  16. package/dist/capture/health-limits.d.ts +14 -0
  17. package/dist/capture/health-limits.d.ts.map +1 -0
  18. package/dist/capture/health-limits.js +17 -0
  19. package/dist/capture/health-limits.js.map +1 -0
  20. package/dist/capture/health.d.ts +124 -0
  21. package/dist/capture/health.d.ts.map +1 -0
  22. package/dist/capture/health.js +327 -0
  23. package/dist/capture/health.js.map +1 -0
  24. package/dist/capture/native-app.d.ts +77 -0
  25. package/dist/capture/native-app.d.ts.map +1 -0
  26. package/dist/capture/native-app.js +172 -0
  27. package/dist/capture/native-app.js.map +1 -0
  28. package/dist/capture/shard.d.ts +17 -0
  29. package/dist/capture/shard.d.ts.map +1 -1
  30. package/dist/capture/shard.js +8 -1
  31. package/dist/capture/shard.js.map +1 -1
  32. package/dist/commands/approve.d.ts.map +1 -1
  33. package/dist/commands/approve.js +20 -0
  34. package/dist/commands/approve.js.map +1 -1
  35. package/dist/commands/env.d.ts +37 -0
  36. package/dist/commands/env.d.ts.map +1 -0
  37. package/dist/commands/env.js +113 -0
  38. package/dist/commands/env.js.map +1 -0
  39. package/dist/commands/merge-captures.d.ts.map +1 -1
  40. package/dist/commands/merge-captures.js +10 -0
  41. package/dist/commands/merge-captures.js.map +1 -1
  42. package/dist/config/local-config.d.ts +27 -0
  43. package/dist/config/local-config.d.ts.map +1 -1
  44. package/dist/config/local-config.js +1 -0
  45. package/dist/config/local-config.js.map +1 -1
  46. package/dist/config/validate-config.d.ts.map +1 -1
  47. package/dist/config/validate-config.js +22 -0
  48. package/dist/config/validate-config.js.map +1 -1
  49. package/dist/diff/attribution.d.ts +16 -2
  50. package/dist/diff/attribution.d.ts.map +1 -1
  51. package/dist/diff/attribution.js +5 -4
  52. package/dist/diff/attribution.js.map +1 -1
  53. package/dist/diff/dom-diff.d.ts.map +1 -1
  54. package/dist/diff/dom-diff.js +7 -1
  55. package/dist/diff/dom-diff.js.map +1 -1
  56. package/dist/index.d.ts +10 -4
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +42 -1
  59. package/dist/index.js.map +1 -1
  60. package/dist/report/anchor.d.ts +18 -0
  61. package/dist/report/anchor.d.ts.map +1 -0
  62. package/dist/report/anchor.js +51 -0
  63. package/dist/report/anchor.js.map +1 -0
  64. package/dist/report/compare.d.ts +18 -1
  65. package/dist/report/compare.d.ts.map +1 -1
  66. package/dist/report/compare.js +107 -16
  67. package/dist/report/compare.js.map +1 -1
  68. package/dist/report/environment.d.ts +101 -0
  69. package/dist/report/environment.d.ts.map +1 -0
  70. package/dist/report/environment.js +354 -0
  71. package/dist/report/environment.js.map +1 -0
  72. package/dist/report/generator.d.ts +20 -2
  73. package/dist/report/generator.d.ts.map +1 -1
  74. package/dist/report/generator.js +46 -6
  75. package/dist/report/generator.js.map +1 -1
  76. package/dist/report/health.d.ts +115 -0
  77. package/dist/report/health.d.ts.map +1 -0
  78. package/dist/report/health.js +279 -0
  79. package/dist/report/health.js.map +1 -0
  80. package/dist/report/index.d.ts +9 -2
  81. package/dist/report/index.d.ts.map +1 -1
  82. package/dist/report/index.js +25 -1
  83. package/dist/report/index.js.map +1 -1
  84. package/dist/report/results.d.ts +73 -1
  85. package/dist/report/results.d.ts.map +1 -1
  86. package/dist/report/shift-check.d.ts +40 -0
  87. package/dist/report/shift-check.d.ts.map +1 -0
  88. package/dist/report/shift-check.js +109 -0
  89. package/dist/report/shift-check.js.map +1 -0
  90. package/dist/report/template.d.ts +28 -1
  91. package/dist/report/template.d.ts.map +1 -1
  92. package/dist/report/template.js +179 -16
  93. package/dist/report/template.js.map +1 -1
  94. package/dist/report/thumbnail.d.ts +76 -0
  95. package/dist/report/thumbnail.d.ts.map +1 -0
  96. package/dist/report/thumbnail.js +166 -0
  97. package/dist/report/thumbnail.js.map +1 -0
  98. package/dist/report/validate.d.ts +53 -0
  99. package/dist/report/validate.d.ts.map +1 -0
  100. package/dist/report/validate.js +383 -0
  101. package/dist/report/validate.js.map +1 -0
  102. package/dist/standalone/run.d.ts +39 -1
  103. package/dist/standalone/run.d.ts.map +1 -1
  104. package/dist/standalone/run.js +142 -3
  105. package/dist/standalone/run.js.map +1 -1
  106. package/package.json +1 -1
@@ -0,0 +1,76 @@
1
+ /**
2
+ * TestivAI Report — the thumbnail of a changed snapshot (thumb.png)
3
+ *
4
+ * A full-page diff is too tall to show inline where space is short (a pull
5
+ * request comment scales it to the column's width, and the change becomes a
6
+ * thin band). The thumbnail crops the changed area instead and puts the
7
+ * baseline, the current capture and the diff of it side by side:
8
+ *
9
+ * baseline | current | diff (2 px apart, at most 800×400 px)
10
+ *
11
+ * The area is on the diff canvas, which is the larger of the two sizes when
12
+ * they differ (witness pads both, anchored at the top left), so it is the
13
+ * same place in all three images; rows or columns a capture does not have
14
+ * are drawn as padding. Each panel is the area downscaled by area average,
15
+ * never upscaled. Plain RGBA arithmetic: no dependency beyond pngjs, which
16
+ * the caller encodes with.
17
+ */
18
+ /** The bounds of a thumbnail. docs/extension-api.md quotes them. */
19
+ export declare const THUMBNAIL_LIMITS: {
20
+ /** The widest strip, the three panels and both separators together. */
21
+ readonly maxWidth: 800;
22
+ /** The tallest strip. */
23
+ readonly maxHeight: 400;
24
+ /** Pixels of context around the changed regions, on every side. */
25
+ readonly padding: 24;
26
+ /** How many of the largest regions (by area) the area covers. */
27
+ readonly regions: 3;
28
+ /** Rows in the band shown when the diff has no regions. */
29
+ readonly bandHeight: 400;
30
+ /** Pixels between two panels. */
31
+ readonly separator: 2;
32
+ };
33
+ /** What a panel shows where its capture has no pixel (the padded part of the canvas). */
34
+ export declare const THUMBNAIL_PADDING_RGBA: readonly [number, number, number, number];
35
+ export interface ThumbnailBox {
36
+ x: number;
37
+ y: number;
38
+ width: number;
39
+ height: number;
40
+ }
41
+ /** Decoded RGBA pixels, 4 bytes a pixel, row by row. */
42
+ export interface RgbaImage {
43
+ data: Uint8Array | Uint8ClampedArray;
44
+ width: number;
45
+ height: number;
46
+ }
47
+ /**
48
+ * The area of the diff canvas the thumbnail shows: the union of the up to
49
+ * three largest regions by area, padded and kept inside the canvas. Without
50
+ * a region (none detected, or none inside the canvas), a full-width band of
51
+ * 400 rows from the first row with a differing pixel, moved up when the
52
+ * canvas ends sooner so it keeps its height. Null when no pixel of the diff
53
+ * differs.
54
+ *
55
+ * @param regions The snapshot's `regions`, on the diff canvas.
56
+ * @param diff The diff image (the canvas): differing pixels are heat
57
+ * (yellow to red); the rest is a grey wash of the baseline,
58
+ * and masked areas are grey hatching.
59
+ */
60
+ export declare function thumbnailArea(regions: readonly ThumbnailBox[] | undefined, diff: RgbaImage): ThumbnailBox | null;
61
+ /**
62
+ * The strip for `area`: baseline | current | diff, each panel the area
63
+ * downscaled by area average to fit the strip in 800×400 px (never
64
+ * upscaled), 2 px apart. `baseline` and `current` keep their own sizes:
65
+ * where the canvas is larger than a capture, its panel shows padding.
66
+ */
67
+ export declare function renderThumbnail(images: {
68
+ baseline: RgbaImage;
69
+ current: RgbaImage;
70
+ diff: RgbaImage;
71
+ }, area: ThumbnailBox): {
72
+ data: Uint8ClampedArray;
73
+ width: number;
74
+ height: number;
75
+ };
76
+ //# sourceMappingURL=thumbnail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thumbnail.d.ts","sourceRoot":"","sources":["../../src/report/thumbnail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,oEAAoE;AACpE,eAAO,MAAM,gBAAgB;IAC3B,uEAAuE;;IAEvE,yBAAyB;;IAEzB,mEAAmE;;IAEnE,iEAAiE;;IAEjE,2DAA2D;;IAE3D,iCAAiC;;CAEzB,CAAC;AAEX,yFAAyF;AACzF,eAAO,MAAM,sBAAsB,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAwB,CAAC;AAKtG,MAAM,WAAW,YAAY;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wDAAwD;AACxD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,UAAU,GAAG,iBAAiB,CAAC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,IAAI,CAgBhH;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,EACpE,IAAI,EAAE,YAAY,GACjB;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CA2D5D"}
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ /**
3
+ * TestivAI Report — the thumbnail of a changed snapshot (thumb.png)
4
+ *
5
+ * A full-page diff is too tall to show inline where space is short (a pull
6
+ * request comment scales it to the column's width, and the change becomes a
7
+ * thin band). The thumbnail crops the changed area instead and puts the
8
+ * baseline, the current capture and the diff of it side by side:
9
+ *
10
+ * baseline | current | diff (2 px apart, at most 800×400 px)
11
+ *
12
+ * The area is on the diff canvas, which is the larger of the two sizes when
13
+ * they differ (witness pads both, anchored at the top left), so it is the
14
+ * same place in all three images; rows or columns a capture does not have
15
+ * are drawn as padding. Each panel is the area downscaled by area average,
16
+ * never upscaled. Plain RGBA arithmetic: no dependency beyond pngjs, which
17
+ * the caller encodes with.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.THUMBNAIL_PADDING_RGBA = exports.THUMBNAIL_LIMITS = void 0;
21
+ exports.thumbnailArea = thumbnailArea;
22
+ exports.renderThumbnail = renderThumbnail;
23
+ /** The bounds of a thumbnail. docs/extension-api.md quotes them. */
24
+ exports.THUMBNAIL_LIMITS = {
25
+ /** The widest strip, the three panels and both separators together. */
26
+ maxWidth: 800,
27
+ /** The tallest strip. */
28
+ maxHeight: 400,
29
+ /** Pixels of context around the changed regions, on every side. */
30
+ padding: 24,
31
+ /** How many of the largest regions (by area) the area covers. */
32
+ regions: 3,
33
+ /** Rows in the band shown when the diff has no regions. */
34
+ bandHeight: 400,
35
+ /** Pixels between two panels. */
36
+ separator: 2,
37
+ };
38
+ /** What a panel shows where its capture has no pixel (the padded part of the canvas). */
39
+ exports.THUMBNAIL_PADDING_RGBA = [175, 184, 193, 255];
40
+ /** The line between two panels. */
41
+ const SEPARATOR_RGBA = [87, 96, 106, 255];
42
+ /**
43
+ * The area of the diff canvas the thumbnail shows: the union of the up to
44
+ * three largest regions by area, padded and kept inside the canvas. Without
45
+ * a region (none detected, or none inside the canvas), a full-width band of
46
+ * 400 rows from the first row with a differing pixel, moved up when the
47
+ * canvas ends sooner so it keeps its height. Null when no pixel of the diff
48
+ * differs.
49
+ *
50
+ * @param regions The snapshot's `regions`, on the diff canvas.
51
+ * @param diff The diff image (the canvas): differing pixels are heat
52
+ * (yellow to red); the rest is a grey wash of the baseline,
53
+ * and masked areas are grey hatching.
54
+ */
55
+ function thumbnailArea(regions, diff) {
56
+ const canvas = { x: 0, y: 0, width: diff.width, height: diff.height };
57
+ const inside = (regions ?? [])
58
+ .map((r) => intersect(r, canvas))
59
+ .filter((r) => r !== null)
60
+ .sort((a, b) => b.width * b.height - a.width * a.height)
61
+ .slice(0, exports.THUMBNAIL_LIMITS.regions);
62
+ if (inside.length > 0) {
63
+ const p = exports.THUMBNAIL_LIMITS.padding;
64
+ const box = inside.reduce(union);
65
+ return intersect({ x: box.x - p, y: box.y - p, width: box.width + 2 * p, height: box.height + 2 * p }, canvas);
66
+ }
67
+ const first = firstDifferingRow(diff);
68
+ if (first === null)
69
+ return null;
70
+ const height = Math.min(exports.THUMBNAIL_LIMITS.bandHeight, diff.height);
71
+ return { x: 0, y: Math.min(first, diff.height - height), width: diff.width, height };
72
+ }
73
+ /**
74
+ * The strip for `area`: baseline | current | diff, each panel the area
75
+ * downscaled by area average to fit the strip in 800×400 px (never
76
+ * upscaled), 2 px apart. `baseline` and `current` keep their own sizes:
77
+ * where the canvas is larger than a capture, its panel shows padding.
78
+ */
79
+ function renderThumbnail(images, area) {
80
+ const { maxWidth, maxHeight, separator } = exports.THUMBNAIL_LIMITS;
81
+ const scale = Math.min(1, (maxWidth - 2 * separator) / (3 * area.width), maxHeight / area.height);
82
+ const panelWidth = Math.max(1, Math.round(area.width * scale));
83
+ const panelHeight = Math.max(1, Math.round(area.height * scale));
84
+ const width = 3 * panelWidth + 2 * separator;
85
+ const out = new Uint8ClampedArray(width * panelHeight * 4);
86
+ // Output column (row) i averages source columns (rows) [start(i), start(i + 1)):
87
+ // a partition of the area, since a panel is never larger than the area.
88
+ const starts = (size, n) => Int32Array.from({ length: n + 1 }, (_, i) => Math.floor((i * size) / n));
89
+ const colStart = starts(area.width, panelWidth);
90
+ const rowStart = starts(area.height, panelHeight);
91
+ const columnOf = new Int32Array(area.width);
92
+ for (let c = 0; c < panelWidth; c++)
93
+ columnOf.fill(c, colStart[c], colStart[c + 1]);
94
+ const sums = new Float64Array(panelWidth * 4);
95
+ const pad = exports.THUMBNAIL_PADDING_RGBA;
96
+ [images.baseline, images.current, images.diff].forEach((image, panel) => {
97
+ const left = panel * (panelWidth + separator);
98
+ // Columns of the area this capture has; the rest is padding.
99
+ const inWidth = Math.max(0, Math.min(area.width, image.width - area.x));
100
+ for (let oy = 0; oy < panelHeight; oy++) {
101
+ sums.fill(0);
102
+ // One pass over the source rows, adding each pixel to its output column.
103
+ for (let y = area.y + rowStart[oy]; y < area.y + rowStart[oy + 1]; y++) {
104
+ const hasRow = y < image.height;
105
+ const rowOffset = (y * image.width + area.x) * 4;
106
+ for (let xi = 0; xi < area.width; xi++) {
107
+ const s = columnOf[xi] * 4;
108
+ if (hasRow && xi < inWidth) {
109
+ const i = rowOffset + xi * 4;
110
+ sums[s] += image.data[i];
111
+ sums[s + 1] += image.data[i + 1];
112
+ sums[s + 2] += image.data[i + 2];
113
+ sums[s + 3] += image.data[i + 3];
114
+ }
115
+ else {
116
+ sums[s] += pad[0];
117
+ sums[s + 1] += pad[1];
118
+ sums[s + 2] += pad[2];
119
+ sums[s + 3] += pad[3];
120
+ }
121
+ }
122
+ }
123
+ const rowsHere = rowStart[oy + 1] - rowStart[oy];
124
+ for (let ox = 0; ox < panelWidth; ox++) {
125
+ const n = rowsHere * (colStart[ox + 1] - colStart[ox]);
126
+ const o = (oy * width + left + ox) * 4;
127
+ for (let ch = 0; ch < 4; ch++)
128
+ out[o + ch] = Math.round(sums[ox * 4 + ch] / n);
129
+ }
130
+ }
131
+ });
132
+ for (const left of [panelWidth, 2 * panelWidth + separator]) {
133
+ for (let y = 0; y < panelHeight; y++) {
134
+ for (let x = left; x < left + separator; x++)
135
+ out.set(SEPARATOR_RGBA, (y * width + x) * 4);
136
+ }
137
+ }
138
+ return { data: out, width, height: panelHeight };
139
+ }
140
+ /** The first row with a heat pixel: the diff paints unchanged pixels grey (r = g = b), changed ones yellow to red. */
141
+ function firstDifferingRow(diff) {
142
+ const { data, width, height } = diff;
143
+ for (let y = 0; y < height; y++) {
144
+ for (let i = y * width * 4, end = i + width * 4; i < end; i += 4) {
145
+ if (data[i + 3] !== 0 && (data[i] !== data[i + 1] || data[i + 1] !== data[i + 2]))
146
+ return y;
147
+ }
148
+ }
149
+ return null;
150
+ }
151
+ /** The overlap of two boxes in whole pixels (a fractional edge takes the pixel it touches), or null when they share none. */
152
+ function intersect(a, b) {
153
+ if (![a.x, a.y, a.width, a.height].every(Number.isFinite))
154
+ return null;
155
+ const x = Math.max(Math.floor(a.x), b.x);
156
+ const y = Math.max(Math.floor(a.y), b.y);
157
+ const right = Math.min(Math.ceil(a.x + a.width), b.x + b.width);
158
+ const bottom = Math.min(Math.ceil(a.y + a.height), b.y + b.height);
159
+ return right > x && bottom > y ? { x, y, width: right - x, height: bottom - y } : null;
160
+ }
161
+ function union(a, b) {
162
+ const x = Math.min(a.x, b.x);
163
+ const y = Math.min(a.y, b.y);
164
+ return { x, y, width: Math.max(a.x + a.width, b.x + b.width) - x, height: Math.max(a.y + a.height, b.y + b.height) - y };
165
+ }
166
+ //# sourceMappingURL=thumbnail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thumbnail.js","sourceRoot":"","sources":["../../src/report/thumbnail.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAmDH,sCAgBC;AAQD,0CA8DC;AAvID,oEAAoE;AACvD,QAAA,gBAAgB,GAAG;IAC9B,uEAAuE;IACvE,QAAQ,EAAE,GAAG;IACb,yBAAyB;IACzB,SAAS,EAAE,GAAG;IACd,mEAAmE;IACnE,OAAO,EAAE,EAAE;IACX,iEAAiE;IACjE,OAAO,EAAE,CAAC;IACV,2DAA2D;IAC3D,UAAU,EAAE,GAAG;IACf,iCAAiC;IACjC,SAAS,EAAE,CAAC;CACJ,CAAC;AAEX,yFAAyF;AAC5E,QAAA,sBAAsB,GAA8C,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AC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;AAC3H,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Read a results.json you did not produce.
3
+ *
4
+ * A published report is rebuilt from results.json, and that file can come
5
+ * from a CI run the reader does not control (a fork's pull request). The
6
+ * template escapes every string it shows; it does not check that numbers
7
+ * are numbers, that enums hold known values, or that the data has the
8
+ * expected shape. This does, for every field the report reads:
9
+ *
10
+ * - each field must have its type (a finite number, text, a known value),
11
+ * within size limits, or the whole file is rejected with the field's path;
12
+ * - fields it does not know are dropped, at every level;
13
+ * - image paths (`baselinePath`, `currentPath`, `diffPath`, `thumbPath`) are
14
+ * never taken from the file: the caller adds them for the images it
15
+ * actually has. A `thumbPath` (schema 2.6.0) that is there must be text,
16
+ * or the file is rejected like for any other field.
17
+ *
18
+ * Its own module with no Node dependencies, so the GitHub Action can bundle
19
+ * it without the rest of the report code.
20
+ */
21
+ import type { ReportData } from './results';
22
+ /** The results.json major version this reads: the major of RESULTS_SCHEMA_VERSION (generator.ts). */
23
+ export declare const SUPPORTED_SCHEMA_MAJOR = 2;
24
+ /** Size limits; a file over one is rejected. Far above what a real suite writes. */
25
+ export declare const REPORT_DATA_LIMITS: {
26
+ readonly snapshots: 5000;
27
+ readonly nameLength: 300;
28
+ readonly textLength: 2000;
29
+ readonly regions: 1000;
30
+ readonly elementsPerRegion: 10;
31
+ readonly styleElements: 200;
32
+ readonly masks: 500;
33
+ readonly maskWarnings: 200;
34
+ readonly maskSpecKeys: 50;
35
+ readonly missingBaselines: 5000;
36
+ readonly environmentKeys: 20;
37
+ readonly environmentValueLength: 200;
38
+ readonly environmentFields: 100;
39
+ readonly healthLines: 100;
40
+ };
41
+ export type ParsedReportData = {
42
+ ok: true;
43
+ data: ReportData;
44
+ } | {
45
+ ok: false;
46
+ reason: string;
47
+ };
48
+ /**
49
+ * Check a parsed results.json and return only the typed data the report
50
+ * needs, or the reason it cannot be shown.
51
+ */
52
+ export declare function parseReportData(json: unknown): ParsedReportData;
53
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/report/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,KAAK,EACV,UAAU,EAOX,MAAM,WAAW,CAAC;AAEnB,qGAAqG;AACrG,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,oFAAoF;AACpF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;CAerB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9F;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAO/D"}