@mizchi/vlmkit-animation-eval 0.22.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 mizchi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # @mizchi/vlmkit-animation-eval
2
+
3
+ Frame-sampled animation evaluation for a web page. Every Web Animation on the
4
+ page is paused and seeked through deterministic sample points; each sample is
5
+ screenshotted and compared, and the report says whether the animation moves
6
+ any pixels at all, when the page settles, whether `prefers-reduced-motion`
7
+ is honoured behaviourally, and whether something outside the Web Animations
8
+ API (rAF, video, GIF) is moving the page on its own.
9
+
10
+ It is the measurement behind two commands that live in different tools:
11
+
12
+ - `vlmkit check animation page.html` — the gate, with rule settings, `--json`,
13
+ `--strip` filmstrips and the run ledger (package `@mizchi/vlmkit-markup`).
14
+ - `vlmkit-anim eval page.html` — the same report from the animation authoring
15
+ tool, on the pages it emits (package `@mizchi/vlmkit-anim`).
16
+
17
+ ```ts
18
+ import { runAnimationEval, formatAnimationEvalReport } from "@mizchi/vlmkit-animation-eval";
19
+
20
+ const report = await runAnimationEval({ source: "page.html", samples: 4 });
21
+ console.log(formatAnimationEvalReport(report));
22
+ report.issues; // [{ kind: "no-visible-effect" | "infinite-animation" | "reduced-motion-ignored" | "long-settle" | "uncontrolled-motion", severity, message, selector? }]
23
+ ```
24
+
25
+ `playwright` is a required peer: the whole job is driving a browser. Depends
26
+ on `@mizchi/vlmkit-core` for page loading, browser launch and PNG utilities,
27
+ and on nothing else in the workspace.
@@ -0,0 +1,242 @@
1
+ import { PageLoadOptions } from "@mizchi/vlmkit-core/page-load.ts";
2
+ import { RuleView } from "@mizchi/vlmkit-core/plugin/contract.ts";
3
+
4
+ //#region src/animation-eval.d.ts
5
+ interface AnimationTimingSample {
6
+ /** Index into the page's animation list at capture time. */
7
+ index: number;
8
+ /** Best-effort stable selector of the animation's effect target. */
9
+ selector: string;
10
+ type: "css-animation" | "css-transition" | "waapi";
11
+ /** animation-name / transition-property / WAAPI id (best effort). */
12
+ name: string;
13
+ durationMs: number;
14
+ delayMs: number;
15
+ /** null = infinite. */
16
+ iterations: number | null;
17
+ /** Play state as found on the page, captured BEFORE the evaluator pauses it. */
18
+ playState: string;
19
+ /** currentTime as found on the page (ms), captured before pausing. */
20
+ currentTimeMs: number;
21
+ /** animation-direction: normal / reverse / alternate / alternate-reverse. */
22
+ direction: string;
23
+ /**
24
+ * Keyframes end where they start (first and last keyframes equal, with a
25
+ * differing keyframe in between) — one iteration is a full out-and-back
26
+ * sweep even without `alternate`.
27
+ */
28
+ palindromic: boolean;
29
+ }
30
+ interface OscillationInfo {
31
+ /** The animation sweeps out and back rather than jumping to restart. */
32
+ oscillating: boolean;
33
+ /** Duration of one visual leg (one extreme to the other), in ms. */
34
+ legMs: number;
35
+ }
36
+ /**
37
+ * Effective oscillation of one animation. WAAPI folds both `alternate`
38
+ * iterations and palindromic keyframes (0% -> 50% -> 100% retracing) into
39
+ * the same `durationMs xN` shape, so two implementations of "pulse forever"
40
+ * can differ 2x in visual frequency while reporting identical duration —
41
+ * the S5 blind spot (motion brief said "1.2s per leg"; a palindromic 1.2s
42
+ * cycle passed the gate at double speed). `alternate` spends one full
43
+ * iteration per leg; palindromic keyframes complete out-and-back within a
44
+ * single iteration, so each leg is half the duration.
45
+ */
46
+ declare function computeOscillation(t: Pick<AnimationTimingSample, "durationMs" | "direction" | "palindromic">): OscillationInfo;
47
+ interface FrameDeltaStat {
48
+ changedPixels: number;
49
+ /** changedPixels / total pixels. */
50
+ ratio: number;
51
+ /** Bounding box of changed pixels; null when nothing changed. */
52
+ bbox: {
53
+ x: number;
54
+ y: number;
55
+ width: number;
56
+ height: number;
57
+ } | null;
58
+ }
59
+ interface AnimationFrameStat extends FrameDeltaStat {
60
+ /** Sampled progress through one iteration (0..1]. */
61
+ fraction: number;
62
+ }
63
+ interface EvaluatedAnimation extends AnimationTimingSample {
64
+ frames: AnimationFrameStat[];
65
+ /** Any sampled interval moved at least minChangedPixels pixels. */
66
+ visible: boolean;
67
+ /** Union of all frame bboxes; null when the animation never moved. */
68
+ motionBbox: {
69
+ x: number;
70
+ y: number;
71
+ width: number;
72
+ height: number;
73
+ } | null;
74
+ totalChangedPixels: number;
75
+ maxFrameRatio: number;
76
+ }
77
+ interface ReducedMotionRemaining {
78
+ selector: string;
79
+ name: string;
80
+ durationMs: number;
81
+ }
82
+ type AnimationEvalIssueKind = "no-visible-effect" | "infinite-animation" | "reduced-motion-ignored" | "long-settle" | "uncontrolled-motion";
83
+ interface AnimationEvalIssue {
84
+ kind: AnimationEvalIssueKind;
85
+ severity: "warn" | "suspect";
86
+ message: string;
87
+ selector?: string;
88
+ }
89
+ interface AnimationEvalReport {
90
+ source: string;
91
+ viewport: {
92
+ width: number;
93
+ height: number;
94
+ };
95
+ animationCount: number;
96
+ evaluated: EvaluatedAnimation[];
97
+ /** Max over finite animations of delay + duration × iterations; null when an infinite animation is present. */
98
+ settleMs: number | null;
99
+ infinite: {
100
+ selector: string;
101
+ name: string;
102
+ }[];
103
+ /** Present unless the reduced-motion pass was skipped or there were no animations. */
104
+ reducedMotion?: {
105
+ remainingCount: number;
106
+ remaining: ReducedMotionRemaining[];
107
+ };
108
+ /**
109
+ * Pixel delta between two back-to-back rest captures with every WAAPI
110
+ * animation held still. Present (nonzero) means a motion source the Web
111
+ * Animations API cannot enumerate or pause — a rAF/JS-driven animation,
112
+ * video, or GIF — is moving the page on its own.
113
+ */
114
+ uncontrolledMotion?: FrameDeltaStat;
115
+ issues: AnimationEvalIssue[];
116
+ /** Written sample frames (when --frames was passed). */
117
+ framePaths?: string[];
118
+ /** Written when `stripPath` was given: one image holding every sampled frame. */
119
+ strip?: {
120
+ path: string;
121
+ columns: number;
122
+ rows: number; /** Evaluated animations left out because they moved no pixels. */
123
+ omitted: number; /** Evaluated animations left out because `--strip-selector` did not match them. */
124
+ outOfScope: number; /** Page-timeline span the columns cover, in ms. */
125
+ windowMs: number; /** The instant each column was taken at, in ms from the animations' start. */
126
+ times: number[]; /** Row order, top to bottom. Empty for an animated strip, which has no rows. */
127
+ rowSelectors: string[];
128
+ width: number;
129
+ height: number; /** True when this is an animated PNG of the whole page rather than a cropped still sheet. */
130
+ animated?: boolean;
131
+ };
132
+ }
133
+ interface AnimationEvalOptions extends PageLoadOptions {
134
+ source: string;
135
+ html?: string;
136
+ viewport?: {
137
+ width: number;
138
+ height: number;
139
+ };
140
+ /** Sample points per animation iteration (default 4 → 25/50/75/100%). */
141
+ samples?: number;
142
+ /** Max animations to evaluate frame-by-frame (default 8). */
143
+ maxAnimations?: number;
144
+ /** Per-channel tolerance when diffing frames (default 8). */
145
+ tolerance?: number;
146
+ /** Pixel floor below which an animation counts as visually dead (default 12). */
147
+ minChangedPixels?: number;
148
+ /** settleMs above this raises `long-settle` (default 3000). */
149
+ settleThresholdMs?: number;
150
+ /** Duration floor for "still animating" under reduced-motion emulation (default 100ms). */
151
+ reducedMotionDurationFloorMs?: number;
152
+ /** Skip the reduced-motion emulation pass. */
153
+ skipReducedMotion?: boolean;
154
+ /** Write each sampled frame PNG into this directory. */
155
+ framesDir?: string;
156
+ /**
157
+ * Composite every sampled frame into ONE image at this path, one row per
158
+ * animation. `--frames` writes N files a reader has to open in order; this
159
+ * writes the sequence a reader (or a model, which cannot press play) can take
160
+ * in at a glance.
161
+ */
162
+ stripPath?: string;
163
+ /** Cap the strip's width, downscaling frames to fit. Default 1600. */
164
+ stripMaxWidth?: number;
165
+ /**
166
+ * Write `stripPath` as an animated PNG of the whole page instead of a cropped still sheet.
167
+ *
168
+ * A different artifact for a different reader, not a better one. The still sheet crops each
169
+ * animation to its motion bbox, which is what makes a small element legible — and is exactly
170
+ * why a dogfood reviewer could not tell that three cards sit side by side ("each row reads as
171
+ * one column in 3 states"). The animated version keeps the page's real arrangement and pays for
172
+ * it in element size, so both stay available.
173
+ */
174
+ stripAnimated?: boolean;
175
+ /**
176
+ * Page-timeline span the strip's columns cover, in ms. Defaults to when the last
177
+ * finite animation ends, so the columns cover the part someone is reviewing rather
178
+ * than an infinite animation's period.
179
+ */
180
+ stripWindowMs?: number;
181
+ /**
182
+ * Restrict the strip's rows to animations whose target matches this CSS selector.
183
+ * The gate still evaluates and reports every animation; this only scopes the image.
184
+ */
185
+ stripSelector?: string;
186
+ }
187
+ interface RgbaFrame {
188
+ width: number;
189
+ height: number;
190
+ data: Uint8Array;
191
+ }
192
+ /**
193
+ * Pixel delta between two same-size RGBA frames: count, ratio, and the
194
+ * bounding box of every pixel whose any channel moved more than tolerance.
195
+ */
196
+ declare function frameDelta(a: RgbaFrame, b: RgbaFrame, tolerance?: number): FrameDeltaStat;
197
+ /**
198
+ * Rest-pose time for an animation: page-paused/finished animations stay at
199
+ * their author-chosen currentTime (their true resting appearance); running
200
+ * finite animations seek past their end (settled appearance); running
201
+ * infinite ones hold at 0.
202
+ */
203
+ declare function restTimeForAnimation(t: AnimationTimingSample): number;
204
+ declare function unionBbox(a: {
205
+ x: number;
206
+ y: number;
207
+ width: number;
208
+ height: number;
209
+ } | null, b: {
210
+ x: number;
211
+ y: number;
212
+ width: number;
213
+ height: number;
214
+ } | null): {
215
+ x: number;
216
+ y: number;
217
+ width: number;
218
+ height: number;
219
+ } | null;
220
+ /** Max over finite animations of delay + duration × iterations; null when any animation is infinite. */
221
+ declare function computeSettleMs(animations: AnimationTimingSample[]): number | null;
222
+ interface DeriveIssuesInput {
223
+ evaluated: EvaluatedAnimation[];
224
+ settleMs: number | null;
225
+ infinite: {
226
+ selector: string;
227
+ name: string;
228
+ }[];
229
+ reducedMotion?: {
230
+ remainingCount: number;
231
+ remaining: ReducedMotionRemaining[];
232
+ };
233
+ uncontrolledMotion?: FrameDeltaStat;
234
+ }
235
+ declare function deriveAnimationIssues(input: DeriveIssuesInput, options?: {
236
+ settleThresholdMs?: number;
237
+ reducedMotionDurationFloorMs?: number;
238
+ }): AnimationEvalIssue[];
239
+ declare function runAnimationEval(options: AnimationEvalOptions): Promise<AnimationEvalReport>;
240
+ declare function formatAnimationEvalReport(report: AnimationEvalReport, rules?: RuleView): string;
241
+ //#endregion
242
+ export { AnimationEvalIssue, AnimationEvalIssueKind, AnimationEvalOptions, AnimationEvalReport, AnimationFrameStat, AnimationTimingSample, DeriveIssuesInput, EvaluatedAnimation, FrameDeltaStat, OscillationInfo, ReducedMotionRemaining, computeOscillation, computeSettleMs, deriveAnimationIssues, formatAnimationEvalReport, frameDelta, restTimeForAnimation, runAnimationEval, unionBbox };
@@ -0,0 +1,638 @@
1
+ #!/usr/bin/env node
2
+ import { mkdir, writeFile } from "node:fs/promises";
3
+ import { STABLE_SELECTOR_JS } from "@mizchi/vlmkit-core/stable-selector.ts";
4
+ import { dirname, join, resolve } from "node:path";
5
+ import { PNG } from "pngjs";
6
+ import { BOLD, CYAN, DIM, GREEN, RED, RESET, YELLOW } from "@mizchi/vlmkit-core/terminal-colors.ts";
7
+ import { retuneNote, tierIssues } from "@mizchi/vlmkit-core/plugin/rule-prose.ts";
8
+ import { navigatePage, navigationOptions } from "@mizchi/vlmkit-core/page-load.ts";
9
+ import { withBrowser } from "@mizchi/vlmkit-core/browser-launch.ts";
10
+ import { UsageError } from "@mizchi/vlmkit-core/cli-error.ts";
11
+ import { composeFilmstrip, scalePngData } from "@mizchi/vlmkit-core/filmstrip.ts";
12
+ import { encodeApng } from "@mizchi/vlmkit-core/apng.ts";
13
+ import { cropRegion, encodePng } from "@mizchi/vlmkit-core/png-utils.ts";
14
+ import { encodeWebp, imageFormatForPath } from "@mizchi/vlmkit-core/webp.ts";
15
+ import { sourceToUrl } from "@mizchi/vlmkit-core/page-open.ts";
16
+ //#region src/animation-eval.ts
17
+ /**
18
+ * Frame-sampled animation evaluator.
19
+ *
20
+ * The behavioral complement of `check motion` (which only scans CSSOM
21
+ * declarations): this drives every animation on the page through a set of
22
+ * deterministic sample points via the Web Animations API — pause, seek
23
+ * `currentTime`, screenshot — and evaluates the *rendered* result:
24
+ *
25
+ * - does the animation visibly change pixels at all (dead animations:
26
+ * declared but no visual effect)?
27
+ * - motion region bbox + per-interval pixel magnitude
28
+ * - settle time (when does the page stop moving) and infinite
29
+ * animations that never settle — the VRT-determinism killers,
30
+ * reported with a ready-to-use `--mask` selector
31
+ * - `prefers-reduced-motion: reduce` honored *behaviorally* (emulated
32
+ * re-render, not a CSS-text regex)
33
+ *
34
+ * Seeking a paused timeline instead of racing the wall clock keeps every
35
+ * frame reproducible. Pixels + Playwright only, no VLM.
36
+ *
37
+ * Hover/focus-triggered transitions are out of scope here — `check motion`
38
+ * reports their declarations, `inspect interact` exercises them.
39
+ *
40
+ * Usage:
41
+ * vlmkit check animation <html-or-url>
42
+ * vlmkit check animation <html-or-url> --json --frames out/frames
43
+ * vlmkit-anim eval <page.html> (the same report from the animation tool)
44
+ *
45
+ * Lives in its own package (`@mizchi/vlmkit-animation-eval`) so the animation
46
+ * authoring tool can depend on the measurement without the rest of vlmkit.
47
+ */
48
+ /**
49
+ * Effective oscillation of one animation. WAAPI folds both `alternate`
50
+ * iterations and palindromic keyframes (0% -> 50% -> 100% retracing) into
51
+ * the same `durationMs xN` shape, so two implementations of "pulse forever"
52
+ * can differ 2x in visual frequency while reporting identical duration —
53
+ * the S5 blind spot (motion brief said "1.2s per leg"; a palindromic 1.2s
54
+ * cycle passed the gate at double speed). `alternate` spends one full
55
+ * iteration per leg; palindromic keyframes complete out-and-back within a
56
+ * single iteration, so each leg is half the duration.
57
+ */
58
+ function computeOscillation(t) {
59
+ if (t.direction.startsWith("alternate")) return {
60
+ oscillating: true,
61
+ legMs: t.durationMs
62
+ };
63
+ if (t.palindromic) return {
64
+ oscillating: true,
65
+ legMs: t.durationMs / 2
66
+ };
67
+ return {
68
+ oscillating: false,
69
+ legMs: t.durationMs
70
+ };
71
+ }
72
+ /**
73
+ * Pixel delta between two same-size RGBA frames: count, ratio, and the
74
+ * bounding box of every pixel whose any channel moved more than tolerance.
75
+ */
76
+ function frameDelta(a, b, tolerance = 8) {
77
+ if (a.width !== b.width || a.height !== b.height) throw new Error(`frameDelta: size mismatch ${a.width}x${a.height} vs ${b.width}x${b.height}`);
78
+ let changed = 0;
79
+ let minX = a.width, minY = a.height, maxX = -1, maxY = -1;
80
+ for (let y = 0; y < a.height; y++) for (let x = 0; x < a.width; x++) {
81
+ const i = (y * a.width + x) * 4;
82
+ if (Math.abs(a.data[i] - b.data[i]) > tolerance || Math.abs(a.data[i + 1] - b.data[i + 1]) > tolerance || Math.abs(a.data[i + 2] - b.data[i + 2]) > tolerance) {
83
+ changed++;
84
+ if (x < minX) minX = x;
85
+ if (x > maxX) maxX = x;
86
+ if (y < minY) minY = y;
87
+ if (y > maxY) maxY = y;
88
+ }
89
+ }
90
+ const total = a.width * a.height;
91
+ return {
92
+ changedPixels: changed,
93
+ ratio: total > 0 ? changed / total : 0,
94
+ bbox: changed > 0 ? {
95
+ x: minX,
96
+ y: minY,
97
+ width: maxX - minX + 1,
98
+ height: maxY - minY + 1
99
+ } : null
100
+ };
101
+ }
102
+ /**
103
+ * Rest-pose time for an animation: page-paused/finished animations stay at
104
+ * their author-chosen currentTime (their true resting appearance); running
105
+ * finite animations seek past their end (settled appearance); running
106
+ * infinite ones hold at 0.
107
+ */
108
+ function restTimeForAnimation(t) {
109
+ if (t.playState !== "running") return t.currentTimeMs;
110
+ return t.iterations === null ? 0 : t.delayMs + t.durationMs * t.iterations;
111
+ }
112
+ function unionBbox(a, b) {
113
+ if (!a) return b;
114
+ if (!b) return a;
115
+ const x = Math.min(a.x, b.x);
116
+ const y = Math.min(a.y, b.y);
117
+ return {
118
+ x,
119
+ y,
120
+ width: Math.max(a.x + a.width, b.x + b.width) - x,
121
+ height: Math.max(a.y + a.height, b.y + b.height) - y
122
+ };
123
+ }
124
+ /** Max over finite animations of delay + duration × iterations; null when any animation is infinite. */
125
+ function computeSettleMs(animations) {
126
+ let settle = 0;
127
+ for (const anim of animations) {
128
+ if (anim.iterations === null) return null;
129
+ settle = Math.max(settle, anim.delayMs + anim.durationMs * anim.iterations);
130
+ }
131
+ return settle;
132
+ }
133
+ function deriveAnimationIssues(input, options = {}) {
134
+ const settleThreshold = options.settleThresholdMs ?? 3e3;
135
+ const durationFloor = options.reducedMotionDurationFloorMs ?? 100;
136
+ const issues = [];
137
+ for (const anim of input.evaluated) if (!anim.visible) issues.push({
138
+ kind: "no-visible-effect",
139
+ severity: "suspect",
140
+ selector: anim.selector,
141
+ message: `${anim.selector} animation \`${anim.name}\` (${anim.durationMs}ms) produced no visible pixel change at any sampled frame — dead animation or animated property has no rendered effect.`
142
+ });
143
+ for (const anim of input.infinite) issues.push({
144
+ kind: "infinite-animation",
145
+ severity: "warn",
146
+ selector: anim.selector,
147
+ message: `${anim.selector} animation \`${anim.name}\` runs forever — the page never settles. To fix the page, give it a bounded \`animation-iteration-count\` (or stop it once its work is done). If it is meant to run forever, the capture side has to absorb it instead: mask it with \`vlmkit snapshot <url> --mask "${anim.selector}"\` (that flag belongs to \`snapshot\` / \`diff html\`, not to this gate) or pause animations before screenshots.`
148
+ });
149
+ if (input.settleMs !== null && input.settleMs > settleThreshold) issues.push({
150
+ kind: "long-settle",
151
+ severity: "warn",
152
+ message: `Page keeps animating for ${Math.round(input.settleMs)}ms after load (threshold ${settleThreshold}ms) — captures inside this window are nondeterministic.`
153
+ });
154
+ if (input.uncontrolledMotion) {
155
+ const m = input.uncontrolledMotion;
156
+ const where = m.bbox ? ` at (${m.bbox.x},${m.bbox.y}) ${m.bbox.width}x${m.bbox.height}` : "";
157
+ issues.push({
158
+ kind: "uncontrolled-motion",
159
+ severity: "warn",
160
+ message: `The page moved between two back-to-back captures with every WAAPI animation held still (${m.changedPixels}px${where}) — a rAF/JS-driven animation, video, or GIF the Web Animations API cannot enumerate or pause. Per-animation frame deltas overlapping this region may be contaminated (a dead animation can read as visible), the page never settles for VRT, and reduced-motion emulation does not affect it. Mask the region or stub the ticker for capture.`
161
+ });
162
+ }
163
+ if (input.reducedMotion && input.reducedMotion.remainingCount > 0) {
164
+ const sample = input.reducedMotion.remaining[0];
165
+ issues.push({
166
+ kind: "reduced-motion-ignored",
167
+ severity: "suspect",
168
+ ...sample ? { selector: sample.selector } : {},
169
+ message: `${input.reducedMotion.remainingCount} animation(s) still run under \`prefers-reduced-motion: reduce\` emulation: ${input.reducedMotion.remaining.slice(0, 4).map((r) => `${r.selector} \`${r.name}\` ${Math.round(r.durationMs)}ms`).join(", ")}${input.reducedMotion.remaining.length > 4 ? `, and ${input.reducedMotion.remaining.length - 4} more` : ""} — motion is not reduced for users who requested it. Add \`@media (prefers-reduced-motion: reduce)\` and either set \`animation: none\` on them or shorten each duration below ${durationFloor}ms.`
170
+ });
171
+ }
172
+ return issues;
173
+ }
174
+ /**
175
+ * Shared browser-side helpers. Kept as one string used by both scripts below,
176
+ * because a recorded animation and a live one must be described identically or
177
+ * the dedupe between them silently fails.
178
+ */
179
+ const ANIMATION_HELPERS_JS = `
180
+ ${STABLE_SELECTOR_JS}
181
+
182
+ function describeTiming(anim) {
183
+ let timing = { duration: 0, delay: 0, iterations: 1, direction: "normal" };
184
+ try {
185
+ const computed = anim.effect && anim.effect.getComputedTiming ? anim.effect.getComputedTiming() : null;
186
+ if (computed) {
187
+ timing = {
188
+ duration: typeof computed.duration === "number" ? computed.duration : 0,
189
+ delay: computed.delay || 0,
190
+ iterations: computed.iterations,
191
+ direction: computed.direction || "normal",
192
+ };
193
+ }
194
+ } catch {}
195
+ return timing;
196
+ }
197
+
198
+ // Palindrome detection: the first and last keyframes agree on every
199
+ // animated property while some keyframe in between differs — one
200
+ // iteration visually sweeps out and back (same effective motion as
201
+ // alternate, at twice the frequency).
202
+ function isPalindromic(anim) {
203
+ try {
204
+ const keyframes = anim.effect && anim.effect.getKeyframes ? anim.effect.getKeyframes() : [];
205
+ if (keyframes.length < 3) return false;
206
+ const skip = new Set(["offset", "computedOffset", "easing", "composite"]);
207
+ const first = keyframes[0];
208
+ const last = keyframes[keyframes.length - 1];
209
+ const props = Object.keys(first).filter((k) => !skip.has(k));
210
+ return props.length > 0
211
+ && props.every((k) => k in last && String(first[k]) === String(last[k]))
212
+ && keyframes.slice(1, -1).some((mid) =>
213
+ props.some((k) => k in mid && String(mid[k]) !== String(first[k]))
214
+ );
215
+ } catch {}
216
+ return false;
217
+ }
218
+
219
+ function animationKind(anim) {
220
+ const ctor = anim.constructor ? anim.constructor.name : "";
221
+ return ctor === "CSSAnimation" ? "css-animation" : ctor === "CSSTransition" ? "css-transition" : "waapi";
222
+ }
223
+
224
+ function animationName(anim) {
225
+ return anim.animationName || anim.transitionProperty || anim.id || "(anonymous)";
226
+ }
227
+ `;
228
+ /**
229
+ * Record every animation as it STARTS, before the page's own scripts run.
230
+ *
231
+ * `document.getAnimations()` only reports animations that still exist, and a
232
+ * finished CSS animation with no `fill` mode — `animation: fadeIn 0.3s ease-out`,
233
+ * the ordinary spelling for an entrance animation — is removed outright. Watched
234
+ * on this repo's own `fixtures/css-challenge/dashboard.html` (four `.stat-card`
235
+ * fade-ins, 300ms, delays to 150ms), polling from navigation start:
236
+ *
237
+ * 47ms:4 151ms:4 255ms:4 358ms:3 462ms:1 564ms:0 668ms:0 771ms:0
238
+ *
239
+ * The collector runs at ~765ms, so it saw **zero animations** on a page with
240
+ * four, and reported `animationCount 0`, `settle 0ms` and no reduced-motion
241
+ * finding. `fill: forwards` stayed at 1 for the whole window, which is why the
242
+ * defect hid: every fixture written to test this gate used `forwards`.
243
+ *
244
+ * `animationstart` fires once per animation per iteration-zero and bubbles to
245
+ * the document, and the Animation object is alive when it does — so the timing
246
+ * can be read then and survives the object's removal. Animations still live at
247
+ * collection time are deduped against these records by (selector, name).
248
+ */
249
+ const RECORD_ANIMATION_STARTS_SCRIPT = `(() => {
250
+ ${ANIMATION_HELPERS_JS}
251
+ const started = [];
252
+ window.__vlmkitStarted = started;
253
+ // Held here as well as recorded. A finite animation is otherwise gone from
254
+ // document.getAnimations() by the time the evaluator looks, and a record alone
255
+ // cannot be seeked -- so the strip showed one animation of five, and the four it
256
+ // dropped were the ones under review. Pausing at the start keeps every animation
257
+ // alive and seekable; the author's own play state is read BEFORE the pause, which
258
+ // is what keeps "the page paused this" distinguishable from "we paused it".
259
+ window.__vlmkitHeld = [];
260
+ const record = (event) => {
261
+ const target = event.target;
262
+ if (!target || !target.getAnimations) return;
263
+ for (const anim of target.getAnimations()) {
264
+ const name = animationName(anim);
265
+ if (event.animationName !== undefined && name !== event.animationName) continue;
266
+ const timing = describeTiming(anim);
267
+ const authorPlayState = anim.playState;
268
+ started.push({
269
+ selector: stableSelector(anim.effect && anim.effect.target ? anim.effect.target : target),
270
+ type: animationKind(anim),
271
+ name,
272
+ durationMs: timing.duration,
273
+ delayMs: timing.delay,
274
+ iterations: Number.isFinite(timing.iterations) ? timing.iterations : null,
275
+ direction: timing.direction || "normal",
276
+ palindromic: isPalindromic(anim),
277
+ authorPlayState,
278
+ });
279
+ window.__vlmkitHeld.push(anim);
280
+ anim.pause();
281
+ return;
282
+ }
283
+ };
284
+ document.addEventListener("animationstart", record, true);
285
+ document.addEventListener("transitionstart", record, true);
286
+ })()`;
287
+ const COLLECT_ANIMATIONS_SCRIPT = `(() => {
288
+ ${ANIMATION_HELPERS_JS}
289
+ const anims = document.getAnimations ? document.getAnimations({ subtree: true }) : [];
290
+ window.__vlmkitAnims = anims;
291
+ return anims.map((anim, index) => {
292
+ const timing = describeTiming(anim);
293
+ const palindromic = isPalindromic(anim);
294
+ const type = animationKind(anim);
295
+ const name = animationName(anim);
296
+ const target = anim.effect && anim.effect.target ? anim.effect.target : null;
297
+ // Record the author-visible state BEFORE pausing for evaluation — an
298
+ // animation the page itself holds paused is visually static and must
299
+ // not be reported as running/never-settling.
300
+ //
301
+ // The init script may already have paused this one at animationstart, in which
302
+ // case the live playState is ours and useless. It stashed the author's state
303
+ // alongside; prefer that. Without this every animation would read "paused" and
304
+ // the settle / never-settles / reduced-motion answers would all invert.
305
+ const held = (window.__vlmkitStarted || []).find((r) =>
306
+ r.name === name && r.selector === stableSelector(target));
307
+ const playState = held ? held.authorPlayState : anim.playState;
308
+ const currentTimeMs = typeof anim.currentTime === "number" ? anim.currentTime : 0;
309
+ anim.pause();
310
+ return {
311
+ index,
312
+ selector: stableSelector(target),
313
+ type,
314
+ name,
315
+ durationMs: timing.duration,
316
+ delayMs: timing.delay,
317
+ iterations: Number.isFinite(timing.iterations) ? timing.iterations : null,
318
+ playState,
319
+ currentTimeMs,
320
+ direction: timing.direction || "normal",
321
+ palindromic,
322
+ };
323
+ });
324
+ })()`;
325
+ function pngFromBuffer(buffer) {
326
+ const png = PNG.sync.read(buffer);
327
+ return {
328
+ width: png.width,
329
+ height: png.height,
330
+ data: new Uint8Array(png.data.buffer, png.data.byteOffset, png.data.byteLength)
331
+ };
332
+ }
333
+ /**
334
+ * Every animation the page ran: the ones still live at this instant, plus the ones
335
+ * that started and were already removed.
336
+ *
337
+ * A recorded-but-gone animation gets `index: -1` — there is no `Animation` object
338
+ * left to seek, so it cannot be frame-sampled — and `playState: "finished"`,
339
+ * which is what it is. It still counts for `animationCount`, `settleMs`,
340
+ * `infinite` and the reduced-motion verdict, all of which are questions about
341
+ * what the page did rather than about what it is doing right now.
342
+ *
343
+ * Deduped on (selector, name): the same animation appears in both sets when it is
344
+ * long enough to still be running, and `animationstart` also fires for each
345
+ * animation of a multi-name shorthand.
346
+ */
347
+ async function collectAnimations(page) {
348
+ const live = await page.evaluate(COLLECT_ANIMATIONS_SCRIPT);
349
+ const started = await page.evaluate("window.__vlmkitStarted || []");
350
+ const seen = new Set(live.map((t) => `${t.selector}\u0000${t.name}`));
351
+ const finished = [];
352
+ for (const record of started) {
353
+ const key = `${record.selector}\u0000${record.name}`;
354
+ if (seen.has(key)) continue;
355
+ seen.add(key);
356
+ finished.push({
357
+ ...record,
358
+ index: -1,
359
+ playState: "finished",
360
+ currentTimeMs: record.delayMs + record.durationMs * (record.iterations ?? 1)
361
+ });
362
+ }
363
+ return [...live, ...finished];
364
+ }
365
+ async function runAnimationEval(options) {
366
+ const viewport = options.viewport ?? {
367
+ width: 1280,
368
+ height: 720
369
+ };
370
+ const samples = Math.max(1, options.samples ?? 4);
371
+ const maxAnimations = options.maxAnimations ?? 8;
372
+ const tolerance = options.tolerance ?? 8;
373
+ const minChangedPixels = options.minChangedPixels ?? 12;
374
+ const pageUrl = options.html !== void 0 ? void 0 : sourceToUrl(options.source);
375
+ const loadPage = async (p) => {
376
+ await p.addInitScript(RECORD_ANIMATION_STARTS_SCRIPT);
377
+ if (options.html !== void 0) await p.setContent(options.html, navigationOptions(options));
378
+ else await navigatePage(p, pageUrl, options);
379
+ };
380
+ return await withBrowser(async (browser) => {
381
+ const page = await browser.newPage({ viewport });
382
+ await loadPage(page);
383
+ const timings = await collectAnimations(page);
384
+ const selfDriven = timings.filter((t) => t.playState !== "paused" && t.playState !== "idle");
385
+ const settleMs = computeSettleMs(selfDriven);
386
+ const infinite = selfDriven.filter((t) => t.iterations === null).map((t) => ({
387
+ selector: t.selector,
388
+ name: t.name
389
+ }));
390
+ const seek = async (index, timeMs) => {
391
+ await page.evaluate(([i, t]) => {
392
+ const anim = window.__vlmkitAnims?.[i];
393
+ if (anim) anim.currentTime = t;
394
+ }, [index, timeMs]);
395
+ };
396
+ const framePaths = [];
397
+ if (options.framesDir) await mkdir(options.framesDir, { recursive: true });
398
+ const shot = async (label) => {
399
+ const buffer = await page.screenshot({ animations: "allow" });
400
+ if (options.framesDir) {
401
+ const path = join(options.framesDir, `${label}.png`);
402
+ await writeFile(path, buffer);
403
+ framePaths.push(path);
404
+ }
405
+ return pngFromBuffer(buffer);
406
+ };
407
+ for (const t of timings) if (t.index >= 0) await seek(t.index, restTimeForAnimation(t));
408
+ const evaluable = timings.filter((t) => t.index >= 0 && t.durationMs > 0).slice(0, maxAnimations);
409
+ const restProbe = await shot("rest");
410
+ const baseline = await shot("rest-recheck");
411
+ const restDelta = frameDelta(restProbe, baseline, tolerance);
412
+ const uncontrolledMotion = restDelta.changedPixels >= minChangedPixels ? restDelta : void 0;
413
+ const evaluated = [];
414
+ const stripRows = [];
415
+ for (const timing of evaluable) {
416
+ const frames = [];
417
+ const rowFrames = [];
418
+ let previous = baseline;
419
+ let motionBbox = null;
420
+ let totalChangedPixels = 0;
421
+ let maxFrameRatio = 0;
422
+ for (let s = 1; s <= samples; s++) {
423
+ const fraction = s / samples;
424
+ const timeMs = timing.delayMs + Math.min(timing.durationMs * fraction, timing.durationMs - 1);
425
+ await seek(timing.index, Math.max(timing.delayMs, timeMs));
426
+ const frame = await shot(`anim-${timing.index}-${Math.round(fraction * 100)}`);
427
+ if (options.stripPath) rowFrames.push(frame);
428
+ const delta = frameDelta(previous, frame, tolerance);
429
+ frames.push({
430
+ fraction,
431
+ ...delta
432
+ });
433
+ motionBbox = unionBbox(motionBbox, delta.bbox);
434
+ totalChangedPixels += delta.changedPixels;
435
+ maxFrameRatio = Math.max(maxFrameRatio, delta.ratio);
436
+ previous = frame;
437
+ }
438
+ await seek(timing.index, restTimeForAnimation(timing));
439
+ if (options.stripPath && rowFrames.length > 0) stripRows.push(rowFrames);
440
+ evaluated.push({
441
+ ...timing,
442
+ frames,
443
+ visible: frames.some((f) => f.changedPixels >= minChangedPixels),
444
+ motionBbox,
445
+ totalChangedPixels,
446
+ maxFrameRatio: Number(maxFrameRatio.toFixed(4))
447
+ });
448
+ }
449
+ let strip;
450
+ if (options.stripPath && evaluated.some((a) => a.motionBbox)) {
451
+ const wanted = options.stripSelector;
452
+ const matched = wanted === void 0 ? null : new Set(await page.evaluate((selector) => {
453
+ const anims = window.__vlmkitAnims ?? [];
454
+ const hits = [];
455
+ anims.forEach((anim, index) => {
456
+ const target = anim.effect?.target;
457
+ if (target && target.matches(selector)) hits.push(index);
458
+ });
459
+ return hits;
460
+ }, wanted));
461
+ const rows = evaluated.filter((a) => a.motionBbox && (matched === null || matched.has(a.index)));
462
+ if (matched !== null && rows.length === 0) throw new UsageError(`--strip-selector \`${wanted}\` matched no animated element. Animated elements on this page: ${evaluated.map((a) => a.selector).join(", ")}`);
463
+ const finiteEnds = rows.filter((a) => a.iterations !== null).map((a) => a.delayMs + a.durationMs * (a.iterations ?? 1));
464
+ const windowMs = options.stripWindowMs ?? (finiteEnds.length > 0 ? Math.max(1, ...finiteEnds) : Math.max(1, ...rows.map((a) => a.delayMs + a.durationMs)));
465
+ const times = Array.from({ length: samples }, (_, i) => Math.round(windowMs * (i + 1) / samples));
466
+ const PAD = 8;
467
+ const columns = [];
468
+ for (const timeMs of times) {
469
+ for (const anim of evaluated) {
470
+ if (anim.index < 0) continue;
471
+ const end = anim.iterations === null ? timeMs : Math.min(timeMs, anim.delayMs + anim.durationMs * anim.iterations - 1);
472
+ await seek(anim.index, Math.max(anim.delayMs, end));
473
+ }
474
+ columns.push(await shot(`t-${timeMs}ms`));
475
+ }
476
+ if (options.stripAnimated) {
477
+ if (imageFormatForPath(options.stripPath) === "webp") throw new UsageError("--strip-animated writes APNG, so --strip cannot be a .webp path.\n Animated WebP needs libwebp's animation encoder, which the optional\n `@jsquash/webp` does not expose. Use a .png name.");
478
+ const cap = options.stripMaxWidth ?? 1600;
479
+ const factor = cap > 0 && columns[0].width > cap ? Math.ceil(columns[0].width / cap) : 1;
480
+ const played = factor === 1 ? columns : columns.map((frame) => scalePngData(frame, factor));
481
+ const gaps = times.slice(1).map((t, i) => t - times[i]);
482
+ const holdMs = gaps.length > 0 ? Math.round(gaps.reduce((a, b) => a + b, 0) / gaps.length) : 200;
483
+ const bytes = encodeApng(played, {
484
+ delaysMs: [...gaps, holdMs],
485
+ delayMs: holdMs
486
+ });
487
+ await mkdir(dirname(resolve(options.stripPath)), { recursive: true });
488
+ await writeFile(resolve(options.stripPath), bytes);
489
+ strip = {
490
+ path: resolve(options.stripPath),
491
+ columns: played.length,
492
+ rows: 1,
493
+ omitted: 0,
494
+ outOfScope: matched === null ? 0 : evaluated.filter((a) => !matched.has(a.index)).length,
495
+ windowMs,
496
+ times,
497
+ rowSelectors: [],
498
+ width: played[0].width,
499
+ height: played[0].height,
500
+ animated: true
501
+ };
502
+ } else {
503
+ const sheet = composeFilmstrip(rows.flatMap((anim) => {
504
+ const bbox = anim.motionBbox;
505
+ return columns.map((frame) => cropRegion(frame, Math.max(0, bbox.x - PAD), Math.max(0, bbox.y - PAD), bbox.width + PAD * 2, bbox.height + PAD * 2));
506
+ }), {
507
+ columns: samples,
508
+ maxWidth: options.stripMaxWidth ?? 1600,
509
+ columnLabels: times.map((t) => `${t}ms`),
510
+ rowLabels: rows.map((anim) => `${anim.selector} ${anim.name}`)
511
+ });
512
+ await mkdir(dirname(resolve(options.stripPath)), { recursive: true });
513
+ if (imageFormatForPath(options.stripPath) === "webp") await writeFile(resolve(options.stripPath), await encodeWebp(sheet));
514
+ else await encodePng(resolve(options.stripPath), sheet);
515
+ strip = {
516
+ path: resolve(options.stripPath),
517
+ columns: sheet.layout.columns,
518
+ rows: sheet.layout.rows,
519
+ omitted: evaluated.filter((a) => !a.motionBbox && (matched === null || matched.has(a.index))).length,
520
+ outOfScope: matched === null ? 0 : evaluated.filter((a) => !matched.has(a.index)).length,
521
+ windowMs,
522
+ times,
523
+ rowSelectors: rows.map((a) => a.selector),
524
+ width: sheet.width,
525
+ height: sheet.height
526
+ };
527
+ }
528
+ }
529
+ await page.close();
530
+ let reducedMotion;
531
+ if (!options.skipReducedMotion && timings.length > 0) {
532
+ const durationFloor = options.reducedMotionDurationFloorMs ?? 100;
533
+ const rmPage = await browser.newPage({ viewport });
534
+ await rmPage.emulateMedia({ reducedMotion: "reduce" });
535
+ await loadPage(rmPage);
536
+ const rmTimings = await collectAnimations(rmPage);
537
+ await rmPage.close();
538
+ const remaining = rmTimings.filter((t) => t.playState !== "paused" && t.playState !== "idle" && t.durationMs >= durationFloor).map((t) => ({
539
+ selector: t.selector,
540
+ name: t.name,
541
+ durationMs: t.durationMs
542
+ }));
543
+ reducedMotion = {
544
+ remainingCount: remaining.length,
545
+ remaining
546
+ };
547
+ }
548
+ const issues = deriveAnimationIssues({
549
+ evaluated,
550
+ settleMs,
551
+ infinite,
552
+ ...reducedMotion ? { reducedMotion } : {},
553
+ ...uncontrolledMotion ? { uncontrolledMotion } : {}
554
+ }, {
555
+ settleThresholdMs: options.settleThresholdMs,
556
+ reducedMotionDurationFloorMs: options.reducedMotionDurationFloorMs
557
+ });
558
+ return {
559
+ source: options.source,
560
+ viewport,
561
+ animationCount: timings.length,
562
+ evaluated,
563
+ settleMs,
564
+ infinite,
565
+ ...reducedMotion ? { reducedMotion } : {},
566
+ ...uncontrolledMotion ? { uncontrolledMotion } : {},
567
+ issues,
568
+ ...framePaths.length > 0 ? { framePaths } : {},
569
+ ...strip ? { strip } : {}
570
+ };
571
+ });
572
+ }
573
+ function formatAnimationEvalReport(report, rules) {
574
+ const lines = [];
575
+ const { shown, status, note } = tierIssues(report.issues, rules);
576
+ lines.push(`${BOLD}${CYAN}vlmkit check animation${RESET}`);
577
+ lines.push(`${DIM}source: ${report.source} (${report.viewport.width}x${report.viewport.height})${RESET}`);
578
+ lines.push("");
579
+ lines.push(`status: ${status}`);
580
+ lines.push(`animations: ${report.animationCount} (evaluated ${report.evaluated.length}, infinite ${report.infinite.length})`);
581
+ const firedKinds = new Set(shown.map((entry) => entry.row.kind));
582
+ const ruleTag = (kind) => firedKinds.has(kind) ? ` ${DIM}[${kind}]${RESET}` : "";
583
+ if (report.settleMs === null) lines.push(`settle: never (infinite animation)` + (firedKinds.has("infinite-animation") ? ` ${DIM}[infinite-animation]${RESET}` : ` ${DIM}(no rule covers this — \`long-settle\` needs a settle time to compare)${RESET}`));
584
+ else lines.push(`settle: ${Math.round(report.settleMs)}ms${ruleTag("long-settle")}`);
585
+ if (report.reducedMotion) lines.push(report.reducedMotion.remainingCount === 0 ? `reduced-motion: honored` : `reduced-motion: ${report.reducedMotion.remainingCount} animation(s) still running${ruleTag("reduced-motion-ignored")}`);
586
+ if (report.uncontrolledMotion) {
587
+ const m = report.uncontrolledMotion;
588
+ const where = m.bbox ? ` at (${m.bbox.x},${m.bbox.y}) ${m.bbox.width}x${m.bbox.height}` : "";
589
+ lines.push(`uncontrolled motion: ${m.changedPixels}px${where} (rAF / video / GIF — frame deltas may be contaminated)${ruleTag("uncontrolled-motion")}`);
590
+ }
591
+ if (report.evaluated.length > 0) {
592
+ lines.push("");
593
+ lines.push("Evaluated animations:");
594
+ for (const anim of report.evaluated) {
595
+ const bbox = anim.motionBbox ? `(${anim.motionBbox.x},${anim.motionBbox.y}) ${anim.motionBbox.width}x${anim.motionBbox.height}` : "none";
596
+ const visibility = anim.visible ? `${GREEN}visible${RESET}` : `${RED}no visible effect${RESET}`;
597
+ const osc = computeOscillation(anim);
598
+ const oscLabel = osc.oscillating ? ` (${anim.direction.startsWith("alternate") ? anim.direction : "palindromic keyframes"}, leg ${Math.round(osc.legMs)}ms)` : "";
599
+ lines.push(` - ${anim.selector} \`${anim.name}\` ${Math.round(anim.durationMs)}ms x${anim.iterations ?? "∞"}${oscLabel}: ${visibility}, motion region ${bbox}, peak frame delta ${(anim.maxFrameRatio * 100).toFixed(2)}%`);
600
+ }
601
+ }
602
+ if (shown.length > 0) {
603
+ lines.push("");
604
+ lines.push("Issues:");
605
+ for (const entry of shown) {
606
+ const issue = entry.row;
607
+ const icon = entry.tier === "suspect" ? `${RED}x${RESET}` : `${YELLOW}!${RESET}`;
608
+ const selector = issue.selector ? ` ${issue.selector}` : "";
609
+ lines.push(` ${icon} ${issue.kind}${selector}: ${issue.message}${retuneNote(entry)}`);
610
+ }
611
+ } else if (note === void 0) {
612
+ lines.push("");
613
+ lines.push(`${GREEN}No animation issues detected.${RESET}`);
614
+ }
615
+ if (note) {
616
+ lines.push("");
617
+ lines.push(`${DIM}${note}${RESET}`);
618
+ }
619
+ if (report.framePaths && report.framePaths.length > 0) {
620
+ lines.push("");
621
+ lines.push(`Frames: ${report.framePaths.length} written`);
622
+ }
623
+ if (report.strip) {
624
+ const s = report.strip;
625
+ lines.push("");
626
+ lines.push(`Strip: ${s.path} (${s.width}x${s.height}, ${s.rows} animation(s) x ${s.columns} sample(s)${s.omitted > 0 ? `; ${s.omitted} omitted as no-visible-effect` : ""}${s.outOfScope > 0 ? `; ${s.outOfScope} outside --strip-selector` : ""})`);
627
+ lines.push(`${DIM} caption: columns are ${s.times.map((ms) => `${ms}ms`).join(" / ")} on the page timeline (window ${s.windowMs}ms, one shared clock); rows top to bottom are ${s.rowSelectors.join(", ")}${RESET}`);
628
+ }
629
+ return lines.join("\n");
630
+ }
631
+ /**
632
+ * CLI entry removed: this module is measurement code now, not a command.
633
+ * `check animation` is declared in `../gates/animation.gate.ts` and driven by the core runner
634
+ * (`@mizchi/vlmkit-core/plugin/runner.ts`), which owns argument parsing,
635
+ * `--json`, `--advisory`, the run ledger and the exit code.
636
+ */
637
+ //#endregion
638
+ export { computeOscillation, computeSettleMs, deriveAnimationIssues, formatAnimationEvalReport, frameDelta, restTimeForAnimation, runAnimationEval, unionBbox };
@@ -0,0 +1,2 @@
1
+ import { AnimationEvalIssue, AnimationEvalIssueKind, AnimationEvalOptions, AnimationEvalReport, AnimationFrameStat, AnimationTimingSample, DeriveIssuesInput, EvaluatedAnimation, FrameDeltaStat, OscillationInfo, ReducedMotionRemaining, computeOscillation, computeSettleMs, deriveAnimationIssues, formatAnimationEvalReport, frameDelta, restTimeForAnimation, runAnimationEval, unionBbox } from "./animation-eval.mjs";
2
+ export { type AnimationEvalIssue, type AnimationEvalIssueKind, type AnimationEvalOptions, type AnimationEvalReport, type AnimationFrameStat, type AnimationTimingSample, type DeriveIssuesInput, type EvaluatedAnimation, type FrameDeltaStat, type OscillationInfo, type ReducedMotionRemaining, computeOscillation, computeSettleMs, deriveAnimationIssues, formatAnimationEvalReport, frameDelta, restTimeForAnimation, runAnimationEval, unionBbox };
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import { computeOscillation, computeSettleMs, deriveAnimationIssues, formatAnimationEvalReport, frameDelta, restTimeForAnimation, runAnimationEval, unionBbox } from "./animation-eval.mjs";
2
+ export { computeOscillation, computeSettleMs, deriveAnimationIssues, formatAnimationEvalReport, frameDelta, restTimeForAnimation, runAnimationEval, unionBbox };
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@mizchi/vlmkit-animation-eval",
3
+ "version": "0.22.0",
4
+ "description": "Frame-sampled animation evaluation for web pages: pause every Web Animation, seek deterministic sample points, and report visible effect, settle time, reduced-motion behaviour and uncontrolled motion. The measurement behind `vlmkit check animation` and `vlmkit-anim eval`.",
5
+ "license": "MIT",
6
+ "author": "mizchi",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/mizchi/vlmkit.git",
10
+ "directory": "packages/vlmkit-animation-eval"
11
+ },
12
+ "homepage": "https://github.com/mizchi/vlmkit/tree/main/packages/vlmkit-animation-eval#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/mizchi/vlmkit/issues"
15
+ },
16
+ "type": "module",
17
+ "engines": {
18
+ "node": ">=24"
19
+ },
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "files": [
24
+ "dist/**",
25
+ "README.md",
26
+ "LICENSE"
27
+ ],
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.mts",
31
+ "import": "./dist/index.mjs"
32
+ },
33
+ "./*.ts": {
34
+ "types": "./dist/*.d.mts",
35
+ "import": "./dist/*.mjs"
36
+ }
37
+ },
38
+ "dependencies": {
39
+ "pngjs": "^7.0.0",
40
+ "@mizchi/vlmkit-core": "0.22.0"
41
+ },
42
+ "peerDependencies": {
43
+ "playwright": ">=1.61 <2"
44
+ },
45
+ "scripts": {
46
+ "build": "pnpm --dir ../.. exec tsdown --config tsdown.packages.config.ts --filter @mizchi/vlmkit-animation-eval",
47
+ "test": "pnpm --dir ../.. exec vitest run packages/vlmkit-animation-eval/src"
48
+ }
49
+ }