@mizchi/vlmkit-core 0.8.0 → 0.8.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.
Files changed (66) hide show
  1. package/dist/a11y-semantic.d.mts +34 -0
  2. package/dist/a11y-semantic.mjs +261 -0
  3. package/dist/authored-style-capture.d.mts +42 -0
  4. package/dist/authored-style-capture.mjs +117 -0
  5. package/dist/authored-style-diff.d.mts +15 -0
  6. package/dist/authored-style-diff.mjs +16 -0
  7. package/dist/cli-args.d.mts +11 -0
  8. package/dist/cli-args.mjs +21 -0
  9. package/dist/cli-error.d.mts +4 -0
  10. package/dist/cli-error.mjs +59 -0
  11. package/dist/computed-style-capture.d.mts +41 -0
  12. package/dist/computed-style-capture.mjs +589 -0
  13. package/dist/computed-style-diff.d.mts +83 -0
  14. package/dist/computed-style-diff.mjs +123 -0
  15. package/dist/diff-regions.d.mts +8 -0
  16. package/dist/diff-regions.mjs +52 -0
  17. package/dist/dom-equivalence.d.mts +51 -0
  18. package/dist/dom-equivalence.mjs +91 -0
  19. package/dist/dom-position-styles.d.mts +166 -0
  20. package/dist/dom-position-styles.mjs +296 -0
  21. package/dist/element-compare.d.mts +71 -0
  22. package/dist/element-compare.mjs +269 -0
  23. package/dist/heatmap-regions.d.mts +57 -0
  24. package/dist/heatmap-regions.mjs +158 -0
  25. package/dist/heatmap.d.mts +86 -0
  26. package/dist/heatmap.mjs +510 -0
  27. package/dist/image-resize.d.mts +34 -0
  28. package/dist/image-resize.mjs +92 -0
  29. package/dist/index.d.mts +15 -0
  30. package/dist/index.mjs +14 -0
  31. package/dist/mask.d.mts +18 -0
  32. package/dist/mask.mjs +27 -0
  33. package/dist/png-utils.d.mts +30 -0
  34. package/dist/png-utils.mjs +80 -0
  35. package/dist/region-shift.d.mts +20 -0
  36. package/dist/region-shift.mjs +128 -0
  37. package/dist/run-ledger.d.mts +14 -0
  38. package/dist/run-ledger.mjs +31 -0
  39. package/dist/terminal-colors.d.mts +12 -0
  40. package/dist/terminal-colors.mjs +14 -0
  41. package/dist/text-rows.d.mts +121 -0
  42. package/dist/text-rows.mjs +246 -0
  43. package/{src/types.ts → dist/types.d.mts} +88 -206
  44. package/dist/types.mjs +1 -0
  45. package/package.json +17 -5
  46. package/src/a11y-semantic.ts +0 -384
  47. package/src/authored-style-capture.ts +0 -185
  48. package/src/authored-style-diff.ts +0 -32
  49. package/src/cli-args.ts +0 -29
  50. package/src/cli-error.ts +0 -85
  51. package/src/computed-style-capture.ts +0 -717
  52. package/src/computed-style-diff.ts +0 -192
  53. package/src/diff-regions.ts +0 -70
  54. package/src/dom-equivalence.ts +0 -158
  55. package/src/dom-position-styles.ts +0 -457
  56. package/src/element-compare.ts +0 -354
  57. package/src/heatmap-regions.ts +0 -245
  58. package/src/heatmap.ts +0 -670
  59. package/src/image-resize.ts +0 -112
  60. package/src/index.ts +0 -105
  61. package/src/mask.ts +0 -41
  62. package/src/png-utils.ts +0 -86
  63. package/src/region-shift.ts +0 -173
  64. package/src/run-ledger.ts +0 -39
  65. package/src/terminal-colors.ts +0 -13
  66. package/src/text-rows.ts +0 -412
