@mizchi/vlmkit-core 0.23.2 → 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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
//#region src/computed-style-capture.d.ts
|
|
2
|
-
type ComputedStyleSnapshot = Record<string, Record<string, string>>;
|
|
3
|
-
type InteractionType = "hover" | "focus" | "active";
|
|
2
|
+
export type ComputedStyleSnapshot = Record<string, Record<string, string>>;
|
|
3
|
+
export type InteractionType = "hover" | "focus" | "active";
|
|
4
4
|
/** Pseudo-class state names that CDP `CSS.forcePseudoState` accepts. */
|
|
5
|
-
type ForcedPseudoState = "hover" | "focus" | "focus-visible" | "focus-within" | "active";
|
|
6
|
-
interface InteractionTargetPlan {
|
|
5
|
+
export type ForcedPseudoState = "hover" | "focus" | "focus-visible" | "focus-within" | "active";
|
|
6
|
+
export interface InteractionTargetPlan {
|
|
7
7
|
selector: string;
|
|
8
8
|
normalizedSelector: string;
|
|
9
9
|
/**
|
|
@@ -18,24 +18,23 @@ interface InteractionTargetPlan {
|
|
|
18
18
|
*/
|
|
19
19
|
forcedStates: ForcedPseudoState[];
|
|
20
20
|
}
|
|
21
|
-
declare const TRACKED_PROPERTIES: string[];
|
|
22
|
-
declare function normalizeInteractionSelector(selector: string): string;
|
|
23
|
-
declare function buildInteractionTargetPlans(selectors: string[]): InteractionTargetPlan[];
|
|
24
|
-
declare function selectInteractionFallbackPlans(plans: InteractionTargetPlan[], emulatedSnapshotMeaningful: boolean): InteractionTargetPlan[];
|
|
25
|
-
declare function mergeComputedStyleSnapshots(...snapshots: ComputedStyleSnapshot[]): ComputedStyleSnapshot;
|
|
26
|
-
declare function captureComputedStyleSnapshotInDom(props: string[]): ComputedStyleSnapshot;
|
|
27
|
-
declare function captureComputedStyleSnapshotForTargetSelectorsInDom(input: {
|
|
21
|
+
export declare const TRACKED_PROPERTIES: string[];
|
|
22
|
+
export declare function normalizeInteractionSelector(selector: string): string;
|
|
23
|
+
export declare function buildInteractionTargetPlans(selectors: string[]): InteractionTargetPlan[];
|
|
24
|
+
export declare function selectInteractionFallbackPlans(plans: InteractionTargetPlan[], emulatedSnapshotMeaningful: boolean): InteractionTargetPlan[];
|
|
25
|
+
export declare function mergeComputedStyleSnapshots(...snapshots: ComputedStyleSnapshot[]): ComputedStyleSnapshot;
|
|
26
|
+
export declare function captureComputedStyleSnapshotInDom(props: string[]): ComputedStyleSnapshot;
|
|
27
|
+
export declare function captureComputedStyleSnapshotForTargetSelectorsInDom(input: {
|
|
28
28
|
props: string[];
|
|
29
29
|
selectors: string[];
|
|
30
30
|
}): ComputedStyleSnapshot;
|
|
31
|
-
declare function collectInteractionTargetPlansInDom(): InteractionTargetPlan[];
|
|
32
|
-
declare function waitForInteractionStylesInDom(): Promise<void>;
|
|
33
|
-
declare function captureEmulatedInteractionStyleSnapshotInDom(props: string[]): Promise<ComputedStyleSnapshot>;
|
|
34
|
-
declare function computedStyleSnapshotToMap(snapshot: ComputedStyleSnapshot): Map<string, Record<string, string>>;
|
|
35
|
-
declare const ESBUILD_NAME_POLYFILL = "var __name = typeof __name !== 'undefined' ? __name : function(fn) { return fn; };";
|
|
36
|
-
declare function buildComputedStyleCaptureExpression(props?: string[]): string;
|
|
37
|
-
declare function buildComputedStyleCaptureJsonExpression(props?: string[]): string;
|
|
38
|
-
declare function parseComputedStyleSnapshot(value: unknown): ComputedStyleSnapshot;
|
|
39
|
-
declare function hasMeaningfulComputedStyleSnapshot(snapshot: ComputedStyleSnapshot): boolean;
|
|
40
|
-
//#endregion
|
|
41
|
-
export { ComputedStyleSnapshot, ESBUILD_NAME_POLYFILL, ForcedPseudoState, InteractionTargetPlan, InteractionType, TRACKED_PROPERTIES, buildComputedStyleCaptureExpression, buildComputedStyleCaptureJsonExpression, buildInteractionTargetPlans, captureComputedStyleSnapshotForTargetSelectorsInDom, captureComputedStyleSnapshotInDom, captureEmulatedInteractionStyleSnapshotInDom, collectInteractionTargetPlansInDom, computedStyleSnapshotToMap, hasMeaningfulComputedStyleSnapshot, mergeComputedStyleSnapshots, normalizeInteractionSelector, parseComputedStyleSnapshot, selectInteractionFallbackPlans, waitForInteractionStylesInDom };
|
|
31
|
+
export declare function collectInteractionTargetPlansInDom(): InteractionTargetPlan[];
|
|
32
|
+
export declare function waitForInteractionStylesInDom(): Promise<void>;
|
|
33
|
+
export declare function captureEmulatedInteractionStyleSnapshotInDom(props: string[]): Promise<ComputedStyleSnapshot>;
|
|
34
|
+
export declare function computedStyleSnapshotToMap(snapshot: ComputedStyleSnapshot): Map<string, Record<string, string>>;
|
|
35
|
+
export declare const ESBUILD_NAME_POLYFILL = "var __name = typeof __name !== 'undefined' ? __name : function(fn) { return fn; };";
|
|
36
|
+
export declare function buildComputedStyleCaptureExpression(props?: string[]): string;
|
|
37
|
+
export declare function buildComputedStyleCaptureJsonExpression(props?: string[]): string;
|
|
38
|
+
export declare function parseComputedStyleSnapshot(value: unknown): ComputedStyleSnapshot;
|
|
39
|
+
export declare function hasMeaningfulComputedStyleSnapshot(snapshot: ComputedStyleSnapshot): boolean;
|
|
40
|
+
//#endregion
|
|
@@ -129,7 +129,7 @@ function mergeComputedStyleSnapshots(...snapshots) {
|
|
|
129
129
|
}
|
|
130
130
|
function captureComputedStyleSnapshotInDom(props) {
|
|
131
131
|
const results = {};
|
|
132
|
-
const semanticTags = new Set([
|
|
132
|
+
const semanticTags = /* @__PURE__ */ new Set([
|
|
133
133
|
"main",
|
|
134
134
|
"nav",
|
|
135
135
|
"header",
|
|
@@ -260,7 +260,7 @@ function captureComputedStyleSnapshotInDom(props) {
|
|
|
260
260
|
function captureComputedStyleSnapshotForTargetSelectorsInDom(input) {
|
|
261
261
|
const { props, selectors } = input;
|
|
262
262
|
const results = {};
|
|
263
|
-
const semanticTags = new Set([
|
|
263
|
+
const semanticTags = /* @__PURE__ */ new Set([
|
|
264
264
|
"main",
|
|
265
265
|
"nav",
|
|
266
266
|
"header",
|
|
@@ -414,7 +414,7 @@ async function waitForInteractionStylesInDom() {
|
|
|
414
414
|
}
|
|
415
415
|
async function captureEmulatedInteractionStyleSnapshotInDom(props) {
|
|
416
416
|
const results = {};
|
|
417
|
-
const semanticTags = new Set([
|
|
417
|
+
const semanticTags = /* @__PURE__ */ new Set([
|
|
418
418
|
"main",
|
|
419
419
|
"nav",
|
|
420
420
|
"header",
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { ComputedStyleSnapshot } from "./computed-style-capture.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/computed-style-diff.d.ts
|
|
4
|
-
interface CsdEntry {
|
|
3
|
+
export interface CsdEntry {
|
|
5
4
|
selector: string;
|
|
6
5
|
property: string;
|
|
7
6
|
baseline: string;
|
|
8
7
|
variant: string;
|
|
9
8
|
}
|
|
10
|
-
interface CsdResult {
|
|
9
|
+
export interface CsdResult {
|
|
11
10
|
/** Per-(selector, property) differences. */
|
|
12
11
|
entries: CsdEntry[];
|
|
13
12
|
/** Total differing (selector, property) pairs. */
|
|
@@ -26,19 +25,19 @@ interface CsdResult {
|
|
|
26
25
|
selectorsOnlyInBaseline: string[];
|
|
27
26
|
selectorsOnlyInVariant: string[];
|
|
28
27
|
}
|
|
29
|
-
interface CsdPerViewportSample {
|
|
28
|
+
export interface CsdPerViewportSample {
|
|
30
29
|
viewport: string;
|
|
31
30
|
baseline: string;
|
|
32
31
|
variant: string;
|
|
33
32
|
}
|
|
34
|
-
interface CsdPerViewportEntry {
|
|
33
|
+
export interface CsdPerViewportEntry {
|
|
35
34
|
selector: string;
|
|
36
35
|
property: string;
|
|
37
36
|
/** Viewports on which this (selector, property) pair differs. */
|
|
38
37
|
viewports: string[];
|
|
39
38
|
samples: CsdPerViewportSample[];
|
|
40
39
|
}
|
|
41
|
-
interface CsdPerViewportResult {
|
|
40
|
+
export interface CsdPerViewportResult {
|
|
42
41
|
/** Total (selector, property, viewport) tuples — i.e. Σ per-viewport counts. */
|
|
43
42
|
totalDiffs: number;
|
|
44
43
|
byViewport: Array<{
|
|
@@ -69,7 +68,7 @@ interface CsdPerViewportResult {
|
|
|
69
68
|
* which is the same order migration-compare captures viewports (small →
|
|
70
69
|
* large or whatever the caller chose).
|
|
71
70
|
*/
|
|
72
|
-
declare function aggregateCsdByViewport(perViewport: ReadonlyArray<{
|
|
71
|
+
export declare function aggregateCsdByViewport(perViewport: ReadonlyArray<{
|
|
73
72
|
viewport: string;
|
|
74
73
|
result: CsdResult;
|
|
75
74
|
}>): CsdPerViewportResult;
|
|
@@ -78,6 +77,6 @@ declare function aggregateCsdByViewport(perViewport: ReadonlyArray<{
|
|
|
78
77
|
* `Record<selector, Record<property, value>>`; produced by
|
|
79
78
|
* `captureComputedStyleSnapshotInDom`.
|
|
80
79
|
*/
|
|
81
|
-
declare function diffComputedStyles(baseline: ComputedStyleSnapshot, variant: ComputedStyleSnapshot): CsdResult;
|
|
80
|
+
export declare function diffComputedStyles(baseline: ComputedStyleSnapshot, variant: ComputedStyleSnapshot): CsdResult;
|
|
82
81
|
//#endregion
|
|
83
|
-
export {
|
|
82
|
+
export type { ComputedStyleSnapshot };
|
|
@@ -82,7 +82,7 @@ function diffComputedStyles(baseline, variant) {
|
|
|
82
82
|
for (const selector of shared) {
|
|
83
83
|
const b = baseline[selector] ?? {};
|
|
84
84
|
const v = variant[selector] ?? {};
|
|
85
|
-
const props = new Set([...Object.keys(b), ...Object.keys(v)]);
|
|
85
|
+
const props = /* @__PURE__ */ new Set([...Object.keys(b), ...Object.keys(v)]);
|
|
86
86
|
for (const property of props) {
|
|
87
87
|
const bv = b[property] ?? "";
|
|
88
88
|
const vv = v[property] ?? "";
|
package/dist/diff-regions.d.mts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { DiffRegion, VrtDiff } from "./types.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/diff-regions.d.ts
|
|
4
|
-
declare function normalizeVrtDiffRegions(diff: VrtDiff): DiffRegion[];
|
|
5
|
-
declare function normalizeVrtDiffRegionPixels(diff: VrtDiff): number[];
|
|
6
|
-
declare function createScopedVrtDiff(diff: VrtDiff, region: DiffRegion): VrtDiff;
|
|
7
|
-
//#endregion
|
|
8
|
-
export { createScopedVrtDiff, normalizeVrtDiffRegionPixels, normalizeVrtDiffRegions };
|
|
3
|
+
export declare function normalizeVrtDiffRegions(diff: VrtDiff): DiffRegion[];
|
|
4
|
+
export declare function normalizeVrtDiffRegionPixels(diff: VrtDiff): number[];
|
|
5
|
+
export declare function createScopedVrtDiff(diff: VrtDiff, region: DiffRegion): VrtDiff;
|
|
6
|
+
//#endregion
|
|
@@ -16,19 +16,19 @@
|
|
|
16
16
|
* here; migration-compare evaluates the script with `page.evaluate()`
|
|
17
17
|
* and feeds the results into `verifyDomEquivalence`.
|
|
18
18
|
*/
|
|
19
|
-
interface DomFingerprint {
|
|
19
|
+
export interface DomFingerprint {
|
|
20
20
|
headingTexts: string[];
|
|
21
21
|
buttonTexts: string[];
|
|
22
22
|
inputValues: string[];
|
|
23
23
|
elementCount: number;
|
|
24
24
|
}
|
|
25
|
-
interface DomEquivalenceWarning {
|
|
25
|
+
export interface DomEquivalenceWarning {
|
|
26
26
|
code: "heading-mismatch" | "button-mismatch" | "input-mismatch" | "element-count-mismatch";
|
|
27
27
|
message: string;
|
|
28
28
|
baseline: string[];
|
|
29
29
|
variant: string[];
|
|
30
30
|
}
|
|
31
|
-
interface DomEquivalenceResult {
|
|
31
|
+
export interface DomEquivalenceResult {
|
|
32
32
|
ok: boolean;
|
|
33
33
|
warnings: DomEquivalenceWarning[];
|
|
34
34
|
}
|
|
@@ -36,11 +36,10 @@ interface DomEquivalenceResult {
|
|
|
36
36
|
* Verify structural DOM equivalence between two captured fingerprints.
|
|
37
37
|
*
|
|
38
38
|
*/
|
|
39
|
-
declare function verifyDomEquivalence(baseline: DomFingerprint, variant: DomFingerprint): DomEquivalenceResult;
|
|
39
|
+
export declare function verifyDomEquivalence(baseline: DomFingerprint, variant: DomFingerprint): DomEquivalenceResult;
|
|
40
40
|
/**
|
|
41
41
|
* Browser-side capture script. Designed to be passed verbatim to
|
|
42
42
|
* `page.evaluate()`; produces a {@link DomFingerprint}.
|
|
43
43
|
*/
|
|
44
|
-
declare const DOM_FINGERPRINT_BROWSER_SCRIPT = "(() => {\n const norm = (s) => (s || \"\").replace(/\\s+/g, \" \").trim();\n const headingTexts = Array.from(document.querySelectorAll(\"h1, h2, h3, h4, h5, h6\")).map((el) => norm(el.textContent));\n const buttonTexts = Array.from(document.querySelectorAll(\"button\")).map((el) => norm(el.textContent));\n const inputValues = Array.from(document.querySelectorAll(\"input, textarea, select\")).map((el) => {\n const v = el.value != null ? el.value : el.getAttribute(\"value\") || \"\";\n return norm(v);\n });\n const elementCount = document.querySelectorAll(\"*\").length;\n return { headingTexts, buttonTexts, inputValues, elementCount };\n})()";
|
|
45
|
-
//#endregion
|
|
46
|
-
export { DOM_FINGERPRINT_BROWSER_SCRIPT, DomEquivalenceResult, DomEquivalenceWarning, DomFingerprint, verifyDomEquivalence };
|
|
44
|
+
export declare const DOM_FINGERPRINT_BROWSER_SCRIPT = "(() => {\n const norm = (s) => (s || \"\").replace(/\\s+/g, \" \").trim();\n const headingTexts = Array.from(document.querySelectorAll(\"h1, h2, h3, h4, h5, h6\")).map((el) => norm(el.textContent));\n const buttonTexts = Array.from(document.querySelectorAll(\"button\")).map((el) => norm(el.textContent));\n const inputValues = Array.from(document.querySelectorAll(\"input, textarea, select\")).map((el) => {\n const v = el.value != null ? el.value : el.getAttribute(\"value\") || \"\";\n return norm(v);\n });\n const elementCount = document.querySelectorAll(\"*\").length;\n return { headingTexts, buttonTexts, inputValues, elementCount };\n})()";
|
|
45
|
+
//#endregion
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* Pure module. The browser-side capture script ships as a string fed
|
|
20
20
|
* to `page.evaluate()`.
|
|
21
21
|
*/
|
|
22
|
-
interface PositionedElement {
|
|
22
|
+
export interface PositionedElement {
|
|
23
23
|
/** DOM path: `tag[childIndex]>tag[childIndex]>...` rooted at body. */
|
|
24
24
|
path: string;
|
|
25
25
|
/** Tag name (lower-case). */
|
|
@@ -35,7 +35,7 @@ interface PositionedElement {
|
|
|
35
35
|
*/
|
|
36
36
|
parentDisplay?: string;
|
|
37
37
|
}
|
|
38
|
-
interface DpEntry {
|
|
38
|
+
export interface DpEntry {
|
|
39
39
|
path: string;
|
|
40
40
|
tag: string;
|
|
41
41
|
baselineClasses: string;
|
|
@@ -59,11 +59,12 @@ interface DpEntry {
|
|
|
59
59
|
*/
|
|
60
60
|
parentDisplayContext?: {
|
|
61
61
|
baselineParent: string;
|
|
62
|
-
variantParent: string;
|
|
62
|
+
variantParent: string;
|
|
63
|
+
/** True when at least one parent is flex/grid/inline-flex/inline-grid. */
|
|
63
64
|
isFlexOrGridItem: boolean;
|
|
64
65
|
};
|
|
65
66
|
}
|
|
66
|
-
interface DpResult {
|
|
67
|
+
export interface DpResult {
|
|
67
68
|
entries: DpEntry[];
|
|
68
69
|
totalDiffs: number;
|
|
69
70
|
/** path strings that appear only in one side (DOM structure drift). */
|
|
@@ -81,7 +82,7 @@ interface DpResult {
|
|
|
81
82
|
count: number;
|
|
82
83
|
}>;
|
|
83
84
|
}
|
|
84
|
-
declare function diffDomPositionStyles(baseline: PositionedElement[], variant: PositionedElement[]): DpResult;
|
|
85
|
+
export declare function diffDomPositionStyles(baseline: PositionedElement[], variant: PositionedElement[]): DpResult;
|
|
85
86
|
/**
|
|
86
87
|
* Browser-side capture script: walks the DOM from `<body>`, emits
|
|
87
88
|
* `{path, tag, classes, styles}` for every element that has a class
|
|
@@ -89,12 +90,12 @@ declare function diffDomPositionStyles(baseline: PositionedElement[], variant: P
|
|
|
89
90
|
* `path` uses 0-based child indices among ALL children, so it's stable
|
|
90
91
|
* across class renames as long as the tree shape is the same.
|
|
91
92
|
*/
|
|
92
|
-
declare const DOM_POSITION_STYLES_BROWSER_SCRIPT: string;
|
|
93
|
-
declare function parseDomPositionStyles(value: unknown): PositionedElement[];
|
|
94
|
-
interface DpEntryWithViewport extends DpEntry {
|
|
93
|
+
export declare const DOM_POSITION_STYLES_BROWSER_SCRIPT: string;
|
|
94
|
+
export declare function parseDomPositionStyles(value: unknown): PositionedElement[];
|
|
95
|
+
export interface DpEntryWithViewport extends DpEntry {
|
|
95
96
|
viewport: string;
|
|
96
97
|
}
|
|
97
|
-
interface DpSample {
|
|
98
|
+
export interface DpSample {
|
|
98
99
|
viewport: string;
|
|
99
100
|
baseline: string;
|
|
100
101
|
variant: string;
|
|
@@ -102,7 +103,7 @@ interface DpSample {
|
|
|
102
103
|
baselineEm?: number;
|
|
103
104
|
variantEm?: number;
|
|
104
105
|
}
|
|
105
|
-
interface DpPerViewportResult {
|
|
106
|
+
export interface DpPerViewportResult {
|
|
106
107
|
/** All per-viewport diff tuples (entries[i] carries its viewport). */
|
|
107
108
|
entries: DpEntryWithViewport[];
|
|
108
109
|
/** Total tuples across all viewports (before any caller-side cap). */
|
|
@@ -126,7 +127,8 @@ interface DpPerViewportResult {
|
|
|
126
127
|
baselineClasses: string;
|
|
127
128
|
variantClasses: string;
|
|
128
129
|
viewports: string[];
|
|
129
|
-
samples: DpSample[];
|
|
130
|
+
samples: DpSample[];
|
|
131
|
+
/** Set on `display`-property pairs when at least one parent is flex/grid. */
|
|
130
132
|
parentDisplayContext?: {
|
|
131
133
|
baselineParent: string;
|
|
132
134
|
variantParent: string;
|
|
@@ -161,6 +163,5 @@ interface DpPerViewportResult {
|
|
|
161
163
|
* "this delta appears at every viewport" vs "this delta only appears at
|
|
162
164
|
* mobile" (the latter usually means a missing or wrong media query).
|
|
163
165
|
*/
|
|
164
|
-
declare function diffPositionStylesAcrossViewports(baselineByVp: Map<string, PositionedElement[]> | Record<string, PositionedElement[]>, variantByVp: Map<string, PositionedElement[]> | Record<string, PositionedElement[]>): DpPerViewportResult;
|
|
165
|
-
//#endregion
|
|
166
|
-
export { DOM_POSITION_STYLES_BROWSER_SCRIPT, DpEntry, DpEntryWithViewport, DpPerViewportResult, DpResult, DpSample, PositionedElement, diffDomPositionStyles, diffPositionStylesAcrossViewports, parseDomPositionStyles };
|
|
166
|
+
export declare function diffPositionStylesAcrossViewports(baselineByVp: Map<string, PositionedElement[]> | Record<string, PositionedElement[]>, variantByVp: Map<string, PositionedElement[]> | Record<string, PositionedElement[]>): DpPerViewportResult;
|
|
167
|
+
//#endregion
|
|
@@ -21,13 +21,13 @@ import { TRACKED_PROPERTIES } from "./computed-style-capture.mjs";
|
|
|
21
21
|
* to `page.evaluate()`.
|
|
22
22
|
*/
|
|
23
23
|
/** Properties for which em-normalization is informative. */
|
|
24
|
-
const EM_RELATIVE = new Set([
|
|
24
|
+
const EM_RELATIVE = /* @__PURE__ */ new Set([
|
|
25
25
|
"letter-spacing",
|
|
26
26
|
"word-spacing",
|
|
27
27
|
"line-height"
|
|
28
28
|
]);
|
|
29
29
|
/** Parent `display` values that coerce inline children to block-ish layouts. */
|
|
30
|
-
const FLEX_OR_GRID_DISPLAYS = new Set([
|
|
30
|
+
const FLEX_OR_GRID_DISPLAYS = /* @__PURE__ */ new Set([
|
|
31
31
|
"flex",
|
|
32
32
|
"inline-flex",
|
|
33
33
|
"grid",
|
|
@@ -69,7 +69,7 @@ function diffDomPositionStyles(baseline, variant) {
|
|
|
69
69
|
const b = baselineMap.get(path);
|
|
70
70
|
const v = variantMap.get(path);
|
|
71
71
|
if (b.tag !== v.tag) continue;
|
|
72
|
-
const props = new Set([...Object.keys(b.styles), ...Object.keys(v.styles)]);
|
|
72
|
+
const props = /* @__PURE__ */ new Set([...Object.keys(b.styles), ...Object.keys(v.styles)]);
|
|
73
73
|
const bFontSize = parseFontSizePx(b.styles["font-size"]);
|
|
74
74
|
const vFontSize = parseFontSizePx(v.styles["font-size"]);
|
|
75
75
|
for (const property of props) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/element-compare.d.ts
|
|
2
|
-
interface ElementCompareOptions {
|
|
2
|
+
export interface ElementCompareOptions {
|
|
3
3
|
/** CSS selectors for elements to compare */
|
|
4
4
|
selectors: string[];
|
|
5
5
|
/** Baseline HTML file path */
|
|
@@ -22,7 +22,7 @@ interface ElementCompareOptions {
|
|
|
22
22
|
/** pixelmatch threshold */
|
|
23
23
|
threshold?: number;
|
|
24
24
|
}
|
|
25
|
-
interface ElementDiffResult {
|
|
25
|
+
export interface ElementDiffResult {
|
|
26
26
|
selector: string;
|
|
27
27
|
found: {
|
|
28
28
|
baseline: boolean;
|
|
@@ -49,7 +49,7 @@ interface ElementDiffResult {
|
|
|
49
49
|
baselinePath?: string;
|
|
50
50
|
currentPath?: string;
|
|
51
51
|
}
|
|
52
|
-
interface ElementCompareReport {
|
|
52
|
+
export interface ElementCompareReport {
|
|
53
53
|
baselineSource: string;
|
|
54
54
|
currentSource: string;
|
|
55
55
|
viewport: {
|
|
@@ -61,11 +61,12 @@ interface ElementCompareReport {
|
|
|
61
61
|
total: number;
|
|
62
62
|
matched: number;
|
|
63
63
|
changed: number;
|
|
64
|
-
missing: number;
|
|
65
|
-
|
|
64
|
+
missing: number;
|
|
65
|
+
/** Full-page diff ratio (for comparison) */
|
|
66
|
+
fullPageDiffRatio?: number;
|
|
67
|
+
/** Sum of element-level diff pixels (isolates actual changes from cascading shifts) */
|
|
66
68
|
elementDiffRatio: number;
|
|
67
69
|
};
|
|
68
70
|
}
|
|
69
|
-
declare function runElementCompare(options: ElementCompareOptions): Promise<ElementCompareReport>;
|
|
70
|
-
//#endregion
|
|
71
|
-
export { ElementCompareOptions, ElementCompareReport, ElementDiffResult, runElementCompare };
|
|
71
|
+
export declare function runElementCompare(options: ElementCompareOptions): Promise<ElementCompareReport>;
|
|
72
|
+
//#endregion
|
package/dist/element-compare.mjs
CHANGED
|
@@ -112,14 +112,15 @@ async function runElementCompare(options) {
|
|
|
112
112
|
});
|
|
113
113
|
continue;
|
|
114
114
|
}
|
|
115
|
-
const
|
|
115
|
+
const snap = {
|
|
116
116
|
testId: `el-${safeSelector}`,
|
|
117
117
|
testTitle: `Element: ${selector}`,
|
|
118
118
|
projectName: "element-compare",
|
|
119
119
|
screenshotPath: currentPath,
|
|
120
120
|
baselinePath,
|
|
121
121
|
status: "changed"
|
|
122
|
-
}
|
|
122
|
+
};
|
|
123
|
+
const diff = await compareScreenshots(snap, {
|
|
123
124
|
outputDir,
|
|
124
125
|
threshold
|
|
125
126
|
});
|
package/dist/filmstrip.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { PngData } from "./png-utils.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/filmstrip.d.ts
|
|
4
|
-
interface FilmstripOptions {
|
|
3
|
+
export interface FilmstripOptions {
|
|
5
4
|
/**
|
|
6
5
|
* Cells per row. Omit for a single row (a filmstrip); set it to wrap into a
|
|
7
6
|
* grid (a contact sheet).
|
|
@@ -43,12 +42,18 @@ interface FilmstripOptions {
|
|
|
43
42
|
* enough for one would dominate a sheet of 200px cells.
|
|
44
43
|
*/
|
|
45
44
|
rowLabels?: readonly string[];
|
|
45
|
+
/**
|
|
46
|
+
* One label per cell, in input order, drawn in a band above that cell (below its row's label).
|
|
47
|
+
* For a sheet whose cells are not one instant per column — a storyboard row of one event's
|
|
48
|
+
* keyframes — each cell says its own time. Empty strings leave a cell unlabelled.
|
|
49
|
+
*/
|
|
50
|
+
cellLabels?: readonly string[];
|
|
46
51
|
/** Integer pixel size of one font unit. Default 2, i.e. 10x14 glyphs. */
|
|
47
52
|
labelScale?: number;
|
|
48
53
|
/** Label ink, RGB. Default near-white, for the default grey sheet. */
|
|
49
54
|
labelColor?: readonly [number, number, number];
|
|
50
55
|
}
|
|
51
|
-
interface FilmstripLayout {
|
|
56
|
+
export interface FilmstripLayout {
|
|
52
57
|
/**
|
|
53
58
|
* Cell box, i.e. the largest frame after scaling.
|
|
54
59
|
*
|
|
@@ -72,18 +77,26 @@ interface FilmstripLayout {
|
|
|
72
77
|
columnLabelBand: number;
|
|
73
78
|
/** Height reserved above each row for its label; 0 when there are none. */
|
|
74
79
|
rowLabelBand: number;
|
|
80
|
+
/** Height reserved above each cell for its own label; 0 when there are none. */
|
|
81
|
+
cellLabelBand: number;
|
|
75
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* The source pixel a scaled pixel `i` shows, along one axis of `srcLen` scaled to `dstLen`. In
|
|
85
|
+
* floating point, as it always was: `105 * (1440 / 175)` is 863.9999999999999, so row 105 shows
|
|
86
|
+
* source row 863, not the 864 exact arithmetic gives. `boxOnSheet` inverts this, not the ideal.
|
|
87
|
+
*/
|
|
88
|
+
export declare function sourceIndex(i: number, srcLen: number, dstLen: number): number;
|
|
76
89
|
/** Nearest-neighbour, matching `image-resize.ts`: hard edges stay legible small. */
|
|
77
90
|
/**
|
|
78
91
|
* Exported for the animated-strip path, which downscales the same frames the sheet would and must
|
|
79
92
|
* shrink them the same way — two nearest-neighbour implementations would drift on which pixel wins.
|
|
80
93
|
*/
|
|
81
|
-
declare function scalePngData(src: PngData, factor: number): PngData;
|
|
94
|
+
export declare function scalePngData(src: PngData, factor: number): PngData;
|
|
82
95
|
/**
|
|
83
96
|
* Where each frame lands. Exported so a caller can label the sheet (in Markdown,
|
|
84
97
|
* a report, a PR comment) without re-deriving the arithmetic.
|
|
85
98
|
*/
|
|
86
|
-
declare function filmstripLayout(frames: readonly PngData[], options?: FilmstripOptions): FilmstripLayout;
|
|
99
|
+
export declare function filmstripLayout(frames: readonly PngData[], options?: FilmstripOptions): FilmstripLayout;
|
|
87
100
|
/**
|
|
88
101
|
* One image containing every frame, in order.
|
|
89
102
|
*
|
|
@@ -114,8 +127,48 @@ declare function filmstripLayout(frames: readonly PngData[], options?: Filmstrip
|
|
|
114
127
|
* reader is looking for — turning visible motion into a still. Cells are sized
|
|
115
128
|
* from the largest frame so nothing is cropped.
|
|
116
129
|
*/
|
|
117
|
-
declare function composeFilmstrip(frames: readonly PngData[], options?: FilmstripOptions): PngData & {
|
|
130
|
+
export declare function composeFilmstrip(frames: readonly PngData[], options?: FilmstripOptions): PngData & {
|
|
118
131
|
layout: FilmstripLayout;
|
|
119
132
|
};
|
|
120
|
-
|
|
121
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Where a box in frame `index`'s own pixels lands on the sheet: the first and last sheet pixel,
|
|
135
|
+
* on each axis, that `scalePngData` fills from a source pixel inside the box. Nearest-neighbour
|
|
136
|
+
* skips source pixels when it shrinks, so a box can fall between two sheet pixels; it then keeps
|
|
137
|
+
* the one showing the source pixel just before it.
|
|
138
|
+
*/
|
|
139
|
+
export declare function boxOnSheet(layout: FilmstripLayout, index: number, frame: {
|
|
140
|
+
width: number;
|
|
141
|
+
height: number;
|
|
142
|
+
}, box: {
|
|
143
|
+
x: number;
|
|
144
|
+
y: number;
|
|
145
|
+
width: number;
|
|
146
|
+
height: number;
|
|
147
|
+
}): {
|
|
148
|
+
x: number;
|
|
149
|
+
y: number;
|
|
150
|
+
width: number;
|
|
151
|
+
height: number;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* A rectangle's outline drawn just OUTSIDE `box`, `thickness` px wide, never over it, so the
|
|
155
|
+
* pixels the box marks stay visible however thin it is. Nothing is drawn outside `clip`: a caller
|
|
156
|
+
* outlining a box inside a sheet cell passes the cell grown by `thickness` into the gap around it,
|
|
157
|
+
* so a box at the frame's edge keeps its outer side in the gap instead of losing it.
|
|
158
|
+
*/
|
|
159
|
+
export declare function strokeOutside(target: {
|
|
160
|
+
width: number;
|
|
161
|
+
height: number;
|
|
162
|
+
data: Uint8Array;
|
|
163
|
+
}, box: {
|
|
164
|
+
x: number;
|
|
165
|
+
y: number;
|
|
166
|
+
width: number;
|
|
167
|
+
height: number;
|
|
168
|
+
}, rgb: readonly [number, number, number], thickness: number, clip: {
|
|
169
|
+
x: number;
|
|
170
|
+
y: number;
|
|
171
|
+
width: number;
|
|
172
|
+
height: number;
|
|
173
|
+
}): void;
|
|
174
|
+
//#endregion
|
package/dist/filmstrip.mjs
CHANGED
|
@@ -12,6 +12,14 @@ const DEFAULT_LABEL_COLOR = [
|
|
|
12
12
|
];
|
|
13
13
|
/** Breathing room under a label band, so ink does not touch the frame below it. */
|
|
14
14
|
const LABEL_PAD = 3;
|
|
15
|
+
/**
|
|
16
|
+
* The source pixel a scaled pixel `i` shows, along one axis of `srcLen` scaled to `dstLen`. In
|
|
17
|
+
* floating point, as it always was: `105 * (1440 / 175)` is 863.9999999999999, so row 105 shows
|
|
18
|
+
* source row 863, not the 864 exact arithmetic gives. `boxOnSheet` inverts this, not the ideal.
|
|
19
|
+
*/
|
|
20
|
+
function sourceIndex(i, srcLen, dstLen) {
|
|
21
|
+
return Math.min(Math.floor(i * (srcLen / dstLen)), srcLen - 1);
|
|
22
|
+
}
|
|
15
23
|
/** Nearest-neighbour, matching `image-resize.ts`: hard edges stay legible small. */
|
|
16
24
|
/**
|
|
17
25
|
* Exported for the animated-strip path, which downscales the same frames the sheet would and must
|
|
@@ -22,12 +30,10 @@ function scalePngData(src, factor) {
|
|
|
22
30
|
const width = Math.max(1, Math.round(src.width / factor));
|
|
23
31
|
const height = Math.max(1, Math.round(src.height / factor));
|
|
24
32
|
const data = new Uint8Array(width * height * 4);
|
|
25
|
-
const xRatio = src.width / width;
|
|
26
|
-
const yRatio = src.height / height;
|
|
27
33
|
for (let y = 0; y < height; y++) {
|
|
28
|
-
const srcY =
|
|
34
|
+
const srcY = sourceIndex(y, src.height, height);
|
|
29
35
|
for (let x = 0; x < width; x++) {
|
|
30
|
-
const srcX =
|
|
36
|
+
const srcX = sourceIndex(x, src.width, width);
|
|
31
37
|
const si = (srcY * src.width + srcX) * 4;
|
|
32
38
|
const di = (y * width + x) * 4;
|
|
33
39
|
data[di] = src.data[si];
|
|
@@ -67,9 +73,12 @@ function filmstripLayout(frames, options = {}) {
|
|
|
67
73
|
width: Math.max(...scaled.map((s) => s.width)),
|
|
68
74
|
height: Math.max(...scaled.map((s) => s.height))
|
|
69
75
|
};
|
|
70
|
-
const
|
|
76
|
+
const labelScale = Math.max(1, Math.round(options.labelScale ?? 2));
|
|
77
|
+
const band = textHeight(labelScale) + LABEL_PAD;
|
|
71
78
|
const columnLabelBand = options.columnLabels && options.columnLabels.length > 0 ? band : 0;
|
|
72
79
|
const rowLabelBand = options.rowLabels && options.rowLabels.length > 0 ? band : 0;
|
|
80
|
+
const cellLabelBand = options.cellLabels && options.cellLabels.some((l) => l.length > 0) ? band : 0;
|
|
81
|
+
const above = rowLabelBand + cellLabelBand;
|
|
73
82
|
return {
|
|
74
83
|
cell,
|
|
75
84
|
columns,
|
|
@@ -78,12 +87,13 @@ function filmstripLayout(frames, options = {}) {
|
|
|
78
87
|
const row = Math.floor(i / columns);
|
|
79
88
|
return {
|
|
80
89
|
x: padding + i % columns * (cell.width + gap),
|
|
81
|
-
y: padding + columnLabelBand + row * (cell.height + gap +
|
|
90
|
+
y: padding + columnLabelBand + row * (cell.height + gap + above) + above
|
|
82
91
|
};
|
|
83
92
|
}),
|
|
84
93
|
scale,
|
|
85
94
|
columnLabelBand,
|
|
86
|
-
rowLabelBand
|
|
95
|
+
rowLabelBand,
|
|
96
|
+
cellLabelBand
|
|
87
97
|
};
|
|
88
98
|
}
|
|
89
99
|
/**
|
|
@@ -122,7 +132,7 @@ function composeFilmstrip(frames, options = {}) {
|
|
|
122
132
|
const padding = options.padding ?? gap;
|
|
123
133
|
const [bgR, bgG, bgB] = options.background ?? DEFAULT_BACKGROUND;
|
|
124
134
|
const width = padding * 2 + layout.columns * layout.cell.width + gap * (layout.columns - 1);
|
|
125
|
-
const height = padding * 2 + layout.columnLabelBand + layout.rows * (layout.cell.height + layout.rowLabelBand) + gap * (layout.rows - 1);
|
|
135
|
+
const height = padding * 2 + layout.columnLabelBand + layout.rows * (layout.cell.height + layout.rowLabelBand + layout.cellLabelBand) + gap * (layout.rows - 1);
|
|
126
136
|
const data = new Uint8Array(width * height * 4);
|
|
127
137
|
for (let i = 0; i < data.length; i += 4) {
|
|
128
138
|
data[i] = bgR;
|
|
@@ -166,10 +176,14 @@ function composeFilmstrip(frames, options = {}) {
|
|
|
166
176
|
if (layout.rowLabelBand > 0) {
|
|
167
177
|
const rowWidth = width - padding * 2;
|
|
168
178
|
options.rowLabels.slice(0, layout.rows).forEach((label, row) => {
|
|
169
|
-
const y = padding + layout.columnLabelBand + row * (layout.cell.height + gap + layout.rowLabelBand);
|
|
179
|
+
const y = padding + layout.columnLabelBand + row * (layout.cell.height + gap + layout.rowLabelBand + layout.cellLabelBand);
|
|
170
180
|
drawText(sheet, fitText(label, rowWidth, labelScale), padding, y, ink, labelScale);
|
|
171
181
|
});
|
|
172
182
|
}
|
|
183
|
+
if (layout.cellLabelBand > 0) options.cellLabels.slice(0, frames.length).forEach((label, index) => {
|
|
184
|
+
const { x, y } = layout.positions[index];
|
|
185
|
+
drawText(sheet, fitText(label, layout.cell.width, labelScale), x, y - layout.cellLabelBand, ink, labelScale);
|
|
186
|
+
});
|
|
173
187
|
return {
|
|
174
188
|
width,
|
|
175
189
|
height,
|
|
@@ -177,5 +191,63 @@ function composeFilmstrip(frames, options = {}) {
|
|
|
177
191
|
layout
|
|
178
192
|
};
|
|
179
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Where a box in frame `index`'s own pixels lands on the sheet: the first and last sheet pixel,
|
|
196
|
+
* on each axis, that `scalePngData` fills from a source pixel inside the box. Nearest-neighbour
|
|
197
|
+
* skips source pixels when it shrinks, so a box can fall between two sheet pixels; it then keeps
|
|
198
|
+
* the one showing the source pixel just before it.
|
|
199
|
+
*/
|
|
200
|
+
function boxOnSheet(layout, index, frame, box) {
|
|
201
|
+
const { x: ox, y: oy } = layout.positions[index];
|
|
202
|
+
const span = (start, length, srcLen) => {
|
|
203
|
+
const dstLen = Math.max(1, Math.round(srcLen / layout.scale));
|
|
204
|
+
let first = -1;
|
|
205
|
+
let last = -1;
|
|
206
|
+
let below = 0;
|
|
207
|
+
for (let i = 0; i < dstLen; i++) {
|
|
208
|
+
const src = sourceIndex(i, srcLen, dstLen);
|
|
209
|
+
if (src < start) below = i;
|
|
210
|
+
else if (src < start + length) {
|
|
211
|
+
if (first === -1) first = i;
|
|
212
|
+
last = i;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return first === -1 ? {
|
|
216
|
+
at: below,
|
|
217
|
+
length: 1
|
|
218
|
+
} : {
|
|
219
|
+
at: first,
|
|
220
|
+
length: last - first + 1
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
const x = span(box.x, box.width, frame.width);
|
|
224
|
+
const y = span(box.y, box.height, frame.height);
|
|
225
|
+
return {
|
|
226
|
+
x: ox + x.at,
|
|
227
|
+
y: oy + y.at,
|
|
228
|
+
width: x.length,
|
|
229
|
+
height: y.length
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* A rectangle's outline drawn just OUTSIDE `box`, `thickness` px wide, never over it, so the
|
|
234
|
+
* pixels the box marks stay visible however thin it is. Nothing is drawn outside `clip`: a caller
|
|
235
|
+
* outlining a box inside a sheet cell passes the cell grown by `thickness` into the gap around it,
|
|
236
|
+
* so a box at the frame's edge keeps its outer side in the gap instead of losing it.
|
|
237
|
+
*/
|
|
238
|
+
function strokeOutside(target, box, rgb, thickness, clip) {
|
|
239
|
+
const x0 = Math.max(0, clip.x, box.x - thickness);
|
|
240
|
+
const y0 = Math.max(0, clip.y, box.y - thickness);
|
|
241
|
+
const x1 = Math.min(target.width - 1, clip.x + clip.width - 1, box.x + box.width - 1 + thickness);
|
|
242
|
+
const y1 = Math.min(target.height - 1, clip.y + clip.height - 1, box.y + box.height - 1 + thickness);
|
|
243
|
+
for (let y = y0; y <= y1; y++) for (let x = x0; x <= x1; x++) {
|
|
244
|
+
if (x >= box.x && x < box.x + box.width && y >= box.y && y < box.y + box.height) continue;
|
|
245
|
+
const i = (y * target.width + x) * 4;
|
|
246
|
+
target.data[i] = rgb[0];
|
|
247
|
+
target.data[i + 1] = rgb[1];
|
|
248
|
+
target.data[i + 2] = rgb[2];
|
|
249
|
+
target.data[i + 3] = 255;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
180
252
|
//#endregion
|
|
181
|
-
export { composeFilmstrip, filmstripLayout, scalePngData };
|
|
253
|
+
export { boxOnSheet, composeFilmstrip, filmstripLayout, scalePngData, sourceIndex, strokeOutside };
|