@mizchi/vlmkit-core 0.9.1 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apng.d.mts +42 -0
- package/dist/apng.mjs +199 -0
- package/dist/auth-state.d.mts +14 -3
- package/dist/auth-state.mjs +30 -6
- package/dist/bitmap-font.d.mts +48 -0
- package/dist/bitmap-font.mjs +945 -0
- package/dist/browser-launch.d.mts +65 -0
- package/dist/browser-launch.mjs +194 -0
- package/dist/cli-error.d.mts +73 -1
- package/dist/cli-error.mjs +164 -32
- package/dist/element-compare.mjs +8 -11
- package/dist/filmstrip.d.mts +121 -0
- package/dist/filmstrip.mjs +181 -0
- package/dist/gate-config.d.mts +107 -22
- package/dist/gate-config.mjs +138 -9
- package/dist/heatmap.d.mts +48 -4
- package/dist/heatmap.mjs +157 -12
- package/dist/index.d.mts +6 -4
- package/dist/index.mjs +4 -2
- package/dist/mask.d.mts +66 -2
- package/dist/mask.mjs +91 -4
- package/dist/page-load.d.mts +83 -0
- package/dist/page-load.mjs +116 -0
- package/dist/page-open.d.mts +123 -2
- package/dist/page-open.mjs +176 -6
- package/dist/plugin/args.d.mts +86 -0
- package/dist/plugin/args.mjs +162 -0
- package/dist/plugin/browser.d.mts +6 -0
- package/dist/plugin/browser.mjs +6 -0
- package/dist/plugin/cli-entry.d.mts +11 -0
- package/dist/plugin/cli-entry.mjs +69 -0
- package/dist/plugin/contract.d.mts +270 -0
- package/dist/plugin/contract.mjs +51 -0
- package/dist/plugin/index.d.mts +82 -0
- package/dist/plugin/index.mjs +81 -0
- package/dist/plugin/load.d.mts +36 -0
- package/dist/plugin/load.mjs +98 -0
- package/dist/plugin/registry.d.mts +60 -0
- package/dist/plugin/registry.mjs +160 -0
- package/dist/plugin/rule-tier.d.mts +65 -0
- package/dist/plugin/rule-tier.mjs +77 -0
- package/dist/plugin/rules.d.mts +112 -0
- package/dist/plugin/rules.mjs +188 -0
- package/dist/plugin/runner.d.mts +198 -0
- package/dist/plugin/runner.mjs +440 -0
- package/dist/png-utils.d.mts +31 -1
- package/dist/png-utils.mjs +24 -1
- package/dist/rect-overlap.d.mts +41 -0
- package/dist/rect-overlap.mjs +28 -0
- package/dist/run-ledger.d.mts +56 -2
- package/dist/run-ledger.mjs +102 -11
- package/dist/types.d.mts +60 -1
- package/dist/version.d.mts +20 -0
- package/dist/version.mjs +20 -0
- package/dist/webp.d.mts +31 -0
- package/dist/webp.mjs +105 -0
- package/package.json +17 -3
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { PngData } from "./png-utils.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/filmstrip.d.ts
|
|
4
|
+
interface FilmstripOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Cells per row. Omit for a single row (a filmstrip); set it to wrap into a
|
|
7
|
+
* grid (a contact sheet).
|
|
8
|
+
*/
|
|
9
|
+
columns?: number;
|
|
10
|
+
/** Gap between cells, in px. Default 8. */
|
|
11
|
+
gap?: number;
|
|
12
|
+
/** Margin around the whole sheet, in px. Defaults to `gap`. */
|
|
13
|
+
padding?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Sheet background, RGB. Default is a mid grey.
|
|
16
|
+
*
|
|
17
|
+
* Not white and not black on purpose: the frames being composited are
|
|
18
|
+
* screenshots of UI, which is usually one or the other, and a background that
|
|
19
|
+
* matches the content makes the cell boundaries invisible — so a frame that
|
|
20
|
+
* came back blank looks like a gap in the sheet rather than like a blank frame.
|
|
21
|
+
*/
|
|
22
|
+
background?: readonly [number, number, number];
|
|
23
|
+
/**
|
|
24
|
+
* Downscale every frame by this factor before compositing (2 = half size).
|
|
25
|
+
* Applied per cell, so the grid geometry below is computed on the scaled sizes.
|
|
26
|
+
*/
|
|
27
|
+
scale?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Cap the sheet's width in px by downscaling further. Applied after `scale`.
|
|
30
|
+
* A 4-sample strip of 1280x720 frames is 5192px wide untouched.
|
|
31
|
+
*
|
|
32
|
+
* `0` disables the cap, matching `snapshot strip --max-width 0`.
|
|
33
|
+
*/
|
|
34
|
+
maxWidth?: number;
|
|
35
|
+
/**
|
|
36
|
+
* One label per column, drawn in a band above the grid. For a shared-clock strip
|
|
37
|
+
* these are the sample times, which is the axis the sheet is read along.
|
|
38
|
+
*/
|
|
39
|
+
columnLabels?: readonly string[];
|
|
40
|
+
/**
|
|
41
|
+
* One label per row, drawn in a band above that row's cells — above rather than
|
|
42
|
+
* in a left gutter, because a row label is a CSS selector and a gutter wide
|
|
43
|
+
* enough for one would dominate a sheet of 200px cells.
|
|
44
|
+
*/
|
|
45
|
+
rowLabels?: readonly string[];
|
|
46
|
+
/** Integer pixel size of one font unit. Default 2, i.e. 10x14 glyphs. */
|
|
47
|
+
labelScale?: number;
|
|
48
|
+
/** Label ink, RGB. Default near-white, for the default grey sheet. */
|
|
49
|
+
labelColor?: readonly [number, number, number];
|
|
50
|
+
}
|
|
51
|
+
interface FilmstripLayout {
|
|
52
|
+
/**
|
|
53
|
+
* Cell box, i.e. the largest frame after scaling.
|
|
54
|
+
*
|
|
55
|
+
* Uniform across the sheet, and a per-row box was tried and rejected — see the measurement in
|
|
56
|
+
* `composeFilmstrip`'s header.
|
|
57
|
+
*/
|
|
58
|
+
cell: {
|
|
59
|
+
width: number;
|
|
60
|
+
height: number;
|
|
61
|
+
};
|
|
62
|
+
columns: number;
|
|
63
|
+
rows: number;
|
|
64
|
+
/** Top-left of each frame in sheet coordinates, in input order. */
|
|
65
|
+
positions: readonly {
|
|
66
|
+
x: number;
|
|
67
|
+
y: number;
|
|
68
|
+
}[];
|
|
69
|
+
/** Scale actually applied, after `maxWidth` was taken into account. */
|
|
70
|
+
scale: number;
|
|
71
|
+
/** Height reserved above the grid for column labels; 0 when there are none. */
|
|
72
|
+
columnLabelBand: number;
|
|
73
|
+
/** Height reserved above each row for its label; 0 when there are none. */
|
|
74
|
+
rowLabelBand: number;
|
|
75
|
+
}
|
|
76
|
+
/** Nearest-neighbour, matching `image-resize.ts`: hard edges stay legible small. */
|
|
77
|
+
/**
|
|
78
|
+
* Exported for the animated-strip path, which downscales the same frames the sheet would and must
|
|
79
|
+
* shrink them the same way — two nearest-neighbour implementations would drift on which pixel wins.
|
|
80
|
+
*/
|
|
81
|
+
declare function scalePngData(src: PngData, factor: number): PngData;
|
|
82
|
+
/**
|
|
83
|
+
* Where each frame lands. Exported so a caller can label the sheet (in Markdown,
|
|
84
|
+
* a report, a PR comment) without re-deriving the arithmetic.
|
|
85
|
+
*/
|
|
86
|
+
declare function filmstripLayout(frames: readonly PngData[], options?: FilmstripOptions): FilmstripLayout;
|
|
87
|
+
/**
|
|
88
|
+
* One image containing every frame, in order.
|
|
89
|
+
*
|
|
90
|
+
* ## Why the cell stays uniform (measured 2026-08-16, closing the "ragged layout" item)
|
|
91
|
+
*
|
|
92
|
+
* A real sheet is half padding: `check animation --strip` on
|
|
93
|
+
* `fixtures/css-challenge/dashboard.html` is 1532x781 and **49.0% background**. The recorded fix
|
|
94
|
+
* was per-row cell sizes. Implemented and measured, it recovers almost nothing, because the
|
|
95
|
+
* recorded diagnosis was wrong about where the padding is:
|
|
96
|
+
*
|
|
97
|
+
* - The four rows are all 393px TALL and 916 / 664 / 412 / 244px WIDE, so per-row height changes
|
|
98
|
+
* nothing on this sheet (byte-identical output).
|
|
99
|
+
* - Per-row WIDTH cannot help either: the sheet must be as wide as its widest row, so a narrow
|
|
100
|
+
* row's grey moves from between its cells to the right of them. Measured on a synthetic
|
|
101
|
+
* three-width sheet: 37.1% uniform against 36.2% ragged.
|
|
102
|
+
* - And it costs correctness where it does apply: a column label names one instant across every
|
|
103
|
+
* row, so ragged widths print `150ms` over a cell from a different sample.
|
|
104
|
+
*
|
|
105
|
+
* So the padding is a property of the composition — one grid, rows of very different widths — and
|
|
106
|
+
* not of the cell rule. Fixing it means a different picture (item: "time axis x rows" plus "spatial
|
|
107
|
+
* arrangement" in one artifact), which is the same conclusion the spatial-arrangement item reached.
|
|
108
|
+
* `--strip-animated` is the other half of that answer: no grid at all.
|
|
109
|
+
*
|
|
110
|
+
* Frames of different sizes are placed **top-left inside a uniform cell**, never
|
|
111
|
+
* centred. That matters for the case this exists for: an animation filmstrip of
|
|
112
|
+
* a `translateX` sweep is read by comparing where the element sits across cells,
|
|
113
|
+
* and centring each frame inside its cell would subtract exactly the offset the
|
|
114
|
+
* reader is looking for — turning visible motion into a still. Cells are sized
|
|
115
|
+
* from the largest frame so nothing is cropped.
|
|
116
|
+
*/
|
|
117
|
+
declare function composeFilmstrip(frames: readonly PngData[], options?: FilmstripOptions): PngData & {
|
|
118
|
+
layout: FilmstripLayout;
|
|
119
|
+
};
|
|
120
|
+
//#endregion
|
|
121
|
+
export { FilmstripLayout, FilmstripOptions, composeFilmstrip, filmstripLayout, scalePngData };
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { drawText, fitText, textHeight } from "./bitmap-font.mjs";
|
|
2
|
+
//#region src/filmstrip.ts
|
|
3
|
+
const DEFAULT_BACKGROUND = [
|
|
4
|
+
96,
|
|
5
|
+
96,
|
|
6
|
+
96
|
|
7
|
+
];
|
|
8
|
+
const DEFAULT_LABEL_COLOR = [
|
|
9
|
+
240,
|
|
10
|
+
240,
|
|
11
|
+
240
|
|
12
|
+
];
|
|
13
|
+
/** Breathing room under a label band, so ink does not touch the frame below it. */
|
|
14
|
+
const LABEL_PAD = 3;
|
|
15
|
+
/** Nearest-neighbour, matching `image-resize.ts`: hard edges stay legible small. */
|
|
16
|
+
/**
|
|
17
|
+
* Exported for the animated-strip path, which downscales the same frames the sheet would and must
|
|
18
|
+
* shrink them the same way — two nearest-neighbour implementations would drift on which pixel wins.
|
|
19
|
+
*/
|
|
20
|
+
function scalePngData(src, factor) {
|
|
21
|
+
if (factor === 1) return src;
|
|
22
|
+
const width = Math.max(1, Math.round(src.width / factor));
|
|
23
|
+
const height = Math.max(1, Math.round(src.height / factor));
|
|
24
|
+
const data = new Uint8Array(width * height * 4);
|
|
25
|
+
const xRatio = src.width / width;
|
|
26
|
+
const yRatio = src.height / height;
|
|
27
|
+
for (let y = 0; y < height; y++) {
|
|
28
|
+
const srcY = Math.min(Math.floor(y * yRatio), src.height - 1);
|
|
29
|
+
for (let x = 0; x < width; x++) {
|
|
30
|
+
const srcX = Math.min(Math.floor(x * xRatio), src.width - 1);
|
|
31
|
+
const si = (srcY * src.width + srcX) * 4;
|
|
32
|
+
const di = (y * width + x) * 4;
|
|
33
|
+
data[di] = src.data[si];
|
|
34
|
+
data[di + 1] = src.data[si + 1];
|
|
35
|
+
data[di + 2] = src.data[si + 2];
|
|
36
|
+
data[di + 3] = src.data[si + 3];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
width,
|
|
41
|
+
height,
|
|
42
|
+
data
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Where each frame lands. Exported so a caller can label the sheet (in Markdown,
|
|
47
|
+
* a report, a PR comment) without re-deriving the arithmetic.
|
|
48
|
+
*/
|
|
49
|
+
function filmstripLayout(frames, options = {}) {
|
|
50
|
+
if (frames.length === 0) throw new Error("filmstrip needs at least one frame");
|
|
51
|
+
const gap = options.gap ?? 8;
|
|
52
|
+
const padding = options.padding ?? gap;
|
|
53
|
+
const columns = Math.max(1, Math.min(options.columns ?? frames.length, frames.length));
|
|
54
|
+
const rows = Math.ceil(frames.length / columns);
|
|
55
|
+
let scale = Math.max(1, options.scale ?? 1);
|
|
56
|
+
const cellWidthAt = (s) => Math.max(...frames.map((f) => Math.max(1, Math.round(f.width / s))));
|
|
57
|
+
if (options.maxWidth !== void 0 && options.maxWidth > 0) {
|
|
58
|
+
const sheetWidthAt = (s) => padding * 2 + columns * cellWidthAt(s) + gap * (columns - 1);
|
|
59
|
+
let guard = 0;
|
|
60
|
+
while (sheetWidthAt(scale) > options.maxWidth && guard++ < 64) scale += .25;
|
|
61
|
+
}
|
|
62
|
+
const scaled = frames.map((f) => ({
|
|
63
|
+
width: Math.max(1, Math.round(f.width / scale)),
|
|
64
|
+
height: Math.max(1, Math.round(f.height / scale))
|
|
65
|
+
}));
|
|
66
|
+
const cell = {
|
|
67
|
+
width: Math.max(...scaled.map((s) => s.width)),
|
|
68
|
+
height: Math.max(...scaled.map((s) => s.height))
|
|
69
|
+
};
|
|
70
|
+
const band = textHeight(Math.max(1, Math.round(options.labelScale ?? 2))) + LABEL_PAD;
|
|
71
|
+
const columnLabelBand = options.columnLabels && options.columnLabels.length > 0 ? band : 0;
|
|
72
|
+
const rowLabelBand = options.rowLabels && options.rowLabels.length > 0 ? band : 0;
|
|
73
|
+
return {
|
|
74
|
+
cell,
|
|
75
|
+
columns,
|
|
76
|
+
rows,
|
|
77
|
+
positions: frames.map((_, i) => {
|
|
78
|
+
const row = Math.floor(i / columns);
|
|
79
|
+
return {
|
|
80
|
+
x: padding + i % columns * (cell.width + gap),
|
|
81
|
+
y: padding + columnLabelBand + row * (cell.height + gap + rowLabelBand) + rowLabelBand
|
|
82
|
+
};
|
|
83
|
+
}),
|
|
84
|
+
scale,
|
|
85
|
+
columnLabelBand,
|
|
86
|
+
rowLabelBand
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* One image containing every frame, in order.
|
|
91
|
+
*
|
|
92
|
+
* ## Why the cell stays uniform (measured 2026-08-16, closing the "ragged layout" item)
|
|
93
|
+
*
|
|
94
|
+
* A real sheet is half padding: `check animation --strip` on
|
|
95
|
+
* `fixtures/css-challenge/dashboard.html` is 1532x781 and **49.0% background**. The recorded fix
|
|
96
|
+
* was per-row cell sizes. Implemented and measured, it recovers almost nothing, because the
|
|
97
|
+
* recorded diagnosis was wrong about where the padding is:
|
|
98
|
+
*
|
|
99
|
+
* - The four rows are all 393px TALL and 916 / 664 / 412 / 244px WIDE, so per-row height changes
|
|
100
|
+
* nothing on this sheet (byte-identical output).
|
|
101
|
+
* - Per-row WIDTH cannot help either: the sheet must be as wide as its widest row, so a narrow
|
|
102
|
+
* row's grey moves from between its cells to the right of them. Measured on a synthetic
|
|
103
|
+
* three-width sheet: 37.1% uniform against 36.2% ragged.
|
|
104
|
+
* - And it costs correctness where it does apply: a column label names one instant across every
|
|
105
|
+
* row, so ragged widths print `150ms` over a cell from a different sample.
|
|
106
|
+
*
|
|
107
|
+
* So the padding is a property of the composition — one grid, rows of very different widths — and
|
|
108
|
+
* not of the cell rule. Fixing it means a different picture (item: "time axis x rows" plus "spatial
|
|
109
|
+
* arrangement" in one artifact), which is the same conclusion the spatial-arrangement item reached.
|
|
110
|
+
* `--strip-animated` is the other half of that answer: no grid at all.
|
|
111
|
+
*
|
|
112
|
+
* Frames of different sizes are placed **top-left inside a uniform cell**, never
|
|
113
|
+
* centred. That matters for the case this exists for: an animation filmstrip of
|
|
114
|
+
* a `translateX` sweep is read by comparing where the element sits across cells,
|
|
115
|
+
* and centring each frame inside its cell would subtract exactly the offset the
|
|
116
|
+
* reader is looking for — turning visible motion into a still. Cells are sized
|
|
117
|
+
* from the largest frame so nothing is cropped.
|
|
118
|
+
*/
|
|
119
|
+
function composeFilmstrip(frames, options = {}) {
|
|
120
|
+
const layout = filmstripLayout(frames, options);
|
|
121
|
+
const gap = options.gap ?? 8;
|
|
122
|
+
const padding = options.padding ?? gap;
|
|
123
|
+
const [bgR, bgG, bgB] = options.background ?? DEFAULT_BACKGROUND;
|
|
124
|
+
const width = padding * 2 + layout.columns * layout.cell.width + gap * (layout.columns - 1);
|
|
125
|
+
const height = padding * 2 + layout.columnLabelBand + layout.rows * (layout.cell.height + layout.rowLabelBand) + gap * (layout.rows - 1);
|
|
126
|
+
const data = new Uint8Array(width * height * 4);
|
|
127
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
128
|
+
data[i] = bgR;
|
|
129
|
+
data[i + 1] = bgG;
|
|
130
|
+
data[i + 2] = bgB;
|
|
131
|
+
data[i + 3] = 255;
|
|
132
|
+
}
|
|
133
|
+
frames.forEach((frame, index) => {
|
|
134
|
+
const scaled = scalePngData(frame, layout.scale);
|
|
135
|
+
const { x: ox, y: oy } = layout.positions[index];
|
|
136
|
+
for (let y = 0; y < scaled.height; y++) {
|
|
137
|
+
const dstRow = (oy + y) * width;
|
|
138
|
+
const srcRow = y * scaled.width;
|
|
139
|
+
for (let x = 0; x < scaled.width; x++) {
|
|
140
|
+
const si = (srcRow + x) * 4;
|
|
141
|
+
const di = (dstRow + ox + x) * 4;
|
|
142
|
+
data[di] = scaled.data[si];
|
|
143
|
+
data[di + 1] = scaled.data[si + 1];
|
|
144
|
+
data[di + 2] = scaled.data[si + 2];
|
|
145
|
+
const alpha = scaled.data[si + 3] / 255;
|
|
146
|
+
if (alpha < 1) {
|
|
147
|
+
data[di] = Math.round(scaled.data[si] * alpha + bgR * (1 - alpha));
|
|
148
|
+
data[di + 1] = Math.round(scaled.data[si + 1] * alpha + bgG * (1 - alpha));
|
|
149
|
+
data[di + 2] = Math.round(scaled.data[si + 2] * alpha + bgB * (1 - alpha));
|
|
150
|
+
}
|
|
151
|
+
data[di + 3] = 255;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
const sheet = {
|
|
156
|
+
width,
|
|
157
|
+
height,
|
|
158
|
+
data
|
|
159
|
+
};
|
|
160
|
+
const labelScale = Math.max(1, Math.round(options.labelScale ?? 2));
|
|
161
|
+
const ink = options.labelColor ?? DEFAULT_LABEL_COLOR;
|
|
162
|
+
if (layout.columnLabelBand > 0) options.columnLabels.slice(0, layout.columns).forEach((label, col) => {
|
|
163
|
+
const x = padding + col * (layout.cell.width + gap);
|
|
164
|
+
drawText(sheet, fitText(label, layout.cell.width, labelScale), x, padding, ink, labelScale);
|
|
165
|
+
});
|
|
166
|
+
if (layout.rowLabelBand > 0) {
|
|
167
|
+
const rowWidth = width - padding * 2;
|
|
168
|
+
options.rowLabels.slice(0, layout.rows).forEach((label, row) => {
|
|
169
|
+
const y = padding + layout.columnLabelBand + row * (layout.cell.height + gap + layout.rowLabelBand);
|
|
170
|
+
drawText(sheet, fitText(label, rowWidth, labelScale), padding, y, ink, labelScale);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
width,
|
|
175
|
+
height,
|
|
176
|
+
data,
|
|
177
|
+
layout
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
export { composeFilmstrip, filmstripLayout, scalePngData };
|
package/dist/gate-config.d.mts
CHANGED
|
@@ -1,24 +1,6 @@
|
|
|
1
|
+
import { RuleSettingEntry, RuleSettings } from "./plugin/rules.mjs";
|
|
2
|
+
|
|
1
3
|
//#region src/gate-config.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* `vlmkit.gates.json` — one reviewed file that says which gates run on which
|
|
4
|
-
* pages, and holds every suppression with a reason attached.
|
|
5
|
-
*
|
|
6
|
-
* Why this exists: the documented convention was npm scripts, one line per
|
|
7
|
-
* page. Three separate reviewers landed on the same complaint — the scripts
|
|
8
|
-
* stop scaling around twenty pages, and once a `--allow-invisible` or an
|
|
9
|
-
* integrity exemption is inlined in a script, the only way to audit what has
|
|
10
|
-
* been silenced repo-wide is `grep`. A suppression nobody can enumerate is a
|
|
11
|
-
* suppression nobody revisits.
|
|
12
|
-
*
|
|
13
|
-
* Two decisions make the file worth reviewing rather than just worth having:
|
|
14
|
-
*
|
|
15
|
-
* 1. **A suppression must carry a reason.** Parsing fails without one. The
|
|
16
|
-
* flag alone records what was silenced but not why, which is exactly the
|
|
17
|
-
* state that makes a reviewer approve it again a year later.
|
|
18
|
-
* 2. **An expired suppression is dropped, not applied.** It is reported
|
|
19
|
-
* loudly and the gate goes back to failing. An expiry date that keeps
|
|
20
|
-
* working after it passes is a comment, not a deadline.
|
|
21
|
-
*/
|
|
22
4
|
interface GateSuppression {
|
|
23
5
|
/**
|
|
24
6
|
* Gate this applies to, as a prefix of the gate command: `check copy`
|
|
@@ -44,11 +26,66 @@ interface GatePage {
|
|
|
44
26
|
/** Extra gates for this page on top of the defaults. */
|
|
45
27
|
extraGates?: string[];
|
|
46
28
|
suppressions?: GateSuppression[];
|
|
29
|
+
/**
|
|
30
|
+
* Rule-granular settings for this page, merged over `defaults.rules`.
|
|
31
|
+
*
|
|
32
|
+
* The narrow instrument next to `suppressions`. A suppression appends a
|
|
33
|
+
* flag the gate had to think to implement; a rule setting works on every
|
|
34
|
+
* registry-driven gate uniformly and is validated against the gate's
|
|
35
|
+
* declared rule table, so a typo is a config error rather than a line
|
|
36
|
+
* that quietly does nothing.
|
|
37
|
+
*/
|
|
38
|
+
rules?: RuleSettings;
|
|
39
|
+
/**
|
|
40
|
+
* The long-form entries from `rules`, keyed by rule reference. Kept beside the
|
|
41
|
+
* flattened settings so a rule setting can carry a reason and an expiry, and go
|
|
42
|
+
* through the same inventory as a suppression.
|
|
43
|
+
*/
|
|
44
|
+
ruleAnnotations?: Readonly<Record<string, RuleSettingEntry>>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A dev server to start before the run and stop after it — Playwright's
|
|
48
|
+
* `webServer`, which it has had for years and this config did not.
|
|
49
|
+
*
|
|
50
|
+
* v6's adopting agent got around it with a HAR, and said so: without that idea
|
|
51
|
+
* you are hand-writing start / trap-kill / poll-for-ready in a shell wrapper,
|
|
52
|
+
* per CI job. A config that declares which URLs to gate but cannot say how to
|
|
53
|
+
* bring them up is only half committed.
|
|
54
|
+
*
|
|
55
|
+
* Named and shaped after Playwright's on purpose. A team that has written one
|
|
56
|
+
* should not have to learn a second vocabulary to write this one.
|
|
57
|
+
*/
|
|
58
|
+
interface GateWebServer {
|
|
59
|
+
/** Shell command that starts the server. */
|
|
60
|
+
command: string;
|
|
61
|
+
/**
|
|
62
|
+
* URL polled until it answers. Required — "started" has to mean "serving",
|
|
63
|
+
* not "spawned", or the first gate races the bundler.
|
|
64
|
+
*/
|
|
65
|
+
url: string;
|
|
66
|
+
/** Milliseconds to wait for `url` before giving up. Default 60000. */
|
|
67
|
+
timeout?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Reuse a server already listening on `url` instead of starting one.
|
|
70
|
+
*
|
|
71
|
+
* Defaults to true locally and FALSE in CI (`process.env.CI`), matching
|
|
72
|
+
* Playwright: locally you want your own `npm run dev`; in CI a listening port
|
|
73
|
+
* usually means a leaked process from an earlier job, and reusing it silently
|
|
74
|
+
* gates the wrong build.
|
|
75
|
+
*/
|
|
76
|
+
reuseExistingServer?: boolean;
|
|
77
|
+
/** Working directory for `command`. Relative to the config file. Default: the config's directory. */
|
|
78
|
+
cwd?: string;
|
|
79
|
+
/** Extra environment for the server process, on top of the current one. */
|
|
80
|
+
env?: Readonly<Record<string, string>>;
|
|
47
81
|
}
|
|
48
82
|
interface GateConfig {
|
|
83
|
+
webServer?: GateWebServer;
|
|
49
84
|
defaults?: {
|
|
50
85
|
gates?: string[];
|
|
51
86
|
suppressions?: GateSuppression[];
|
|
87
|
+
rules?: RuleSettings;
|
|
88
|
+
ruleAnnotations?: Readonly<Record<string, RuleSettingEntry>>;
|
|
52
89
|
};
|
|
53
90
|
pages: GatePage[];
|
|
54
91
|
}
|
|
@@ -58,15 +95,30 @@ interface ResolvedSuppression extends GateSuppression {
|
|
|
58
95
|
status: "active" | "expired" | "permanent";
|
|
59
96
|
/** Days until expiry; negative when overdue, null when permanent. */
|
|
60
97
|
daysLeft: number | null;
|
|
98
|
+
/**
|
|
99
|
+
* Which config block this came from.
|
|
100
|
+
*
|
|
101
|
+
* A long-form `rules` entry flows through the SAME resolved shape, the same
|
|
102
|
+
* expiry rule, and the same inventory as a `suppressions` entry — otherwise
|
|
103
|
+
* `rules` would need a second parallel set of all three, and the two would
|
|
104
|
+
* eventually disagree about what expiry means. The discriminator keeps them
|
|
105
|
+
* distinguishable to a reader; for a rule entry, `gate` is the gate the rule
|
|
106
|
+
* belongs to and `flag` is the `--rule` flag the plan appends.
|
|
107
|
+
*/
|
|
108
|
+
kind: "suppression" | "rule";
|
|
109
|
+
/** Rule reference, for `kind: "rule"` only. */
|
|
110
|
+
ref?: string;
|
|
61
111
|
}
|
|
62
112
|
interface GateJob {
|
|
63
113
|
pageId: string;
|
|
64
114
|
source: string;
|
|
65
|
-
/** Gate command with
|
|
115
|
+
/** Gate command with active suppression flags and rule settings appended. */
|
|
66
116
|
gate: string;
|
|
67
117
|
/** The gate as written in the config, before suppression flags. */
|
|
68
118
|
baseGate: string;
|
|
69
119
|
appliedSuppressions: ResolvedSuppression[];
|
|
120
|
+
/** Rule settings in effect, defaults merged with the page's. */
|
|
121
|
+
rules: RuleSettings;
|
|
70
122
|
}
|
|
71
123
|
interface GatePlan {
|
|
72
124
|
jobs: GateJob[];
|
|
@@ -81,9 +133,40 @@ interface GatePlan {
|
|
|
81
133
|
declare const GATE_CONFIG_FILENAMES: string[];
|
|
82
134
|
/** Parse and validate. Every error names the JSON path so the fix is obvious. */
|
|
83
135
|
declare function parseGateConfig(raw: string): GateConfig;
|
|
136
|
+
/**
|
|
137
|
+
* Whether to reuse a server already listening. Playwright's default, and for
|
|
138
|
+
* Playwright's reason: locally the listening port is your own `npm run dev`; in
|
|
139
|
+
* CI it is usually a leaked process from an earlier job, and reusing it gates a
|
|
140
|
+
* build nobody asked about.
|
|
141
|
+
*/
|
|
142
|
+
declare function shouldReuseExistingServer(server: GateWebServer, env?: NodeJS.ProcessEnv): boolean;
|
|
84
143
|
declare function resolveSuppression(s: GateSuppression, scope: string, now: Date): ResolvedSuppression;
|
|
144
|
+
/**
|
|
145
|
+
* Resolve one long-form `rules` entry onto the same shape as a suppression, so
|
|
146
|
+
* the inventory, the expiry notice and `--require-expiry` cover both.
|
|
147
|
+
*
|
|
148
|
+
* `gate` is the gate portion of the reference (`check.integrity/text-collision`
|
|
149
|
+
* -> `check.integrity`), which is what a reader scanning the inventory wants to
|
|
150
|
+
* see; a bare rule id has no gate to name and reports as `*`.
|
|
151
|
+
*/
|
|
152
|
+
declare function resolveRuleSetting(ref: string, entry: RuleSettingEntry, scope: string, now: Date): ResolvedSuppression;
|
|
85
153
|
interface ResolveOptions {
|
|
86
154
|
now?: Date;
|
|
155
|
+
/**
|
|
156
|
+
* Which of the resolved rule settings belong on THIS gate's command line.
|
|
157
|
+
*
|
|
158
|
+
* Every setting used to be appended to every gate, so a `check copy` invocation
|
|
159
|
+
* carried `--rule check.a11y.touch/target-undersized=off` and a single typo'd key
|
|
160
|
+
* printed the same config error once per gate. v7's agent-l and agent-m reported
|
|
161
|
+
* it independently.
|
|
162
|
+
*
|
|
163
|
+
* A callback rather than logic here, because deciding it needs the gate registry
|
|
164
|
+
* (which rules a gate declares) and this module deliberately does not depend on
|
|
165
|
+
* it. Omitted keeps the old behaviour, which is what a library caller with no
|
|
166
|
+
* registry should get: over-passing is harmless to the gate, since a `--rule`
|
|
167
|
+
* naming another gate is accepted and ignored by design.
|
|
168
|
+
*/
|
|
169
|
+
rulesForGate?: (baseGate: string, rules: RuleSettings) => RuleSettings;
|
|
87
170
|
/** Page ids or sources to keep. Substring match, so `admin` selects a subtree. */
|
|
88
171
|
only?: string[];
|
|
89
172
|
}
|
|
@@ -96,6 +179,8 @@ interface ResolveOptions {
|
|
|
96
179
|
* supposed to mean.
|
|
97
180
|
*/
|
|
98
181
|
declare function resolveGatePlan(config: GateConfig, options?: ResolveOptions): GatePlan;
|
|
182
|
+
/** `{ "check.integrity/text-collision": "off" }` → `["--rule", "check.integrity/text-collision=off"]`. */
|
|
183
|
+
declare function ruleFlags(rules: RuleSettings): string[];
|
|
99
184
|
/**
|
|
100
185
|
* Token-wise prefix match: `check copy` matches `check copy --manifest x.txt`
|
|
101
186
|
* but not `check copyright`, and `check` matches every check gate.
|
|
@@ -113,4 +198,4 @@ interface SuppressionSummary {
|
|
|
113
198
|
}
|
|
114
199
|
declare function summarizeSuppressions(suppressions: ResolvedSuppression[], soonDays?: number): SuppressionSummary;
|
|
115
200
|
//#endregion
|
|
116
|
-
export { GATE_CONFIG_FILENAMES, GateConfig, GateJob, GatePage, GatePlan, GateSuppression, ResolveOptions, ResolvedSuppression, SuppressionSummary, gateMatches, parseGateConfig, resolveGatePlan, resolveSuppression, summarizeSuppressions };
|
|
201
|
+
export { GATE_CONFIG_FILENAMES, GateConfig, GateJob, GatePage, GatePlan, GateSuppression, GateWebServer, ResolveOptions, ResolvedSuppression, SuppressionSummary, gateMatches, parseGateConfig, resolveGatePlan, resolveRuleSetting, resolveSuppression, ruleFlags, shouldReuseExistingServer, summarizeSuppressions };
|