framesheet 0.0.0-stage → 0.2.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 +22 -0
- package/README.md +247 -2
- package/dist/analysis.d.ts +84 -0
- package/dist/analysis.d.ts.map +1 -0
- package/dist/analysis.js +335 -0
- package/dist/analysis.js.map +1 -0
- package/dist/checks.d.ts +44 -0
- package/dist/checks.d.ts.map +1 -0
- package/dist/checks.js +200 -0
- package/dist/checks.js.map +1 -0
- package/dist/compose.d.ts +130 -0
- package/dist/compose.d.ts.map +1 -0
- package/dist/compose.js +266 -0
- package/dist/compose.js.map +1 -0
- package/dist/driver.d.ts +56 -0
- package/dist/driver.d.ts.map +1 -0
- package/dist/driver.js +94 -0
- package/dist/driver.js.map +1 -0
- package/dist/generated/assets.d.ts +13 -0
- package/dist/generated/assets.d.ts.map +1 -0
- package/dist/generated/assets.js +15 -0
- package/dist/generated/assets.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/inspect.d.ts +163 -0
- package/dist/inspect.d.ts.map +1 -0
- package/dist/inspect.js +593 -0
- package/dist/inspect.js.map +1 -0
- package/dist/marks.d.ts +49 -0
- package/dist/marks.d.ts.map +1 -0
- package/dist/marks.js +460 -0
- package/dist/marks.js.map +1 -0
- package/dist/marks.schema.json +307 -0
- package/dist/media.d.ts +22 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +306 -0
- package/dist/media.js.map +1 -0
- package/dist/models.d.ts +208 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +9 -0
- package/dist/models.js.map +1 -0
- package/dist/pixels.d.ts +52 -0
- package/dist/pixels.d.ts.map +1 -0
- package/dist/pixels.js +275 -0
- package/dist/pixels.js.map +1 -0
- package/dist/pyfmt.d.ts +16 -0
- package/dist/pyfmt.d.ts.map +1 -0
- package/dist/pyfmt.js +54 -0
- package/dist/pyfmt.js.map +1 -0
- package/dist/report.schema.json +1326 -0
- package/dist/sources.d.ts +43 -0
- package/dist/sources.d.ts.map +1 -0
- package/dist/sources.js +164 -0
- package/dist/sources.js.map +1 -0
- package/dist/test.d.ts +46 -0
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +58 -0
- package/dist/test.js.map +1 -0
- package/dist/timing.d.ts +30 -0
- package/dist/timing.d.ts.map +1 -0
- package/dist/timing.js +128 -0
- package/dist/timing.js.map +1 -0
- package/dist/video.d.ts +65 -0
- package/dist/video.d.ts.map +1 -0
- package/dist/video.js +440 -0
- package/dist/video.js.map +1 -0
- package/package.json +79 -4
- package/src/analysis.ts +416 -0
- package/src/checks.ts +261 -0
- package/src/compose.ts +337 -0
- package/src/driver.ts +115 -0
- package/src/generated/assets.ts +20 -0
- package/src/index.ts +54 -0
- package/src/inspect.ts +722 -0
- package/src/marks.ts +481 -0
- package/src/media.ts +296 -0
- package/src/models.ts +225 -0
- package/src/pixels.ts +284 -0
- package/src/pyfmt.ts +55 -0
- package/src/sources.ts +175 -0
- package/src/test.ts +100 -0
- package/src/timing.ts +133 -0
- package/src/video.ts +513 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, Philipp Temminghoff
|
|
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.
|
|
22
|
+
|
package/README.md
CHANGED
|
@@ -1,3 +1,248 @@
|
|
|
1
|
-
#
|
|
1
|
+
# framesheet (npm)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Frame-accurate contact sheets, motion heatmaps and checks for animated SVG/HTML, and for
|
|
4
|
+
animated components in a running web app. TypeScript port of the Python package
|
|
5
|
+
[`framesheet`](https://pypi.org/project/framesheet/): same in-page time control
|
|
6
|
+
(`runtime.js`, shared byte for byte), same report schema, same image layout. Use it in a
|
|
7
|
+
Playwright e2e suite for visual regression of animations, or in a Node server so an AI
|
|
8
|
+
agent can look at the SVG/HTML it generated.
|
|
9
|
+
|
|
10
|
+
An agent (or a reviewer) can only look at still images, and one screenshot shows one
|
|
11
|
+
moment. framesheet renders the whole cycle at exact virtual times and returns:
|
|
12
|
+
|
|
13
|
+
| Image | Use it for |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| `full` | One full-resolution frame (default `t=0`, `at`): layout, text, margins. |
|
|
16
|
+
| `sheet` | Contact sheet: N frames over one cycle, each labelled `t=0.50s`. The last tile is one 60 fps frame before the cycle end, so the loop seam is visible. |
|
|
17
|
+
| `heatmap` | Every pixel that changes at any time, coloured over a dimmed first frame. |
|
|
18
|
+
| `report` | Duration and how it was found, findings (stable codes), per-frame changed-pixel ratios, boxes of animated elements, loop seamlessness. Schema: `framesheet/schema/report.schema.json`. |
|
|
19
|
+
|
|
20
|
+

|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install -D framesheet playwright-core # or: bun add -d framesheet playwright-core
|
|
26
|
+
npx playwright install chromium # once (Linux CI: --with-deps chromium)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`playwright-core` (>= 1.45) is a peer dependency: framesheet uses your Playwright and its
|
|
30
|
+
browsers. A project that already has `@playwright/test` or `playwright` has it. ESM only,
|
|
31
|
+
Node >= 20 or Bun. No native dependencies (PNG decoding is pure JS; the sheet and heatmap
|
|
32
|
+
are drawn on a canvas in the same Chromium, with the font the Python images use).
|
|
33
|
+
|
|
34
|
+
## `inspect()`: a file, markup string or URL
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { inspect } from "framesheet";
|
|
38
|
+
|
|
39
|
+
const result = await inspect("banner.svg", { frames: 12 });
|
|
40
|
+
console.log(result.summary()); // same text as the Python CLI
|
|
41
|
+
result.images.sheet; // PNG Buffer (also full, heatmap)
|
|
42
|
+
result.report.loop.seamless; // report.json content (snake_case, shared schema)
|
|
43
|
+
for (const f of result.findings) console.log(f.severity, f.code, f.element, f.times);
|
|
44
|
+
|
|
45
|
+
await inspect('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10">...</svg>');
|
|
46
|
+
await inspect("https://example.com/anim.html", { size: [1440, 900], scale: 2 });
|
|
47
|
+
await inspect("canvas.html", { duration: 4, out: "/tmp/check" }); // also writes the files
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Options: `frames` (2-100, default 12), `duration` (s; detected if omitted), `at` (s, time
|
|
51
|
+
of `full`), `size` (`[w, h]`), `scale`, `tile`, `columns`, `heatFrames` (default 48),
|
|
52
|
+
`keepFrames`, `colorScheme`, `out` (write `full.png`, `sheet.png`, `heatmap.png`,
|
|
53
|
+
`report.json`; without it nothing touches the disk), `timeout` (ms), `browser` (reuse a
|
|
54
|
+
launched `Browser`; a fresh context is used per call), `launchOptions`, `blockNetwork`
|
|
55
|
+
(abort every request except the input: use it for untrusted markup). Videos only: `every`,
|
|
56
|
+
`times`, `start`, `end`, `marks`, `staticStretch` (see below).
|
|
57
|
+
|
|
58
|
+
The result is an `Inspection`: `report`, `images` (`full`, `sheet`, `heatmap`,
|
|
59
|
+
`frames?`), `files` (paths, with `out`), `findings`, `errors`, `warnings`, `codes()`,
|
|
60
|
+
`summary()`. Output is deterministic: same input, same environment, same PNG bytes.
|
|
61
|
+
|
|
62
|
+
## Videos and animated images
|
|
63
|
+
|
|
64
|
+
`inspect()` also takes `.mp4`, `.mov`, `.webm`, `.mkv` and animated `.gif`/`.webp` (path
|
|
65
|
+
or URL). Same images and report, plus a timeline strip under the sheet and a `video`
|
|
66
|
+
section in the report (same schema as Python):
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
const r = await inspect("demo.mp4", {
|
|
70
|
+
every: 1, // or frames: 12, or times: [1.2, 3.4] / "marks"
|
|
71
|
+
start: 0, end: 15, // range (default: the whole media)
|
|
72
|
+
marks: "marks.json", // or an object; validated (framesheet/schema/marks.schema.json)
|
|
73
|
+
staticStretch: 1.5, // seconds without change reported as video-static-stretch
|
|
74
|
+
launchOptions: { channel: "chrome" }, // only if your Chromium lacks H.264
|
|
75
|
+
});
|
|
76
|
+
r.report.video!.tiles; // media_time, black, blank, duplicate, sharpness, marks per tile
|
|
77
|
+
r.report.video!.samples; // dense pacing samples: t, changed_ratio
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Findings: `video-static-stretch`, `video-black-frames`, `video-blank-frames`,
|
|
81
|
+
`video-abrupt-cut` (info), `video-mark-overlap` (a span box, e.g. a caption, covers an
|
|
82
|
+
active `target` region box). Frames are seeked exactly: `<video>` `currentTime` + `seeked`
|
|
83
|
+
+ `requestVideoFrameCallback`, animated images via WebCodecs `ImageDecoder`; the frame is
|
|
84
|
+
drawn on a canvas filling the viewport (shared `video.js`, byte-identical to the Python
|
|
85
|
+
package's). No ffmpeg. Playwright's Chromium always decodes VP8/VP9/AV1, GIF and WebP;
|
|
86
|
+
H.264/HEVC depend on the build (re-encode to VP9 or use `channel: "chrome"`).
|
|
87
|
+
|
|
88
|
+
Marks schema, the timeline and the "demo video optimization loop" (what to look for in
|
|
89
|
+
the sheet, heatmap, timeline and report) are documented in the
|
|
90
|
+
[main README](https://github.com/phil65/framesheet#video-input). Helpers for tools that
|
|
91
|
+
write marks: `parseMarks`, `loadMarks`, `MarksError`, `planTimes`, `probe` (container
|
|
92
|
+
facts without a browser).
|
|
93
|
+
|
|
94
|
+
## `inspectPage()`: a page or component you already have open
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
import { inspectPage, prepare } from "framesheet";
|
|
98
|
+
|
|
99
|
+
const result = await inspectPage(page, {
|
|
100
|
+
locator: page.locator("#mindmap"), // optional: one component (also inside an iframe)
|
|
101
|
+
frames: 8,
|
|
102
|
+
trigger: () => page.getByRole("button", { name: "Open" }).click(),
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
What works where:
|
|
107
|
+
|
|
108
|
+
| Motion | Works on any page, any time | Needs `prepare(page)` **before** `goto` |
|
|
109
|
+
| --- | --- | --- |
|
|
110
|
+
| SMIL (`<animate>`, `<animateMotion>`, ...) | yes: paused and seeked per frame | |
|
|
111
|
+
| CSS animations and transitions | yes: `document.getAnimations()` seeked | |
|
|
112
|
+
| Web Animations (`el.animate`) | yes, same | |
|
|
113
|
+
| `requestAnimationFrame`, timers, `Date`, `performance.now` (canvas, spring/rAF animation libraries) | runs on real time: frames are not exact | yes: Playwright's fake clock is stepped per frame |
|
|
114
|
+
|
|
115
|
+
- `prepare(page)` installs Playwright's fake clock before navigation. It follows real
|
|
116
|
+
time, so the app behaves normally, until `inspectPage` pauses it (on a 16 ms frame
|
|
117
|
+
boundary) and steps it frame by frame; afterwards it runs on.
|
|
118
|
+
- `prepare(page, { paused: true })` freezes time from navigation on, exactly like
|
|
119
|
+
`inspect()`: JS-driven motion that starts on load is captured from its first frame.
|
|
120
|
+
App timers stand still until an inspection (or `page.clock.runFor`) advances them;
|
|
121
|
+
good for component pages and stories, risky for whole apps that rely on timers.
|
|
122
|
+
- `trigger` runs after time is frozen and before `t=0` is captured: start an "open"
|
|
123
|
+
animation by clicking, and the sheet shows it from its first frame. Declarative
|
|
124
|
+
animations that already ran are rewound to their start either way (every animation is
|
|
125
|
+
timed from when the inspection first sees it).
|
|
126
|
+
- `locator` limits everything to the component: duration detection (animations of
|
|
127
|
+
other elements are ignored), geometry and checks, and the images (clipped to its box,
|
|
128
|
+
plus `padding`). Geometry is in the coordinates of the component's frame.
|
|
129
|
+
- Afterwards the page is handed back: SMIL and animations that were running play again
|
|
130
|
+
(from where the inspection left them) and the fake clock resumes.
|
|
131
|
+
- Static source checks are off for pages (`staticChecks: true` runs them on the
|
|
132
|
+
serialised markup of the page or component).
|
|
133
|
+
- A second inspection of the same page gives the same geometry and report, but Chromium
|
|
134
|
+
may antialias a few edge pixels differently on a page that already painted other
|
|
135
|
+
states; a fresh navigation (as in an e2e test) is byte-identical.
|
|
136
|
+
|
|
137
|
+
## Visual regression in a Playwright suite: `framesheet/test`
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
// e2e/mindmap.spec.ts
|
|
141
|
+
import { test } from "@playwright/test";
|
|
142
|
+
import { expectAnimation, prepare } from "framesheet/test";
|
|
143
|
+
|
|
144
|
+
test("mind map opens smoothly", async ({ page }) => {
|
|
145
|
+
await page.goto("/mindmap/demo");
|
|
146
|
+
await expectAnimation(page.locator("#mindmap"), "mindmap-open", {
|
|
147
|
+
frames: 8,
|
|
148
|
+
trigger: () => page.getByRole("button", { name: "Expand" }).click(),
|
|
149
|
+
maxDiffPixelRatio: 0.01,
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test("drawing replays its strokes", async ({ page }) => {
|
|
154
|
+
await prepare(page, { paused: true }); // JS-driven: freeze the clock before goto
|
|
155
|
+
await page.goto("/drawings/demo");
|
|
156
|
+
await expectAnimation(page.locator("canvas"), "drawing-replay", { duration: 2 });
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
`expectAnimation(target, name, options)` builds the contact sheet of a page or locator
|
|
161
|
+
and asserts it with Playwright's own `expect(buffer).toMatchSnapshot("<name>.png")`, so
|
|
162
|
+
`--update-snapshots`, per-platform baseline names (`<name>-chromium-linux.png`) and the
|
|
163
|
+
HTML report's diff view work as usual. Options: everything of `inspectPage`, plus
|
|
164
|
+
`maxDiffPixelRatio`, `maxDiffPixels`, `threshold`, `heatmap` (also compare
|
|
165
|
+
`<name>-heatmap.png`), `failOn` (`"error"` default, `"warning"`, or `false`), `ignore`
|
|
166
|
+
(codes), `snapshot` (`false`: findings only), `attach` (default: attach sheet, heatmap,
|
|
167
|
+
full frame and report.json to the test). It returns the `Inspection`. The sheet title is
|
|
168
|
+
`name`, so baselines do not depend on the dev server's URL.
|
|
169
|
+
|
|
170
|
+
For stable baselines launch Chromium like framesheet does:
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
// playwright.config.ts
|
|
174
|
+
import { LAUNCH_ARGS } from "framesheet";
|
|
175
|
+
export default defineConfig({
|
|
176
|
+
use: { launchOptions: { args: LAUNCH_ARGS } }, // main-thread animations, sRGB, no LCD text
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Baselines differ between platforms and font setups (as with `toHaveScreenshot`): record
|
|
181
|
+
them where CI runs (e.g. the Playwright Docker image) and keep `maxDiffPixelRatio` small
|
|
182
|
+
but non-zero.
|
|
183
|
+
|
|
184
|
+
## In a server (agent tools)
|
|
185
|
+
|
|
186
|
+
framesheet runs anywhere Node and Chromium run; nothing is written to disk unless you pass
|
|
187
|
+
`out`. Markup strings are served from a virtual origin through `page.route`, never from
|
|
188
|
+
the filesystem.
|
|
189
|
+
|
|
190
|
+
- **Chromium must be available in the deployment.** Playwright's Chromium builds need
|
|
191
|
+
glibc: use a Debian/Ubuntu base (`node:24-bookworm-slim` +
|
|
192
|
+
`npx playwright install --with-deps chromium`) or the
|
|
193
|
+
`mcr.microsoft.com/playwright:v1.65.1-noble` image. Alpine (musl) is not supported by
|
|
194
|
+
Playwright's browsers; there, run Chromium in a sidecar container
|
|
195
|
+
(`npx playwright run-server`) and pass `browser: await chromium.connect(wsEndpoint)`.
|
|
196
|
+
- Launch one browser and reuse it (`browser` option): launching costs ~0.5 s. With the
|
|
197
|
+
defaults (12 tiles + 48 heatmap frames) an inspection takes ~5-8 s, most of it one
|
|
198
|
+
browser round trip per frame; `frames: 8, heatFrames: 12` takes ~2 s.
|
|
199
|
+
- Untrusted input: `blockNetwork: true`, a `timeout`, a concurrency limit, and never
|
|
200
|
+
`out` paths derived from user input.
|
|
201
|
+
|
|
202
|
+
See [docs/contexter-skill.md](https://github.com/phil65/framesheet/blob/main/docs/contexter-skill.md)
|
|
203
|
+
for a worked sketch of an agent tool.
|
|
204
|
+
|
|
205
|
+
## How time is controlled
|
|
206
|
+
|
|
207
|
+
Same as the Python package (see its README): SMIL `pauseAnimations()` +
|
|
208
|
+
`setCurrentTime(t)`; every `document.getAnimations()` entry paused with `currentTime`
|
|
209
|
+
set; JS clocks on Playwright's fake clock, advanced with `clock.runFor`. Duration
|
|
210
|
+
detection: SMIL `begin`/`dur`/`repeatCount` and CSS/Web Animation timing (alternate = 2x,
|
|
211
|
+
several loops = LCM when short enough, positive delays added, finite animations end);
|
|
212
|
+
`duration` overrides; no declarative animation -> 3 s and a `js-driven-motion` warning.
|
|
213
|
+
|
|
214
|
+
## Checks
|
|
215
|
+
|
|
216
|
+
Static (source text; `inspect()` only by default): `malformed-xml`, `not-svg`,
|
|
217
|
+
`missing-xmlns`, `missing-viewbox`, `missing-title`, `script`, `foreign-object`,
|
|
218
|
+
`event-handler`, `external-url`, `positive-begin`, `duplicate-id`, `broken-ref`,
|
|
219
|
+
`css-external`, `no-reduced-motion`, `transform-origin-without-box`,
|
|
220
|
+
`transform-without-box`, `large-file`. Render (geometry and pixels over time):
|
|
221
|
+
`parked-at-origin`, `outside-bounds`, `text-overflow`, `svg-transform-box`,
|
|
222
|
+
`non-seamless-loop`, `js-driven-motion`, `no-visible-motion`, `no-motion`,
|
|
223
|
+
`console-error`. Video: `video-static-stretch`, `video-black-frames`,
|
|
224
|
+
`video-blank-frames`, `video-abrupt-cut`, `video-mark-overlap`. Codes are API; the schema
|
|
225
|
+
pins them.
|
|
226
|
+
|
|
227
|
+
## Development
|
|
228
|
+
|
|
229
|
+
The package lives in `js/` of the [framesheet repo](https://github.com/phil65/framesheet).
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
cd js
|
|
233
|
+
npm ci && npx playwright install chromium
|
|
234
|
+
npm run build # embeds ../src/framesheet/runtime.js + font, compiles to dist/
|
|
235
|
+
npm run typecheck
|
|
236
|
+
npm test # vitest: Python fixtures, determinism, schema parity
|
|
237
|
+
npm run test:e2e # Playwright: expectAnimation demo (e2e/)
|
|
238
|
+
npm run check:runtime # dist/ embeds exactly ../src/framesheet/runtime.js
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Parity with Python is checked against `../schema/report.schema.json` and the golden
|
|
242
|
+
Python reports in `../schema/golden/` (regenerate both with
|
|
243
|
+
`uv run python scripts/sync_schema.py --golden` from the repo root; CI regenerates them
|
|
244
|
+
on the runner and compares strictly).
|
|
245
|
+
|
|
246
|
+
## License
|
|
247
|
+
|
|
248
|
+
MIT
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render checks on per-frame geometry (port of analysis.py).
|
|
3
|
+
*
|
|
4
|
+
* Each check is a function `(Geometry) => Finding[]` registered in {@link CHECKS}.
|
|
5
|
+
* Keep the logic, thresholds and messages in step with analysis.py.
|
|
6
|
+
*/
|
|
7
|
+
import type { AnimationTiming, ElementTrack, Finding, Rect } from "./models.js";
|
|
8
|
+
/** Pixels an element may poke out of its container/canvas before it is reported. */
|
|
9
|
+
export declare const TOLERANCE = 1;
|
|
10
|
+
export declare const MAX_TRACKS = 30;
|
|
11
|
+
export declare const MAX_REPORTED = 12;
|
|
12
|
+
export declare const SMALL_FRACTION = 0.2;
|
|
13
|
+
export declare const CONTAINERS: Set<string>;
|
|
14
|
+
export interface Element {
|
|
15
|
+
index: number;
|
|
16
|
+
tag: string;
|
|
17
|
+
label: string;
|
|
18
|
+
svg: boolean;
|
|
19
|
+
parent: number;
|
|
20
|
+
}
|
|
21
|
+
/** `[index, clientRect, userRect | null, visible]` per rendered element (runtime `measure()`). */
|
|
22
|
+
export type GeometryEntry = [number, number[], number[] | null, boolean];
|
|
23
|
+
/** Everything captured at one sample time. */
|
|
24
|
+
export interface FrameGeometry {
|
|
25
|
+
t: number;
|
|
26
|
+
geometry: GeometryEntry[];
|
|
27
|
+
/** HTML text overflow `[index, dx, dy]`. */
|
|
28
|
+
overflow: [number, number, number][];
|
|
29
|
+
}
|
|
30
|
+
export interface Description {
|
|
31
|
+
i: number;
|
|
32
|
+
tag: string;
|
|
33
|
+
label: string;
|
|
34
|
+
svg: boolean;
|
|
35
|
+
parent: number;
|
|
36
|
+
}
|
|
37
|
+
/** Inputs shared by all render checks. */
|
|
38
|
+
export declare class Geometry {
|
|
39
|
+
elements: Map<number, Element>;
|
|
40
|
+
times: number[];
|
|
41
|
+
/** Client rect (CSS px) per element per frame; `null` = not rendered/invisible. */
|
|
42
|
+
client: Map<number, (Rect | null)[]>;
|
|
43
|
+
/** SVG user-space rect (outermost `<svg>`) per element per frame. */
|
|
44
|
+
user: Map<number, (Rect | null)[]>;
|
|
45
|
+
canvas: Rect;
|
|
46
|
+
viewbox: Rect | null;
|
|
47
|
+
targets: Map<number, string[]>;
|
|
48
|
+
animations: AnimationTiming[];
|
|
49
|
+
isSvgDoc: boolean;
|
|
50
|
+
/** `[index, dx, dy]` per frame. */
|
|
51
|
+
htmlOverflow: [number, number, number][][];
|
|
52
|
+
constructor(elements: Map<number, Element>, times: number[],
|
|
53
|
+
/** Client rect (CSS px) per element per frame; `null` = not rendered/invisible. */
|
|
54
|
+
client: Map<number, (Rect | null)[]>,
|
|
55
|
+
/** SVG user-space rect (outermost `<svg>`) per element per frame. */
|
|
56
|
+
user: Map<number, (Rect | null)[]>, canvas: Rect, viewbox: Rect | null, targets: Map<number, string[]>, animations: AnimationTiming[], isSvgDoc: boolean,
|
|
57
|
+
/** `[index, dx, dy]` per frame. */
|
|
58
|
+
htmlOverflow: [number, number, number][][]);
|
|
59
|
+
static build(description: Description[], snapshots: FrameGeometry[], opts: {
|
|
60
|
+
canvas: Rect;
|
|
61
|
+
viewbox: Rect | null;
|
|
62
|
+
targets: Record<string, string[]>;
|
|
63
|
+
animations: AnimationTiming[];
|
|
64
|
+
isSvgDoc: boolean;
|
|
65
|
+
}): Geometry;
|
|
66
|
+
ancestors(index: number): number[];
|
|
67
|
+
label(index: number): string;
|
|
68
|
+
moved(): Set<number>;
|
|
69
|
+
}
|
|
70
|
+
export declare function fmtTimes(times: number[]): string;
|
|
71
|
+
/** Per-frame boxes of animated elements (declared targets or anything that moved). */
|
|
72
|
+
export declare function tracks(geo: Geometry): ElementTrack[];
|
|
73
|
+
/** Elements extending past the viewBox (SVG) or viewport (HTML). */
|
|
74
|
+
export declare function checkOutside(geo: Geometry): Finding[];
|
|
75
|
+
/** Small SVG elements sitting on the user-space origin (0,0), e.g. before `begin`. */
|
|
76
|
+
export declare function checkParked(geo: Geometry): Finding[];
|
|
77
|
+
/** SVG `<text>` poking out of the `<rect>` painted under it; HTML text overflow. */
|
|
78
|
+
export declare function checkTextOverflow(geo: Geometry): Finding[];
|
|
79
|
+
/** CSS transform animations on SVG elements without `transform-box: fill-box`. */
|
|
80
|
+
export declare function checkTransformBox(geo: Geometry): Finding[];
|
|
81
|
+
/** Render checks run on every inspection, in order. Append to add a check. */
|
|
82
|
+
export declare const CHECKS: ((geo: Geometry) => Finding[])[];
|
|
83
|
+
export declare function runChecks(geo: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