@mizchi/vlmkit-core 0.23.1 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a11y-semantic.d.mts +7 -9
- package/dist/a11y-semantic.mjs +2 -2
- package/dist/animated-image.d.mts +29 -0
- package/dist/animated-image.mjs +113 -0
- package/dist/apng.d.mts +6 -8
- package/dist/apng.mjs +5 -5
- package/dist/arg-reader.d.mts +10 -11
- package/dist/auth-state.d.mts +7 -8
- package/dist/authored-style-capture.d.mts +8 -9
- package/dist/authored-style-diff.d.mts +7 -9
- package/dist/bitmap-font.d.mts +8 -9
- package/dist/browser-launch.d.mts +8 -10
- package/dist/cli-args.d.mts +9 -10
- package/dist/cli-error.d.mts +10 -11
- package/dist/cli-error.mjs +1 -1
- package/dist/computed-style-capture.d.mts +21 -22
- package/dist/computed-style-capture.mjs +3 -3
- package/dist/computed-style-diff.d.mts +8 -9
- package/dist/computed-style-diff.mjs +1 -1
- package/dist/diff-regions.d.mts +4 -6
- package/dist/dom-equivalence.d.mts +6 -7
- package/dist/dom-position-styles.d.mts +15 -14
- package/dist/dom-position-styles.mjs +3 -3
- package/dist/element-compare.d.mts +9 -8
- package/dist/element-compare.mjs +3 -2
- package/dist/filmstrip.d.mts +61 -8
- package/dist/filmstrip.mjs +82 -10
- package/dist/gate-config.d.mts +19 -21
- package/dist/gate-exit.d.mts +6 -7
- package/dist/gif.d.mts +43 -0
- package/dist/gif.mjs +74 -0
- package/dist/heatmap-regions.d.mts +5 -6
- package/dist/heatmap.d.mts +21 -15
- package/dist/heatmap.mjs +11 -3
- package/dist/image-resize.d.mts +9 -10
- package/dist/image-timing.d.mts +59 -0
- package/dist/image-timing.mjs +167 -0
- package/dist/index.d.mts +2 -2
- package/dist/mask.d.mts +6 -8
- package/dist/navigation-redirect.d.mts +2 -3
- package/dist/page-load.d.mts +12 -13
- package/dist/page-open.d.mts +12 -14
- package/dist/plugin/args.d.mts +17 -11
- package/dist/plugin/args.mjs +12 -1
- package/dist/plugin/cli-entry.d.mts +2 -3
- package/dist/plugin/contract.d.mts +18 -20
- package/dist/plugin/index.d.mts +3 -4
- package/dist/plugin/index.mjs +2 -2
- package/dist/plugin/load.d.mts +7 -9
- package/dist/plugin/registry.d.mts +9 -11
- package/dist/plugin/rule-prose.d.mts +5 -7
- package/dist/plugin/rule-tier.d.mts +8 -10
- package/dist/plugin/rules.d.mts +19 -21
- package/dist/plugin/runner.d.mts +19 -20
- package/dist/plugin/runner.mjs +43 -2
- package/dist/png-decode.d.mts +19 -0
- package/dist/png-decode.mjs +161 -0
- package/dist/png-utils.d.mts +8 -9
- package/dist/png-utils.mjs +2 -1
- package/dist/project-config.d.mts +8 -9
- package/dist/rect-overlap.d.mts +4 -5
- package/dist/region-shift.d.mts +3 -5
- package/dist/run-ledger.d.mts +11 -12
- package/dist/run-ledger.mjs +3 -2
- package/dist/stable-selector.d.mts +2 -3
- package/dist/terminal-colors.d.mts +9 -10
- package/dist/text-rows.d.mts +11 -12
- package/dist/types.d.mts +87 -62
- package/dist/version.d.mts +2 -3
- package/dist/version.mjs +1 -1
- package/dist/video-decode.d.mts +146 -0
- package/dist/video-decode.mjs +936 -0
- package/dist/video-frames.d.mts +306 -0
- package/dist/video-frames.mjs +565 -0
- package/dist/webp.d.mts +8 -10
- package/dist/webp.mjs +2 -1
- package/package.json +4 -4
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import * as zlib from "node:zlib";
|
|
2
|
+
import { PNG } from "pngjs";
|
|
3
|
+
//#region src/png-decode.ts
|
|
4
|
+
/**
|
|
5
|
+
* A PNG decoder for the one shape a browser screenshot has — 8-bit RGB or RGBA, not interlaced —
|
|
6
|
+
* in a tight loop over typed arrays, falling back to pngjs for anything else.
|
|
7
|
+
*
|
|
8
|
+
* Why: `check flash` decodes every 60fps frame of a sweep, 181 frames for a 3-second window at
|
|
9
|
+
* 1280x720, and pngjs's generic unfilter and bitmapper took 19 of the 24 seconds of judging one.
|
|
10
|
+
* The inflate is zlib's either way; only the unfilter and the copy to RGBA are done here.
|
|
11
|
+
*
|
|
12
|
+
* Pixels come back only for a file whose header and data agree. Before either decoder sees it,
|
|
13
|
+
* the IHDR must be the first chunk, exactly 13 bytes, of a non-zero size and pass its CRC, and
|
|
14
|
+
* every chunk must lie inside the file up to an IEND. On the fast path the inflated data must
|
|
15
|
+
* then be exactly `height * (1 + width * channels)` bytes; zlib's own adler-32 vouches for the
|
|
16
|
+
* IDAT bytes, so their CRCs are not recomputed. A file that breaks one of these throws instead of
|
|
17
|
+
* going to pngjs, because pngjs 7 does not refuse all of them: measured, it decodes a 14-byte
|
|
18
|
+
* IHDR and a zero width without a word, and reads the last row of a stream one row short from
|
|
19
|
+
* memory it never filled (some runs return the image, some throw on a filter byte). What is only
|
|
20
|
+
* not the fast path's shape (another depth or colour type, interlacing, a `tRNS` colour key) goes
|
|
21
|
+
* to pngjs.
|
|
22
|
+
*/
|
|
23
|
+
const SIGNATURE = [
|
|
24
|
+
137,
|
|
25
|
+
80,
|
|
26
|
+
78,
|
|
27
|
+
71,
|
|
28
|
+
13,
|
|
29
|
+
10,
|
|
30
|
+
26,
|
|
31
|
+
10
|
|
32
|
+
];
|
|
33
|
+
let crcTable;
|
|
34
|
+
/**
|
|
35
|
+
* CRC-32 (ISO 3309, the one PNG chunks carry), by a 256-entry table. Only for a Node without
|
|
36
|
+
* `zlib.crc32` (before 22.2 / 20.15); exported so a test holds it to zlib's.
|
|
37
|
+
*/
|
|
38
|
+
function tableCrc32(bytes) {
|
|
39
|
+
if (!crcTable) {
|
|
40
|
+
crcTable = /* @__PURE__ */ new Uint32Array(256);
|
|
41
|
+
for (let n = 0; n < 256; n++) {
|
|
42
|
+
let c = n;
|
|
43
|
+
for (let k = 0; k < 8; k++) c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
44
|
+
crcTable[n] = c >>> 0;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
let c = 4294967295;
|
|
48
|
+
for (let i = 0; i < bytes.length; i++) c = crcTable[(c ^ bytes[i]) & 255] ^ c >>> 8;
|
|
49
|
+
return (c ^ 4294967295) >>> 0;
|
|
50
|
+
}
|
|
51
|
+
const nativeCrc32 = zlib.crc32;
|
|
52
|
+
const crc32 = (bytes) => nativeCrc32 ? nativeCrc32(bytes) >>> 0 : tableCrc32(bytes);
|
|
53
|
+
/** A PNG as RGBA. */
|
|
54
|
+
function decodePngBuffer(buffer) {
|
|
55
|
+
const px = decodePngPixels(buffer);
|
|
56
|
+
if (px.channels === 4) return {
|
|
57
|
+
width: px.width,
|
|
58
|
+
height: px.height,
|
|
59
|
+
data: px.data
|
|
60
|
+
};
|
|
61
|
+
const out = new Uint8Array(px.width * px.height * 4);
|
|
62
|
+
for (let p = 0, i = 0; i < px.data.length; p += 4, i += 3) {
|
|
63
|
+
out[p] = px.data[i];
|
|
64
|
+
out[p + 1] = px.data[i + 1];
|
|
65
|
+
out[p + 2] = px.data[i + 2];
|
|
66
|
+
out[p + 3] = 255;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
width: px.width,
|
|
70
|
+
height: px.height,
|
|
71
|
+
data: out
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** A PNG's pixels without widening RGB to RGBA: a screenshot is RGB, and the copy is a third of the decode. */
|
|
75
|
+
function decodePngPixels(buffer) {
|
|
76
|
+
for (let i = 0; i < 8; i++) if (buffer[i] !== SIGNATURE[i]) throw new Error("not a PNG");
|
|
77
|
+
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
78
|
+
if (buffer.length < 33) throw new Error("PNG is truncated inside its IHDR chunk");
|
|
79
|
+
if (String.fromCharCode(...buffer.subarray(12, 16)) !== "IHDR") throw new Error("PNG does not begin with IHDR");
|
|
80
|
+
if (view.getUint32(8) !== 13) throw new Error(`PNG IHDR is ${view.getUint32(8)} bytes, not 13`);
|
|
81
|
+
if (crc32(buffer.subarray(12, 29)) !== view.getUint32(29)) throw new Error("PNG IHDR fails its CRC");
|
|
82
|
+
const width = view.getUint32(16);
|
|
83
|
+
const height = view.getUint32(20);
|
|
84
|
+
if (width === 0 || height === 0) throw new Error(`PNG IHDR gives a ${width}x${height} image`);
|
|
85
|
+
const depth = buffer[24];
|
|
86
|
+
const colour = buffer[25];
|
|
87
|
+
const method = buffer[26] | buffer[27];
|
|
88
|
+
const interlace = buffer[28];
|
|
89
|
+
let at = 33;
|
|
90
|
+
let ended = false;
|
|
91
|
+
let keyed = false;
|
|
92
|
+
const idat = [];
|
|
93
|
+
while (at + 12 <= buffer.length) {
|
|
94
|
+
const length = view.getUint32(at);
|
|
95
|
+
if (at + 12 + length > buffer.length) break;
|
|
96
|
+
const type = String.fromCharCode(buffer[at + 4], buffer[at + 5], buffer[at + 6], buffer[at + 7]);
|
|
97
|
+
if (type === "IDAT") idat.push(buffer.subarray(at + 8, at + 8 + length));
|
|
98
|
+
else if (type === "IEND") {
|
|
99
|
+
ended = true;
|
|
100
|
+
break;
|
|
101
|
+
} else if (type === "tRNS") keyed = true;
|
|
102
|
+
at += 12 + length;
|
|
103
|
+
}
|
|
104
|
+
if (!ended) throw new Error("PNG is truncated: it ends before its IEND chunk");
|
|
105
|
+
if (idat.length === 0) throw new Error("PNG has no image data");
|
|
106
|
+
const channels = colour === 6 ? 4 : colour === 2 ? 3 : 0;
|
|
107
|
+
if (depth !== 8 || channels === 0 || method !== 0 || interlace !== 0 || keyed) return {
|
|
108
|
+
...viaPngjs(buffer),
|
|
109
|
+
channels: 4
|
|
110
|
+
};
|
|
111
|
+
const inflated = zlib.inflateSync(idat.length === 1 ? idat[0] : Buffer.concat(idat));
|
|
112
|
+
const raw = new Uint8Array(inflated.buffer, inflated.byteOffset, inflated.byteLength);
|
|
113
|
+
const stride = width * channels;
|
|
114
|
+
const expected = (stride + 1) * height;
|
|
115
|
+
if (raw.length !== expected) throw new Error(`PNG data is ${raw.length} bytes; its ${width}x${height} IHDR needs ${expected}`);
|
|
116
|
+
const out = new Uint8Array(width * height * channels);
|
|
117
|
+
const zero = new Uint8Array(stride);
|
|
118
|
+
for (let y = 0; y < height; y++) {
|
|
119
|
+
const filter = raw[y * (stride + 1)];
|
|
120
|
+
const cur = y * (stride + 1) + 1;
|
|
121
|
+
const up = y === 0 ? -1 : cur - (stride + 1);
|
|
122
|
+
const above = up < 0 ? zero : raw;
|
|
123
|
+
const ua = up < 0 ? 0 : up;
|
|
124
|
+
const c = channels;
|
|
125
|
+
if (filter === 1) for (let i = c; i < stride; i++) raw[cur + i] = raw[cur + i] + raw[cur + i - c] & 255;
|
|
126
|
+
else if (filter === 2) for (let i = 0; i < stride; i++) raw[cur + i] = raw[cur + i] + above[ua + i] & 255;
|
|
127
|
+
else if (filter === 3) {
|
|
128
|
+
for (let i = 0; i < c; i++) raw[cur + i] = raw[cur + i] + (above[ua + i] >> 1) & 255;
|
|
129
|
+
for (let i = c; i < stride; i++) raw[cur + i] = raw[cur + i] + (raw[cur + i - c] + above[ua + i] >> 1) & 255;
|
|
130
|
+
} else if (filter === 4) {
|
|
131
|
+
for (let i = 0; i < c; i++) raw[cur + i] = raw[cur + i] + above[ua + i] & 255;
|
|
132
|
+
for (let i = c; i < stride; i++) {
|
|
133
|
+
const a = raw[cur + i - c];
|
|
134
|
+
const b = above[ua + i];
|
|
135
|
+
const d = above[ua + i - c];
|
|
136
|
+
const pa = b > d ? b - d : d - b;
|
|
137
|
+
const pb = a > d ? a - d : d - a;
|
|
138
|
+
const pc0 = a + b - d - d;
|
|
139
|
+
const pc = pc0 < 0 ? -pc0 : pc0;
|
|
140
|
+
raw[cur + i] = raw[cur + i] + (pa <= pb && pa <= pc ? a : pb <= pc ? b : d) & 255;
|
|
141
|
+
}
|
|
142
|
+
} else if (filter !== 0) throw new Error(`PNG row ${y} has filter ${filter}`);
|
|
143
|
+
out.set(raw.subarray(cur, cur + stride), y * stride);
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
width,
|
|
147
|
+
height,
|
|
148
|
+
channels,
|
|
149
|
+
data: out
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function viaPngjs(buffer) {
|
|
153
|
+
const png = PNG.sync.read(Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength));
|
|
154
|
+
return {
|
|
155
|
+
width: png.width,
|
|
156
|
+
height: png.height,
|
|
157
|
+
data: new Uint8Array(png.data.buffer, png.data.byteOffset, png.data.byteLength)
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
export { decodePngBuffer, decodePngPixels, tableCrc32 };
|
package/dist/png-utils.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/png-utils.d.ts
|
|
2
|
-
interface PngData {
|
|
2
|
+
export interface PngData {
|
|
3
3
|
width: number;
|
|
4
4
|
height: number;
|
|
5
5
|
data: Uint8Array;
|
|
@@ -22,7 +22,7 @@ interface PngData {
|
|
|
22
22
|
* differently — a size mismatch, not a colour change, and one the caller should
|
|
23
23
|
* see as such rather than folded into a colour statistic.
|
|
24
24
|
*/
|
|
25
|
-
interface ChangeMagnitude {
|
|
25
|
+
export interface ChangeMagnitude {
|
|
26
26
|
/** Pixels with any non-zero channel delta, however small. */
|
|
27
27
|
changedPixels: number;
|
|
28
28
|
totalPixels: number;
|
|
@@ -33,12 +33,12 @@ interface ChangeMagnitude {
|
|
|
33
33
|
/** Mean per-pixel max-channel delta over the whole image, 0-255. */
|
|
34
34
|
meanChannelDelta: number;
|
|
35
35
|
}
|
|
36
|
-
declare function measureChangeMagnitude(a: PngData, b: PngData): ChangeMagnitude;
|
|
36
|
+
export declare function measureChangeMagnitude(a: PngData, b: PngData): ChangeMagnitude;
|
|
37
37
|
/**
|
|
38
38
|
* Crop or pad an image to the target dimensions.
|
|
39
39
|
* Only handles the common region; overflow is zero-filled.
|
|
40
40
|
*/
|
|
41
|
-
declare function cropImage(img: PngData, w: number, h: number): PngData;
|
|
41
|
+
export declare function cropImage(img: PngData, w: number, h: number): PngData;
|
|
42
42
|
/**
|
|
43
43
|
* Crop an arbitrary rectangle out of an image.
|
|
44
44
|
*
|
|
@@ -47,14 +47,13 @@ declare function cropImage(img: PngData, w: number, h: number): PngData;
|
|
|
47
47
|
* clamped to the image bounds, so the returned crop may be smaller than
|
|
48
48
|
* requested when the region overruns an edge (or off the top-left).
|
|
49
49
|
*/
|
|
50
|
-
declare function cropRegion(img: PngData, x: number, y: number, w: number, h: number): PngData;
|
|
50
|
+
export declare function cropRegion(img: PngData, x: number, y: number, w: number, h: number): PngData;
|
|
51
51
|
/**
|
|
52
52
|
* Read a PNG file and return RGBA pixel data.
|
|
53
53
|
*/
|
|
54
|
-
declare function decodePng(path: string): Promise<PngData>;
|
|
54
|
+
export declare function decodePng(path: string): Promise<PngData>;
|
|
55
55
|
/**
|
|
56
56
|
* Write RGBA pixel data to a PNG file.
|
|
57
57
|
*/
|
|
58
|
-
declare function encodePng(path: string, data: PngData): Promise<void>;
|
|
59
|
-
//#endregion
|
|
60
|
-
export { ChangeMagnitude, PngData, cropImage, cropRegion, decodePng, encodePng, measureChangeMagnitude };
|
|
58
|
+
export declare function encodePng(path: string, data: PngData): Promise<void>;
|
|
59
|
+
//#endregion
|
package/dist/png-utils.mjs
CHANGED
|
@@ -97,7 +97,8 @@ async function encodePng(path, data) {
|
|
|
97
97
|
height: data.height
|
|
98
98
|
});
|
|
99
99
|
Buffer.from(data.data.buffer, data.data.byteOffset, data.data.byteLength).copy(png.data);
|
|
100
|
-
|
|
100
|
+
const buffer = PNG.sync.write(png);
|
|
101
|
+
await writeFile(path, buffer);
|
|
101
102
|
}
|
|
102
103
|
//#endregion
|
|
103
104
|
export { cropImage, cropRegion, decodePng, encodePng, measureChangeMagnitude };
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
//#region src/project-config.d.ts
|
|
2
|
-
declare const STATE_DIR = ".vlmkit";
|
|
3
|
-
declare const CONFIG_FILE = "vlmkit.config.json";
|
|
4
|
-
declare const CONFIG_CANDIDATES: readonly ["vlmkit.config.json", "vlmkit.config.toml"];
|
|
2
|
+
export declare const STATE_DIR = ".vlmkit";
|
|
3
|
+
export declare const CONFIG_FILE = "vlmkit.config.json";
|
|
4
|
+
export declare const CONFIG_CANDIDATES: readonly ["vlmkit.config.json", "vlmkit.config.toml"];
|
|
5
5
|
/** Resolve a project-owned state entry below the canonical state directory. */
|
|
6
|
-
declare function resolveStatePath(cwd: string, entry: string): string;
|
|
6
|
+
export declare function resolveStatePath(cwd: string, entry: string): string;
|
|
7
7
|
/** Read a canonical VLMKIT_* environment variable. */
|
|
8
|
-
declare function readEnv(suffix: string): string | undefined;
|
|
9
|
-
declare function debugEnabled(): boolean;
|
|
10
|
-
declare const ENV_SUFFIXES: readonly ["BASE_URL", "CAPTURE_BACKEND", "CONFIG_FILE", "CONFIG_PATH", "LLM_MODEL", "LLM_PROVIDER", "PROJECT_ROOT", "VLM_MODEL"];
|
|
11
|
-
//#endregion
|
|
12
|
-
export { CONFIG_CANDIDATES, CONFIG_FILE, ENV_SUFFIXES, STATE_DIR, debugEnabled, readEnv, resolveStatePath };
|
|
8
|
+
export declare function readEnv(suffix: string): string | undefined;
|
|
9
|
+
export declare function debugEnabled(): boolean;
|
|
10
|
+
export declare const ENV_SUFFIXES: readonly ["BASE_URL", "CAPTURE_BACKEND", "CONFIG_FILE", "CONFIG_PATH", "LLM_MODEL", "LLM_PROVIDER", "PROJECT_ROOT", "VLM_MODEL"];
|
|
11
|
+
//#endregion
|
package/dist/rect-overlap.d.mts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* rather than the area, because they report which axis collided.
|
|
17
17
|
*/
|
|
18
18
|
/** Any box with a top-left origin. `x`/`y`-shaped callers pass `{ left: x, top: y, … }`. */
|
|
19
|
-
interface OverlapBox {
|
|
19
|
+
export interface OverlapBox {
|
|
20
20
|
left: number;
|
|
21
21
|
top: number;
|
|
22
22
|
width: number;
|
|
@@ -28,7 +28,7 @@ interface OverlapBox {
|
|
|
28
28
|
* `Math.max(0, …)` on each axis rather than an early return: boxes that touch along one edge have a
|
|
29
29
|
* zero-width intersection, and multiplying gives 0 without a special case.
|
|
30
30
|
*/
|
|
31
|
-
declare function overlapArea(a: OverlapBox, b: OverlapBox): number;
|
|
31
|
+
export declare function overlapArea(a: OverlapBox, b: OverlapBox): number;
|
|
32
32
|
/**
|
|
33
33
|
* Intersection over union, the standard box-similarity ratio: 1 for identical boxes, 0 for disjoint.
|
|
34
34
|
*
|
|
@@ -36,6 +36,5 @@ declare function overlapArea(a: OverlapBox, b: OverlapBox): number;
|
|
|
36
36
|
* hand every caller a value that fails every comparison it is put into. `NaN > threshold` is false,
|
|
37
37
|
* so the case would read as "not similar" in some callers and be silently skipped in others.
|
|
38
38
|
*/
|
|
39
|
-
declare function iou(a: OverlapBox, b: OverlapBox): number;
|
|
40
|
-
//#endregion
|
|
41
|
-
export { OverlapBox, iou, overlapArea };
|
|
39
|
+
export declare function iou(a: OverlapBox, b: OverlapBox): number;
|
|
40
|
+
//#endregion
|
package/dist/region-shift.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { PngData } from "./png-utils.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/region-shift.d.ts
|
|
4
|
-
interface RegionShiftEstimate {
|
|
3
|
+
export interface RegionShiftEstimate {
|
|
5
4
|
/** Content moved by +dx px horizontally in current (vs baseline). */
|
|
6
5
|
dx: number;
|
|
7
6
|
/** Content moved by +dy px vertically in current (vs baseline). */
|
|
@@ -15,6 +14,5 @@ interface RegionRect {
|
|
|
15
14
|
width: number;
|
|
16
15
|
height: number;
|
|
17
16
|
}
|
|
18
|
-
declare function estimateRegionShift(baseline: PngData, current: PngData, region: RegionRect, maxOffset?: number): RegionShiftEstimate | null;
|
|
19
|
-
//#endregion
|
|
20
|
-
export { RegionShiftEstimate, estimateRegionShift };
|
|
17
|
+
export declare function estimateRegionShift(baseline: PngData, current: PngData, region: RegionRect, maxOffset?: number): RegionShiftEstimate | null;
|
|
18
|
+
//#endregion
|
package/dist/run-ledger.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/run-ledger.d.ts
|
|
2
|
-
interface RunLedgerEntry {
|
|
2
|
+
export interface RunLedgerEntry {
|
|
3
3
|
/** Tool name, e.g. "build-page", "check-breakpoints", "verify-markup". */
|
|
4
4
|
tool: string;
|
|
5
5
|
/** Primary input (attempt HTML or URL). */
|
|
@@ -10,7 +10,7 @@ interface RunLedgerEntry {
|
|
|
10
10
|
headline: Record<string, string | number | boolean | null>;
|
|
11
11
|
}
|
|
12
12
|
/** Default location, relative to the working directory. */
|
|
13
|
-
declare const LEDGER_RELATIVE_PATH: string;
|
|
13
|
+
export declare const LEDGER_RELATIVE_PATH: string;
|
|
14
14
|
/**
|
|
15
15
|
* The directories a vlmkit run creates under the working directory. Exported so
|
|
16
16
|
* `gates init` can write them into `.gitignore` and the runner can name them in
|
|
@@ -19,14 +19,14 @@ declare const LEDGER_RELATIVE_PATH: string;
|
|
|
19
19
|
* v6's adopting agent had to discover both with `ls` and write the `.gitignore`
|
|
20
20
|
* itself: "adopting the tool dirtied the repo silently."
|
|
21
21
|
*/
|
|
22
|
-
declare const VLMKIT_IGNORE_ENTRIES: readonly [".vlmkit/", "test-results/"];
|
|
23
|
-
interface LedgerWrite {
|
|
22
|
+
export declare const VLMKIT_IGNORE_ENTRIES: readonly [".vlmkit/", "test-results/"];
|
|
23
|
+
export interface LedgerWrite {
|
|
24
24
|
/** Absolute path appended to. */
|
|
25
25
|
path: string;
|
|
26
26
|
/** True when this call brought the file into existence. */
|
|
27
27
|
created: boolean;
|
|
28
28
|
}
|
|
29
|
-
interface AppendRunLedgerOptions {
|
|
29
|
+
export interface AppendRunLedgerOptions {
|
|
30
30
|
cwd?: string;
|
|
31
31
|
/**
|
|
32
32
|
* Explicit target from `--ledger <path>`. A directory-less path is still
|
|
@@ -37,20 +37,20 @@ interface AppendRunLedgerOptions {
|
|
|
37
37
|
disabled?: boolean;
|
|
38
38
|
}
|
|
39
39
|
/** Replace the run-level settings. Called once per run; resets the first-write record. */
|
|
40
|
-
declare function configureRunLedger(options?: AppendRunLedgerOptions): void;
|
|
40
|
+
export declare function configureRunLedger(options?: AppendRunLedgerOptions): void;
|
|
41
41
|
/**
|
|
42
42
|
* The append that brought the ledger into existence this run, if any.
|
|
43
43
|
*
|
|
44
44
|
* Reported by whoever prints, so a gate that writes from inside its measurement
|
|
45
45
|
* gets the same announcement as one using the `gate.ledger` hook.
|
|
46
46
|
*/
|
|
47
|
-
declare function firstLedgerWrite(): LedgerWrite | null;
|
|
47
|
+
export declare function firstLedgerWrite(): LedgerWrite | null;
|
|
48
48
|
/**
|
|
49
49
|
* Append one entry. Returns what was written, or `null` when the ledger is off
|
|
50
50
|
* or the write failed — the caller uses that to announce a first write rather
|
|
51
51
|
* than to decide anything.
|
|
52
52
|
*/
|
|
53
|
-
declare function appendRunLedger(entry: RunLedgerEntry, options?: AppendRunLedgerOptions | string): LedgerWrite | null;
|
|
53
|
+
export declare function appendRunLedger(entry: RunLedgerEntry, options?: AppendRunLedgerOptions | string): LedgerWrite | null;
|
|
54
54
|
/**
|
|
55
55
|
* Is `target` already covered by the working directory's `.gitignore`?
|
|
56
56
|
*
|
|
@@ -61,8 +61,7 @@ declare function appendRunLedger(entry: RunLedgerEntry, options?: AppendRunLedge
|
|
|
61
61
|
* is the right trade — but it must not guess wrong in the *other* direction,
|
|
62
62
|
* which is why anything unreadable counts as "not ignored" rather than ignored.
|
|
63
63
|
*/
|
|
64
|
-
declare function isGitIgnored(cwd: string, target: string): boolean;
|
|
64
|
+
export declare function isGitIgnored(cwd: string, target: string): boolean;
|
|
65
65
|
/** Is this working directory a git repo at all? Nothing to advise if it is not. */
|
|
66
|
-
declare function isGitRepo(cwd: string): boolean;
|
|
67
|
-
//#endregion
|
|
68
|
-
export { AppendRunLedgerOptions, LEDGER_RELATIVE_PATH, LedgerWrite, RunLedgerEntry, VLMKIT_IGNORE_ENTRIES, appendRunLedger, configureRunLedger, firstLedgerWrite, isGitIgnored, isGitRepo };
|
|
66
|
+
export declare function isGitRepo(cwd: string): boolean;
|
|
67
|
+
//#endregion
|
package/dist/run-ledger.mjs
CHANGED
|
@@ -75,10 +75,11 @@ function appendRunLedger(entry, options = {}) {
|
|
|
75
75
|
try {
|
|
76
76
|
const created = !existsSync(target);
|
|
77
77
|
mkdirSync(dirname(target), { recursive: true });
|
|
78
|
-
|
|
78
|
+
const line = JSON.stringify({
|
|
79
79
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
80
80
|
...entry
|
|
81
|
-
})
|
|
81
|
+
});
|
|
82
|
+
appendFileSync(target, line + "\n");
|
|
82
83
|
const write = {
|
|
83
84
|
path: target,
|
|
84
85
|
created
|
|
@@ -45,6 +45,5 @@
|
|
|
45
45
|
* `page.evaluate`, so it carries its own copy on purpose and the uniqueness test is
|
|
46
46
|
* what holds the two in agreement.
|
|
47
47
|
*/
|
|
48
|
-
declare const STABLE_SELECTOR_JS = "\n function stableSelector(el) {\n if (!el || !el.tagName) return \"(no target)\";\n const id = el.getAttribute && el.getAttribute(\"id\");\n if (id) return \"#\" + CSS.escape(id);\n const classes = el.classList ? Array.from(el.classList).slice(0, 3) : [];\n if (classes.length > 0) {\n const selector = el.tagName.toLowerCase() + classes.map((c) => \".\" + CSS.escape(c)).join(\"\");\n if (document.querySelectorAll(selector).length === 1) return selector;\n }\n const parent = el.parentElement;\n if (!parent) return el.tagName.toLowerCase();\n const siblings = Array.from(parent.children).filter((item) => item.tagName === el.tagName);\n return stableSelector(parent) + \" > \" + el.tagName.toLowerCase() + \":nth-of-type(\" + (siblings.indexOf(el) + 1) + \")\";\n }\n";
|
|
49
|
-
//#endregion
|
|
50
|
-
export { STABLE_SELECTOR_JS };
|
|
48
|
+
export declare const STABLE_SELECTOR_JS = "\n function stableSelector(el) {\n if (!el || !el.tagName) return \"(no target)\";\n const id = el.getAttribute && el.getAttribute(\"id\");\n if (id) return \"#\" + CSS.escape(id);\n const classes = el.classList ? Array.from(el.classList).slice(0, 3) : [];\n if (classes.length > 0) {\n const selector = el.tagName.toLowerCase() + classes.map((c) => \".\" + CSS.escape(c)).join(\"\");\n if (document.querySelectorAll(selector).length === 1) return selector;\n }\n const parent = el.parentElement;\n if (!parent) return el.tagName.toLowerCase();\n const siblings = Array.from(parent.children).filter((item) => item.tagName === el.tagName);\n return stableSelector(parent) + \" > \" + el.tagName.toLowerCase() + \":nth-of-type(\" + (siblings.indexOf(el) + 1) + \")\";\n }\n";
|
|
49
|
+
//#endregion
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
//#region src/terminal-colors.d.ts
|
|
2
2
|
/** Shared ANSI terminal color codes and helpers */
|
|
3
|
-
declare const DIM = "
|
|
4
|
-
declare const RESET = "
|
|
5
|
-
declare const GREEN = "
|
|
6
|
-
declare const RED = "
|
|
7
|
-
declare const YELLOW = "
|
|
8
|
-
declare const CYAN = "
|
|
9
|
-
declare const BOLD = "
|
|
10
|
-
declare function hr(width?: number): void;
|
|
11
|
-
//#endregion
|
|
12
|
-
export { BOLD, CYAN, DIM, GREEN, RED, RESET, YELLOW, hr };
|
|
3
|
+
export declare const DIM = "[2m";
|
|
4
|
+
export declare const RESET = "[0m";
|
|
5
|
+
export declare const GREEN = "[32m";
|
|
6
|
+
export declare const RED = "[31m";
|
|
7
|
+
export declare const YELLOW = "[33m";
|
|
8
|
+
export declare const CYAN = "[36m";
|
|
9
|
+
export declare const BOLD = "[1m";
|
|
10
|
+
export declare function hr(width?: number): void;
|
|
11
|
+
//#endregion
|
package/dist/text-rows.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/text-rows.d.ts
|
|
2
|
-
interface TextRow {
|
|
2
|
+
export interface TextRow {
|
|
3
3
|
/** Optional OCR/debug text when a caller can supply it. Pixel extraction does not infer this. */
|
|
4
4
|
text?: string;
|
|
5
5
|
/** Y-coordinate of the row's vertical center. */
|
|
@@ -36,7 +36,7 @@ interface TextRow {
|
|
|
36
36
|
inkLeft?: number;
|
|
37
37
|
inkRight?: number;
|
|
38
38
|
}
|
|
39
|
-
interface MatchedTextRow {
|
|
39
|
+
export interface MatchedTextRow {
|
|
40
40
|
/** Position in the ordered list of detected rows (0 = topmost). */
|
|
41
41
|
rank: number;
|
|
42
42
|
baseline: TextRow;
|
|
@@ -44,7 +44,7 @@ interface MatchedTextRow {
|
|
|
44
44
|
/** variant.yCenter − baseline.yCenter (px). */
|
|
45
45
|
deltaY: number;
|
|
46
46
|
}
|
|
47
|
-
interface RowGapDelta {
|
|
47
|
+
export interface RowGapDelta {
|
|
48
48
|
/** Rank of the row above the gap. */
|
|
49
49
|
aboveRank: number;
|
|
50
50
|
/** Rank of the row below the gap. */
|
|
@@ -56,7 +56,7 @@ interface RowGapDelta {
|
|
|
56
56
|
/** variantGap − baselineGap; positive means the gap grew. */
|
|
57
57
|
delta: number;
|
|
58
58
|
}
|
|
59
|
-
interface ExtractTextRowsOptions {
|
|
59
|
+
export interface ExtractTextRowsOptions {
|
|
60
60
|
/**
|
|
61
61
|
* Minimum dip in mean luminance (vs. the median row luminance) for a
|
|
62
62
|
* row to be considered "text". Default 12 — picks up body text but
|
|
@@ -68,8 +68,8 @@ interface ExtractTextRowsOptions {
|
|
|
68
68
|
/** Maximum bands to return (top-N by yCenter, i.e. all of them). */
|
|
69
69
|
maxBands?: number;
|
|
70
70
|
}
|
|
71
|
-
declare function extractTextRowsFromRgba(data: Uint8Array, width: number, height: number, options?: ExtractTextRowsOptions): TextRow[];
|
|
72
|
-
declare function extractTextRowsFromFile(path: string, options?: ExtractTextRowsOptions): Promise<TextRow[]>;
|
|
71
|
+
export declare function extractTextRowsFromRgba(data: Uint8Array, width: number, height: number, options?: ExtractTextRowsOptions): TextRow[];
|
|
72
|
+
export declare function extractTextRowsFromFile(path: string, options?: ExtractTextRowsOptions): Promise<TextRow[]>;
|
|
73
73
|
/**
|
|
74
74
|
* Pair text rows by ordered index. When baseline has 6 rows and variant
|
|
75
75
|
* has 6 rows, this maps row #0 → row #0, #1 → #1, etc. When the counts
|
|
@@ -78,7 +78,7 @@ declare function extractTextRowsFromFile(path: string, options?: ExtractTextRows
|
|
|
78
78
|
* Reports rows with |Δy| above `minDeltaY` to keep the table focused on
|
|
79
79
|
* actionable shifts (small subpixel deltas are excluded by default).
|
|
80
80
|
*/
|
|
81
|
-
declare function matchTextRows(baseline: TextRow[], variant: TextRow[], minDeltaY?: number): MatchedTextRow[];
|
|
81
|
+
export declare function matchTextRows(baseline: TextRow[], variant: TextRow[], minDeltaY?: number): MatchedTextRow[];
|
|
82
82
|
/**
|
|
83
83
|
* Compute per-pair gap deltas from baseline ↔ variant row matches.
|
|
84
84
|
* The gap above row N+1 = `row[N+1].yCenter − row[N].yCenter` — the
|
|
@@ -92,7 +92,7 @@ declare function matchTextRows(baseline: TextRow[], variant: TextRow[], minDelta
|
|
|
92
92
|
* doesn't yet suggest which CSS knob to turn." Gap deltas tell
|
|
93
93
|
* the agent exactly which margin to adjust.
|
|
94
94
|
*/
|
|
95
|
-
interface TypographyMismatch {
|
|
95
|
+
export interface TypographyMismatch {
|
|
96
96
|
rank: number;
|
|
97
97
|
baselineFontSize?: number;
|
|
98
98
|
variantFontSize?: number;
|
|
@@ -115,7 +115,6 @@ interface TypographyMismatch {
|
|
|
115
115
|
* and the comparison is noisier — only large bucket jumps are
|
|
116
116
|
* surfaced.
|
|
117
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 };
|
|
118
|
+
export declare function compareRowTypography(baseline: TextRow[], variant: TextRow[], minDensityDelta?: number): TypographyMismatch[];
|
|
119
|
+
export declare function computeRowGapDeltas(baseline: TextRow[], variant: TextRow[], minAbsoluteDelta?: number): RowGapDelta[];
|
|
120
|
+
//#endregion
|