@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,167 @@
|
|
|
1
|
+
//#region src/image-timing.ts
|
|
2
|
+
/** What Chromium holds a frame for: 10ms or less is 100ms. */
|
|
3
|
+
const browserDelayMs = (storedMs) => storedMs <= 10 ? 100 : storedMs;
|
|
4
|
+
const ascii = (bytes, at, length) => String.fromCharCode(...bytes.subarray(at, at + length));
|
|
5
|
+
const u32 = (bytes, at) => (bytes[at] << 24 | bytes[at + 1] << 16 | bytes[at + 2] << 8 | bytes[at + 3]) >>> 0;
|
|
6
|
+
const u16 = (bytes, at) => bytes[at] << 8 | bytes[at + 1];
|
|
7
|
+
const u16le = (bytes, at) => bytes[at] | bytes[at + 1] << 8;
|
|
8
|
+
/**
|
|
9
|
+
* A GIF's frames: one per image descriptor, its delay from the graphic control extension before it
|
|
10
|
+
* (none: 0). Plays: once with no NETSCAPE2.0 (or ANIMEXTS1.0) block, forever when its loop count
|
|
11
|
+
* is 0, else loop count + 1 (the first play and the repeats).
|
|
12
|
+
*/
|
|
13
|
+
function gifTiming(bytes) {
|
|
14
|
+
let at = 13;
|
|
15
|
+
const lsd = bytes[10] ?? 0;
|
|
16
|
+
if (lsd & 128) at += 3 * (1 << (lsd & 7) + 1);
|
|
17
|
+
const screen = {
|
|
18
|
+
width: u16le(bytes, 6),
|
|
19
|
+
height: u16le(bytes, 8)
|
|
20
|
+
};
|
|
21
|
+
const images = [];
|
|
22
|
+
const storedMs = [];
|
|
23
|
+
let pendingDelay = 0;
|
|
24
|
+
let pendingDisposal = 0;
|
|
25
|
+
let pendingTransparent = false;
|
|
26
|
+
let plays = 1;
|
|
27
|
+
const subBlocks = () => {
|
|
28
|
+
const out = [];
|
|
29
|
+
while (at < bytes.length) {
|
|
30
|
+
const size = bytes[at];
|
|
31
|
+
at += 1;
|
|
32
|
+
if (size === 0) break;
|
|
33
|
+
out.push(bytes.subarray(at, at + size));
|
|
34
|
+
at += size;
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
};
|
|
38
|
+
while (at < bytes.length) {
|
|
39
|
+
const block = bytes[at];
|
|
40
|
+
if (block === 59) break;
|
|
41
|
+
if (block === 33) {
|
|
42
|
+
const label = bytes[at + 1];
|
|
43
|
+
at += 2;
|
|
44
|
+
const blocks = subBlocks();
|
|
45
|
+
if (label === 249 && blocks[0] && blocks[0].length >= 4) {
|
|
46
|
+
pendingDelay = u16le(blocks[0], 1) * 10;
|
|
47
|
+
pendingDisposal = blocks[0][0] >> 2 & 7;
|
|
48
|
+
pendingTransparent = (blocks[0][0] & 1) === 1;
|
|
49
|
+
} else if (label === 255 && blocks[0] && (ascii(blocks[0], 0, 11) === "NETSCAPE2.0" || ascii(blocks[0], 0, 11) === "ANIMEXTS1.0")) {
|
|
50
|
+
const data = blocks[1];
|
|
51
|
+
if (data && data.length >= 3 && data[0] === 1) {
|
|
52
|
+
const loops = u16le(data, 1);
|
|
53
|
+
plays = loops === 0 ? null : loops + 1;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} else if (block === 44) {
|
|
57
|
+
storedMs.push(pendingDelay);
|
|
58
|
+
images.push({
|
|
59
|
+
x: u16le(bytes, at + 1),
|
|
60
|
+
y: u16le(bytes, at + 3),
|
|
61
|
+
width: u16le(bytes, at + 5),
|
|
62
|
+
height: u16le(bytes, at + 7),
|
|
63
|
+
disposal: pendingDisposal,
|
|
64
|
+
transparent: pendingTransparent
|
|
65
|
+
});
|
|
66
|
+
pendingDelay = 0;
|
|
67
|
+
pendingDisposal = 0;
|
|
68
|
+
pendingTransparent = false;
|
|
69
|
+
const packed = bytes[at + 9] ?? 0;
|
|
70
|
+
at += 10;
|
|
71
|
+
if (packed & 128) at += 3 * (1 << (packed & 7) + 1);
|
|
72
|
+
at += 1;
|
|
73
|
+
subBlocks();
|
|
74
|
+
} else break;
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
format: "gif",
|
|
78
|
+
storedMs,
|
|
79
|
+
plays,
|
|
80
|
+
gif: {
|
|
81
|
+
screen,
|
|
82
|
+
globalTable: (lsd & 128) !== 0,
|
|
83
|
+
images
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Where ffmpeg 6.1's GIF decoder composites otherwise than Chromium (measured,
|
|
89
|
+
* `docs/reports/2026-10-13-scan-video-v1.md`), or null. ffmpeg's background is the global colour
|
|
90
|
+
* table's background entry, opaque, wherever a browser leaves the canvas transparent — but only
|
|
91
|
+
* when the GIF has a global table and the image it fills under has no transparent index; otherwise
|
|
92
|
+
* it fills with its transparent colour, as a browser does (measured: those decode pixel for pixel
|
|
93
|
+
* as Chromium shows them). So refused: a first image larger than the logical screen (a browser grows
|
|
94
|
+
* the canvas, ffmpeg crops); one that does not cover it, opaque, under a global table; a frame
|
|
95
|
+
* disposed to background, opaque, under a global table, that the next image does not paint over
|
|
96
|
+
* opaquely; and one restored to previous where what is restored holds that fill (ffmpeg saved it,
|
|
97
|
+
* a browser restores the cleared canvas). Frame 0 of every pass is drawn on a cleared canvas in both.
|
|
98
|
+
*/
|
|
99
|
+
function gifCompositingProblem(timing) {
|
|
100
|
+
const gif = timing.gif;
|
|
101
|
+
if (!gif || gif.images.length === 0) return null;
|
|
102
|
+
const { screen, images, globalTable } = gif;
|
|
103
|
+
const first = images[0];
|
|
104
|
+
if (first.x + first.width > screen.width || first.y + first.height > screen.height) return `its first image (${first.width}x${first.height} at ${first.x},${first.y}) reaches past the ${screen.width}x${screen.height} logical screen: a browser grows the canvas to it, ffmpeg crops it`;
|
|
105
|
+
if (!globalTable) return null;
|
|
106
|
+
if (!(first.x === 0 && first.y === 0 && first.width >= screen.width && first.height >= screen.height) && !first.transparent) return `its first image (${first.width}x${first.height} at ${first.x},${first.y}) does not cover the ${screen.width}x${screen.height} logical screen and has no transparent colour: a browser leaves the rest transparent, ffmpeg paints it the background colour`;
|
|
107
|
+
const paintsOver = (b, a) => !b.transparent && b.x <= a.x && b.y <= a.y && b.x + b.width >= a.x + a.width && b.y + b.height >= a.y + a.height;
|
|
108
|
+
const screenRect = {
|
|
109
|
+
x: 0,
|
|
110
|
+
y: 0,
|
|
111
|
+
...screen,
|
|
112
|
+
disposal: 0,
|
|
113
|
+
transparent: false
|
|
114
|
+
};
|
|
115
|
+
let fillBefore = !first.transparent;
|
|
116
|
+
for (let i = 0; i + 1 < images.length; i++) {
|
|
117
|
+
const a = images[i];
|
|
118
|
+
const b = images[i + 1];
|
|
119
|
+
if (a.disposal === 2 && !a.transparent && !paintsOver(b, a)) return `image ${i} is disposed to background with no transparent colour, and image ${i + 1} does not paint over all of it opaquely: a browser clears it to transparent, ffmpeg fills it with the background colour`;
|
|
120
|
+
if (a.disposal === 3 && fillBefore && !paintsOver(b, a)) return `image ${i} is restored to the canvas before it, which ffmpeg filled with the background colour, and image ${i + 1} does not paint over all of it opaquely: a browser restores a transparent canvas`;
|
|
121
|
+
const afterDraw = fillBefore && !paintsOver(a, screenRect);
|
|
122
|
+
fillBefore = a.disposal === 3 ? fillBefore : a.disposal === 2 && !a.transparent ? true : afterDraw;
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* An APNG's frames: one per `fcTL`, delay_num / delay_den seconds (a 0 denominator is 100) in
|
|
128
|
+
* whole ms, as Chromium holds it. Plays: `acTL`'s num_plays, 0 forever; its num_frames is how many
|
|
129
|
+
* of them a browser plays.
|
|
130
|
+
*/
|
|
131
|
+
function apngTiming(bytes) {
|
|
132
|
+
let at = 8;
|
|
133
|
+
let plays;
|
|
134
|
+
let declaredFrames = 0;
|
|
135
|
+
const storedMs = [];
|
|
136
|
+
while (at + 8 <= bytes.length) {
|
|
137
|
+
const length = u32(bytes, at);
|
|
138
|
+
const type = ascii(bytes, at + 4, 4);
|
|
139
|
+
const data = at + 8;
|
|
140
|
+
if (type === "IEND") break;
|
|
141
|
+
if (type === "acTL" && length >= 8 && plays === void 0) {
|
|
142
|
+
declaredFrames = u32(bytes, data);
|
|
143
|
+
const n = u32(bytes, data + 4);
|
|
144
|
+
plays = n === 0 ? null : n;
|
|
145
|
+
}
|
|
146
|
+
if (type === "fcTL" && length >= 26) {
|
|
147
|
+
const num = u16(bytes, data + 20);
|
|
148
|
+
const den = u16(bytes, data + 22) || 100;
|
|
149
|
+
storedMs.push(Math.floor(num * 1e3 / den));
|
|
150
|
+
}
|
|
151
|
+
at += 12 + length;
|
|
152
|
+
}
|
|
153
|
+
return plays === void 0 ? null : {
|
|
154
|
+
format: "apng",
|
|
155
|
+
storedMs,
|
|
156
|
+
plays,
|
|
157
|
+
declaredFrames
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/** The timing of an animated GIF or APNG, or null for anything else (a still PNG, a video). */
|
|
161
|
+
function imageTiming(bytes) {
|
|
162
|
+
if (bytes.length >= 13 && (ascii(bytes, 0, 6) === "GIF87a" || ascii(bytes, 0, 6) === "GIF89a")) return gifTiming(bytes);
|
|
163
|
+
if (bytes.length >= 8 && bytes[0] === 137 && ascii(bytes, 1, 3) === "PNG") return apngTiming(bytes);
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
|
+
export { browserDelayMs, gifCompositingProblem, imageTiming };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A11yChange, A11yChangeType, A11yDiff, A11yExpectation, A11yNode, A11ySnapshot, AffectedComponent, AgentContext, Attachment, ChangeIntent, CrossValidationResult, DepEdge, DepGraph, DepNode, DiffHunk, DiffIgnoreRegion, DiffIgnoredRegionReport, DiffMaskSummary, DiffRegion, DiffRegionColor, DiffRegionColorPair, DiffRegionColorSample, DiffRegionSelectorCandidate, DiffRegionShift, DiffRegionType, DiffReport, DiffSemantics, ExpectedA11yChange, FileChange, HtmlSource, IntrospectResult, Language, LoopScore, NlAssertion, PageExpectation, PageIntrospection, PageSpec, PlaywrightReport, ProjectConfig, QualityCheckResult, QualityCheckType, ScoreDetail, ShiftRegion, SpecCheckType, SpecInvariant, TestAttempt, TestError, TestResult, TestSpec, TestSuite, UiSpec, UnifiedAgentContext, VisualChangeType, VisualExpectation, VisualSemanticChange, VisualSemanticDiff, VrtDiff, VrtExpectation, VrtSnapshot, VrtVerdict } from "./types.mjs";
|
|
1
|
+
import { A11yChange, A11yChangeType, A11yDiff, A11yExpectation, A11yNode, A11ySnapshot, AffectedComponent, AgentContext, Attachment, ChangeIntent, CrossValidationResult, DepEdge, DepGraph, DepNode, DiffHunk, DiffIgnoreRegion, DiffIgnoredRegionReport, DiffMaskSummary, DiffRegion, DiffRegionColor, DiffRegionColorPair, DiffRegionColorSample, DiffRegionKind, DiffRegionSelectorCandidate, DiffRegionShift, DiffRegionType, DiffReport, DiffSemantics, ExpectedA11yChange, FileChange, HtmlSource, IntrospectResult, Language, LoopScore, NlAssertion, PageExpectation, PageIntrospection, PageSpec, PlaywrightReport, ProjectConfig, QualityCheckResult, QualityCheckType, ScoreDetail, ShiftRegion, SpecCheckType, SpecInvariant, TestAttempt, TestError, TestResult, TestSpec, TestSuite, UiSpec, UnifiedAgentContext, VisualChangeType, VisualExpectation, VisualSemanticChange, VisualSemanticDiff, VrtDiff, VrtExpectation, VrtSnapshot, VrtVerdict } from "./types.mjs";
|
|
2
2
|
import { INTERACTIVE_ROLES, LANDMARK_ROLES, diffA11yTrees, parsePlaywrightA11ySnapshot, verifyA11yTree } from "./a11y-semantic.mjs";
|
|
3
3
|
import { cropImage, decodePng, encodePng } from "./png-utils.mjs";
|
|
4
4
|
import { AUTHORED_PROPERTIES } from "./authored-style-capture.mjs";
|
|
@@ -14,4 +14,4 @@ import { compareScreenshots, detectBandShifts, detectEmptyContent, detectWhiteou
|
|
|
14
14
|
import { RESOLUTION_PRESETS, getImageDimensions, resizePngBuffer, resolveResolutionForViewport } from "./image-resize.mjs";
|
|
15
15
|
import { WebpEncodeOptions, encodeWebp, imageFormatForPath, webpEncoderAvailable } from "./webp.mjs";
|
|
16
16
|
import { compareRowTypography, computeRowGapDeltas, extractTextRowsFromFile, extractTextRowsFromRgba, matchTextRows } from "./text-rows.mjs";
|
|
17
|
-
export { A11yChange, A11yChangeType, A11yDiff, A11yExpectation, A11yNode, A11ySnapshot, AUTHORED_PROPERTIES, AffectedComponent, AgentContext, Attachment, ChangeIntent, CrossValidationResult, DepEdge, DepGraph, DepNode, DiffHunk, DiffIgnoreRegion, DiffIgnoredRegionReport, DiffMaskSummary, DiffRegion, DiffRegionColor, DiffRegionColorPair, DiffRegionColorSample, DiffRegionSelectorCandidate, DiffRegionShift, DiffRegionType, DiffReport, DiffSemantics, ExpectedA11yChange, FileChange, type FilmstripLayout, type FilmstripOptions, HtmlSource, INTERACTIVE_ROLES, IntrospectResult, LANDMARK_ROLES, Language, LoopScore, NlAssertion, PageExpectation, PageIntrospection, PageSpec, PlaywrightReport, ProjectConfig, QualityCheckResult, QualityCheckType, RESOLUTION_PRESETS, ScoreDetail, ShiftRegion, SpecCheckType, SpecInvariant, TRACKED_PROPERTIES, TestAttempt, TestError, TestResult, TestSpec, TestSuite, UiSpec, UnifiedAgentContext, VisualChangeType, VisualExpectation, VisualSemanticChange, VisualSemanticDiff, VrtDiff, VrtExpectation, VrtSnapshot, VrtVerdict, type WebpEncodeOptions, aggregateAuthoredStyleByViewport, compareRowTypography, compareScreenshots, composeFilmstrip, computeRowGapDeltas, createScopedVrtDiff, cropImage, decodePng, detectBandShifts, detectEmptyContent, detectWhiteout, diffA11yTrees, diffAuthoredStyles, diffComputedStyles, diffDomPositionStyles, diffPositionStylesAcrossViewports, encodePng, encodeWebp, extractTextRowsFromFile, extractTextRowsFromRgba, filmstripLayout, findHeatmapRegionsFromFile, findHeatmapRegionsFromRgba, generateDiffReport, getImageDimensions, imageFormatForPath, matchTextRows, normalizeVrtDiffRegionPixels, normalizeVrtDiffRegions, parseIgnoreRegionSpec, parsePlaywrightA11ySnapshot, resizePngBuffer, resolveResolutionForViewport, verifyA11yTree, verifyDomEquivalence, webpEncoderAvailable };
|
|
17
|
+
export { A11yChange, A11yChangeType, A11yDiff, A11yExpectation, A11yNode, A11ySnapshot, AUTHORED_PROPERTIES, AffectedComponent, AgentContext, Attachment, ChangeIntent, CrossValidationResult, DepEdge, DepGraph, DepNode, DiffHunk, DiffIgnoreRegion, DiffIgnoredRegionReport, DiffMaskSummary, DiffRegion, DiffRegionColor, DiffRegionColorPair, DiffRegionColorSample, DiffRegionKind, DiffRegionSelectorCandidate, DiffRegionShift, DiffRegionType, DiffReport, DiffSemantics, ExpectedA11yChange, FileChange, type FilmstripLayout, type FilmstripOptions, HtmlSource, INTERACTIVE_ROLES, IntrospectResult, LANDMARK_ROLES, Language, LoopScore, NlAssertion, PageExpectation, PageIntrospection, PageSpec, PlaywrightReport, ProjectConfig, QualityCheckResult, QualityCheckType, RESOLUTION_PRESETS, ScoreDetail, ShiftRegion, SpecCheckType, SpecInvariant, TRACKED_PROPERTIES, TestAttempt, TestError, TestResult, TestSpec, TestSuite, UiSpec, UnifiedAgentContext, VisualChangeType, VisualExpectation, VisualSemanticChange, VisualSemanticDiff, VrtDiff, VrtExpectation, VrtSnapshot, VrtVerdict, type WebpEncodeOptions, aggregateAuthoredStyleByViewport, compareRowTypography, compareScreenshots, composeFilmstrip, computeRowGapDeltas, createScopedVrtDiff, cropImage, decodePng, detectBandShifts, detectEmptyContent, detectWhiteout, diffA11yTrees, diffAuthoredStyles, diffComputedStyles, diffDomPositionStyles, diffPositionStylesAcrossViewports, encodePng, encodeWebp, extractTextRowsFromFile, extractTextRowsFromRgba, filmstripLayout, findHeatmapRegionsFromFile, findHeatmapRegionsFromRgba, generateDiffReport, getImageDimensions, imageFormatForPath, matchTextRows, normalizeVrtDiffRegionPixels, normalizeVrtDiffRegions, parseIgnoreRegionSpec, parsePlaywrightA11ySnapshot, resizePngBuffer, resolveResolutionForViewport, verifyA11yTree, verifyDomEquivalence, webpEncoderAvailable };
|
package/dist/mask.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Page } from "playwright";
|
|
2
|
-
|
|
3
2
|
//#region src/mask.d.ts
|
|
4
3
|
/** What `applyMask` could and could not do, for the caller to report. */
|
|
5
|
-
interface MaskResult {
|
|
4
|
+
export interface MaskResult {
|
|
6
5
|
/** Selectors that matched at least one element and are now hidden. */
|
|
7
6
|
applied: string[];
|
|
8
7
|
/**
|
|
@@ -38,7 +37,7 @@ interface MaskResult {
|
|
|
38
37
|
* on exactly the thing we need to detect, and it is the same engine that will apply the
|
|
39
38
|
* CSS.
|
|
40
39
|
*/
|
|
41
|
-
declare function applyMask(page: Page, selectors: string[]): Promise<MaskResult>;
|
|
40
|
+
export declare function applyMask(page: Page, selectors: string[]): Promise<MaskResult>;
|
|
42
41
|
/**
|
|
43
42
|
* Accumulates mask outcomes across a run so the report is per-run, not per-page.
|
|
44
43
|
*
|
|
@@ -51,7 +50,7 @@ declare function applyMask(page: Page, selectors: string[]): Promise<MaskResult>
|
|
|
51
50
|
* exists on one route only — so it is worth reporting only for a selector that
|
|
52
51
|
* matched nothing *anywhere*, which is not knowable until the run ends.
|
|
53
52
|
*/
|
|
54
|
-
declare class MaskTally {
|
|
53
|
+
export declare class MaskTally {
|
|
55
54
|
private readonly invalid;
|
|
56
55
|
private readonly everMatched;
|
|
57
56
|
private readonly everTried;
|
|
@@ -69,7 +68,7 @@ declare class MaskTally {
|
|
|
69
68
|
* `Mask: <selectors>` line, which was a claim about state that a malformed selector made
|
|
70
69
|
* false.
|
|
71
70
|
*/
|
|
72
|
-
declare function formatMaskProblems(invalid: string[], neverMatched: string[]): string | null;
|
|
71
|
+
export declare function formatMaskProblems(invalid: string[], neverMatched: string[]): string | null;
|
|
73
72
|
/**
|
|
74
73
|
* Parse selector array from CLI --mask flags.
|
|
75
74
|
* Supports comma-separated or multiple --mask flags.
|
|
@@ -77,6 +76,5 @@ declare function formatMaskProblems(invalid: string[], neverMatched: string[]):
|
|
|
77
76
|
* --mask ".stars,.carousel"
|
|
78
77
|
* --mask ".stars" --mask ".carousel"
|
|
79
78
|
*/
|
|
80
|
-
declare function parseMaskSelectors(args: string[]): string[];
|
|
81
|
-
//#endregion
|
|
82
|
-
export { MaskResult, MaskTally, applyMask, formatMaskProblems, parseMaskSelectors };
|
|
79
|
+
export declare function parseMaskSelectors(args: string[]): string[];
|
|
80
|
+
//#endregion
|
|
@@ -23,6 +23,5 @@
|
|
|
23
23
|
* than the one requested, or `null` when the navigation landed where the
|
|
24
24
|
* caller intended (or when either URL is unparseable / not http(s)).
|
|
25
25
|
*/
|
|
26
|
-
declare function describeRedirect(requested: string, final: string): string | null;
|
|
27
|
-
//#endregion
|
|
28
|
-
export { describeRedirect };
|
|
26
|
+
export declare function describeRedirect(requested: string, final: string): string | null;
|
|
27
|
+
//#endregion
|
package/dist/page-load.d.mts
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import { GateInput } from "./plugin/contract.mjs";
|
|
2
2
|
import { applyHar } from "./page-open.mjs";
|
|
3
3
|
import { Page } from "playwright";
|
|
4
|
-
|
|
5
4
|
//#region src/page-load.d.ts
|
|
6
5
|
/** The navigation milestones a gate exposes. Playwright's `commit` is not one of
|
|
7
6
|
* them: no gate can read a document that has not parsed. */
|
|
8
|
-
declare const PAGE_LOAD_WAIT_UNTIL: readonly ["domcontentloaded", "load", "networkidle"];
|
|
9
|
-
type PageLoadWaitUntil = (typeof PAGE_LOAD_WAIT_UNTIL)[number];
|
|
7
|
+
export declare const PAGE_LOAD_WAIT_UNTIL: readonly ["domcontentloaded", "load", "networkidle"];
|
|
8
|
+
export type PageLoadWaitUntil = (typeof PAGE_LOAD_WAIT_UNTIL)[number];
|
|
10
9
|
/** Playwright's own default, restated so callers can name it. */
|
|
11
|
-
declare const DEFAULT_PAGE_LOAD_TIMEOUT_MS = 30000;
|
|
10
|
+
export declare const DEFAULT_PAGE_LOAD_TIMEOUT_MS = 30000;
|
|
12
11
|
/** The default milestone every gate has always used. */
|
|
13
|
-
declare const DEFAULT_PAGE_LOAD_WAIT_UNTIL: PageLoadWaitUntil;
|
|
12
|
+
export declare const DEFAULT_PAGE_LOAD_WAIT_UNTIL: PageLoadWaitUntil;
|
|
14
13
|
/**
|
|
15
14
|
* What a gate carries from argv down to its `page.goto`.
|
|
16
15
|
*
|
|
17
16
|
* Structurally a subset of `OpenPageOptions`, so a measurement module that
|
|
18
17
|
* loads through `openSource` can forward this object as-is.
|
|
19
18
|
*/
|
|
20
|
-
interface PageLoadOptions {
|
|
19
|
+
export interface PageLoadOptions {
|
|
21
20
|
/** Navigation milestone. Defaults to `networkidle`. */
|
|
22
21
|
waitUntil?: PageLoadWaitUntil;
|
|
23
22
|
/** Navigation timeout in milliseconds. Defaults to 30000. */
|
|
@@ -29,14 +28,14 @@ interface PageLoadOptions {
|
|
|
29
28
|
* `inputs` fragment. Spread at the END of a gate's `inputs` array so the
|
|
30
29
|
* gate-specific flags stay first in `--help`.
|
|
31
30
|
*/
|
|
32
|
-
declare const PAGE_LOAD_INPUTS: readonly GateInput[];
|
|
31
|
+
export declare const PAGE_LOAD_INPUTS: readonly GateInput[];
|
|
33
32
|
/** The flag spellings, for `readPositionals` value-flag lists. */
|
|
34
|
-
declare const PAGE_LOAD_VALUE_FLAGS: readonly string[];
|
|
33
|
+
export declare const PAGE_LOAD_VALUE_FLAGS: readonly string[];
|
|
35
34
|
/**
|
|
36
35
|
* Read the three flags off argv. Absent flags produce absent keys, so spreading
|
|
37
36
|
* the result never overwrites a gate's own default with `undefined`.
|
|
38
37
|
*/
|
|
39
|
-
declare function parsePageLoad(argv: readonly string[]): PageLoadOptions;
|
|
38
|
+
export declare function parsePageLoad(argv: readonly string[]): PageLoadOptions;
|
|
40
39
|
/**
|
|
41
40
|
* Narrow a wider options object down to just these three keys.
|
|
42
41
|
*
|
|
@@ -45,7 +44,7 @@ declare function parsePageLoad(argv: readonly string[]): PageLoadOptions;
|
|
|
45
44
|
* friends, and `OpenPageOptions` is not an index type, so the extra keys would
|
|
46
45
|
* pass silently today and collide the day one of those names is reused.
|
|
47
46
|
*/
|
|
48
|
-
declare function pickPageLoad(options: PageLoadOptions): PageLoadOptions;
|
|
47
|
+
export declare function pickPageLoad(options: PageLoadOptions): PageLoadOptions;
|
|
49
48
|
/**
|
|
50
49
|
* The `goto` / `setContent` option object, with the call site's own historical
|
|
51
50
|
* default preserved.
|
|
@@ -56,7 +55,7 @@ declare function pickPageLoad(options: PageLoadOptions): PageLoadOptions;
|
|
|
56
55
|
* a page that never reaches network idle. Passing a single global default here
|
|
57
56
|
* would have silently *broken* them while fixing the others.
|
|
58
57
|
*/
|
|
59
|
-
declare function navigationOptions(options?: PageLoadOptions, defaultWaitUntil?: PageLoadWaitUntil): {
|
|
58
|
+
export declare function navigationOptions(options?: PageLoadOptions, defaultWaitUntil?: PageLoadWaitUntil): {
|
|
60
59
|
waitUntil: PageLoadWaitUntil;
|
|
61
60
|
timeout: number;
|
|
62
61
|
};
|
|
@@ -78,6 +77,6 @@ declare function navigationOptions(options?: PageLoadOptions, defaultWaitUntil?:
|
|
|
78
77
|
* `navigationOptions(options, "load")` + their own `settlePage` instead, so the
|
|
79
78
|
* settle is not done twice.
|
|
80
79
|
*/
|
|
81
|
-
declare function navigatePage(page: Page, url: string, options?: PageLoadOptions): Promise<void>;
|
|
80
|
+
export declare function navigatePage(page: Page, url: string, options?: PageLoadOptions): Promise<void>;
|
|
82
81
|
//#endregion
|
|
83
|
-
export {
|
|
82
|
+
export { applyHar };
|
package/dist/page-open.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Browser, Page, ViewportSize } from "playwright";
|
|
2
|
-
|
|
3
2
|
//#region src/page-open.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Is this source already a URL, or is it a path that has to become one?
|
|
@@ -28,7 +27,7 @@ import { Browser, Page, ViewportSize } from "playwright";
|
|
|
28
27
|
* and `about:` are not sources any caller resolves, and a bare Windows drive letter
|
|
29
28
|
* (`C:\page.html`) must stay a path.
|
|
30
29
|
*/
|
|
31
|
-
declare const isUrlSource: (source: string) => boolean;
|
|
30
|
+
export declare const isUrlSource: (source: string) => boolean;
|
|
32
31
|
/**
|
|
33
32
|
* Normalize a source for storage and display: an absolute path for a file, the
|
|
34
33
|
* URL untouched for a URL.
|
|
@@ -37,7 +36,7 @@ declare const isUrlSource: (source: string) => boolean;
|
|
|
37
36
|
* yields `<cwd>/http:/x/p.html`, which then fails as "file not found" and tells
|
|
38
37
|
* the caller nothing about what actually went wrong.
|
|
39
38
|
*/
|
|
40
|
-
declare function resolveSource(source: string): string;
|
|
39
|
+
export declare function resolveSource(source: string): string;
|
|
41
40
|
/**
|
|
42
41
|
* File path or URL → a URL Playwright can navigate to.
|
|
43
42
|
*
|
|
@@ -50,7 +49,7 @@ declare function resolveSource(source: string): string;
|
|
|
50
49
|
* file and the part before the `?` / `#` is, so a file that really has `?` in its name still
|
|
51
50
|
* opens as that file.
|
|
52
51
|
*/
|
|
53
|
-
declare function sourceToUrl(source: string): string;
|
|
52
|
+
export declare function sourceToUrl(source: string): string;
|
|
54
53
|
/**
|
|
55
54
|
* Wait for the page to stop moving: bounded network idle, then webfonts, then
|
|
56
55
|
* one frame. Every part is best-effort — a page with a long-poll connection
|
|
@@ -99,7 +98,7 @@ declare function sourceToUrl(source: string): string;
|
|
|
99
98
|
* wait regardless, because a long finite animation is not worth stalling a run for — a page
|
|
100
99
|
* with a 30-second intro gets measured at the cap and that is the correct trade.
|
|
101
100
|
*/
|
|
102
|
-
declare function settlePage(page: Page, settleMs?: number, animationCapMs?: number): Promise<void>;
|
|
101
|
+
export declare function settlePage(page: Page, settleMs?: number, animationCapMs?: number): Promise<void>;
|
|
103
102
|
/**
|
|
104
103
|
* Install HAR replay on a page, when the caller asked for it.
|
|
105
104
|
*
|
|
@@ -125,7 +124,7 @@ declare function settlePage(page: Page, settleMs?: number, animationCapMs?: numb
|
|
|
125
124
|
* documented once and the gates that have since adopted `--har` cannot disagree
|
|
126
125
|
* about it.
|
|
127
126
|
*/
|
|
128
|
-
declare function applyHar(page: Page, har?: string): Promise<HarReplay | null>;
|
|
127
|
+
export declare function applyHar(page: Page, har?: string): Promise<HarReplay | null>;
|
|
129
128
|
/**
|
|
130
129
|
* What the recording contains, and what the run asked for that it did not.
|
|
131
130
|
*
|
|
@@ -142,7 +141,7 @@ declare function applyHar(page: Page, har?: string): Promise<HarReplay | null>;
|
|
|
142
141
|
* doc comment. A gate that judges resources can ask which failures were fixture
|
|
143
142
|
* misses and blame the recording instead of the page.
|
|
144
143
|
*/
|
|
145
|
-
interface HarReplay {
|
|
144
|
+
export interface HarReplay {
|
|
146
145
|
/** Absolute path of the recording in use. */
|
|
147
146
|
path: string;
|
|
148
147
|
/** Origins the recording actually contains, deduped, in first-seen order. */
|
|
@@ -158,7 +157,7 @@ interface HarReplay {
|
|
|
158
157
|
*/
|
|
159
158
|
originMismatch(pageUrl: string): string | null;
|
|
160
159
|
}
|
|
161
|
-
interface OpenPageOptions {
|
|
160
|
+
export interface OpenPageOptions {
|
|
162
161
|
viewport?: ViewportSize;
|
|
163
162
|
deviceScaleFactor?: number;
|
|
164
163
|
/** `prefers-color-scheme` for the page's context (theme-parity opens both). */
|
|
@@ -188,7 +187,7 @@ interface OpenPageOptions {
|
|
|
188
187
|
/** Skip settling entirely (a gate that measures load timing does its own). */
|
|
189
188
|
skipSettle?: boolean;
|
|
190
189
|
}
|
|
191
|
-
interface OpenedPage {
|
|
190
|
+
export interface OpenedPage {
|
|
192
191
|
page: Page;
|
|
193
192
|
/**
|
|
194
193
|
* Human-readable note when a URL redirected somewhere meaningful (a login
|
|
@@ -200,8 +199,8 @@ interface OpenedPage {
|
|
|
200
199
|
/**
|
|
201
200
|
* Open a file or URL by navigation, so relative assets resolve.
|
|
202
201
|
*/
|
|
203
|
-
declare function openSource(browser: Browser, source: string, options?: OpenPageOptions): Promise<OpenedPage>;
|
|
204
|
-
interface OpenHtmlOptions extends OpenPageOptions {
|
|
202
|
+
export declare function openSource(browser: Browser, source: string, options?: OpenPageOptions): Promise<OpenedPage>;
|
|
203
|
+
export interface OpenHtmlOptions extends OpenPageOptions {
|
|
205
204
|
/**
|
|
206
205
|
* The file or URL this HTML came from. The page navigates there first, so the
|
|
207
206
|
* document keeps that base URL and the mutated copy still resolves the
|
|
@@ -229,6 +228,5 @@ interface OpenHtmlOptions extends OpenPageOptions {
|
|
|
229
228
|
* the document a real base URL, and `setContent` replaces the markup without
|
|
230
229
|
* discarding it.
|
|
231
230
|
*/
|
|
232
|
-
declare function openHtml(browser: Browser, html: string, options?: OpenHtmlOptions): Promise<Page>;
|
|
233
|
-
//#endregion
|
|
234
|
-
export { HarReplay, OpenHtmlOptions, OpenPageOptions, OpenedPage, applyHar, isUrlSource, openHtml, openSource, resolveSource, settlePage, sourceToUrl };
|
|
231
|
+
export declare function openHtml(browser: Browser, html: string, options?: OpenHtmlOptions): Promise<Page>;
|
|
232
|
+
//#endregion
|
package/dist/plugin/args.d.mts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* rather than a boundary. Re-exported from `./index.ts`, which is the entry a
|
|
17
17
|
* plugin should import.
|
|
18
18
|
*/
|
|
19
|
-
declare function firstPositional(argv: readonly string[], usage: string, valueFlags?: readonly string[]): string;
|
|
19
|
+
export declare function firstPositional(argv: readonly string[], usage: string, valueFlags?: readonly string[]): string;
|
|
20
20
|
/**
|
|
21
21
|
* The first positional, or `undefined` when there is none.
|
|
22
22
|
*
|
|
@@ -24,7 +24,7 @@ declare function firstPositional(argv: readonly string[], usage: string, valueFl
|
|
|
24
24
|
* distinction `check integrity` needs in order to *reject* being given both a page and
|
|
25
25
|
* `--elements` rather than silently preferring one.
|
|
26
26
|
*/
|
|
27
|
-
declare function firstPositionalOrUndefined(argv: readonly string[], valueFlags?: readonly string[]): string | undefined;
|
|
27
|
+
export declare function firstPositionalOrUndefined(argv: readonly string[], valueFlags?: readonly string[]): string | undefined;
|
|
28
28
|
/**
|
|
29
29
|
* Drop an optionally-valued flag and whatever value it consumed.
|
|
30
30
|
*
|
|
@@ -41,20 +41,27 @@ declare function firstPositionalOrUndefined(argv: readonly string[], valueFlags?
|
|
|
41
41
|
* positional left and fails with the usage line, which is the honest outcome
|
|
42
42
|
* for a genuinely ambiguous command line.
|
|
43
43
|
*/
|
|
44
|
-
declare function withoutOptionalValue(argv: readonly string[], name: string): string[];
|
|
44
|
+
export declare function withoutOptionalValue(argv: readonly string[], name: string): string[];
|
|
45
45
|
/** `--breakpoints 768,1024` → `[768, 1024]`. Absent flag → `undefined`. */
|
|
46
|
-
declare function numberList(argv: readonly string[], name: string): number[] | undefined;
|
|
46
|
+
export declare function numberList(argv: readonly string[], name: string): number[] | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* `--at 0,150,1.5s,0..1s/100ms` → instants in ms, sorted and deduplicated. Absent flag →
|
|
49
|
+
* `undefined`. The grammar is `parseInstants` (`@mizchi/vlmkit-judge/frames.ts`): bare numbers
|
|
50
|
+
* are ms, and `s`, `ms`, `f` (60fps frames), `mm:ss.sss` and ranges are accepted. Not
|
|
51
|
+
* `numberList`, whose `parseInt` read `1.5s` as 1 ms.
|
|
52
|
+
*/
|
|
53
|
+
export declare function instantList(argv: readonly string[], name: string): number[] | undefined;
|
|
47
54
|
/**
|
|
48
55
|
* Like `numberList`, but for scales that are legitimately fractional
|
|
49
56
|
* (`--tolerance`-adjacent flags such as `--radius-scale 0,2,4.5`).
|
|
50
57
|
*/
|
|
51
|
-
declare function numberListFloat(argv: readonly string[], name: string): number[] | undefined;
|
|
58
|
+
export declare function numberListFloat(argv: readonly string[], name: string): number[] | undefined;
|
|
52
59
|
/** `--viewport 1280x720` → `{width, height}`. */
|
|
53
|
-
declare function viewportFlag(argv: readonly string[], name?: string): {
|
|
60
|
+
export declare function viewportFlag(argv: readonly string[], name?: string): {
|
|
54
61
|
width: number;
|
|
55
62
|
height: number;
|
|
56
63
|
} | undefined;
|
|
57
|
-
declare function optionalInt(argv: readonly string[], name: string, options?: {
|
|
64
|
+
export declare function optionalInt(argv: readonly string[], name: string, options?: {
|
|
58
65
|
min?: number;
|
|
59
66
|
}): number | undefined;
|
|
60
67
|
/**
|
|
@@ -65,7 +72,7 @@ declare function optionalInt(argv: readonly string[], name: string, options?: {
|
|
|
65
72
|
* `readFlag` cannot express this: the value is optional, so a bare `--vlm`
|
|
66
73
|
* followed by another flag must not consume it.
|
|
67
74
|
*/
|
|
68
|
-
declare function vlmFlag(argv: readonly string[], name?: string): string | true | undefined;
|
|
75
|
+
export declare function vlmFlag(argv: readonly string[], name?: string): string | true | undefined;
|
|
69
76
|
/**
|
|
70
77
|
* Default output directory for a gate run, keyed on what the run measured.
|
|
71
78
|
*
|
|
@@ -81,6 +88,5 @@ declare function vlmFlag(argv: readonly string[], name?: string): string | true
|
|
|
81
88
|
* `discriminator` is for a gate where the source is not the whole question - drift
|
|
82
89
|
* passes its `--selector`, since two selectors on one page are two different runs.
|
|
83
90
|
*/
|
|
84
|
-
declare function runOutputDir(gateDir: string, source: string, discriminator?: string): string;
|
|
85
|
-
//#endregion
|
|
86
|
-
export { firstPositional, firstPositionalOrUndefined, numberList, numberListFloat, optionalInt, runOutputDir, viewportFlag, vlmFlag, withoutOptionalValue };
|
|
91
|
+
export declare function runOutputDir(gateDir: string, source: string, discriminator?: string): string;
|
|
92
|
+
//#endregion
|
package/dist/plugin/args.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UsageError } from "../cli-error.mjs";
|
|
2
2
|
import { readFlag, readInt, readPositionals } from "../arg-reader.mjs";
|
|
3
3
|
import { basename, join, resolve } from "node:path";
|
|
4
|
+
import { parseInstants } from "@mizchi/vlmkit-judge/frames.ts";
|
|
4
5
|
import { createHash } from "node:crypto";
|
|
5
6
|
//#region src/plugin/args.ts
|
|
6
7
|
/**
|
|
@@ -98,6 +99,16 @@ function numberList(argv, name) {
|
|
|
98
99
|
});
|
|
99
100
|
}
|
|
100
101
|
/**
|
|
102
|
+
* `--at 0,150,1.5s,0..1s/100ms` → instants in ms, sorted and deduplicated. Absent flag →
|
|
103
|
+
* `undefined`. The grammar is `parseInstants` (`@mizchi/vlmkit-judge/frames.ts`): bare numbers
|
|
104
|
+
* are ms, and `s`, `ms`, `f` (60fps frames), `mm:ss.sss` and ranges are accepted. Not
|
|
105
|
+
* `numberList`, whose `parseInt` read `1.5s` as 1 ms.
|
|
106
|
+
*/
|
|
107
|
+
function instantList(argv, name) {
|
|
108
|
+
const raw = readFlag(argv, name);
|
|
109
|
+
return raw === void 0 ? void 0 : parseInstants(raw, `--${name}`);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
101
112
|
* Like `numberList`, but for scales that are legitimately fractional
|
|
102
113
|
* (`--tolerance`-adjacent flags such as `--radius-scale 0,2,4.5`).
|
|
103
114
|
*/
|
|
@@ -159,4 +170,4 @@ function runOutputDir(gateDir, source, discriminator = "") {
|
|
|
159
170
|
return join(process.cwd(), "test-results", gateDir, name.replace(/[^A-Za-z0-9._-]+/g, "-") + "-" + hash);
|
|
160
171
|
}
|
|
161
172
|
//#endregion
|
|
162
|
-
export { firstPositional, firstPositionalOrUndefined, numberList, numberListFloat, optionalInt, runOutputDir, viewportFlag, vlmFlag, withoutOptionalValue };
|
|
173
|
+
export { firstPositional, firstPositionalOrUndefined, instantList, numberList, numberListFloat, optionalInt, runOutputDir, viewportFlag, vlmFlag, withoutOptionalValue };
|
|
@@ -6,6 +6,5 @@
|
|
|
6
6
|
* so for a dispatched command the env var is the entry signal and argv[1] is the
|
|
7
7
|
* dispatcher rather than the module.
|
|
8
8
|
*/
|
|
9
|
-
declare function isCliEntry(moduleUrl: string, dispatcherName?: string): boolean;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { isCliEntry };
|
|
9
|
+
export declare function isCliEntry(moduleUrl: string, dispatcherName?: string): boolean;
|
|
10
|
+
//#endregion
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { RunLedgerEntry } from "../run-ledger.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/plugin/contract.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Normalized finding severity.
|
|
@@ -10,14 +9,14 @@ import { RunLedgerEntry } from "../run-ledger.mjs";
|
|
|
10
9
|
* the normal form and adapters map into it. `info` exists for findings a
|
|
11
10
|
* gate wants to report without ever affecting a verdict.
|
|
12
11
|
*/
|
|
13
|
-
type FindingSeverity = "suspect" | "warn" | "info";
|
|
14
|
-
declare const FINDING_SEVERITIES: readonly FindingSeverity[];
|
|
12
|
+
export type FindingSeverity = "suspect" | "warn" | "info";
|
|
13
|
+
export declare const FINDING_SEVERITIES: readonly FindingSeverity[];
|
|
15
14
|
/**
|
|
16
15
|
* One normalized finding. `rule` is the gate-local rule id — the same
|
|
17
16
|
* string the gate's own report calls `kind`, so a migration is a rename
|
|
18
17
|
* rather than a re-classification.
|
|
19
18
|
*/
|
|
20
|
-
interface Finding {
|
|
19
|
+
export interface Finding {
|
|
21
20
|
/** Gate-local rule id, e.g. `text-collision`. Must exist in the gate's rule table. */
|
|
22
21
|
rule: string;
|
|
23
22
|
severity: FindingSeverity;
|
|
@@ -41,7 +40,7 @@ interface Finding {
|
|
|
41
40
|
* silence `check integrity` entirely, or append a flag the gate happened to
|
|
42
41
|
* implement).
|
|
43
42
|
*/
|
|
44
|
-
interface RuleDefinition {
|
|
43
|
+
export interface RuleDefinition {
|
|
45
44
|
/** Gate-local id. Stable — it appears in configs and reports. */
|
|
46
45
|
id: string;
|
|
47
46
|
/** One-line human name, used in `--rules` listings. */
|
|
@@ -70,7 +69,7 @@ interface RuleDefinition {
|
|
|
70
69
|
* mini-DSL, `--viewports 1280,768,375`). `inputs` is the machine-readable
|
|
71
70
|
* summary of what `parse` accepts, not a replacement for it.
|
|
72
71
|
*/
|
|
73
|
-
interface GateInput {
|
|
72
|
+
export interface GateInput {
|
|
74
73
|
/** Flag name without dashes, or `"source"` / `"target"` for positionals. */
|
|
75
74
|
name: string;
|
|
76
75
|
/**
|
|
@@ -92,7 +91,7 @@ interface GateInput {
|
|
|
92
91
|
defaultDescription?: string;
|
|
93
92
|
}
|
|
94
93
|
/** Everything the runner hands a gate that the gate should not read from globals. */
|
|
95
|
-
interface GateContext {
|
|
94
|
+
export interface GateContext {
|
|
96
95
|
cwd: string;
|
|
97
96
|
/** Raw argv after the command tokens, for gates that need a flag `parse` dropped. */
|
|
98
97
|
argv: readonly string[];
|
|
@@ -112,15 +111,15 @@ interface GateContext {
|
|
|
112
111
|
* "is the page broken", "does it behave", "does it look like our system",
|
|
113
112
|
* "is it done", "is my tooling working".
|
|
114
113
|
*/
|
|
115
|
-
declare const GATE_CATEGORIES: {
|
|
114
|
+
export declare const GATE_CATEGORIES: {
|
|
116
115
|
readonly correctness: "Is the page broken, on its own terms? No reference needed.";
|
|
117
116
|
readonly behavior: "Does it respond correctly to size, scroll, motion and input?";
|
|
118
117
|
readonly "design-system": "Does it conform to the design language the project declares?";
|
|
119
118
|
readonly verdict: "Is this attempt done? Aggregates other signals into one answer.";
|
|
120
119
|
readonly infrastructure: "Is the measurement toolchain itself working?";
|
|
121
120
|
};
|
|
122
|
-
type GateCategory = keyof typeof GATE_CATEGORIES;
|
|
123
|
-
declare const GATE_CATEGORY_ORDER: readonly GateCategory[];
|
|
121
|
+
export type GateCategory = keyof typeof GATE_CATEGORIES;
|
|
122
|
+
export declare const GATE_CATEGORY_ORDER: readonly GateCategory[];
|
|
124
123
|
/**
|
|
125
124
|
* A gate definition.
|
|
126
125
|
*
|
|
@@ -135,7 +134,7 @@ declare const GATE_CATEGORY_ORDER: readonly GateCategory[];
|
|
|
135
134
|
* needs "what is this rule worth now", and handing it the suppressed/retuned lists
|
|
136
135
|
* would invite it to re-derive the runner's decisions and disagree with them.
|
|
137
136
|
*/
|
|
138
|
-
interface RuleView {
|
|
137
|
+
export interface RuleView {
|
|
139
138
|
/**
|
|
140
139
|
* Effective setting for a rule id, after project config and `--rule`, falling back to the
|
|
141
140
|
* severity the gate DECLARED for it.
|
|
@@ -157,7 +156,7 @@ interface RuleView {
|
|
|
157
156
|
*/
|
|
158
157
|
setting(ruleId: string): "off" | FindingSeverity | undefined;
|
|
159
158
|
}
|
|
160
|
-
interface GateDefinition<Report = unknown, Options = unknown> {
|
|
159
|
+
export interface GateDefinition<Report = unknown, Options = unknown> {
|
|
161
160
|
/**
|
|
162
161
|
* Stable machine id, `<group>.<leaf>` — `check.integrity`. Used by rule
|
|
163
162
|
* settings, the ledger, and plugin conflict detection. Never localized,
|
|
@@ -246,25 +245,24 @@ interface GateDefinition<Report = unknown, Options = unknown> {
|
|
|
246
245
|
ledger?: (report: Report, options: Options) => RunLedgerEntry | null;
|
|
247
246
|
}
|
|
248
247
|
/** A definition with its type parameters erased, for registries and lists. */
|
|
249
|
-
type AnyGateDefinition = GateDefinition<any, any>;
|
|
248
|
+
export type AnyGateDefinition = GateDefinition<any, any>;
|
|
250
249
|
/**
|
|
251
250
|
* A plugin is a named bundle of gates. Built-in gates ship as plugins too
|
|
252
251
|
* (`vlmkit-markup` exports one), so "add a gate" is the same operation for
|
|
253
252
|
* this repo and for a third party — there is no privileged built-in path.
|
|
254
253
|
*/
|
|
255
|
-
interface VlmkitPlugin {
|
|
254
|
+
export interface VlmkitPlugin {
|
|
256
255
|
/** Unique plugin name, reported in conflict errors and `vlmkit rules --plugins`. */
|
|
257
256
|
name: string;
|
|
258
257
|
version?: string;
|
|
259
258
|
gates: readonly AnyGateDefinition[];
|
|
260
259
|
}
|
|
261
260
|
/** Identity helper that pins the type parameters at the definition site. */
|
|
262
|
-
declare function defineGate<Report, Options>(definition: GateDefinition<Report, Options>): GateDefinition<Report, Options>;
|
|
261
|
+
export declare function defineGate<Report, Options>(definition: GateDefinition<Report, Options>): GateDefinition<Report, Options>;
|
|
263
262
|
/** Identity helper for plugin authors; also the documented entry point. */
|
|
264
|
-
declare function definePlugin(plugin: VlmkitPlugin): VlmkitPlugin;
|
|
263
|
+
export declare function definePlugin(plugin: VlmkitPlugin): VlmkitPlugin;
|
|
265
264
|
/** `check integrity` — the human-facing form of `command`. */
|
|
266
|
-
declare function gateCommandString(gate: AnyGateDefinition): string;
|
|
265
|
+
export declare function gateCommandString(gate: AnyGateDefinition): string;
|
|
267
266
|
/** Fully-qualified rule reference used in configs: `check.integrity/text-collision`. */
|
|
268
|
-
declare function ruleRef(gateId: string, ruleId: string): string;
|
|
269
|
-
//#endregion
|
|
270
|
-
export { AnyGateDefinition, FINDING_SEVERITIES, Finding, FindingSeverity, GATE_CATEGORIES, GATE_CATEGORY_ORDER, GateCategory, GateContext, GateDefinition, GateInput, RuleDefinition, RuleView, VlmkitPlugin, defineGate, definePlugin, gateCommandString, ruleRef };
|
|
267
|
+
export declare function ruleRef(gateId: string, ruleId: string): string;
|
|
268
|
+
//#endregion
|