package/dist/mask.mjs ADDED
@@ -0,0 +1,27 @@
1
+ //#region src/mask.ts
2
+ /**
3
+ * Inject mask styles into the page.
4
+ * Sets visibility: hidden on target selectors including descendants.
5
+ */
6
+ async function applyMask(page, selectors) {
7
+ if (selectors.length === 0) return;
8
+ const css = selectors.map((s) => `${s} { visibility: hidden !important; }`).join("\n");
9
+ await page.addStyleTag({ content: css });
10
+ }
11
+ /**
12
+ * Parse selector array from CLI --mask flags.
13
+ * Supports comma-separated or multiple --mask flags.
14
+ *
15
+ * --mask ".stars,.carousel"
16
+ * --mask ".stars" --mask ".carousel"
17
+ */
18
+ function parseMaskSelectors(args) {
19
+ const selectors = [];
20
+ for (let i = 0; i < args.length; i++) if (args[i] === "--mask" && args[i + 1]) for (const s of args[i + 1].split(",")) {
21
+ const trimmed = s.trim();
22
+ if (trimmed) selectors.push(trimmed);
23
+ }
24
+ return selectors;
25
+ }
26
+ //#endregion
27
+ export { applyMask, parseMaskSelectors };
@@ -0,0 +1,30 @@
1
+ //#region src/png-utils.d.ts
2
+ interface PngData {
3
+ width: number;
4
+ height: number;
5
+ data: Uint8Array;
6
+ }
7
+ /**
8
+ * Crop or pad an image to the target dimensions.
9
+ * Only handles the common region; overflow is zero-filled.
10
+ */
11
+ declare function cropImage(img: PngData, w: number, h: number): PngData;
12
+ /**
13
+ * Crop an arbitrary rectangle out of an image.
14
+ *
15
+ * Unlike {@link cropImage} (which only clips the top-left common region),
16
+ * this extracts a region at an arbitrary (x, y) offset. The rectangle is
17
+ * clamped to the image bounds, so the returned crop may be smaller than
18
+ * requested when the region overruns an edge (or off the top-left).
19
+ */
20
+ declare function cropRegion(img: PngData, x: number, y: number, w: number, h: number): PngData;
21
+ /**
22
+ * Read a PNG file and return RGBA pixel data.
23
+ */
24
+ declare function decodePng(path: string): Promise<PngData>;
25
+ /**
26
+ * Write RGBA pixel data to a PNG file.
27
+ */
28
+ declare function encodePng(path: string, data: PngData): Promise<void>;
29
+ //#endregion
30
+ export { PngData, cropImage, cropRegion, decodePng, encodePng };
@@ -0,0 +1,80 @@
1
+ import { readFile, writeFile } from "node:fs/promises";
2
+ //#region src/png-utils.ts
3
+ /**
4
+ * PNG I/O utilities
5
+ *
6
+ * Low-level PNG decode/encode using pngjs.
7
+ * Used by heatmap.ts and other modules that need raw pixel data.
8
+ */
9
+ /**
10
+ * Crop or pad an image to the target dimensions.
11
+ * Only handles the common region; overflow is zero-filled.
12
+ */
13
+ function cropImage(img, w, h) {
14
+ if (img.width === w && img.height === h) return img;
15
+ const data = new Uint8Array(w * h * 4);
16
+ for (let y = 0; y < h; y++) {
17
+ const srcOffset = y * img.width * 4;
18
+ const dstOffset = y * w * 4;
19
+ data.set(img.data.subarray(srcOffset, srcOffset + w * 4), dstOffset);
20
+ }
21
+ return {
22
+ width: w,
23
+ height: h,
24
+ data
25
+ };
26
+ }
27
+ /**
28
+ * Crop an arbitrary rectangle out of an image.
29
+ *
30
+ * Unlike {@link cropImage} (which only clips the top-left common region),
31
+ * this extracts a region at an arbitrary (x, y) offset. The rectangle is
32
+ * clamped to the image bounds, so the returned crop may be smaller than
33
+ * requested when the region overruns an edge (or off the top-left).
34
+ */
35
+ function cropRegion(img, x, y, w, h) {
36
+ const x0 = Math.max(0, Math.min(Math.floor(x), img.width));
37
+ const y0 = Math.max(0, Math.min(Math.floor(y), img.height));
38
+ const x1 = Math.max(x0, Math.min(Math.floor(x + w), img.width));
39
+ const y1 = Math.max(y0, Math.min(Math.floor(y + h), img.height));
40
+ const cw = x1 - x0;
41
+ const ch = y1 - y0;
42
+ const data = new Uint8Array(cw * ch * 4);
43
+ for (let row = 0; row < ch; row++) {
44
+ const srcOffset = ((y0 + row) * img.width + x0) * 4;
45
+ const dstOffset = row * cw * 4;
46
+ data.set(img.data.subarray(srcOffset, srcOffset + cw * 4), dstOffset);
47
+ }
48
+ return {
49
+ width: cw,
50
+ height: ch,
51
+ data
52
+ };
53
+ }
54
+ /**
55
+ * Read a PNG file and return RGBA pixel data.
56
+ */
57
+ async function decodePng(path) {
58
+ const { PNG } = await import("pngjs");
59
+ const buffer = await readFile(path);
60
+ const png = PNG.sync.read(buffer);
61
+ return {
62
+ width: png.width,
63
+ height: png.height,
64
+ data: new Uint8Array(png.data.buffer, png.data.byteOffset, png.data.byteLength)
65
+ };
66
+ }
67
+ /**
68
+ * Write RGBA pixel data to a PNG file.
69
+ */
70
+ async function encodePng(path, data) {
71
+ const { PNG } = await import("pngjs");
72
+ const png = new PNG({
73
+ width: data.width,
74
+ height: data.height
75
+ });
76
+ Buffer.from(data.data.buffer, data.data.byteOffset, data.data.byteLength).copy(png.data);
77
+ await writeFile(path, PNG.sync.write(png));
78
+ }
79
+ //#endregion
80
+ export { cropImage, cropRegion, decodePng, encodePng };
@@ -0,0 +1,20 @@
1
+ import { PngData } from "./png-utils.mjs";
2
+
3
+ //#region src/region-shift.d.ts
4
+ interface RegionShiftEstimate {
5
+ /** Content moved by +dx px horizontally in current (vs baseline). */
6
+ dx: number;
7
+ /** Content moved by +dy px vertically in current (vs baseline). */
8
+ dy: number;
9
+ /** 0..1; correlation peak strength of the dominant axis. */
10
+ confidence: number;
11
+ }
12
+ interface RegionRect {
13
+ x: number;
14
+ y: number;
15
+ width: number;
16
+ height: number;
17
+ }
18
+ declare function estimateRegionShift(baseline: PngData, current: PngData, region: RegionRect, maxOffset?: number): RegionShiftEstimate | null;
19
+ //#endregion
20
+ export { RegionShiftEstimate, estimateRegionShift };
@@ -0,0 +1,128 @@
1
+ //#region src/region-shift.ts
2
+ const MIN_REGION_EDGE = 8;
3
+ const MIN_PEAK = .6;
4
+ /** The shifted-lag peak must beat the zero-lag correlation by this much. */
5
+ const MIN_PEAK_ADVANTAGE = .15;
6
+ function estimateRegionShift(baseline, current, region, maxOffset = 64) {
7
+ if (region.width < MIN_REGION_EDGE || region.height < MIN_REGION_EDGE) return null;
8
+ const width = Math.min(baseline.width, current.width);
9
+ const height = Math.min(baseline.height, current.height);
10
+ const x0 = clamp(region.x - maxOffset, 0, width);
11
+ const x1 = clamp(region.x + region.width + maxOffset, 0, width);
12
+ const y0 = clamp(region.y, 0, height);
13
+ const y1 = clamp(region.y + region.height, 0, height);
14
+ const yw0 = clamp(region.y - maxOffset, 0, height);
15
+ const yw1 = clamp(region.y + region.height + maxOffset, 0, height);
16
+ const xr0 = clamp(region.x, 0, width);
17
+ const xr1 = clamp(region.x + region.width, 0, width);
18
+ if (x1 <= x0 || y1 <= y0 || yw1 <= yw0 || xr1 <= xr0) return null;
19
+ const horizontal = bestLag(columnProfile(baseline, x0, x1, y0, y1), columnProfile(current, x0, x1, y0, y1), maxOffset);
20
+ const vertical = bestLag(rowProfile(baseline, xr0, xr1, yw0, yw1), rowProfile(current, xr0, xr1, yw0, yw1), maxOffset);
21
+ const dx = acceptAxis(horizontal) ? horizontal.lag : 0;
22
+ const dy = acceptAxis(vertical) ? vertical.lag : 0;
23
+ if (dx === 0 && dy === 0) return null;
24
+ const confidences = [];
25
+ if (dx !== 0) confidences.push(horizontal.peak);
26
+ if (dy !== 0) confidences.push(vertical.peak);
27
+ return {
28
+ dx,
29
+ dy,
30
+ confidence: Number(Math.max(...confidences).toFixed(3))
31
+ };
32
+ }
33
+ function acceptAxis(result) {
34
+ return !result.flat && result.lag !== 0 && result.peak >= MIN_PEAK && result.peak - result.zeroLag >= MIN_PEAK_ADVANTAGE;
35
+ }
36
+ /**
37
+ * Find the lag maximizing normalized cross-correlation between two
38
+ * mean-subtracted profiles. Positive lag = current content sits at a
39
+ * higher coordinate than baseline (moved right / down).
40
+ */
41
+ function bestLag(base, curr, maxOffset) {
42
+ const a = meanSubtract(base);
43
+ const b = meanSubtract(curr);
44
+ if (a.flat || b.flat) return {
45
+ lag: 0,
46
+ peak: 0,
47
+ zeroLag: 0,
48
+ flat: true
49
+ };
50
+ let bestLag = 0;
51
+ let bestVal = -Infinity;
52
+ let zeroVal = 0;
53
+ const n = Math.min(a.values.length, b.values.length);
54
+ const limit = Math.min(maxOffset, n - 1);
55
+ for (let lag = -limit; lag <= limit; lag++) {
56
+ let dot = 0;
57
+ let normA = 0;
58
+ let normB = 0;
59
+ for (let i = 0; i < n; i++) {
60
+ const j = i + lag;
61
+ if (j < 0 || j >= n) continue;
62
+ dot += a.values[i] * b.values[j];
63
+ normA += a.values[i] * a.values[i];
64
+ normB += b.values[j] * b.values[j];
65
+ }
66
+ if (normA === 0 || normB === 0) continue;
67
+ const val = dot / Math.sqrt(normA * normB);
68
+ if (lag === 0) zeroVal = val;
69
+ if (val > bestVal) {
70
+ bestVal = val;
71
+ bestLag = lag;
72
+ }
73
+ }
74
+ if (!Number.isFinite(bestVal)) return {
75
+ lag: 0,
76
+ peak: 0,
77
+ zeroLag: 0,
78
+ flat: true
79
+ };
80
+ return {
81
+ lag: bestLag,
82
+ peak: bestVal,
83
+ zeroLag: zeroVal,
84
+ flat: false
85
+ };
86
+ }
87
+ function meanSubtract(profile) {
88
+ let sum = 0;
89
+ for (const v of profile) sum += v;
90
+ const mean = sum / profile.length;
91
+ const values = new Float64Array(profile.length);
92
+ let variance = 0;
93
+ for (let i = 0; i < profile.length; i++) {
94
+ values[i] = profile[i] - mean;
95
+ variance += values[i] * values[i];
96
+ }
97
+ return {
98
+ values,
99
+ flat: variance / profile.length < 1
100
+ };
101
+ }
102
+ function columnProfile(img, x0, x1, y0, y1) {
103
+ const profile = new Float64Array(x1 - x0);
104
+ for (let x = x0; x < x1; x++) {
105
+ let sum = 0;
106
+ for (let y = y0; y < y1; y++) sum += lumaAt(img, x, y);
107
+ profile[x - x0] = sum / (y1 - y0);
108
+ }
109
+ return profile;
110
+ }
111
+ function rowProfile(img, x0, x1, y0, y1) {
112
+ const profile = new Float64Array(y1 - y0);
113
+ for (let y = y0; y < y1; y++) {
114
+ let sum = 0;
115
+ for (let x = x0; x < x1; x++) sum += lumaAt(img, x, y);
116
+ profile[y - y0] = sum / (x1 - x0);
117
+ }
118
+ return profile;
119
+ }
120
+ function lumaAt(img, x, y) {
121
+ const i = (y * img.width + x) * 4;
122
+ return .299 * img.data[i] + .587 * img.data[i + 1] + .114 * img.data[i + 2];
123
+ }
124
+ function clamp(value, min, max) {
125
+ return Math.max(min, Math.min(max, value));
126
+ }
127
+ //#endregion
128
+ export { estimateRegionShift };
@@ -0,0 +1,14 @@
1
+ //#region src/run-ledger.d.ts
2
+ interface RunLedgerEntry {
3
+ /** Tool name, e.g. "build-page", "check-breakpoints", "verify-markup". */
4
+ tool: string;
5
+ /** Primary input (attempt HTML or URL). */
6
+ source: string;
7
+ /** Secondary input (target PNG, manifest, ...) when applicable. */
8
+ target?: string;
9
+ /** Headline numbers, tool-specific but flat (matched/missing/extra/status/diffRatio...). */
10
+ headline: Record<string, string | number | boolean | null>;
11
+ }
12
+ declare function appendRunLedger(entry: RunLedgerEntry, cwd?: string): void;
13
+ //#endregion
14
+ export { RunLedgerEntry, appendRunLedger };
@@ -0,0 +1,31 @@
1
+ import { appendFileSync, mkdirSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ //#region src/run-ledger.ts
4
+ /**
5
+ * Append-only run ledger for agent-loop tools.
6
+ *
7
+ * Every measurement invocation (`build page`, the dynamic gates,
8
+ * `verify markup`) appends one JSONL line to `.vlmkit/run-ledger.jsonl`
9
+ * under the working directory. This turns the "rounds" KPI from an agent
10
+ * self-report into an auditable record: a verifier can check that the
11
+ * agent actually re-measured after each fix, and how the headline numbers
12
+ * moved round by round (see docs/knowledge.md "Markup Agent KPI" — round
13
+ * counts were self-reported and unreliable in 5/5 S5 runs).
14
+ *
15
+ * Writes are best-effort: a ledger failure must never break the tool run.
16
+ * Opt out with VLMKIT_NO_LEDGER=1 (e.g. CI bulk runs).
17
+ */
18
+ function appendRunLedger(entry, cwd = process.cwd()) {
19
+ if (process.env.VLMKIT_NO_LEDGER === "1") return;
20
+ try {
21
+ const dir = join(cwd, ".vlmkit");
22
+ mkdirSync(dir, { recursive: true });
23
+ const line = JSON.stringify({
24
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
25
+ ...entry
26
+ });
27
+ appendFileSync(join(dir, "run-ledger.jsonl"), line + "\n");
28
+ } catch {}
29
+ }
30
+ //#endregion
31
+ export { appendRunLedger };
@@ -0,0 +1,12 @@
1
+ //#region src/terminal-colors.d.ts
2
+ /** Shared ANSI terminal color codes and helpers */
3
+ declare const DIM = "\u001B[2m";
4
+ declare const RESET = "\u001B[0m";
5
+ declare const GREEN = "\u001B[32m";
6
+ declare const RED = "\u001B[31m";
7
+ declare const YELLOW = "\u001B[33m";
8
+ declare const CYAN = "\u001B[36m";
9
+ declare const BOLD = "\u001B[1m";
10
+ declare function hr(width?: number): void;
11
+ //#endregion
12
+ export { BOLD, CYAN, DIM, GREEN, RED, RESET, YELLOW, hr };
@@ -0,0 +1,14 @@
1
+ //#region src/terminal-colors.ts
2
+ /** Shared ANSI terminal color codes and helpers */
3
+ const DIM = "\x1B[2m";
4
+ const RESET = "\x1B[0m";
5
+ const GREEN = "\x1B[32m";
6
+ const RED = "\x1B[31m";
7
+ const YELLOW = "\x1B[33m";
8
+ const CYAN = "\x1B[36m";
9
+ const BOLD = "\x1B[1m";
10
+ function hr(width = 72) {
11
+ console.log(`${DIM}${"─".repeat(width)}${RESET}`);
12
+ }
13
+ //#endregion
14
+ export { BOLD, CYAN, DIM, GREEN, RED, RESET, YELLOW, hr };
@@ -0,0 +1,121 @@
1
+ //#region src/text-rows.d.ts
2
+ interface TextRow {
3
+ /** Optional OCR/debug text when a caller can supply it. Pixel extraction does not infer this. */
4
+ text?: string;
5
+ /** Y-coordinate of the row's vertical center. */
6
+ yCenter: number;
7
+ /** Top y of the run of dark rows (inclusive). */
8
+ yStart: number;
9
+ /** Bottom y of the run of dark rows (inclusive). */
10
+ yEnd: number;
11
+ /** Mean luminance across the band (0-255). */
12
+ meanLuma: number;
13
+ /** Approximate height in pixels. */
14
+ height: number;
15
+ /**
16
+ * Estimated font-size in px, derived from band height. Typical UI
17
+ * fonts have a band height ≈ 0.75 × fontSize (the band spans
18
+ * baseline to ascender; descenders push it a bit further). Rounded
19
+ * to the nearest common UI size (12, 14, 16, 18, 20, 24, …, 72).
20
+ */
21
+ estimatedFontSize?: number;
22
+ /**
23
+ * Ink density inside the text's horizontal bounding box. Computed
24
+ * as (dark pixels with luma < 100) / (pixels in text-bbox). Larger
25
+ * values = thicker strokes = bolder weight. Empirical buckets:
26
+ * - < 0.10 → regular / light
27
+ * - 0.10-0.16 → medium / semibold
28
+ * - > 0.16 → bold / heavy
29
+ * Noisy on short text — compare same-content baseline vs variant
30
+ * for high-confidence weight-mismatch detection.
31
+ */
32
+ inkDensity?: number;
33
+ /** Bucketed weight class — heuristic, see `inkDensity` doc. */
34
+ weightBucket?: "light" | "regular" | "medium" | "bold";
35
+ /** Horizontal extent of ink within the band (px from left edge of image). */
36
+ inkLeft?: number;
37
+ inkRight?: number;
38
+ }
39
+ interface MatchedTextRow {
40
+ /** Position in the ordered list of detected rows (0 = topmost). */
41
+ rank: number;
42
+ baseline: TextRow;
43
+ variant: TextRow;
44
+ /** variant.yCenter − baseline.yCenter (px). */
45
+ deltaY: number;
46
+ }
47
+ interface RowGapDelta {
48
+ /** Rank of the row above the gap. */
49
+ aboveRank: number;
50
+ /** Rank of the row below the gap. */
51
+ belowRank: number;
52
+ /** Baseline gap (yCenter[below] − yCenter[above]). */
53
+ baselineGap: number;
54
+ /** Variant gap. */
55
+ variantGap: number;
56
+ /** variantGap − baselineGap; positive means the gap grew. */
57
+ delta: number;
58
+ }
59
+ interface ExtractTextRowsOptions {
60
+ /**
61
+ * Minimum dip in mean luminance (vs. the median row luminance) for a
62
+ * row to be considered "text". Default 12 — picks up body text but
63
+ * ignores subpixel-rendering noise.
64
+ */
65
+ minLumaDip?: number;
66
+ /** Minimum band height in px. Default 4. */
67
+ minBandHeight?: number;
68
+ /** Maximum bands to return (top-N by yCenter, i.e. all of them). */
69
+ maxBands?: number;
70
+ }
71
+ declare function extractTextRowsFromRgba(data: Uint8Array, width: number, height: number, options?: ExtractTextRowsOptions): TextRow[];
72
+ declare function extractTextRowsFromFile(path: string, options?: ExtractTextRowsOptions): Promise<TextRow[]>;
73
+ /**
74
+ * Pair text rows by ordered index. When baseline has 6 rows and variant
75
+ * has 6 rows, this maps row #0 → row #0, #1 → #1, etc. When the counts
76
+ * differ, only the prefix common to both is matched.
77
+ *
78
+ * Reports rows with |Δy| above `minDeltaY` to keep the table focused on
79
+ * actionable shifts (small subpixel deltas are excluded by default).
80
+ */
81
+ declare function matchTextRows(baseline: TextRow[], variant: TextRow[], minDeltaY?: number): MatchedTextRow[];
82
+ /**
83
+ * Compute per-pair gap deltas from baseline ↔ variant row matches.
84
+ * The gap above row N+1 = `row[N+1].yCenter − row[N].yCenter` — the
85
+ * vertical distance between consecutive text bands. If the gap
86
+ * differs between baseline and variant, the spacing between those
87
+ * two pieces of content is wrong, and the fix is on the preceding
88
+ * element's `margin-bottom` / `padding-bottom`.
89
+ *
90
+ * Subagent G v3 dogfood: "once IoU > 0.98, the remaining ~1.7%
91
+ * diff is text baseline Δy in the 2-19px range, and the report
92
+ * doesn't yet suggest which CSS knob to turn." Gap deltas tell
93
+ * the agent exactly which margin to adjust.
94
+ */
95
+ interface TypographyMismatch {
96
+ rank: number;
97
+ baselineFontSize?: number;
98
+ variantFontSize?: number;
99
+ baselineWeight?: TextRow["weightBucket"];
100
+ variantWeight?: TextRow["weightBucket"];
101
+ baselineDensity?: number;
102
+ variantDensity?: number;
103
+ /** "size" | "weight" | "both" */
104
+ kind: "size" | "weight" | "both";
105
+ }
106
+ /**
107
+ * Compare typography hints across ordered baseline ↔ variant pairs.
108
+ * Reports rows where:
109
+ * - estimated font-size buckets differ (different snapped px), OR
110
+ * - weight buckets differ ("regular" vs "bold").
111
+ *
112
+ * Same-content assumption: when baseline and variant render the same
113
+ * text content, ink density is directly comparable. When content
114
+ * differs, density can vary by character makeup ("iii" vs "WWW")
115
+ * and the comparison is noisier — only large bucket jumps are
116
+ * surfaced.
117
+ */
118
+ declare function compareRowTypography(baseline: TextRow[], variant: TextRow[], minDensityDelta?: number): TypographyMismatch[];
119
+ declare function computeRowGapDeltas(baseline: TextRow[], variant: TextRow[], minAbsoluteDelta?: number): RowGapDelta[];
120
+ //#endregion
121
+ export { ExtractTextRowsOptions, MatchedTextRow, RowGapDelta, TextRow, TypographyMismatch, compareRowTypography, computeRowGapDeltas, extractTextRowsFromFile, extractTextRowsFromRgba, matchTextRows };