found-pixel 0.7.0 → 0.8.0-alpha.143

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.
Files changed (71) hide show
  1. package/README.md +37 -23
  2. package/dist/baselines.d.ts +15 -0
  3. package/dist/baselines.d.ts.map +1 -0
  4. package/dist/baselines.js +148 -0
  5. package/dist/baselines.js.map +1 -0
  6. package/dist/bin.d.ts +1 -7
  7. package/dist/bin.d.ts.map +1 -1
  8. package/dist/bin.js +3 -15
  9. package/dist/bin.js.map +1 -1
  10. package/dist/capture/browser.d.ts +5 -0
  11. package/dist/capture/browser.d.ts.map +1 -0
  12. package/dist/capture/browser.js +21 -0
  13. package/dist/capture/browser.js.map +1 -0
  14. package/dist/capture/compare.d.ts +8 -0
  15. package/dist/capture/compare.d.ts.map +1 -0
  16. package/dist/capture/compare.js +40 -0
  17. package/dist/capture/compare.js.map +1 -0
  18. package/dist/capture/engine.d.ts +33 -0
  19. package/dist/capture/engine.d.ts.map +1 -0
  20. package/dist/capture/engine.js +211 -0
  21. package/dist/capture/engine.js.map +1 -0
  22. package/dist/capture/inPage.d.ts +39 -0
  23. package/dist/capture/inPage.d.ts.map +1 -0
  24. package/dist/capture/inPage.js +106 -0
  25. package/dist/capture/inPage.js.map +1 -0
  26. package/dist/capture/server.d.ts +6 -0
  27. package/dist/capture/server.d.ts.map +1 -0
  28. package/dist/capture/server.js +67 -0
  29. package/dist/capture/server.js.map +1 -0
  30. package/dist/capture/shotPlan.d.ts +25 -0
  31. package/dist/capture/shotPlan.d.ts.map +1 -0
  32. package/dist/capture/shotPlan.js +89 -0
  33. package/dist/capture/shotPlan.js.map +1 -0
  34. package/dist/cli.d.ts.map +1 -1
  35. package/dist/cli.js +10 -2
  36. package/dist/cli.js.map +1 -1
  37. package/dist/comment.d.ts +2 -1
  38. package/dist/comment.d.ts.map +1 -1
  39. package/dist/comment.js +4 -1
  40. package/dist/comment.js.map +1 -1
  41. package/dist/config.d.ts +23 -93
  42. package/dist/config.d.ts.map +1 -1
  43. package/dist/config.js +2 -38
  44. package/dist/config.js.map +1 -1
  45. package/dist/diffViewerResults.d.ts +2 -0
  46. package/dist/diffViewerResults.d.ts.map +1 -1
  47. package/dist/diffViewerResults.js +2 -1
  48. package/dist/diffViewerResults.js.map +1 -1
  49. package/dist/review.d.ts.map +1 -1
  50. package/dist/review.js +21 -59
  51. package/dist/review.js.map +1 -1
  52. package/dist/shotIds.js +1 -1
  53. package/dist/shotIds.js.map +1 -1
  54. package/dist/storage.d.ts +5 -0
  55. package/dist/storage.d.ts.map +1 -1
  56. package/dist/storage.js +32 -0
  57. package/dist/storage.js.map +1 -1
  58. package/dist/storyIndex.d.ts +2 -0
  59. package/dist/storyIndex.d.ts.map +1 -1
  60. package/dist/storyIndex.js +15 -10
  61. package/dist/storyIndex.js.map +1 -1
  62. package/dist/storybook.d.ts +4 -0
  63. package/dist/storybook.d.ts.map +1 -0
  64. package/dist/storybook.js +41 -0
  65. package/dist/storybook.js.map +1 -0
  66. package/dist/visualRegression.d.ts +9 -32
  67. package/dist/visualRegression.d.ts.map +1 -1
  68. package/dist/visualRegression.js +165 -237
  69. package/dist/visualRegression.js.map +1 -1
  70. package/package.json +7 -8
  71. package/patches/lostPixelWindowApi.cjs +0 -215
package/README.md CHANGED
@@ -11,13 +11,13 @@ On every build:
11
11
  1. Runs the configured storybook build command
12
12
  2. Uploads the archive and static site to S3 under `<repoName>/storybook/<branch-slug>/`
13
13
  3. Annotates the Buildkite build with a link to the hosted storybook
14
- 4. If the branch is the default branch, also uploads under the commit SHA for future base resolution
14
+ 4. If the branch is the default branch, also uploads under the commit SHA for future base resolution, and updates the shared baseline screenshots for PRs (see [Baselines](#baselines))
15
15
 
16
16
  On pull requests (additional to the above):
17
17
 
18
18
  5. Resolves a base storybook from S3 — tries merge-base SHA first (for PRs into the default branch), then the base branch slug, then the default branch
19
19
  6. Runs [storybook-diff](https://www.npmjs.com/package/storybook-diff) between base and head, writing the JSON to `artifacts/`
20
- 7. Runs [lost-pixel](https://github.com/lost-pixel/lost-pixel) against the changed stories only, capturing pixel-level diffs; uploads screenshots to S3 and constructs PR comment image URLs via `screenshots.baseUrl` (if configured)
20
+ 7. Screenshots the changed stories with Playwright (see [Screenshots](#screenshots)), compares them against the base, and re-shoots every difference in isolation before reporting it; uploads screenshots to S3 and constructs PR comment image URLs via `screenshots.baseUrl` (if configured)
21
21
  8. Upserts a PR comment with added / deleted / modified sections, thumbnail previews for stories with visual changes, and a "Detected N story changes" summary
22
22
  9. Annotates the Buildkite build with a diff summary and a link to the PR comment
23
23
 
@@ -37,7 +37,7 @@ Runtime requirements on the Buildkite agent:
37
37
  - `git` (for merge-base resolution)
38
38
  - `buildkite-agent` (for annotations and artifact upload)
39
39
 
40
- Chromium is installed lazily on first `review` run via `playwright install --with-deps chromium`, using the `playwright-core` copy bundled with `lost-pixel` (so browser revisions match lost-pixel's expectations).
40
+ Chromium is installed on each `review` and `baseline` run via `playwright-core install --with-deps --only-shell chromium`. `playwright-core` is pinned, so every build uses the same Chromium; bumping it makes the next default-branch build re-shoot the whole baseline.
41
41
 
42
42
  ## Configuration
43
43
 
@@ -83,15 +83,7 @@ Example:
83
83
  "timeoutMinutes": 120,
84
84
  "threshold": 0,
85
85
  "shotConcurrency": 5,
86
- "compareConcurrency": 10,
87
- "waitBeforeScreenshot": 1000,
88
- "waitForFirstRequest": 1000,
89
- "waitForLastRequest": 1000,
90
- "timeouts": {
91
- "fetchStories": 30000,
92
- "loadState": 30000,
93
- "networkRequests": 30000
94
- }
86
+ "baselines": true
95
87
  },
96
88
  "comment": {
97
89
  "heading": "📘 UI Review",
@@ -111,13 +103,10 @@ Example:
111
103
  - `artifactsDir`: `"artifacts"`
112
104
  - `defaultBranch`: `"master"`
113
105
  - `visualRegression.enabled`: `true`
114
- - `visualRegression.timeoutMinutes`: `120` (per lost-pixel pass — baseline and compare are timed independently)
115
- - `visualRegression.shotConcurrency`: `5`
116
- - `visualRegression.compareConcurrency`: `10`
117
- - `visualRegression.waitBeforeScreenshot`: `1000`
118
- - `visualRegression.waitForFirstRequest`: `1000`
119
- - `visualRegression.waitForLastRequest`: `1000`
106
+ - `visualRegression.timeoutMinutes`: `120` — time budget for all screenshots in one run; stories still unshot when it runs out are reported as failed
107
+ - `visualRegression.shotConcurrency`: `5` — stories shot in parallel, each in its own browser context
120
108
  - `visualRegression.threshold`: `0` — Values `>=1` measure in absolute pixels, values from `0.00` to `1.00` are percentage
109
+ - `visualRegression.baselines`: `true` — keep shared baseline screenshots of the default branch and compare PRs against them (requires `screenshots`)
121
110
  - `skipLabels`: `[ "skip-ui-review" ]` — GitHub labels (from `BUILDKITE_PULL_REQUEST_LABELS`) that skip the `review` stage (storybook is still built and uploaded)
122
111
  - `fullReviewLabels`: `[ "full-ui-review" ]` — GitHub labels that force a full review: every story in the storybook is screenshotted and compared, bypassing the storybook-diff filter (including `autoIgnoreThreshold` exclusions)
123
112
  - `comment.heading`: `"📘 UI Review"`
@@ -142,6 +131,29 @@ All flags accepted by the [`storybook-diff`](https://www.npmjs.com/package/story
142
131
 
143
132
  See [src/config.ts](src/config.ts) for the full zod schema.
144
133
 
134
+ ### Screenshots
135
+
136
+ Stories are rendered in Chromium from the built storybook, served over a local HTTP server. Each stories file is loaded once and its stories are rendered in turn through Storybook's preview channel. A story is shot once Storybook reports it rendered and the page has settled: no network requests in flight, no pending timers of 3s or less, no DOM changes for 250ms, fonts loaded and images decoded. CSS animations are disabled and `prefers-reduced-motion` is set.
137
+
138
+ The viewport is 1280×720, resized to the page's content before the shot. These story parameters are honoured:
139
+
140
+ | Parameter | Effect |
141
+ |---|---|
142
+ | `viewport` | `width`/`height`, a named viewport from `globals.viewport`, or `viewport.defaultViewport` |
143
+ | `lostpixel.breakpoints` | One full-page shot per width, named `<storyId>__[w<width>px]` |
144
+ | `lostpixel.mask` | `[{ selector }]` regions blanked out before comparing |
145
+ | `lostpixel.threshold` | Per-story `threshold` |
146
+ | `lostpixel.waitBeforeScreenshot` | Extra wait (ms) once the story has settled |
147
+ | `lostpixel.disable` | Skip the story |
148
+
149
+ Stories rendered one after another in the same page can leak state into each other (module-level caches, randomness seeded once per page). So every shot that differs from its baseline is re-shot on both sides in a fresh page per story, and only differences that reproduce are reported. Seed any randomness per story (e.g. `faker.seed()` in a decorator) to keep those re-shoots rare.
150
+
151
+ ### Baselines
152
+
153
+ The default branch keeps one shared set of screenshots in `screenshots.s3`: `<repoName>/baseline/<shotId>.png`, plus `<repoName>/baseline.json` recording the commit and Chromium they were shot from. Each default-branch build runs storybook-diff against that commit, re-shoots only the stories it reports as changed and overwrites their files; the first build, or one with a different Chromium, shoots every story.
154
+
155
+ PRs into the default branch download the baseline shots for the stories they compare instead of screenshotting the base storybook, and shoot the base storybook for any that are missing. The baseline tracks the latest default-branch build rather than the PR's merge-base, so a story that differs from its baseline is re-shot from the PR's actual base storybook before it is treated as a change.
156
+
145
157
  ## Environment variables
146
158
 
147
159
  Read from the Buildkite environment automatically:
@@ -188,12 +200,13 @@ steps:
188
200
  ## CLI reference
189
201
 
190
202
  ```
191
- found-pixel build # build storybook, upload to S3, annotate
192
- found-pixel review # (PR only) download base, diff, regress, upsert comment
193
- found-pixel run # build then review
203
+ found-pixel build # build storybook, upload to S3, annotate
204
+ found-pixel baseline # (default branch only) update the shared baseline screenshots
205
+ found-pixel review # (PR only) download base, diff, regress, upsert comment
206
+ found-pixel run # build, then baseline or review
194
207
  ```
195
208
 
196
- `review` is a no-op when the build isn't a pull request.
209
+ `review` is a no-op when the build isn't a pull request, and `baseline` is a no-op off the default branch.
197
210
 
198
211
  ## Library usage
199
212
 
@@ -225,6 +238,7 @@ const body = renderComment({
225
238
 
226
239
  ```bash
227
240
  npm install
241
+ npx playwright-core install --only-shell chromium # once, for the screenshot engine tests
228
242
  npm test # runs vitest against all fixtures
229
243
  npm run build # tsc → dist/
230
244
  npm run typecheck # tsc --noEmit
@@ -249,7 +263,7 @@ npm install --save-dev found-pixel@alpha-<branch-slug>
249
263
 
250
264
  Two gates apply, and both bite silently when they fail:
251
265
 
252
- 1. **Path filter** — the PR must change at least one file matching the workflow's `paths:` list (`src/**`, `patches/**`, `package.json`, `package-lock.json`). A docs- or test-only PR never starts the workflow at all, so there is no skipped job to notice.
266
+ 1. **Path filter** — the PR must change at least one file matching the workflow's `paths:` list (`src/**`, `package.json`, `package-lock.json`). A docs- or test-only PR never starts the workflow at all, so there is no skipped job to notice.
253
267
  2. **Head commit only** — only `HEAD` is checked, not the whole PR. `[publish]` in an earlier commit does nothing; amend or add a new commit to re-publish. Each push increments `run_number`, so every alpha gets a distinct version.
254
268
 
255
269
  **Release, on merge to main.** Bump `version` in `package.json` as part of the PR. Once it lands on `main` the workflow compares the version against `HEAD~1` — if it changed, it publishes to the `latest` tag, pushes a `v<version>` tag, and creates a GitHub release with generated notes. If the version is untouched, the run succeeds and publishes nothing, which is what makes dependency-only and refactor-only merges safe.
@@ -0,0 +1,15 @@
1
+ import type { Config } from "./config.js";
2
+ export declare const WORK_DIR = ".found-pixel";
3
+ export interface BaselineState {
4
+ sha: string;
5
+ engine: string;
6
+ updatedAt: string;
7
+ }
8
+ export interface BaselineShots {
9
+ sha: string;
10
+ download: (shotId: string, localPath: string) => Promise<boolean>;
11
+ }
12
+ export declare function parseState(raw: string): BaselineState | null;
13
+ export declare function baselineLoader(cfg: Config): ((engine: string) => Promise<BaselineShots | null>) | undefined;
14
+ export declare function publishBaselines(cfg: Config): Promise<void>;
15
+ //# sourceMappingURL=baselines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baselines.d.ts","sourceRoot":"","sources":["../src/baselines.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAK1C,eAAO,MAAM,QAAQ,iBAAiB,CAAC;AAEvC,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACnE;AAqCD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAO5D;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC,GAAG,SAAS,CAoB3G;AAED,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAyDjE"}
@@ -0,0 +1,148 @@
1
+ import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
+ import { join, resolve } from "node:path";
3
+ import { annotate, readContext } from "./buildkite.js";
4
+ import { engineFingerprint, installChromium, launchChromium } from "./capture/browser.js";
5
+ import { captureStories, logProblems } from "./capture/engine.js";
6
+ import { baselinePrefix, baselineStateKey, createS3 } from "./storage.js";
7
+ import { diffStorybooks, fetchStorybook } from "./storybook.js";
8
+ import { readCaptureStories } from "./storyIndex.js";
9
+ export const WORK_DIR = ".found-pixel";
10
+ function createBaselineStore(cfg, screenshots, workDir) {
11
+ const s3 = createS3(screenshots.s3);
12
+ const s3Key = (key) => (screenshots.uploadPrefix ? `${screenshots.uploadPrefix}/${key}` : key);
13
+ const s3Url = (key) => `s3://${screenshots.s3.bucket}/${s3Key(key)}`;
14
+ const fetchTo = async (key, localPath) => {
15
+ if (!screenshots.baseUrl)
16
+ return s3.download(s3Key(key), localPath);
17
+ const path = key.split("/").map(encodeURIComponent).join("/");
18
+ const res = await fetch(`${screenshots.baseUrl}/${path}`);
19
+ if (!res.ok)
20
+ return false;
21
+ writeFileSync(localPath, Buffer.from(await res.arrayBuffer()));
22
+ return true;
23
+ };
24
+ return {
25
+ async readState() {
26
+ mkdirSync(workDir, { recursive: true });
27
+ const localPath = join(workDir, "baseline.json");
28
+ if (!(await fetchTo(baselineStateKey(cfg), localPath)))
29
+ return null;
30
+ return parseState(readFileSync(localPath, "utf8"));
31
+ },
32
+ async writeState(state) {
33
+ const localPath = join(workDir, "baseline.json");
34
+ writeFileSync(localPath, JSON.stringify(state));
35
+ await s3.cp(localPath, s3Url(baselineStateKey(cfg)), { noCache: true });
36
+ },
37
+ download: (shotId, localPath) => fetchTo(`${baselinePrefix(cfg)}/${shotId}.png`, localPath),
38
+ upload: (dir) => s3.cp(dir, `${s3Url(baselinePrefix(cfg))}/`, { recursive: true, noCache: true }),
39
+ replace: (dir) => s3.mirror(dir, `${s3Url(baselinePrefix(cfg))}/`),
40
+ remove: (storyIds) => s3.removeStories(s3Key(baselinePrefix(cfg)), storyIds),
41
+ };
42
+ }
43
+ export function parseState(raw) {
44
+ try {
45
+ const state = JSON.parse(raw);
46
+ return typeof state.sha === "string" && typeof state.engine === "string" ? state : null;
47
+ }
48
+ catch {
49
+ return null;
50
+ }
51
+ }
52
+ export function baselineLoader(cfg) {
53
+ const { screenshots } = cfg;
54
+ if (!screenshots || !cfg.visualRegression.baselines)
55
+ return undefined;
56
+ const store = createBaselineStore(cfg, screenshots, resolve(WORK_DIR, "state"));
57
+ return async (engine) => {
58
+ const state = await store.readState().catch((err) => {
59
+ console.warn("Could not read baselines:", err);
60
+ return null;
61
+ });
62
+ if (!state) {
63
+ console.log("No baselines yet; shooting the base storybook instead");
64
+ return null;
65
+ }
66
+ if (state.engine !== engine) {
67
+ console.log(`Baselines were shot with ${state.engine}, not ${engine}; shooting the base storybook instead`);
68
+ return null;
69
+ }
70
+ return { sha: state.sha, download: store.download };
71
+ };
72
+ }
73
+ export async function publishBaselines(cfg) {
74
+ const ctx = readContext();
75
+ const vr = cfg.visualRegression;
76
+ if (!vr.enabled || !vr.baselines || ctx.branch !== cfg.defaultBranch || !ctx.commitSha)
77
+ return;
78
+ if (!cfg.screenshots) {
79
+ console.log("Skipping baselines: `screenshots` is not configured");
80
+ return;
81
+ }
82
+ const workDir = resolve(WORK_DIR, "baseline");
83
+ rmSync(workDir, { recursive: true, force: true });
84
+ mkdirSync(workDir, { recursive: true });
85
+ const shotsDir = join(workDir, "shots");
86
+ const store = createBaselineStore(cfg, cfg.screenshots, workDir);
87
+ await installChromium();
88
+ const browser = await launchChromium();
89
+ try {
90
+ const engine = engineFingerprint(browser);
91
+ const state = await store.readState();
92
+ const changes = state?.engine === engine ? await changedSince(cfg, state.sha, workDir) : null;
93
+ const stories = readCaptureStories(cfg.outputDir, changes?.shoot);
94
+ console.log(changes
95
+ ? `--- :camera_with_flash: Updating baselines: ${stories.length} stories changed since ${state?.sha.slice(0, 7)}`
96
+ : `--- :camera_with_flash: Shooting baselines for all ${stories.length} stories`);
97
+ const result = await captureStories({
98
+ browser,
99
+ storybookDir: cfg.outputDir,
100
+ stories,
101
+ outDir: shotsDir,
102
+ concurrency: vr.shotConcurrency,
103
+ deadline: Date.now() + vr.timeoutMinutes * 60_000,
104
+ label: "baselines",
105
+ });
106
+ logProblems(result, "baselines");
107
+ console.log("--- :s3: Uploading baselines");
108
+ mkdirSync(shotsDir, { recursive: true });
109
+ if (changes) {
110
+ if (changes.remove.length > 0)
111
+ await store.remove(changes.remove);
112
+ if (result.shots.length > 0)
113
+ await store.upload(shotsDir);
114
+ }
115
+ else {
116
+ await store.replace(shotsDir);
117
+ }
118
+ await store.writeState({ sha: ctx.commitSha, engine, updatedAt: new Date().toISOString() });
119
+ const failed = result.failures.length > 0 ? `, ${result.failures.length} failed` : "";
120
+ await annotate(`:camera_with_flash: Baselines: shot ${result.shots.length} of ${stories.length} stories in ${Math.round(result.seconds)}s${failed}`, { context: "found-pixel-baselines", style: result.failures.length > 0 ? "warning" : "info" });
121
+ }
122
+ finally {
123
+ await browser.close();
124
+ }
125
+ }
126
+ async function changedSince(cfg, sha, workDir) {
127
+ const dir = join(workDir, "previous");
128
+ try {
129
+ if (!(await fetchStorybook(cfg, sha, dir, join(workDir, "previous.tar.gz")))) {
130
+ console.warn(`No storybook archive for ${sha}; shooting every story`);
131
+ return null;
132
+ }
133
+ const diff = JSON.parse(await diffStorybooks(cfg, dir, cfg.outputDir));
134
+ const modified = diff.modified ?? [];
135
+ return {
136
+ shoot: [...modified.map((s) => s.id), ...(diff.created ?? []).map((s) => s.id)],
137
+ remove: [
138
+ ...(diff.deleted ?? []).map((s) => s.id),
139
+ ...modified.flatMap((s) => (s.previousRef && s.previousRef.id !== s.id ? [s.previousRef.id] : [])),
140
+ ],
141
+ };
142
+ }
143
+ catch (error) {
144
+ console.warn(`Could not diff against ${sha}; shooting every story:`, error);
145
+ return null;
146
+ }
147
+ }
148
+ //# sourceMappingURL=baselines.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baselines.js","sourceRoot":"","sources":["../src/baselines.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,CAAC,MAAM,QAAQ,GAAG,cAAc,CAAC;AAevC,SAAS,mBAAmB,CAAC,GAAW,EAAE,WAAwB,EAAE,OAAe;IACjF,MAAM,EAAE,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GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YAC/E,MAAM,EAAE;gBACN,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;aACnG;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,0BAA0B,GAAG,yBAAyB,EAAE,KAAK,CAAC,CAAC;QAC5E,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
package/dist/bin.d.ts CHANGED
@@ -1,10 +1,4 @@
1
+ export declare function packageRoot(pkg: string): string;
1
2
  /** Resolve an installed package's CLI entry, accounting for string or object `bin` fields. */
2
3
  export declare function resolveBin(pkg: string, binName?: string): string;
3
- /**
4
- * Lost-pixel bundles its own `playwright-core` with matching browser revisions.
5
- * We must use *that* copy's CLI to install browsers, otherwise we'd install
6
- * browsers for our top-level playwright-core version and lost-pixel would fail
7
- * at runtime looking for a different chromium build.
8
- */
9
- export declare function lostPixelPlaywrightCoreDir(): string;
10
4
  //# sourceMappingURL=bin.d.ts.map
package/dist/bin.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":"AA4BA,8FAA8F;AAC9F,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAchE;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAGnD"}
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":"AAMA,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAkB/C;AAED,8FAA8F;AAC9F,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAchE"}
package/dist/bin.js CHANGED
@@ -2,11 +2,9 @@ import { readFileSync } from "node:fs";
2
2
  import { dirname, resolve } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  // Some deps are ESM-only with `exports` that block both `./package.json` and
5
- // the CJS resolution of `.`, so we walk `node_modules` directly instead. Pass
6
- // `from` to resolve a nested dep (e.g. the playwright-core copy bundled inside
7
- // lost-pixel) rather than the top-level install.
8
- function packageRoot(pkg, from) {
9
- let dir = from ?? dirname(fileURLToPath(import.meta.url));
5
+ // the CJS resolution of `.`, so we walk `node_modules` directly instead.
6
+ export function packageRoot(pkg) {
7
+ let dir = dirname(fileURLToPath(import.meta.url));
10
8
  while (true) {
11
9
  const candidate = resolve(dir, "node_modules", pkg, "package.json");
12
10
  try {
@@ -38,14 +36,4 @@ export function resolveBin(pkg, binName) {
38
36
  }
39
37
  return resolve(root, binRel);
40
38
  }
41
- /**
42
- * Lost-pixel bundles its own `playwright-core` with matching browser revisions.
43
- * We must use *that* copy's CLI to install browsers, otherwise we'd install
44
- * browsers for our top-level playwright-core version and lost-pixel would fail
45
- * at runtime looking for a different chromium build.
46
- */
47
- export function lostPixelPlaywrightCoreDir() {
48
- const lostPixelRoot = packageRoot("lost-pixel");
49
- return packageRoot("playwright-core", lostPixelRoot);
50
- }
51
39
  //# sourceMappingURL=bin.js.map
package/dist/bin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.js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5 @@
1
+ import { type Browser } from "playwright-core";
2
+ export declare function installChromium(): Promise<void>;
3
+ export declare function launchChromium(): Promise<Browser>;
4
+ export declare function engineFingerprint(browser: Browser): string;
5
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/capture/browser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAMzD,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAOrD;AAED,wBAAgB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAEjD;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAE1D"}
@@ -0,0 +1,21 @@
1
+ import { execa } from "execa";
2
+ import { resolve } from "node:path";
3
+ import { chromium } from "playwright-core";
4
+ import { packageRoot } from "../bin.js";
5
+ const INSTALL_TIMEOUT_MS = 5 * 60_000;
6
+ const CAPTURE_VERSION = 1;
7
+ export async function installChromium() {
8
+ console.log("~~~ :chrome: Installing chromium");
9
+ const cli = resolve(packageRoot("playwright-core"), "cli.js");
10
+ await execa("node", [cli, "install", "--with-deps", "--only-shell", "chromium"], {
11
+ stdio: "inherit",
12
+ timeout: INSTALL_TIMEOUT_MS,
13
+ });
14
+ }
15
+ export function launchChromium() {
16
+ return chromium.launch({ args: ["--force-color-profile=srgb"] });
17
+ }
18
+ export function engineFingerprint(browser) {
19
+ return `capture/${CAPTURE_VERSION} chromium/${browser.version()} ${process.platform}-${process.arch}`;
20
+ }
21
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/capture/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAgB,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,kBAAkB,GAAG,CAAC,GAAG,MAAM,CAAC;AACtC,MAAM,eAAe,GAAG,CAAC,CAAC;AAE1B,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;IAChD,MAAM,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC,iBAAiB,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC9D,MAAM,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,CAAC,EAAE;QAC/E,KAAK,EAAE,SAAS;QAChB,OAAO,EAAE,kBAAkB;KAC5B,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,4BAA4B,CAAC,EAAE,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAgB;IAChD,OAAO,WAAW,eAAe,aAAa,OAAO,CAAC,OAAO,EAAE,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;AACxG,CAAC"}
@@ -0,0 +1,8 @@
1
+ export interface ImageComparison {
2
+ pixelDifference: number;
3
+ ratio: number;
4
+ withinThreshold: boolean;
5
+ }
6
+ export declare function withinThreshold(threshold: number, pixelsTotal: number, pixelDifference: number): boolean;
7
+ export declare function compareImageFiles(baselinePath: string, currentPath: string, threshold: number, diffPath?: string): ImageComparison;
8
+ //# sourceMappingURL=compare.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../src/capture/compare.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAExG;AAED,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,MAAM,GAChB,eAAe,CAwBjB"}
@@ -0,0 +1,40 @@
1
+ import { readFileSync, writeFileSync } from "node:fs";
2
+ import pixelmatch from "pixelmatch";
3
+ import { PNG } from "pngjs";
4
+ export function withinThreshold(threshold, pixelsTotal, pixelDifference) {
5
+ return threshold < 1 ? pixelDifference <= pixelsTotal * threshold : pixelDifference <= threshold;
6
+ }
7
+ export function compareImageFiles(baselinePath, currentPath, threshold, diffPath) {
8
+ const baselineBuffer = readFileSync(baselinePath);
9
+ const currentBuffer = readFileSync(currentPath);
10
+ if (baselineBuffer.equals(currentBuffer)) {
11
+ return { pixelDifference: 0, ratio: 0, withinThreshold: true };
12
+ }
13
+ let baseline = PNG.sync.read(baselineBuffer);
14
+ let current = PNG.sync.read(currentBuffer);
15
+ const width = Math.max(baseline.width, current.width);
16
+ const height = Math.max(baseline.height, current.height);
17
+ if (baseline.width !== width || baseline.height !== height)
18
+ baseline = padImage(baseline, width, height);
19
+ if (current.width !== width || current.height !== height)
20
+ current = padImage(current, width, height);
21
+ const diff = new PNG({ width, height });
22
+ const pixelDifference = pixelmatch(baseline.data, current.data, diff.data, width, height, { threshold: 0 });
23
+ const pixelsTotal = width * height;
24
+ const result = {
25
+ pixelDifference,
26
+ ratio: pixelDifference / pixelsTotal,
27
+ withinThreshold: withinThreshold(threshold, pixelsTotal, pixelDifference),
28
+ };
29
+ if (!result.withinThreshold && diffPath)
30
+ writeFileSync(diffPath, PNG.sync.write(diff));
31
+ return result;
32
+ }
33
+ function padImage(image, width, height) {
34
+ const padded = new PNG({ width, height, fill: true });
35
+ for (let i = 3; i < padded.data.length; i += 4)
36
+ padded.data[i] = 64;
37
+ PNG.bitblt(image, padded, 0, 0, image.width, image.height, 0, 0);
38
+ return padded;
39
+ }
40
+ //# sourceMappingURL=compare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compare.js","sourceRoot":"","sources":["../../src/capture/compare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAQ5B,MAAM,UAAU,eAAe,CAAC,SAAiB,EAAE,WAAmB,EAAE,eAAuB;IAC7F,OAAO,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,IAAI,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,eAAe,IAAI,SAAS,CAAC;AACnG,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,YAAoB,EACpB,WAAmB,EACnB,SAAiB,EACjB,QAAiB;IAEjB,MAAM,cAAc,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;IAClD,MAAM,aAAa,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;IAChD,IAAI,cAAc,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;QACzC,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;IACjE,CAAC;IAED,IAAI,QAAQ,GAAQ,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAClD,IAAI,OAAO,GAAQ,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,MAAM,GAAG,IAA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G,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC;QAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACpE,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACjE,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { Browser } from "playwright-core";
2
+ import { type ShotPlan } from "./shotPlan.js";
3
+ export interface CaptureStory {
4
+ id: string;
5
+ importPath?: string;
6
+ }
7
+ export interface CapturedShot extends ShotPlan {
8
+ file: string;
9
+ error?: string;
10
+ }
11
+ export interface CaptureFailure {
12
+ storyId: string;
13
+ error: string;
14
+ }
15
+ export interface CaptureResult {
16
+ shots: CapturedShot[];
17
+ failures: CaptureFailure[];
18
+ seconds: number;
19
+ }
20
+ export interface CaptureOptions {
21
+ browser: Browser;
22
+ storybookDir: string;
23
+ stories: CaptureStory[];
24
+ outDir: string;
25
+ concurrency: number;
26
+ isolate?: boolean;
27
+ deadline?: number;
28
+ label?: string;
29
+ }
30
+ export declare function captureStories(options: CaptureOptions): Promise<CaptureResult>;
31
+ export declare function logProblems(result: CaptureResult, label: string): void;
32
+ export declare function groupStories(stories: CaptureStory[], isolate: boolean): CaptureStory[][];
33
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/capture/engine.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAwB,MAAM,iBAAiB,CAAC;AAYrE,OAAO,EAAmD,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE/F,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;A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