storybook-addon-vis 4.3.5 → 4.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # CHANGE LOG
2
2
 
3
+ ## 4.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1002](https://github.com/repobuddy/visual-testing/pull/1002) [`3dd963f`](https://github.com/repobuddy/visual-testing/commit/3dd963fdb902b0dfbecf3fccc9d562287e9ea583) Thanks [@unional](https://github.com/unional)! - Add an `animations` option (`'disabled' | 'allow'`, default `'allow'`) to `toMatchImageSnapshot()`, `page.toMatchImageSnapshot()`, `setAutoSnapshotOptions()` and `vis.setup()`. With `'disabled'`, finite CSS animations and transitions are finished and infinite ones are cancelled before the snapshot, so animated components give stable images with both the Playwright and WebdriverIO providers.
8
+
9
+ - [#1003](https://github.com/repobuddy/visual-testing/pull/1003) [`09440c3`](https://github.com/repobuddy/visual-testing/commit/09440c3d9a0a21c7fcc0535eb89c96b8d016ce45) Thanks [@unional](https://github.com/unional)! - Add a `mask` option to `toMatchImageSnapshot()` (both `expect(...)` and `page.`), `setAutoSnapshotOptions()` and `vis.setup({ auto })`. It takes selectors, locators or elements and paints them over before the snapshot is taken, so content that changes on every run does not fail the comparison. `maskColor` sets the color. It works with the Playwright and WebdriverIO providers.
10
+
11
+ ### Patch Changes
12
+
13
+ - [#949](https://github.com/repobuddy/visual-testing/pull/949) [`a4ce784`](https://github.com/repobuddy/visual-testing/commit/a4ce78437d5ff697176b25002f411be2868346ef) Thanks [@dependabot](https://github.com/apps/dependabot)! - Update `glob` to v14.
14
+
15
+ - [#1005](https://github.com/repobuddy/visual-testing/pull/1005) [`3a7ed6e`](https://github.com/repobuddy/visual-testing/commit/3a7ed6e9c1621af94a8535517b6be000f5b44e3a) Thanks [@unional](https://github.com/unional)! - State on the Compare pages that masking is supported.
16
+
17
+ - [#993](https://github.com/repobuddy/visual-testing/pull/993) [`67ac628`](https://github.com/repobuddy/visual-testing/commit/67ac628e3d6f41cfc8fdfe77e6153180b9595062) Thanks [@unional](https://github.com/unional)! - List the new Vitest plugin guides, examples, troubleshooting and reference pages in `llms.txt`, and document more of the plugin's public API.
18
+
19
+ - [#992](https://github.com/repobuddy/visual-testing/pull/992) [`b427b9e`](https://github.com/repobuddy/visual-testing/commit/b427b9eb73f88ebaa6e6eeafdda618e971b9ad58) Thanks [@unional](https://github.com/unional)! - Document `addonVis`, `isSnapshotEnabled` and the preset entry in the overview page, and link the new addon guides from `llms.txt`.
20
+
21
+ - [#988](https://github.com/repobuddy/visual-testing/pull/988) [`42dc3dd`](https://github.com/repobuddy/visual-testing/commit/42dc3ddfa4b18e171ab1da832000fac5220de65b) Thanks [@unional](https://github.com/unional)! - Update the readme, `llms.txt` and `review-image-snapshot-failures` skill links to the new website page locations.
22
+ The old page URLs still redirect to the new ones.
23
+
24
+ - [#991](https://github.com/repobuddy/visual-testing/pull/991) [`06d72bf`](https://github.com/repobuddy/visual-testing/commit/06d72bfe7490723e77a75dbeb0d6bdea863468ca) Thanks [@unional](https://github.com/unional)! - List the new Visual testing concept pages of the website in `llms.txt`.
25
+ - Updated dependencies [[`a4ce784`](https://github.com/repobuddy/visual-testing/commit/a4ce78437d5ff697176b25002f411be2868346ef), [`3a7ed6e`](https://github.com/repobuddy/visual-testing/commit/3a7ed6e9c1621af94a8535517b6be000f5b44e3a), [`3dd963f`](https://github.com/repobuddy/visual-testing/commit/3dd963fdb902b0dfbecf3fccc9d562287e9ea583), [`09440c3`](https://github.com/repobuddy/visual-testing/commit/09440c3d9a0a21c7fcc0535eb89c96b8d016ce45), [`67ac628`](https://github.com/repobuddy/visual-testing/commit/67ac628e3d6f41cfc8fdfe77e6153180b9595062), [`42dc3dd`](https://github.com/repobuddy/visual-testing/commit/42dc3ddfa4b18e171ab1da832000fac5220de65b), [`06d72bf`](https://github.com/repobuddy/visual-testing/commit/06d72bfe7490723e77a75dbeb0d6bdea863468ca)]:
26
+ - vitest-plugin-vis@5.4.0
27
+
28
+ ## 4.4.0
29
+
30
+ ### Minor Changes
31
+
32
+ - [#970](https://github.com/repobuddy/visual-testing/pull/970) [`830f5c4`](https://github.com/repobuddy/visual-testing/commit/830f5c448ade9b1d395b6840d618221c62000841) Thanks [@unional](https://github.com/unional)! - The `Vis` panel compares a failed snapshot the way GitHub compares images.
33
+ Pick side by side, swipe, or onion skin to compare the baseline with the result, or pick Diff to see the diff image.
34
+ Snapshots that passed show the baseline as before.
35
+ When a failed snapshot has no result image, such as one from an older run, the panel shows its images one after another as before.
36
+
37
+ ### Patch Changes
38
+
39
+ - Updated dependencies [[`830f5c4`](https://github.com/repobuddy/visual-testing/commit/830f5c448ade9b1d395b6840d618221c62000841)]:
40
+ - vitest-plugin-vis@5.3.0
41
+
3
42
  ## 4.3.5
4
43
 
5
44
  ### Patch Changes
@@ -5,7 +5,7 @@ import { globSync } from "glob";
5
5
  import ci from "is-ci";
6
6
  import memoize from "memoize";
7
7
  import { basename, resolve } from "pathe";
8
- import { BASELINE_DIR, DIFF_DIR, REVIEW_IMAGE_SUFFIX, SNAPSHOT_ROOT_DIR, getSnapshotRootDir, resolveSnapshotSubpathWithinLimits, trimCommonFolder } from "vitest-plugin-vis/server-utils";
8
+ import { BASELINE_DIR, DIFF_DIR, RESULT_DIR, REVIEW_IMAGE_SUFFIX, SNAPSHOT_ROOT_DIR, getSnapshotRootDir, resolveSnapshotSubpathWithinLimits, trimCommonFolder } from "vitest-plugin-vis/server-utils";
9
9
 
10
10
  //#region src/server/create_storybook_vis_server.ts
11
11
  function createStorybookVisServer(options) {
@@ -31,12 +31,18 @@ function createStorybookVisServer(options) {
31
31
  const taskId = name.replace(/[^a-z0-9]/gi, "-").toLowerCase();
32
32
  const taskGlob = `${taskId}-*.png`;
33
33
  const baselineGlob = resolve(snapshotRootDir, BASELINE_DIR, snapshotSubpath, taskGlob);
34
+ const resultGlob = resolve(snapshotRootDir, RESULT_DIR, snapshotSubpath, taskGlob);
34
35
  const diffGlob = resolve(snapshotRootDir, DIFF_DIR, snapshotSubpath, taskGlob);
35
36
  const taskIdRegex = /* @__PURE__ */ new RegExp(`${taskId}-[^-]*.png$`);
36
37
  const isSnapshotFile = (filePath) => taskIdRegex.test(filePath) && !filePath.endsWith(REVIEW_IMAGE_SUFFIX);
37
38
  const baselineFiles = globSync(baselineGlob).filter(isSnapshotFile);
39
+ const resultFiles = globSync(resultGlob).filter(isSnapshotFile);
38
40
  const diffFiles = globSync(diffGlob).filter(isSnapshotFile);
39
- return [...baselineFiles.map((filePath) => mapFileToResult(filePath, snapshotRootDir, "baseline")), ...diffFiles.map((filePath) => mapFileToResult(filePath, snapshotRootDir, "diff"))];
41
+ return [
42
+ ...baselineFiles.map((filePath) => mapFileToResult(filePath, snapshotRootDir, "baseline")),
43
+ ...resultFiles.map((filePath) => mapFileToResult(filePath, snapshotRootDir, "result")),
44
+ ...diffFiles.map((filePath) => mapFileToResult(filePath, snapshotRootDir, "diff"))
45
+ ];
40
46
  });
41
47
  }
42
48
  };
@@ -1 +1 @@
1
- {"version":3,"file":"preset.mjs","names":[],"sources":["../../src/server/create_storybook_vis_server.ts","../../src/shared/events.ts","../../src/exports/preset.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { platform } from 'node:process'\nimport { globSync } from 'glob'\nimport ci from 'is-ci'\nimport memoize from 'memoize'\nimport { basename, resolve } from 'pathe'\nimport {\n\tBASELINE_DIR,\n\tDIFF_DIR,\n\tgetSnapshotRootDir,\n\tREVIEW_IMAGE_SUFFIX,\n\tresolveSnapshotSubpathWithinLimits,\n\tSNAPSHOT_ROOT_DIR,\n\ttrimCommonFolder,\n} from 'vitest-plugin-vis/server-utils'\nimport type { StorybookVisOptions } from './types.ts'\n\nexport function createStorybookVisServer(options: StorybookVisOptions) {\n\tconst visSuites = options.visProjects ?? [{}]\n\treturn {\n\t\toptions,\n\t\tasync getImageSnapshotResults(name: string, importPath: string) {\n\t\t\treturn visSuites\n\t\t\t\t.map((suite) => {\n\t\t\t\t\tconst snapshotRootDir =\n\t\t\t\t\t\ttypeof suite.snapshotRootDir === 'string'\n\t\t\t\t\t\t\t? suite.snapshotRootDir\n\t\t\t\t\t\t\t: typeof suite.snapshotRootDir === 'function'\n\t\t\t\t\t\t\t\t? memoize(suite.snapshotRootDir)({\n\t\t\t\t\t\t\t\t\t\tci,\n\t\t\t\t\t\t\t\t\t\tplatform,\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t: memoize(getSnapshotRootDir)(SNAPSHOT_ROOT_DIR)\n\n\t\t\t\t\tconst snapshotSubpathFn =\n\t\t\t\t\t\ttypeof suite.snapshotSubpath === 'function'\n\t\t\t\t\t\t\t? memoize(suite.snapshotSubpath)\n\t\t\t\t\t\t\t: memoize(({ subpath }: { subpath: string }) =>\n\t\t\t\t\t\t\t\t\ttrimCommonFolder(subpath.startsWith('./') ? subpath.slice(2) : subpath),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\tconst snapshotSubpathRaw = snapshotSubpathFn({ subpath: importPath })\n\t\t\t\t\tconst snapshotBaselineRootAbs = resolve(snapshotRootDir, BASELINE_DIR)\n\t\t\t\t\tconst snapshotSubpath = resolveSnapshotSubpathWithinLimits({\n\t\t\t\t\t\tsnapshotBaselineRootAbs,\n\t\t\t\t\t\trawSnapshotSubpath: snapshotSubpathRaw,\n\t\t\t\t\t\tshortenLongSnapshotPaths: suite.shortenLongSnapshotPaths === true,\n\t\t\t\t\t})\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsnapshotRootDir,\n\t\t\t\t\t\tsnapshotSubpath,\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.flatMap(({ snapshotRootDir, snapshotSubpath }) => {\n\t\t\t\t\tconst taskId = name.replace(/[^a-z0-9]/gi, '-').toLowerCase()\n\t\t\t\t\tconst taskGlob = `${taskId}-*.png`\n\t\t\t\t\tconst baselineGlob = resolve(snapshotRootDir, BASELINE_DIR, snapshotSubpath, taskGlob)\n\t\t\t\t\tconst diffGlob = resolve(snapshotRootDir, DIFF_DIR, snapshotSubpath, taskGlob)\n\n\t\t\t\t\tconst taskIdRegex = new RegExp(`${taskId}-[^-]*.png$`)\n\t\t\t\t\tconst isSnapshotFile = (filePath: string) =>\n\t\t\t\t\t\ttaskIdRegex.test(filePath) && !filePath.endsWith(REVIEW_IMAGE_SUFFIX)\n\t\t\t\t\tconst baselineFiles = globSync(baselineGlob).filter(isSnapshotFile)\n\t\t\t\t\tconst diffFiles = globSync(diffGlob).filter(isSnapshotFile)\n\t\t\t\t\treturn [\n\t\t\t\t\t\t...baselineFiles.map((filePath) => mapFileToResult(filePath, snapshotRootDir, 'baseline')),\n\t\t\t\t\t\t...diffFiles.map((filePath) => mapFileToResult(filePath, snapshotRootDir, 'diff')),\n\t\t\t\t\t]\n\t\t\t\t})\n\t\t},\n\t}\n}\n\nfunction mapFileToResult(filePath: string, snapshotRootDir: string, type: 'baseline' | 'diff') {\n\treturn {\n\t\tfilePath,\n\t\tfileName: basename(filePath),\n\t\tsnapshotRootDir,\n\t\ttype,\n\t\tbase64: readFileSync(filePath, 'base64'),\n\t}\n}\n","export type VisEvent = ImageSnapshotResultsRequest | ImageSnapshotResultsResponse\n\nexport const IMAGE_SNAPSHOT_RESULTS_REQUEST = 'IMAGE_SNAPSHOT_RESULTS_REQUEST'\nexport const IMAGE_SNAPSHOT_RESULTS_RESPONSE = 'IMAGE_SNAPSHOT_RESULTS_RESPONSE'\n\nexport function requestImageSnapshotResults({ name, importPath }: { name: string; importPath: string }) {\n\treturn {\n\t\ttype: IMAGE_SNAPSHOT_RESULTS_REQUEST,\n\t\tname,\n\t\timportPath,\n\t}\n}\n\nexport type ImageSnapshotResultsRequest = {\n\ttype: typeof IMAGE_SNAPSHOT_RESULTS_REQUEST\n\tname: string\n\timportPath: string\n}\n\nexport type ImageSnapshotResultsResponse = {\n\ttype: typeof IMAGE_SNAPSHOT_RESULTS_RESPONSE\n\tname: string\n\timportPath: string\n\tresults: ImageSnapshotResults[]\n}\n\nexport type ImageSnapshotResults = {\n\tfilePath: string\n\tfileName: string\n\tsnapshotRootDir: string\n\ttype: 'baseline' | 'diff' | 'result'\n\tbase64: string\n}\n","import type { Channel } from 'storybook/internal/channels'\nimport { createStorybookVisServer } from '../server/create_storybook_vis_server.ts'\nimport type { StorybookVisOptions } from '../server/types.ts'\nimport { NAME } from '../shared/constants.ts'\nimport { IMAGE_SNAPSHOT_RESULTS_REQUEST, IMAGE_SNAPSHOT_RESULTS_RESPONSE, type VisEvent } from '../shared/events.ts'\n\nexport const experimental_serverChannel = async (channel: Channel, options: StorybookVisOptions) => {\n\tconst server = createStorybookVisServer(options)\n\n\tchannel.on(NAME, async (event: VisEvent) => {\n\t\tif (event.type === IMAGE_SNAPSHOT_RESULTS_REQUEST) {\n\t\t\tconst results = await server.getImageSnapshotResults(event.name, event.importPath)\n\t\t\tchannel.emit(NAME, {\n\t\t\t\ttype: IMAGE_SNAPSHOT_RESULTS_RESPONSE,\n\t\t\t\tname: event.name,\n\t\t\t\timportPath: event.importPath,\n\t\t\t\tresults,\n\t\t\t})\n\t\t}\n\t})\n\n\treturn channel\n}\n"],"mappings":";;;;;;;;;;AAiBA,SAAgB,yBAAyB,SAA8B;CACtE,MAAM,YAAY,QAAQ,eAAe,CAAC,EAAE,CAAC;AAC7C,QAAO;EACN;EACA,MAAM,wBAAwB,MAAc,YAAoB;AAC/D,UAAO,UACL,KAAK,UAAU;IACf,MAAM,kBACL,OAAO,MAAM,oBAAoB,WAC9B,MAAM,kBACN,OAAO,MAAM,oBAAoB,aAChC,QAAQ,MAAM,gBAAgB,CAAC;KAC/B;KACA;KACA,CAAC,GACD,QAAQ,mBAAmB,CAAC,kBAAkB;IAQnD,MAAM,sBALL,OAAO,MAAM,oBAAoB,aAC9B,QAAQ,MAAM,gBAAgB,GAC9B,SAAS,EAAE,cACX,iBAAiB,QAAQ,WAAW,KAAK,GAAG,QAAQ,MAAM,EAAE,GAAG,QAAQ,CACvE,EACyC,EAAE,SAAS,YAAY,CAAC;AAOrE,WAAO;KACN;KACA,iBAPuB,mCAAmC;MAC1D,yBAF+B,QAAQ,iBAAiB,aAAa;MAGrE,oBAAoB;MACpB,0BAA0B,MAAM,6BAA6B;MAC7D,CAAC;KAID;KACA,CACD,SAAS,EAAE,iBAAiB,sBAAsB;IAClD,MAAM,SAAS,KAAK,QAAQ,eAAe,IAAI,CAAC,aAAa;IAC7D,MAAM,WAAW,GAAG,OAAO;IAC3B,MAAM,eAAe,QAAQ,iBAAiB,cAAc,iBAAiB,SAAS;IACtF,MAAM,WAAW,QAAQ,iBAAiB,UAAU,iBAAiB,SAAS;IAE9E,MAAM,8BAAc,IAAI,OAAO,GAAG,OAAO,aAAa;IACtD,MAAM,kBAAkB,aACvB,YAAY,KAAK,SAAS,IAAI,CAAC,SAAS,SAAS,oBAAoB;IACtE,MAAM,gBAAgB,SAAS,aAAa,CAAC,OAAO,eAAe;IACnE,MAAM,YAAY,SAAS,SAAS,CAAC,OAAO,eAAe;AAC3D,WAAO,CACN,GAAG,cAAc,KAAK,aAAa,gBAAgB,UAAU,iBAAiB,WAAW,CAAC,EAC1F,GAAG,UAAU,KAAK,aAAa,gBAAgB,UAAU,iBAAiB,OAAO,CAAC,CAClF;KACA;;EAEJ;;AAGF,SAAS,gBAAgB,UAAkB,iBAAyB,MAA2B;AAC9F,QAAO;EACN;EACA,UAAU,SAAS,SAAS;EAC5B;EACA;EACA,QAAQ,aAAa,UAAU,SAAS;EACxC;;;;;AC7EF,MAAa,iCAAiC;AAC9C,MAAa,kCAAkC;;;;ACG/C,MAAa,6BAA6B,OAAO,SAAkB,YAAiC;CACnG,MAAM,SAAS,yBAAyB,QAAQ;AAEhD,SAAQ,GAAG,MAAM,OAAO,UAAoB;AAC3C,MAAI,MAAM,SAAS,gCAAgC;GAClD,MAAM,UAAU,MAAM,OAAO,wBAAwB,MAAM,MAAM,MAAM,WAAW;AAClF,WAAQ,KAAK,MAAM;IAClB,MAAM;IACN,MAAM,MAAM;IACZ,YAAY,MAAM;IAClB;IACA,CAAC;;GAEF;AAEF,QAAO"}
1
+ {"version":3,"file":"preset.mjs","names":[],"sources":["../../src/server/create_storybook_vis_server.ts","../../src/shared/events.ts","../../src/exports/preset.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { platform } from 'node:process'\nimport { globSync } from 'glob'\nimport ci from 'is-ci'\nimport memoize from 'memoize'\nimport { basename, resolve } from 'pathe'\nimport {\n\tBASELINE_DIR,\n\tDIFF_DIR,\n\tgetSnapshotRootDir,\n\tRESULT_DIR,\n\tREVIEW_IMAGE_SUFFIX,\n\tresolveSnapshotSubpathWithinLimits,\n\tSNAPSHOT_ROOT_DIR,\n\ttrimCommonFolder,\n} from 'vitest-plugin-vis/server-utils'\nimport type { ImageSnapshotResults } from '../shared/events.ts'\nimport type { StorybookVisOptions } from './types.ts'\n\nexport function createStorybookVisServer(options: StorybookVisOptions) {\n\tconst visSuites = options.visProjects ?? [{}]\n\treturn {\n\t\toptions,\n\t\tasync getImageSnapshotResults(name: string, importPath: string) {\n\t\t\treturn visSuites\n\t\t\t\t.map((suite) => {\n\t\t\t\t\tconst snapshotRootDir =\n\t\t\t\t\t\ttypeof suite.snapshotRootDir === 'string'\n\t\t\t\t\t\t\t? suite.snapshotRootDir\n\t\t\t\t\t\t\t: typeof suite.snapshotRootDir === 'function'\n\t\t\t\t\t\t\t\t? memoize(suite.snapshotRootDir)({\n\t\t\t\t\t\t\t\t\t\tci,\n\t\t\t\t\t\t\t\t\t\tplatform,\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t: memoize(getSnapshotRootDir)(SNAPSHOT_ROOT_DIR)\n\n\t\t\t\t\tconst snapshotSubpathFn =\n\t\t\t\t\t\ttypeof suite.snapshotSubpath === 'function'\n\t\t\t\t\t\t\t? memoize(suite.snapshotSubpath)\n\t\t\t\t\t\t\t: memoize(({ subpath }: { subpath: string }) =>\n\t\t\t\t\t\t\t\t\ttrimCommonFolder(subpath.startsWith('./') ? subpath.slice(2) : subpath),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\tconst snapshotSubpathRaw = snapshotSubpathFn({ subpath: importPath })\n\t\t\t\t\tconst snapshotBaselineRootAbs = resolve(snapshotRootDir, BASELINE_DIR)\n\t\t\t\t\tconst snapshotSubpath = resolveSnapshotSubpathWithinLimits({\n\t\t\t\t\t\tsnapshotBaselineRootAbs,\n\t\t\t\t\t\trawSnapshotSubpath: snapshotSubpathRaw,\n\t\t\t\t\t\tshortenLongSnapshotPaths: suite.shortenLongSnapshotPaths === true,\n\t\t\t\t\t})\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsnapshotRootDir,\n\t\t\t\t\t\tsnapshotSubpath,\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.flatMap(({ snapshotRootDir, snapshotSubpath }) => {\n\t\t\t\t\tconst taskId = name.replace(/[^a-z0-9]/gi, '-').toLowerCase()\n\t\t\t\t\tconst taskGlob = `${taskId}-*.png`\n\t\t\t\t\tconst baselineGlob = resolve(snapshotRootDir, BASELINE_DIR, snapshotSubpath, taskGlob)\n\t\t\t\t\tconst resultGlob = resolve(snapshotRootDir, RESULT_DIR, snapshotSubpath, taskGlob)\n\t\t\t\t\tconst diffGlob = resolve(snapshotRootDir, DIFF_DIR, snapshotSubpath, taskGlob)\n\n\t\t\t\t\tconst taskIdRegex = new RegExp(`${taskId}-[^-]*.png$`)\n\t\t\t\t\tconst isSnapshotFile = (filePath: string) =>\n\t\t\t\t\t\ttaskIdRegex.test(filePath) && !filePath.endsWith(REVIEW_IMAGE_SUFFIX)\n\t\t\t\t\tconst baselineFiles = globSync(baselineGlob).filter(isSnapshotFile)\n\t\t\t\t\tconst resultFiles = globSync(resultGlob).filter(isSnapshotFile)\n\t\t\t\t\tconst diffFiles = globSync(diffGlob).filter(isSnapshotFile)\n\t\t\t\t\treturn [\n\t\t\t\t\t\t...baselineFiles.map((filePath) => mapFileToResult(filePath, snapshotRootDir, 'baseline')),\n\t\t\t\t\t\t...resultFiles.map((filePath) => mapFileToResult(filePath, snapshotRootDir, 'result')),\n\t\t\t\t\t\t...diffFiles.map((filePath) => mapFileToResult(filePath, snapshotRootDir, 'diff')),\n\t\t\t\t\t]\n\t\t\t\t})\n\t\t},\n\t}\n}\n\nfunction mapFileToResult(\n\tfilePath: string,\n\tsnapshotRootDir: string,\n\ttype: ImageSnapshotResults['type'],\n): ImageSnapshotResults {\n\treturn {\n\t\tfilePath,\n\t\tfileName: basename(filePath),\n\t\tsnapshotRootDir,\n\t\ttype,\n\t\tbase64: readFileSync(filePath, 'base64'),\n\t}\n}\n","export type VisEvent = ImageSnapshotResultsRequest | ImageSnapshotResultsResponse\n\nexport const IMAGE_SNAPSHOT_RESULTS_REQUEST = 'IMAGE_SNAPSHOT_RESULTS_REQUEST'\nexport const IMAGE_SNAPSHOT_RESULTS_RESPONSE = 'IMAGE_SNAPSHOT_RESULTS_RESPONSE'\n\nexport function requestImageSnapshotResults({ name, importPath }: { name: string; importPath: string }) {\n\treturn {\n\t\ttype: IMAGE_SNAPSHOT_RESULTS_REQUEST,\n\t\tname,\n\t\timportPath,\n\t}\n}\n\nexport type ImageSnapshotResultsRequest = {\n\ttype: typeof IMAGE_SNAPSHOT_RESULTS_REQUEST\n\tname: string\n\timportPath: string\n}\n\nexport type ImageSnapshotResultsResponse = {\n\ttype: typeof IMAGE_SNAPSHOT_RESULTS_RESPONSE\n\tname: string\n\timportPath: string\n\tresults: ImageSnapshotResults[]\n}\n\nexport type ImageSnapshotResults = {\n\tfilePath: string\n\tfileName: string\n\tsnapshotRootDir: string\n\ttype: 'baseline' | 'diff' | 'result'\n\tbase64: string\n}\n","import type { Channel } from 'storybook/internal/channels'\nimport { createStorybookVisServer } from '../server/create_storybook_vis_server.ts'\nimport type { StorybookVisOptions } from '../server/types.ts'\nimport { NAME } from '../shared/constants.ts'\nimport { IMAGE_SNAPSHOT_RESULTS_REQUEST, IMAGE_SNAPSHOT_RESULTS_RESPONSE, type VisEvent } from '../shared/events.ts'\n\nexport const experimental_serverChannel = async (channel: Channel, options: StorybookVisOptions) => {\n\tconst server = createStorybookVisServer(options)\n\n\tchannel.on(NAME, async (event: VisEvent) => {\n\t\tif (event.type === IMAGE_SNAPSHOT_RESULTS_REQUEST) {\n\t\t\tconst results = await server.getImageSnapshotResults(event.name, event.importPath)\n\t\t\tchannel.emit(NAME, {\n\t\t\t\ttype: IMAGE_SNAPSHOT_RESULTS_RESPONSE,\n\t\t\t\tname: event.name,\n\t\t\t\timportPath: event.importPath,\n\t\t\t\tresults,\n\t\t\t})\n\t\t}\n\t})\n\n\treturn channel\n}\n"],"mappings":";;;;;;;;;;AAmBA,SAAgB,yBAAyB,SAA8B;CACtE,MAAM,YAAY,QAAQ,eAAe,CAAC,EAAE,CAAC;AAC7C,QAAO;EACN;EACA,MAAM,wBAAwB,MAAc,YAAoB;AAC/D,UAAO,UACL,KAAK,UAAU;IACf,MAAM,kBACL,OAAO,MAAM,oBAAoB,WAC9B,MAAM,kBACN,OAAO,MAAM,oBAAoB,aAChC,QAAQ,MAAM,gBAAgB,CAAC;KAC/B;KACA;KACA,CAAC,GACD,QAAQ,mBAAmB,CAAC,kBAAkB;IAQnD,MAAM,sBALL,OAAO,MAAM,oBAAoB,aAC9B,QAAQ,MAAM,gBAAgB,GAC9B,SAAS,EAAE,cACX,iBAAiB,QAAQ,WAAW,KAAK,GAAG,QAAQ,MAAM,EAAE,GAAG,QAAQ,CACvE,EACyC,EAAE,SAAS,YAAY,CAAC;AAOrE,WAAO;KACN;KACA,iBAPuB,mCAAmC;MAC1D,yBAF+B,QAAQ,iBAAiB,aAAa;MAGrE,oBAAoB;MACpB,0BAA0B,MAAM,6BAA6B;MAC7D,CAAC;KAID;KACA,CACD,SAAS,EAAE,iBAAiB,sBAAsB;IAClD,MAAM,SAAS,KAAK,QAAQ,eAAe,IAAI,CAAC,aAAa;IAC7D,MAAM,WAAW,GAAG,OAAO;IAC3B,MAAM,eAAe,QAAQ,iBAAiB,cAAc,iBAAiB,SAAS;IACtF,MAAM,aAAa,QAAQ,iBAAiB,YAAY,iBAAiB,SAAS;IAClF,MAAM,WAAW,QAAQ,iBAAiB,UAAU,iBAAiB,SAAS;IAE9E,MAAM,8BAAc,IAAI,OAAO,GAAG,OAAO,aAAa;IACtD,MAAM,kBAAkB,aACvB,YAAY,KAAK,SAAS,IAAI,CAAC,SAAS,SAAS,oBAAoB;IACtE,MAAM,gBAAgB,SAAS,aAAa,CAAC,OAAO,eAAe;IACnE,MAAM,cAAc,SAAS,WAAW,CAAC,OAAO,eAAe;IAC/D,MAAM,YAAY,SAAS,SAAS,CAAC,OAAO,eAAe;AAC3D,WAAO;KACN,GAAG,cAAc,KAAK,aAAa,gBAAgB,UAAU,iBAAiB,WAAW,CAAC;KAC1F,GAAG,YAAY,KAAK,aAAa,gBAAgB,UAAU,iBAAiB,SAAS,CAAC;KACtF,GAAG,UAAU,KAAK,aAAa,gBAAgB,UAAU,iBAAiB,OAAO,CAAC;KAClF;KACA;;EAEJ;;AAGF,SAAS,gBACR,UACA,iBACA,MACuB;AACvB,QAAO;EACN;EACA,UAAU,SAAS,SAAS;EAC5B;EACA;EACA,QAAQ,aAAa,UAAU,SAAS;EACxC;;;;;ACtFF,MAAa,iCAAiC;AAC9C,MAAa,kCAAkC;;;;ACG/C,MAAa,6BAA6B,OAAO,SAAkB,YAAiC;CACnG,MAAM,SAAS,yBAAyB,QAAQ;AAEhD,SAAQ,GAAG,MAAM,OAAO,UAAoB;AAC3C,MAAI,MAAM,SAAS,gCAAgC;GAClD,MAAM,UAAU,MAAM,OAAO,wBAAwB,MAAM,MAAM,MAAM,WAAW;AAClF,WAAQ,KAAK,MAAM;IAClB,MAAM;IACN,MAAM,MAAM;IACZ,YAAY,MAAM;IAClB;IACA,CAAC;;GAEF;AAEF,QAAO"}
@@ -1,5 +1,5 @@
1
1
  import "../global_matcher_augment-B1plNA_9.mjs";
2
- import { t as visAnnotations } from "../vis_annotation-N0xbuXis.mjs";
2
+ import { t as visAnnotations } from "../vis_annotation-pQo0FcfJ.mjs";
3
3
  import { setAutoSnapshotOptions } from "vitest-plugin-vis";
4
4
  import * as vitest_plugin_vis_setup_api0 from "vitest-plugin-vis/setup-api";
5
5
 
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./global_matcher_augment-B1plNA_9.mjs";
2
- import { t as visAnnotations } from "./vis_annotation-N0xbuXis.mjs";
2
+ import { t as visAnnotations } from "./vis_annotation-pQo0FcfJ.mjs";
3
3
  import * as storybook_internal_csf0 from "storybook/internal/csf";
4
4
  import { ComparisonMethod, FailureThresholdOptions, ImageSnapshotCompareOptions, ImageSnapshotKeyOptions, ImageSnapshotKeyOptions as ImageSnapshotKeyOptions$1, ImageSnapshotSubjectOptions, ImageSnapshotTimeoutOptions, PixelComparisonOptions, SsimComparisonOptions, ToMatchImageSnapshotOptions } from "vitest-plugin-vis/client-api";
5
5
  import * as vitest_plugin_vis0 from "vitest-plugin-vis";
@@ -24,7 +24,7 @@ declare function hasImageSnapshot(options?: ImageSnapshotKeyOptions$1 | undefine
24
24
  * Define snapshot parameter for auto snapshot.
25
25
  */
26
26
  declare function defineAutoSnapshotParam<M extends ComparisonMethod>(snapshot: ToMatchImageSnapshotOptions<M> & ImageSnapshotSubjectOptions): {
27
- snapshot: ImageSnapshotTimeoutOptions & ImageSnapshotKeyOptions & (M extends "ssim" ? SsimComparisonOptions<M> : PixelComparisonOptions<M>) & FailureThresholdOptions & vitest_plugin_vis0.ReviewImageOptions & {
27
+ snapshot: ImageSnapshotTimeoutOptions & ImageSnapshotKeyOptions & (M extends "ssim" ? SsimComparisonOptions<M> : PixelComparisonOptions<M>) & FailureThresholdOptions & vitest_plugin_vis0.ReviewImageOptions & vitest_plugin_vis0.AnimationsOptions & vitest_plugin_vis0.MaskOptions & {
28
28
  expectToFail?: boolean | undefined;
29
29
  createMissingBaseline?: boolean | undefined;
30
30
  } & ImageSnapshotSubjectOptions;
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { a as commands, c as whenVitestProxyReady, i as cdp, l as isVitestBrowser, n as isSnapshotEnabled, o as getCurrentTest, r as toMatchImageSnapshot, s as page, t as visAnnotations } from "./vis_annotation-BHBO0X19.mjs";
2
2
  import { definePreviewAddon } from "storybook/internal/csf";
3
3
  import { expect } from "storybook/test";
4
- import { autoSnapshotMatcher, hasImageSnapshotAction, setAutoSnapshotOptions, toTaskId } from "vitest-plugin-vis/client-api";
4
+ import { autoSnapshotMatcher, hasImageSnapshotAction, setAutoSnapshotOptions, toSuiteDefaults, toTaskId } from "vitest-plugin-vis/client-api";
5
5
 
6
6
  export * from "vitest-plugin-vis"
7
7
 
@@ -45,7 +45,7 @@ var src_default = (options = { auto: false }) => {
45
45
  if (!isVitestBrowser()) return;
46
46
  await whenVitestProxyReady();
47
47
  matcher = autoSnapshotMatcher(commands, expect);
48
- const suiteDefaults = options?.createMissingBaseline !== void 0 ? { createMissingBaseline: options.createMissingBaseline } : void 0;
48
+ const suiteDefaults = toSuiteDefaults(options);
49
49
  if (typeof options?.auto === "function") matcherFn = matcher.createMatcher({ auto: options.auto }, suiteDefaults);
50
50
  else if (typeof options?.auto === "object") matcherFn = matcher.createMatcher(options.auto, suiteDefaults);
51
51
  else matcherFn = matcher.createMatcher({ async auto() {} }, suiteDefaults);
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/client/ctx.ts","../src/client/has_image_snapshot.ts","../src/client/storybook/param.ts","../src/index.ts"],"sourcesContent":["import { getCurrentTest } from './vitest_proxy.ts'\n\nexport const ctx = {\n\tgetCurrentTest,\n\t__test__reset() {\n\t\tctx.getCurrentTest = getCurrentTest\n\t},\n}\n","import { hasImageSnapshotAction, type ImageSnapshotKeyOptions, toTaskId } from 'vitest-plugin-vis/client-api'\nimport { ctx } from './ctx.ts'\nimport { commands } from './vitest_proxy.ts'\n\n/**\n * Check if the snapshot image exists.\n */\nexport function hasImageSnapshot(options?: ImageSnapshotKeyOptions | undefined) {\n\tconst test = ctx.getCurrentTest()\n\tif (!test) return false\n\n\treturn hasImageSnapshotAction(commands, toTaskId(test), options)\n}\n","import type {\n\tComparisonMethod,\n\tFailureThresholdOptions,\n\tImageSnapshotCompareOptions,\n\tImageSnapshotKeyOptions,\n\tImageSnapshotSubjectOptions,\n\tImageSnapshotTimeoutOptions,\n\tPixelComparisonOptions,\n\tSsimComparisonOptions,\n\tToMatchImageSnapshotOptions,\n} from 'vitest-plugin-vis/client-api'\n\n// This fix the inferred type cannot be named error\nexport type {\n\tComparisonMethod,\n\tFailureThresholdOptions,\n\tImageSnapshotCompareOptions,\n\tImageSnapshotKeyOptions,\n\tImageSnapshotSubjectOptions,\n\tImageSnapshotTimeoutOptions,\n\tPixelComparisonOptions,\n\tSsimComparisonOptions,\n\tToMatchImageSnapshotOptions,\n}\n\n/**\n * Define snapshot parameter for auto snapshot.\n */\nexport function defineAutoSnapshotParam<M extends ComparisonMethod>(\n\tsnapshot: ToMatchImageSnapshotOptions<M> & ImageSnapshotSubjectOptions,\n) {\n\treturn { snapshot }\n}\n","// `storybook-addon-vis` provides code that can be used in test files.\nimport './shared/global_matcher_augment.ts'\n\nimport { definePreviewAddon } from 'storybook/internal/csf'\nimport { expect } from 'storybook/test'\nimport type { SetupVisOptions } from 'vitest-plugin-vis'\nimport { autoSnapshotMatcher, setAutoSnapshotOptions } from 'vitest-plugin-vis/client-api'\nimport { toMatchImageSnapshot } from './client/expect/to_match_image_snapshot.ts'\nimport { isVitestBrowser } from './client/is_vitest_browser.ts'\nimport { cdp, commands, page, whenVitestProxyReady } from './client/vitest_proxy.ts'\nimport { visAnnotations } from './preview/vis_annotation.ts'\n\n// Register at module load time so it's available in Storybook dev mode.\n// (visAnnotations.beforeEach is only wired via vitest's setProjectAnnotations, not in dev mode)\nexpect.extend({ toMatchImageSnapshot })\n\nexport * from 'vitest-plugin-vis'\nexport * from './client/has_image_snapshot.ts'\nexport * from './client/storybook/param.ts'\nexport * from './client/storybook/tags.ts'\n\nexport { cdp, page, visAnnotations }\n\nexport default (options: SetupVisOptions<{ tags: string[] }> = { auto: false }) => {\n\tlet matcher: ReturnType<typeof autoSnapshotMatcher>\n\tlet matcherFn: () => Promise<void>\n\treturn definePreviewAddon({\n\t\ttags: options.auto === true ? ['snapshot'] : [],\n\t\tasync beforeAll() {\n\t\t\tif (!isVitestBrowser()) return\n\t\t\t// `page` and `getCurrentTest` come from a dynamic import; the hooks that\n\t\t\t// follow read them synchronously, so wait for it here (#835).\n\t\t\tawait whenVitestProxyReady()\n\t\t\tmatcher = autoSnapshotMatcher(commands, expect)\n\t\t\tconst suiteDefaults =\n\t\t\t\toptions?.createMissingBaseline !== undefined\n\t\t\t\t\t? { createMissingBaseline: options.createMissingBaseline }\n\t\t\t\t\t: undefined\n\t\t\tif (typeof options?.auto === 'function') {\n\t\t\t\tmatcherFn = matcher.createMatcher(\n\t\t\t\t\t{\n\t\t\t\t\t\tauto: options.auto,\n\t\t\t\t\t},\n\t\t\t\t\tsuiteDefaults,\n\t\t\t\t)\n\t\t\t} else if (typeof options?.auto === 'object') {\n\t\t\t\tmatcherFn = matcher.createMatcher(options.auto, suiteDefaults)\n\t\t\t} else matcherFn = matcher.createMatcher({ async auto() {} }, suiteDefaults)\n\n\t\t\tawait matcher.setup()\n\t\t\tawait setAutoSnapshotOptions(true)\n\t\t},\n\t\tafterEach() {\n\t\t\tif (matcherFn) {\n\t\t\t\treturn matcherFn()\n\t\t\t}\n\t\t},\n\t\t...visAnnotations,\n\t})\n}\n"],"mappings":";;;;;;;;AAEA,MAAa,MAAM;CAClB;CACA,gBAAgB;AACf,MAAI,iBAAiB;;CAEtB;;;;;;;ACAD,SAAgB,iBAAiB,SAA+C;CAC/E,MAAM,OAAO,IAAI,gBAAgB;AACjC,KAAI,CAAC,KAAM,QAAO;AAElB,QAAO,uBAAuB,UAAU,SAAS,KAAK,EAAE,QAAQ;;;;;;;;ACiBjE,SAAgB,wBACf,UACC;AACD,QAAO,EAAE,UAAU;;;;;ACjBpB,OAAO,OAAO,EAAE,sBAAsB,CAAC;AASvC,mBAAgB,UAA+C,EAAE,MAAM,OAAO,KAAK;CAClF,IAAI;CACJ,IAAI;AACJ,QAAO,mBAAmB;EACzB,MAAM,QAAQ,SAAS,OAAO,CAAC,WAAW,GAAG,EAAE;EAC/C,MAAM,YAAY;AACjB,OAAI,CAAC,iBAAiB,CAAE;AAGxB,SAAM,sBAAsB;AAC5B,aAAU,oBAAoB,UAAU,OAAO;GAC/C,MAAM,gBACL,SAAS,0BAA0B,SAChC,EAAE,uBAAuB,QAAQ,uBAAuB,GACxD;AACJ,OAAI,OAAO,SAAS,SAAS,WAC5B,aAAY,QAAQ,cACnB,EACC,MAAM,QAAQ,MACd,EACD,cACA;YACS,OAAO,SAAS,SAAS,SACnC,aAAY,QAAQ,cAAc,QAAQ,MAAM,cAAc;OACxD,aAAY,QAAQ,cAAc,EAAE,MAAM,OAAO,IAAI,EAAE,cAAc;AAE5E,SAAM,QAAQ,OAAO;AACrB,SAAM,uBAAuB,KAAK;;EAEnC,YAAY;AACX,OAAI,UACH,QAAO,WAAW;;EAGpB,GAAG;EACH,CAAC"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/client/ctx.ts","../src/client/has_image_snapshot.ts","../src/client/storybook/param.ts","../src/index.ts"],"sourcesContent":["import { getCurrentTest } from './vitest_proxy.ts'\n\nexport const ctx = {\n\tgetCurrentTest,\n\t__test__reset() {\n\t\tctx.getCurrentTest = getCurrentTest\n\t},\n}\n","import { hasImageSnapshotAction, type ImageSnapshotKeyOptions, toTaskId } from 'vitest-plugin-vis/client-api'\nimport { ctx } from './ctx.ts'\nimport { commands } from './vitest_proxy.ts'\n\n/**\n * Check if the snapshot image exists.\n */\nexport function hasImageSnapshot(options?: ImageSnapshotKeyOptions | undefined) {\n\tconst test = ctx.getCurrentTest()\n\tif (!test) return false\n\n\treturn hasImageSnapshotAction(commands, toTaskId(test), options)\n}\n","import type {\n\tComparisonMethod,\n\tFailureThresholdOptions,\n\tImageSnapshotCompareOptions,\n\tImageSnapshotKeyOptions,\n\tImageSnapshotSubjectOptions,\n\tImageSnapshotTimeoutOptions,\n\tPixelComparisonOptions,\n\tSsimComparisonOptions,\n\tToMatchImageSnapshotOptions,\n} from 'vitest-plugin-vis/client-api'\n\n// This fix the inferred type cannot be named error\nexport type {\n\tComparisonMethod,\n\tFailureThresholdOptions,\n\tImageSnapshotCompareOptions,\n\tImageSnapshotKeyOptions,\n\tImageSnapshotSubjectOptions,\n\tImageSnapshotTimeoutOptions,\n\tPixelComparisonOptions,\n\tSsimComparisonOptions,\n\tToMatchImageSnapshotOptions,\n}\n\n/**\n * Define snapshot parameter for auto snapshot.\n */\nexport function defineAutoSnapshotParam<M extends ComparisonMethod>(\n\tsnapshot: ToMatchImageSnapshotOptions<M> & ImageSnapshotSubjectOptions,\n) {\n\treturn { snapshot }\n}\n","// `storybook-addon-vis` provides code that can be used in test files.\nimport './shared/global_matcher_augment.ts'\n\nimport { definePreviewAddon } from 'storybook/internal/csf'\nimport { expect } from 'storybook/test'\nimport type { SetupVisOptions } from 'vitest-plugin-vis'\nimport { autoSnapshotMatcher, setAutoSnapshotOptions, toSuiteDefaults } from 'vitest-plugin-vis/client-api'\nimport { toMatchImageSnapshot } from './client/expect/to_match_image_snapshot.ts'\nimport { isVitestBrowser } from './client/is_vitest_browser.ts'\nimport { cdp, commands, page, whenVitestProxyReady } from './client/vitest_proxy.ts'\nimport { visAnnotations } from './preview/vis_annotation.ts'\n\n// Register at module load time so it's available in Storybook dev mode.\n// (visAnnotations.beforeEach is only wired via vitest's setProjectAnnotations, not in dev mode)\nexpect.extend({ toMatchImageSnapshot })\n\nexport * from 'vitest-plugin-vis'\nexport * from './client/has_image_snapshot.ts'\nexport * from './client/storybook/param.ts'\nexport * from './client/storybook/tags.ts'\n\nexport { cdp, page, visAnnotations }\n\nexport default (options: SetupVisOptions<{ tags: string[] }> = { auto: false }) => {\n\tlet matcher: ReturnType<typeof autoSnapshotMatcher>\n\tlet matcherFn: () => Promise<void>\n\treturn definePreviewAddon({\n\t\ttags: options.auto === true ? ['snapshot'] : [],\n\t\tasync beforeAll() {\n\t\t\tif (!isVitestBrowser()) return\n\t\t\t// `page` and `getCurrentTest` come from a dynamic import; the hooks that\n\t\t\t// follow read them synchronously, so wait for it here (#835).\n\t\t\tawait whenVitestProxyReady()\n\t\t\tmatcher = autoSnapshotMatcher(commands, expect)\n\t\t\tconst suiteDefaults = toSuiteDefaults(options)\n\t\t\tif (typeof options?.auto === 'function') {\n\t\t\t\tmatcherFn = matcher.createMatcher(\n\t\t\t\t\t{\n\t\t\t\t\t\tauto: options.auto,\n\t\t\t\t\t},\n\t\t\t\t\tsuiteDefaults,\n\t\t\t\t)\n\t\t\t} else if (typeof options?.auto === 'object') {\n\t\t\t\tmatcherFn = matcher.createMatcher(options.auto, suiteDefaults)\n\t\t\t} else matcherFn = matcher.createMatcher({ async auto() {} }, suiteDefaults)\n\n\t\t\tawait matcher.setup()\n\t\t\tawait setAutoSnapshotOptions(true)\n\t\t},\n\t\tafterEach() {\n\t\t\tif (matcherFn) {\n\t\t\t\treturn matcherFn()\n\t\t\t}\n\t\t},\n\t\t...visAnnotations,\n\t})\n}\n"],"mappings":";;;;;;;;AAEA,MAAa,MAAM;CAClB;CACA,gBAAgB;AACf,MAAI,iBAAiB;;CAEtB;;;;;;;ACAD,SAAgB,iBAAiB,SAA+C;CAC/E,MAAM,OAAO,IAAI,gBAAgB;AACjC,KAAI,CAAC,KAAM,QAAO;AAElB,QAAO,uBAAuB,UAAU,SAAS,KAAK,EAAE,QAAQ;;;;;;;;ACiBjE,SAAgB,wBACf,UACC;AACD,QAAO,EAAE,UAAU;;;;;ACjBpB,OAAO,OAAO,EAAE,sBAAsB,CAAC;AASvC,mBAAgB,UAA+C,EAAE,MAAM,OAAO,KAAK;CAClF,IAAI;CACJ,IAAI;AACJ,QAAO,mBAAmB;EACzB,MAAM,QAAQ,SAAS,OAAO,CAAC,WAAW,GAAG,EAAE;EAC/C,MAAM,YAAY;AACjB,OAAI,CAAC,iBAAiB,CAAE;AAGxB,SAAM,sBAAsB;AAC5B,aAAU,oBAAoB,UAAU,OAAO;GAC/C,MAAM,gBAAgB,gBAAgB,QAAQ;AAC9C,OAAI,OAAO,SAAS,SAAS,WAC5B,aAAY,QAAQ,cACnB,EACC,MAAM,QAAQ,MACd,EACD,cACA;YACS,OAAO,SAAS,SAAS,SACnC,aAAY,QAAQ,cAAc,QAAQ,MAAM,cAAc;OACxD,aAAY,QAAQ,cAAc,EAAE,MAAM,OAAO,IAAI,EAAE,cAAc;AAE5E,SAAM,QAAQ,OAAO;AACrB,SAAM,uBAAuB,KAAK;;EAEnC,YAAY;AACX,OAAI,UACH,QAAO,WAAW;;EAGpB,GAAG;EACH,CAAC"}
package/dist/manager.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import React, { memo, useEffect, useState } from "react";
2
2
  import { addons, types } from "storybook/manager-api";
3
+ import { ImageCompare } from "@just-web/react-image-compare";
3
4
  import { RefreshIcon } from "@storybook/icons";
4
5
  import { AddonPanel, Button, Placeholder, ScrollArea } from "storybook/internal/components";
5
6
  import { styled } from "storybook/theming";
@@ -16,21 +17,95 @@ const VisPanel = memo(function VisPanel$1({ active, getSnapshotResults, onRefres
16
17
  acc[key] = [...acc[key] ?? [], result];
17
18
  return acc;
18
19
  }, {});
19
- return /* @__PURE__ */ React.createElement(AddonPanel, { active }, snapshotResults.length > 0 ? /* @__PURE__ */ React.createElement(ScrollArea, { vertical: true }, Object.entries(groupedResults).map(([key, results]) => /* @__PURE__ */ React.createElement("div", { key }, results.some((result) => result.type === "diff") ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SnapshotRow, { failed: true }, key), results.map((result) => /* @__PURE__ */ React.createElement("img", {
20
- key: result.filePath,
21
- src: `data:image/png;base64,${result.base64}`,
22
- alt: result.fileName
23
- }))) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SnapshotRow, null, /* @__PURE__ */ React.createElement("span", null, key), /* @__PURE__ */ React.createElement(Button, {
24
- "aria-label": "Reload snapshot",
20
+ const snapshots = Object.entries(groupedResults).filter(([, results]) => results.some((result) => result.type !== "result"));
21
+ return /* @__PURE__ */ React.createElement(AddonPanel, { active }, snapshots.length > 0 ? /* @__PURE__ */ React.createElement(ScrollArea, { vertical: true }, snapshots.map(([key, results]) => {
22
+ const baseline = results.find((result$1) => result$1.type === "baseline");
23
+ const result = results.find((result$1) => result$1.type === "result");
24
+ const diff = results.find((result$1) => result$1.type === "diff");
25
+ return /* @__PURE__ */ React.createElement("div", { key }, diff ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SnapshotRow, { failed: true }, key), baseline && result ? /* @__PURE__ */ React.createElement(SnapshotCompare, {
26
+ baseline,
27
+ result,
28
+ diff
29
+ }) : results.map((result$1) => /* @__PURE__ */ React.createElement("img", {
30
+ key: result$1.filePath,
31
+ src: toDataUrl(result$1),
32
+ alt: result$1.fileName
33
+ }))) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SnapshotRow, null, /* @__PURE__ */ React.createElement("span", null, key), /* @__PURE__ */ React.createElement(Button, {
34
+ "aria-label": "Reload snapshot",
35
+ onClick: () => {
36
+ onRefresh();
37
+ getSnapshotResults().then(setSnapshotResults);
38
+ }
39
+ }, /* @__PURE__ */ React.createElement(RefreshIcon, null))), baseline && /* @__PURE__ */ React.createElement(SnapshotImage, { image: baseline })));
40
+ })) : /* @__PURE__ */ React.createElement(Placeholder, null, "There is no snapshots for this story"));
41
+ });
42
+ function toDataUrl(image) {
43
+ return `data:image/png;base64,${image.base64}`;
44
+ }
45
+ function SnapshotImage({ image }) {
46
+ return /* @__PURE__ */ React.createElement("img", {
47
+ src: toDataUrl(image),
48
+ alt: image.fileName
49
+ });
50
+ }
51
+ const compareViews = [
52
+ {
53
+ view: "side-by-side",
54
+ label: "Side by side"
55
+ },
56
+ {
57
+ view: "swipe",
58
+ label: "Swipe"
59
+ },
60
+ {
61
+ view: "onion-skin",
62
+ label: "Onion skin"
63
+ },
64
+ {
65
+ view: "diff",
66
+ label: "Diff"
67
+ }
68
+ ];
69
+ /**
70
+ * Compares the baseline and the result of a failed snapshot like GitHub's image diff,
71
+ * plus the diff image that marks the changed pixels.
72
+ */
73
+ function SnapshotCompare({ baseline, result, diff }) {
74
+ const [view, setView] = useState("side-by-side");
75
+ const [mode, setMode] = useState("side-by-side");
76
+ return /* @__PURE__ */ React.createElement(CompareContainer, null, /* @__PURE__ */ React.createElement(ViewSwitcher, {
77
+ role: "group",
78
+ "aria-label": "Comparison view"
79
+ }, compareViews.map(({ view: v, label }) => /* @__PURE__ */ React.createElement(Button, {
80
+ key: v,
81
+ size: "small",
82
+ variant: "ghost",
83
+ active: v === view,
84
+ "aria-pressed": v === view,
25
85
  onClick: () => {
26
- onRefresh();
27
- getSnapshotResults().then(setSnapshotResults);
86
+ setView(v);
87
+ if (v !== "diff") setMode(v);
28
88
  }
29
- }, /* @__PURE__ */ React.createElement(RefreshIcon, null))), /* @__PURE__ */ React.createElement("img", {
30
- key: results[0].filePath,
31
- src: `data:image/png;base64,${results[0].base64}`,
32
- alt: results[0].fileName
33
- }))))) : /* @__PURE__ */ React.createElement(Placeholder, null, "There is no snapshots for this story"));
89
+ }, label))), /* @__PURE__ */ React.createElement(ImageCompare, {
90
+ base: toDataUrl(baseline),
91
+ compare: toDataUrl(result),
92
+ baseLabel: "Baseline",
93
+ compareLabel: "Result",
94
+ mode,
95
+ showModeSwitcher: false,
96
+ style: view === "diff" ? { display: "none" } : void 0
97
+ }), view === "diff" && /* @__PURE__ */ React.createElement(SnapshotImage, { image: diff }));
98
+ }
99
+ const CompareContainer = styled.div({
100
+ display: "flex",
101
+ flexDirection: "column",
102
+ alignItems: "flex-start",
103
+ gap: "0.5rem",
104
+ padding: "0.5rem"
105
+ });
106
+ const ViewSwitcher = styled.div({
107
+ display: "flex",
108
+ gap: "0.25rem"
34
109
  });
35
110
  const SnapshotRow = styled.div(({ theme, failed }) => ({
36
111
  display: "flex",
@@ -1 +1 @@
1
- {"version":3,"file":"manager.js","names":["VisPanel"],"sources":["../src/components/vis_panel.tsx","../src/shared/constants.ts","../src/shared/events.ts","../src/exports/manager.tsx"],"sourcesContent":["import { RefreshIcon } from '@storybook/icons'\nimport React, { memo, useEffect, useState } from 'react'\nimport { AddonPanel, Button, Placeholder, ScrollArea } from 'storybook/internal/components'\nimport { styled } from 'storybook/theming'\nimport { SNAPSHOT_ROOT_DIR } from 'vitest-plugin-vis/client-api'\nimport type { ImageSnapshotResults } from '../shared/events.ts'\n\ninterface PanelProps {\n\tactive: boolean\n\tgetSnapshotResults: () => Promise<ImageSnapshotResults[]>\n\tonRefresh: () => void\n}\n\nexport const VisPanel = memo(function VisPanel({ active, getSnapshotResults, onRefresh }: PanelProps) {\n\tconst [snapshotResults, setSnapshotResults] = useState<ImageSnapshotResults[]>([])\n\n\tuseEffect(() => {\n\t\tgetSnapshotResults().then(setSnapshotResults)\n\t}, [getSnapshotResults])\n\n\tconst groupedResults = snapshotResults.reduce(\n\t\t(acc, result) => {\n\t\t\tconst suiteName = result.snapshotRootDir.slice(SNAPSHOT_ROOT_DIR.length + 1)\n\t\t\tconst key = `(${suiteName}) ${result.fileName}`\n\t\t\tacc[key] = [...(acc[key] ?? []), result]\n\t\t\treturn acc\n\t\t},\n\t\t{} as Record<string, ImageSnapshotResults[]>,\n\t)\n\treturn (\n\t\t<AddonPanel active={active}>\n\t\t\t{snapshotResults.length > 0 ? (\n\t\t\t\t<ScrollArea vertical>\n\t\t\t\t\t{Object.entries(groupedResults).map(([key, results]) => (\n\t\t\t\t\t\t<div key={key}>\n\t\t\t\t\t\t\t{results.some((result) => result.type === 'diff') ? (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<SnapshotRow failed>{key}</SnapshotRow>\n\t\t\t\t\t\t\t\t\t{results.map((result) => (\n\t\t\t\t\t\t\t\t\t\t<img key={result.filePath} src={`data:image/png;base64,${result.base64}`} alt={result.fileName} />\n\t\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<SnapshotRow>\n\t\t\t\t\t\t\t\t\t\t<span>{key}</span>\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\taria-label=\"Reload snapshot\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t\t\t\tonRefresh()\n\t\t\t\t\t\t\t\t\t\t\t\tgetSnapshotResults().then(setSnapshotResults)\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<RefreshIcon />\n\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t</SnapshotRow>\n\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\tkey={results[0].filePath}\n\t\t\t\t\t\t\t\t\t\tsrc={`data:image/png;base64,${results[0].base64}`}\n\t\t\t\t\t\t\t\t\t\talt={results[0].fileName}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t))}\n\t\t\t\t</ScrollArea>\n\t\t\t) : (\n\t\t\t\t<Placeholder>There is no snapshots for this story</Placeholder>\n\t\t\t)}\n\t\t</AddonPanel>\n\t)\n})\n\nconst SnapshotRow = styled.div<{ failed?: boolean }>(\n\t({ theme, failed }: { theme: any; failed?: boolean | undefined }) => ({\n\t\tdisplay: 'flex',\n\t\talignItems: 'center',\n\t\tgap: '0.5rem',\n\t\tpaddingBlock: '0.5rem',\n\t\tpaddingInline: '0.2rem',\n\t\tbackgroundColor: failed ? theme.background.negative : theme.background.positive,\n\t\tcolor: theme.barTextColor,\n\t}),\n)\n","export const NAME = 'storybook-addon-vis'\nexport const VIS_PANEL_ID = `${NAME}/vis_panel`\n","export type VisEvent = ImageSnapshotResultsRequest | ImageSnapshotResultsResponse\n\nexport const IMAGE_SNAPSHOT_RESULTS_REQUEST = 'IMAGE_SNAPSHOT_RESULTS_REQUEST'\nexport const IMAGE_SNAPSHOT_RESULTS_RESPONSE = 'IMAGE_SNAPSHOT_RESULTS_RESPONSE'\n\nexport function requestImageSnapshotResults({ name, importPath }: { name: string; importPath: string }) {\n\treturn {\n\t\ttype: IMAGE_SNAPSHOT_RESULTS_REQUEST,\n\t\tname,\n\t\timportPath,\n\t}\n}\n\nexport type ImageSnapshotResultsRequest = {\n\ttype: typeof IMAGE_SNAPSHOT_RESULTS_REQUEST\n\tname: string\n\timportPath: string\n}\n\nexport type ImageSnapshotResultsResponse = {\n\ttype: typeof IMAGE_SNAPSHOT_RESULTS_RESPONSE\n\tname: string\n\timportPath: string\n\tresults: ImageSnapshotResults[]\n}\n\nexport type ImageSnapshotResults = {\n\tfilePath: string\n\tfileName: string\n\tsnapshotRootDir: string\n\ttype: 'baseline' | 'diff' | 'result'\n\tbase64: string\n}\n","import React from 'react'\nimport { addons, types } from 'storybook/manager-api'\nimport { VisPanel } from '../components/vis_panel.tsx'\nimport { NAME, VIS_PANEL_ID } from '../shared/constants.ts'\nimport {\n\tIMAGE_SNAPSHOT_RESULTS_RESPONSE,\n\ttype ImageSnapshotResults,\n\trequestImageSnapshotResults,\n\ttype VisEvent,\n} from '../shared/events.ts'\n\n// Register the addon\naddons.register(NAME, (api) => {\n\t// Register the tool\n\tif ((globalThis as any).CONFIG_TYPE === 'DEVELOPMENT') {\n\t\taddons.add(VIS_PANEL_ID, {\n\t\t\ttype: types.PANEL,\n\t\t\ttitle: 'Vis',\n\t\t\tmatch: ({ tabId, viewMode }) => !tabId && viewMode === 'story',\n\t\t\trender({ active }) {\n\t\t\t\tif (!active) return null\n\t\t\t\tconst storyData = api.getCurrentStoryData()\n\t\t\t\tif (!storyData) return null\n\t\t\t\tapi.emit(NAME, requestImageSnapshotResults(storyData))\n\t\t\t\tasync function getSnapshotResults() {\n\t\t\t\t\treturn new Promise<ImageSnapshotResults[]>((resolve) => {\n\t\t\t\t\t\tapi.once(NAME, (event: VisEvent) => {\n\t\t\t\t\t\t\tif (event.name !== storyData.name) return\n\t\t\t\t\t\t\tif (event.importPath !== storyData.importPath) return\n\t\t\t\t\t\t\tif (event.type === IMAGE_SNAPSHOT_RESULTS_RESPONSE) {\n\t\t\t\t\t\t\t\tresolve(event.results)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\treturn (\n\t\t\t\t\t<VisPanel\n\t\t\t\t\t\tactive={active}\n\t\t\t\t\t\tgetSnapshotResults={getSnapshotResults}\n\t\t\t\t\t\tonRefresh={() => {\n\t\t\t\t\t\t\tif (storyData) api.emit(NAME, requestImageSnapshotResults(storyData))\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t},\n\t\t})\n\t}\n})\n"],"mappings":";;;;;;;;AAaA,MAAa,WAAW,KAAK,SAASA,WAAS,EAAE,QAAQ,oBAAoB,aAAyB;CACrG,MAAM,CAAC,iBAAiB,sBAAsB,SAAiC,EAAE,CAAC;AAElF,iBAAgB;AACf,sBAAoB,CAAC,KAAK,mBAAmB;IAC3C,CAAC,mBAAmB,CAAC;CAExB,MAAM,iBAAiB,gBAAgB,QACrC,KAAK,WAAW;EAEhB,MAAM,MAAM,IADM,OAAO,gBAAgB,MAAM,kBAAkB,SAAS,EAAE,CAClD,IAAI,OAAO;AACrC,MAAI,OAAO,CAAC,GAAI,IAAI,QAAQ,EAAE,EAAG,OAAO;AACxC,SAAO;IAER,EAAE,CACF;AACD,QACC,oCAAC,cAAmB,UAClB,gBAAgB,SAAS,IACzB,oCAAC,cAAW,kBACV,OAAO,QAAQ,eAAe,CAAC,KAAK,CAAC,KAAK,aAC1C,oCAAC,SAAS,OACR,QAAQ,MAAM,WAAW,OAAO,SAAS,OAAO,GAChD,0DACC,oCAAC,eAAY,gBAAQ,IAAkB,EACtC,QAAQ,KAAK,WACb,oCAAC;EAAI,KAAK,OAAO;EAAU,KAAK,yBAAyB,OAAO;EAAU,KAAK,OAAO;GAAY,CACjG,CACA,GAEH,0DACC,oCAAC,mBACA,oCAAC,cAAM,IAAW,EAClB,oCAAC;EACA,cAAW;EACX,eAAe;AACd,cAAW;AACX,uBAAoB,CAAC,KAAK,mBAAmB;;IAG9C,oCAAC,kBAAc,CACP,CACI,EACd,oCAAC;EACA,KAAK,QAAQ,GAAG;EAChB,KAAK,yBAAyB,QAAQ,GAAG;EACzC,KAAK,QAAQ,GAAG;GACf,CACA,CAEC,CACL,CACU,GAEb,oCAAC,mBAAY,uCAAkD,CAEpD;EAEb;AAEF,MAAM,cAAc,OAAO,KACzB,EAAE,OAAO,cAA4D;CACrE,SAAS;CACT,YAAY;CACZ,KAAK;CACL,cAAc;CACd,eAAe;CACf,iBAAiB,SAAS,MAAM,WAAW,WAAW,MAAM,WAAW;CACvE,OAAO,MAAM;CACb,EACD;;;;ACnFD,MAAa,OAAO;AACpB,MAAa,eAAe,GAAG,KAAK;;;;ACCpC,MAAa,iCAAiC;AAC9C,MAAa,kCAAkC;AAE/C,SAAgB,4BAA4B,EAAE,MAAM,cAAoD;AACvG,QAAO;EACN,MAAM;EACN;EACA;EACA;;;;;ACEF,OAAO,SAAS,OAAO,QAAQ;AAE9B,KAAK,WAAmB,gBAAgB,cACvC,QAAO,IAAI,cAAc;EACxB,MAAM,MAAM;EACZ,OAAO;EACP,QAAQ,EAAE,OAAO,eAAe,CAAC,SAAS,aAAa;EACvD,OAAO,EAAE,UAAU;AAClB,OAAI,CAAC,OAAQ,QAAO;GACpB,MAAM,YAAY,IAAI,qBAAqB;AAC3C,OAAI,CAAC,UAAW,QAAO;AACvB,OAAI,KAAK,MAAM,4BAA4B,UAAU,CAAC;GACtD,eAAe,qBAAqB;AACnC,WAAO,IAAI,SAAiC,YAAY;AACvD,SAAI,KAAK,OAAO,UAAoB;AACnC,UAAI,MAAM,SAAS,UAAU,KAAM;AACnC,UAAI,MAAM,eAAe,UAAU,WAAY;AAC/C,UAAI,MAAM,SAAS,gCAClB,SAAQ,MAAM,QAAQ;OAEtB;MACD;;AAEH,UACC,oCAAC;IACQ;IACY;IACpB,iBAAiB;AAChB,SAAI,UAAW,KAAI,KAAK,MAAM,4BAA4B,UAAU,CAAC;;KAErE;;EAGJ,CAAC;EAEF"}
1
+ {"version":3,"file":"manager.js","names":["VisPanel","result"],"sources":["../src/components/vis_panel.tsx","../src/shared/constants.ts","../src/shared/events.ts","../src/exports/manager.tsx"],"sourcesContent":["import { ImageCompare, type ImageCompareMode } from '@just-web/react-image-compare'\nimport { RefreshIcon } from '@storybook/icons'\nimport React, { memo, useEffect, useState } from 'react'\nimport { AddonPanel, Button, Placeholder, ScrollArea } from 'storybook/internal/components'\nimport { styled } from 'storybook/theming'\nimport { SNAPSHOT_ROOT_DIR } from 'vitest-plugin-vis/client-api'\nimport type { ImageSnapshotResults } from '../shared/events.ts'\n\ninterface PanelProps {\n\tactive: boolean\n\tgetSnapshotResults: () => Promise<ImageSnapshotResults[]>\n\tonRefresh: () => void\n}\n\nexport const VisPanel = memo(function VisPanel({ active, getSnapshotResults, onRefresh }: PanelProps) {\n\tconst [snapshotResults, setSnapshotResults] = useState<ImageSnapshotResults[]>([])\n\n\tuseEffect(() => {\n\t\tgetSnapshotResults().then(setSnapshotResults)\n\t}, [getSnapshotResults])\n\n\tconst groupedResults = snapshotResults.reduce(\n\t\t(acc, result) => {\n\t\t\tconst suiteName = result.snapshotRootDir.slice(SNAPSHOT_ROOT_DIR.length + 1)\n\t\t\tconst key = `(${suiteName}) ${result.fileName}`\n\t\t\tacc[key] = [...(acc[key] ?? []), result]\n\t\t\treturn acc\n\t\t},\n\t\t{} as Record<string, ImageSnapshotResults[]>,\n\t)\n\t// A result alone (no baseline, no diff) is a snapshot that has no baseline yet, so there is nothing to review.\n\tconst snapshots = Object.entries(groupedResults).filter(([, results]) =>\n\t\tresults.some((result) => result.type !== 'result'),\n\t)\n\treturn (\n\t\t<AddonPanel active={active}>\n\t\t\t{snapshots.length > 0 ? (\n\t\t\t\t<ScrollArea vertical>\n\t\t\t\t\t{snapshots.map(([key, results]) => {\n\t\t\t\t\t\tconst baseline = results.find((result) => result.type === 'baseline')\n\t\t\t\t\t\tconst result = results.find((result) => result.type === 'result')\n\t\t\t\t\t\tconst diff = results.find((result) => result.type === 'diff')\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<div key={key}>\n\t\t\t\t\t\t\t\t{diff ? (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<SnapshotRow failed>{key}</SnapshotRow>\n\t\t\t\t\t\t\t\t\t\t{baseline && result ? (\n\t\t\t\t\t\t\t\t\t\t\t<SnapshotCompare baseline={baseline} result={result} diff={diff} />\n\t\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t\t// No result to compare with (e.g. an old run): show each image as is.\n\t\t\t\t\t\t\t\t\t\t\tresults.map((result) => (\n\t\t\t\t\t\t\t\t\t\t\t\t<img key={result.filePath} src={toDataUrl(result)} alt={result.fileName} />\n\t\t\t\t\t\t\t\t\t\t\t))\n\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<SnapshotRow>\n\t\t\t\t\t\t\t\t\t\t\t<span>{key}</span>\n\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\taria-label=\"Reload snapshot\"\n\t\t\t\t\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tonRefresh()\n\t\t\t\t\t\t\t\t\t\t\t\t\tgetSnapshotResults().then(setSnapshotResults)\n\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<RefreshIcon />\n\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t</SnapshotRow>\n\t\t\t\t\t\t\t\t\t\t{baseline && <SnapshotImage image={baseline} />}\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)\n\t\t\t\t\t})}\n\t\t\t\t</ScrollArea>\n\t\t\t) : (\n\t\t\t\t<Placeholder>There is no snapshots for this story</Placeholder>\n\t\t\t)}\n\t\t</AddonPanel>\n\t)\n})\n\nfunction toDataUrl(image: ImageSnapshotResults) {\n\treturn `data:image/png;base64,${image.base64}`\n}\n\nfunction SnapshotImage({ image }: { image: ImageSnapshotResults }) {\n\treturn <img src={toDataUrl(image)} alt={image.fileName} />\n}\n\ntype CompareView = ImageCompareMode | 'diff'\n\nconst compareViews: Array<{ view: CompareView; label: string }> = [\n\t{ view: 'side-by-side', label: 'Side by side' },\n\t{ view: 'swipe', label: 'Swipe' },\n\t{ view: 'onion-skin', label: 'Onion skin' },\n\t{ view: 'diff', label: 'Diff' },\n]\n\ninterface SnapshotCompareProps {\n\tbaseline: ImageSnapshotResults\n\tresult: ImageSnapshotResults\n\tdiff: ImageSnapshotResults\n}\n\n/**\n * Compares the baseline and the result of a failed snapshot like GitHub's image diff,\n * plus the diff image that marks the changed pixels.\n */\nfunction SnapshotCompare({ baseline, result, diff }: SnapshotCompareProps) {\n\tconst [view, setView] = useState<CompareView>('side-by-side')\n\t// The compare mode stays mounted while the diff shows, so the swipe position and the opacity are kept.\n\tconst [mode, setMode] = useState<ImageCompareMode>('side-by-side')\n\treturn (\n\t\t<CompareContainer>\n\t\t\t<ViewSwitcher role=\"group\" aria-label=\"Comparison view\">\n\t\t\t\t{compareViews.map(({ view: v, label }) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={v}\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\tactive={v === view}\n\t\t\t\t\t\taria-pressed={v === view}\n\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\tsetView(v)\n\t\t\t\t\t\t\tif (v !== 'diff') setMode(v)\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{label}\n\t\t\t\t\t</Button>\n\t\t\t\t))}\n\t\t\t</ViewSwitcher>\n\t\t\t<ImageCompare\n\t\t\t\tbase={toDataUrl(baseline)}\n\t\t\t\tcompare={toDataUrl(result)}\n\t\t\t\tbaseLabel=\"Baseline\"\n\t\t\t\tcompareLabel=\"Result\"\n\t\t\t\tmode={mode}\n\t\t\t\tshowModeSwitcher={false}\n\t\t\t\tstyle={view === 'diff' ? { display: 'none' } : undefined}\n\t\t\t/>\n\t\t\t{view === 'diff' && <SnapshotImage image={diff} />}\n\t\t</CompareContainer>\n\t)\n}\n\nconst CompareContainer = styled.div({\n\tdisplay: 'flex',\n\tflexDirection: 'column',\n\talignItems: 'flex-start',\n\tgap: '0.5rem',\n\tpadding: '0.5rem',\n})\n\nconst ViewSwitcher = styled.div({\n\tdisplay: 'flex',\n\tgap: '0.25rem',\n})\n\nconst SnapshotRow = styled.div<{ failed?: boolean }>(\n\t({ theme, failed }: { theme: any; failed?: boolean | undefined }) => ({\n\t\tdisplay: 'flex',\n\t\talignItems: 'center',\n\t\tgap: '0.5rem',\n\t\tpaddingBlock: '0.5rem',\n\t\tpaddingInline: '0.2rem',\n\t\tbackgroundColor: failed ? theme.background.negative : theme.background.positive,\n\t\tcolor: theme.barTextColor,\n\t}),\n)\n","export const NAME = 'storybook-addon-vis'\nexport const VIS_PANEL_ID = `${NAME}/vis_panel`\n","export type VisEvent = ImageSnapshotResultsRequest | ImageSnapshotResultsResponse\n\nexport const IMAGE_SNAPSHOT_RESULTS_REQUEST = 'IMAGE_SNAPSHOT_RESULTS_REQUEST'\nexport const IMAGE_SNAPSHOT_RESULTS_RESPONSE = 'IMAGE_SNAPSHOT_RESULTS_RESPONSE'\n\nexport function requestImageSnapshotResults({ name, importPath }: { name: string; importPath: string }) {\n\treturn {\n\t\ttype: IMAGE_SNAPSHOT_RESULTS_REQUEST,\n\t\tname,\n\t\timportPath,\n\t}\n}\n\nexport type ImageSnapshotResultsRequest = {\n\ttype: typeof IMAGE_SNAPSHOT_RESULTS_REQUEST\n\tname: string\n\timportPath: string\n}\n\nexport type ImageSnapshotResultsResponse = {\n\ttype: typeof IMAGE_SNAPSHOT_RESULTS_RESPONSE\n\tname: string\n\timportPath: string\n\tresults: ImageSnapshotResults[]\n}\n\nexport type ImageSnapshotResults = {\n\tfilePath: string\n\tfileName: string\n\tsnapshotRootDir: string\n\ttype: 'baseline' | 'diff' | 'result'\n\tbase64: string\n}\n","import React from 'react'\nimport { addons, types } from 'storybook/manager-api'\nimport { VisPanel } from '../components/vis_panel.tsx'\nimport { NAME, VIS_PANEL_ID } from '../shared/constants.ts'\nimport {\n\tIMAGE_SNAPSHOT_RESULTS_RESPONSE,\n\ttype ImageSnapshotResults,\n\trequestImageSnapshotResults,\n\ttype VisEvent,\n} from '../shared/events.ts'\n\n// Register the addon\naddons.register(NAME, (api) => {\n\t// Register the tool\n\tif ((globalThis as any).CONFIG_TYPE === 'DEVELOPMENT') {\n\t\taddons.add(VIS_PANEL_ID, {\n\t\t\ttype: types.PANEL,\n\t\t\ttitle: 'Vis',\n\t\t\tmatch: ({ tabId, viewMode }) => !tabId && viewMode === 'story',\n\t\t\trender({ active }) {\n\t\t\t\tif (!active) return null\n\t\t\t\tconst storyData = api.getCurrentStoryData()\n\t\t\t\tif (!storyData) return null\n\t\t\t\tapi.emit(NAME, requestImageSnapshotResults(storyData))\n\t\t\t\tasync function getSnapshotResults() {\n\t\t\t\t\treturn new Promise<ImageSnapshotResults[]>((resolve) => {\n\t\t\t\t\t\tapi.once(NAME, (event: VisEvent) => {\n\t\t\t\t\t\t\tif (event.name !== storyData.name) return\n\t\t\t\t\t\t\tif (event.importPath !== storyData.importPath) return\n\t\t\t\t\t\t\tif (event.type === IMAGE_SNAPSHOT_RESULTS_RESPONSE) {\n\t\t\t\t\t\t\t\tresolve(event.results)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\treturn (\n\t\t\t\t\t<VisPanel\n\t\t\t\t\t\tactive={active}\n\t\t\t\t\t\tgetSnapshotResults={getSnapshotResults}\n\t\t\t\t\t\tonRefresh={() => {\n\t\t\t\t\t\t\tif (storyData) api.emit(NAME, requestImageSnapshotResults(storyData))\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t},\n\t\t})\n\t}\n})\n"],"mappings":";;;;;;;;;AAcA,MAAa,WAAW,KAAK,SAASA,WAAS,EAAE,QAAQ,oBAAoB,aAAyB;CACrG,MAAM,CAAC,iBAAiB,sBAAsB,SAAiC,EAAE,CAAC;AAElF,iBAAgB;AACf,sBAAoB,CAAC,KAAK,mBAAmB;IAC3C,CAAC,mBAAmB,CAAC;CAExB,MAAM,iBAAiB,gBAAgB,QACrC,KAAK,WAAW;EAEhB,MAAM,MAAM,IADM,OAAO,gBAAgB,MAAM,kBAAkB,SAAS,EAAE,CAClD,IAAI,OAAO;AACrC,MAAI,OAAO,CAAC,GAAI,IAAI,QAAQ,EAAE,EAAG,OAAO;AACxC,SAAO;IAER,EAAE,CACF;CAED,MAAM,YAAY,OAAO,QAAQ,eAAe,CAAC,QAAQ,GAAG,aAC3D,QAAQ,MAAM,WAAW,OAAO,SAAS,SAAS,CAClD;AACD,QACC,oCAAC,cAAmB,UAClB,UAAU,SAAS,IACnB,oCAAC,cAAW,kBACV,UAAU,KAAK,CAAC,KAAK,aAAa;EAClC,MAAM,WAAW,QAAQ,MAAM,aAAWC,SAAO,SAAS,WAAW;EACrE,MAAM,SAAS,QAAQ,MAAM,aAAWA,SAAO,SAAS,SAAS;EACjE,MAAM,OAAO,QAAQ,MAAM,aAAWA,SAAO,SAAS,OAAO;AAC7D,SACC,oCAAC,SAAS,OACR,OACA,0DACC,oCAAC,eAAY,gBAAQ,IAAkB,EACtC,YAAY,SACZ,oCAAC;GAA0B;GAAkB;GAAc;IAAQ,GAGnE,QAAQ,KAAK,aACZ,oCAAC;GAAI,KAAKA,SAAO;GAAU,KAAK,UAAUA,SAAO;GAAE,KAAKA,SAAO;IAAY,CAC1E,CAED,GAEH,0DACC,oCAAC,mBACA,oCAAC,cAAM,IAAW,EAClB,oCAAC;GACA,cAAW;GACX,eAAe;AACd,eAAW;AACX,wBAAoB,CAAC,KAAK,mBAAmB;;KAG9C,oCAAC,kBAAc,CACP,CACI,EACb,YAAY,oCAAC,iBAAc,OAAO,WAAY,CAC7C,CAEC;GAEN,CACU,GAEb,oCAAC,mBAAY,uCAAkD,CAEpD;EAEb;AAEF,SAAS,UAAU,OAA6B;AAC/C,QAAO,yBAAyB,MAAM;;AAGvC,SAAS,cAAc,EAAE,SAA0C;AAClE,QAAO,oCAAC;EAAI,KAAK,UAAU,MAAM;EAAE,KAAK,MAAM;GAAY;;AAK3D,MAAM,eAA4D;CACjE;EAAE,MAAM;EAAgB,OAAO;EAAgB;CAC/C;EAAE,MAAM;EAAS,OAAO;EAAS;CACjC;EAAE,MAAM;EAAc,OAAO;EAAc;CAC3C;EAAE,MAAM;EAAQ,OAAO;EAAQ;CAC/B;;;;;AAYD,SAAS,gBAAgB,EAAE,UAAU,QAAQ,QAA8B;CAC1E,MAAM,CAAC,MAAM,WAAW,SAAsB,eAAe;CAE7D,MAAM,CAAC,MAAM,WAAW,SAA2B,eAAe;AAClE,QACC,oCAAC,wBACA,oCAAC;EAAa,MAAK;EAAQ,cAAW;IACpC,aAAa,KAAK,EAAE,MAAM,GAAG,YAC7B,oCAAC;EACA,KAAK;EACL,MAAK;EACL,SAAQ;EACR,QAAQ,MAAM;EACd,gBAAc,MAAM;EACpB,eAAe;AACd,WAAQ,EAAE;AACV,OAAI,MAAM,OAAQ,SAAQ,EAAE;;IAG5B,MACO,CACR,CACY,EACf,oCAAC;EACA,MAAM,UAAU,SAAS;EACzB,SAAS,UAAU,OAAO;EAC1B,WAAU;EACV,cAAa;EACP;EACN,kBAAkB;EAClB,OAAO,SAAS,SAAS,EAAE,SAAS,QAAQ,GAAG;GAC9C,EACD,SAAS,UAAU,oCAAC,iBAAc,OAAO,OAAQ,CAChC;;AAIrB,MAAM,mBAAmB,OAAO,IAAI;CACnC,SAAS;CACT,eAAe;CACf,YAAY;CACZ,KAAK;CACL,SAAS;CACT,CAAC;AAEF,MAAM,eAAe,OAAO,IAAI;CAC/B,SAAS;CACT,KAAK;CACL,CAAC;AAEF,MAAM,cAAc,OAAO,KACzB,EAAE,OAAO,cAA4D;CACrE,SAAS;CACT,YAAY;CACZ,KAAK;CACL,cAAc;CACd,eAAe;CACf,iBAAiB,SAAS,MAAM,WAAW,WAAW,MAAM,WAAW;CACvE,OAAO,MAAM;CACb,EACD;;;;AC3KD,MAAa,OAAO;AACpB,MAAa,eAAe,GAAG,KAAK;;;;ACCpC,MAAa,iCAAiC;AAC9C,MAAa,kCAAkC;AAE/C,SAAgB,4BAA4B,EAAE,MAAM,cAAoD;AACvG,QAAO;EACN,MAAM;EACN;EACA;EACA;;;;;ACEF,OAAO,SAAS,OAAO,QAAQ;AAE9B,KAAK,WAAmB,gBAAgB,cACvC,QAAO,IAAI,cAAc;EACxB,MAAM,MAAM;EACZ,OAAO;EACP,QAAQ,EAAE,OAAO,eAAe,CAAC,SAAS,aAAa;EACvD,OAAO,EAAE,UAAU;AAClB,OAAI,CAAC,OAAQ,QAAO;GACpB,MAAM,YAAY,IAAI,qBAAqB;AAC3C,OAAI,CAAC,UAAW,QAAO;AACvB,OAAI,KAAK,MAAM,4BAA4B,UAAU,CAAC;GACtD,eAAe,qBAAqB;AACnC,WAAO,IAAI,SAAiC,YAAY;AACvD,SAAI,KAAK,OAAO,UAAoB;AACnC,UAAI,MAAM,SAAS,UAAU,KAAM;AACnC,UAAI,MAAM,eAAe,UAAU,WAAY;AAC/C,UAAI,MAAM,SAAS,gCAClB,SAAQ,MAAM,QAAQ;OAEtB;MACD;;AAEH,UACC,oCAAC;IACQ;IACY;IACpB,iBAAiB;AAChB,SAAI,UAAW,KAAI,KAAK,MAAM,4BAA4B,UAAU,CAAC;;KAErE;;EAGJ,CAAC;EAEF"}
@@ -0,0 +1,9 @@
1
+ import * as storybook_internal_types0 from "storybook/internal/types";
2
+
3
+ //#region src/preview/vis_annotation.d.ts
4
+ declare const visAnnotations: {
5
+ beforeEach(ctx: storybook_internal_types0.StoryContext<any, storybook_internal_types0.Args>): void;
6
+ };
7
+ //#endregion
8
+ export { visAnnotations as t };
9
+ //# sourceMappingURL=vis_annotation-pQo0FcfJ.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vis_annotation-pQo0FcfJ.d.mts","names":[],"sources":["../src/preview/vis_annotation.ts"],"sourcesContent":[],"mappings":";;;cAUa;kBAgBoC,yBAAA,CAAA,kBAAA,yBAAA,CAAA,IAAA"}
package/llms.txt CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  This file is generated by `packages/storybook-addon-vis/scripts/generate-llms-txt.mjs` from the packages' `exports` maps, their source, and the documentation pages. Do not edit it by hand; run `pnpm docs:llms` instead.
6
6
 
7
- If an image snapshot test fails, read [Reviewing Failures with Agents](https://repobuddy.github.io/visual-testing/guides/reviewing-failures-with-agents/) before opening any image. Without network access, read it from `node_modules/storybook-addon-vis/src/reviewing_failures_with_agents.mdx`.
7
+ If an image snapshot test fails, read [Reviewing Failures with Agents](https://repobuddy.github.io/visual-testing/visual-testing/reviewing-failures-with-agents/) before opening any image. Without network access, read it from `node_modules/storybook-addon-vis/src/reviewing_failures_with_agents.mdx`.
8
8
 
9
9
  Image snapshots are stored in the repository under `__vis__/`. Within it, `__baselines__` holds the expected images, `__results__` holds the images from the latest run, and `__diffs__` holds the diff images of failed comparisons. Next to each diff image, `<name>.review.png` is the review image of the changed regions and `<name>.regions.json` lists those regions.
10
10
 
@@ -12,7 +12,7 @@ Import from the entry points listed below, not from package internals. Documenta
12
12
 
13
13
  ## Start here
14
14
 
15
- - [storybook-addon-vis: Reviewing Failures with Agents](https://repobuddy.github.io/visual-testing/guides/reviewing-failures-with-agents/): When an image snapshot fails, a coding agent often opens the baseline and the result and compares them.
15
+ - [storybook-addon-vis: Reviewing Failures with Agents](https://repobuddy.github.io/visual-testing/visual-testing/reviewing-failures-with-agents/): When an image snapshot fails, a coding agent often opens the baseline and the result and compares them.
16
16
 
17
17
  ## Packages
18
18
 
@@ -20,26 +20,48 @@ Import from the entry points listed below, not from package internals. Documenta
20
20
 
21
21
  ## Documentation
22
22
 
23
- - [storybook-addon-vis: Automatic snapshots](https://repobuddy.github.io/visual-testing/addon/automatic-snapshots/): Take an image snapshot of every story without writing test code.
24
- - [storybook-addon-vis: Install](https://repobuddy.github.io/visual-testing/addon/install/): Install storybook-addon-vis and its peer dependencies.
25
- - [storybook-addon-vis: Manual snapshots](https://repobuddy.github.io/visual-testing/addon/manual-snapshots/): Take snapshots in a play function, check that one exists, and use the Chrome DevTools Protocol.
23
+ - [storybook-addon-vis: Automatic snapshots](https://repobuddy.github.io/visual-testing/addon/guides/automatic-snapshots/): Take an image snapshot of every story without writing test code.
24
+ - [storybook-addon-vis: CI](https://repobuddy.github.io/visual-testing/addon/guides/ci/): Run story snapshots on CI with platform baselines.
25
+ - [storybook-addon-vis: CSF Next and story.test()](https://repobuddy.github.io/visual-testing/addon/guides/csf-next/): Set up visual testing in the preview for CSF Next stories.
26
+ - [storybook-addon-vis: Chrome DevTools Protocol](https://repobuddy.github.io/visual-testing/addon/guides/chrome-devtools-protocol/): Use cdp() inside a story under Playwright and Chromium.
27
+ - [storybook-addon-vis: Features](https://repobuddy.github.io/visual-testing/addon/features/): Every capability of the addon, each linked to its guide.
28
+ - [storybook-addon-vis: Install](https://repobuddy.github.io/visual-testing/addon/get-started/): Install storybook-addon-vis and its peer dependencies.
29
+ - [storybook-addon-vis: Manual snapshots](https://repobuddy.github.io/visual-testing/addon/guides/manual-snapshots/): Take snapshots in a play function, check that one exists, and use the Chrome DevTools Protocol.
30
+ - [storybook-addon-vis: Monorepos and custom snapshot paths](https://repobuddy.github.io/visual-testing/addon/guides/monorepo-and-paths/): Tell the Vis panel where the snapshots are.
26
31
  - [storybook-addon-vis: Releases/Migrating to 1.0](https://repobuddy.github.io/visual-testing/releases/migrate-to-1/): storybook-addon-vis 1.0 has made some major improvements over the previous version.
27
32
  - [storybook-addon-vis: Releases/Migrating to 3.0](https://repobuddy.github.io/visual-testing/releases/migrate-to-3/): storybook-addon-vis 3.0.0 supports Storybook 10.
28
- - [storybook-addon-vis: Setup](https://repobuddy.github.io/visual-testing/addon/setup/): Configure Storybook, Vitest, TypeScript and .gitignore for storybook-addon-vis. Documents: cdp, defineAutoSnapshotParam, hasImageSnapshot, page, visAnnotations, storybookVis, vis.
33
+ - [storybook-addon-vis: Reviewing failures (addon view)](https://repobuddy.github.io/visual-testing/addon/guides/reviewing-failures/): Find what changed when a story snapshot fails.
34
+ - [storybook-addon-vis: Setup](https://repobuddy.github.io/visual-testing/addon/configuration/): Configure Storybook, Vitest, TypeScript and .gitignore for storybook-addon-vis. Documents: cdp, default, defineAutoSnapshotParam, hasImageSnapshot, isSnapshotEnabled, page, visAnnotations, experimental_serverChannel, storybookVis, vis.
35
+ - [storybook-addon-vis: The Vis panel](https://repobuddy.github.io/visual-testing/addon/guides/the-vis-panel/): Review baseline, result and diff of a story inside Storybook.
36
+ - [storybook-addon-vis: Themes](https://repobuddy.github.io/visual-testing/addon/guides/themes/): Take every snapshot once per theme, such as light and dark.
37
+ - [storybook-addon-vis: Thresholds and comparison for stories](https://repobuddy.github.io/visual-testing/addon/guides/thresholds-and-comparison/): Tolerate small differences and pick pixel or SSIM comparison for stories.
29
38
  - [storybook-addon-vis: Troubleshooting](https://repobuddy.github.io/visual-testing/addon/troubleshooting/): Fix common installation and runtime problems.
30
- - [storybook-addon-vis: node](https://repobuddy.github.io/visual-testing/reference/addon/node/): `storybook-addon-vis/node` provides functionality to configure the Storybook Visual Testing addon in the `.storybook/main.ts` file.
31
- - [storybook-addon-vis: node/defineStorybookVis](https://repobuddy.github.io/visual-testing/reference/addon/define-storybook-vis/): A helper function to configure the Storybook Visual Testing addon in `.storybook/main.ts`. Documents: defineStorybookVis.
32
- - [storybook-addon-vis: node/defineStorybookVisOptions](https://repobuddy.github.io/visual-testing/reference/addon/define-storybook-vis-options/): A helper function to configure options for Storybook Visual Testing addon. Documents: defineStorybookVisOptions.
33
- - [vitest-plugin-vis: auto snapshots/setAutoSnapshotOptions](https://repobuddy.github.io/visual-testing/reference/plugin/set-auto-snapshot-options/): A function to configure visual snapshot testing options for the current test or test suite. Documents: setAutoSnapshotOptions.
34
- - [vitest-plugin-vis: config/trimCommonFolder](https://repobuddy.github.io/visual-testing/reference/plugin/config/trim-common-folder/): The `trimCommonFolder` function is a utility that removes common folder prefixes from file paths to generate cleaner snapshot sub-paths. Documents: trimCommonFolder.
39
+ - [storybook-addon-vis: Viewports and multiple instances](https://repobuddy.github.io/visual-testing/addon/guides/viewports-and-multiple-instances/): Snapshot the same stories at several browser sizes.
40
+ - [storybook-addon-vis: node](https://repobuddy.github.io/visual-testing/addon/reference/node/): `storybook-addon-vis/node` provides functionality to configure the Storybook Visual Testing addon in the `.storybook/main.ts` file.
41
+ - [storybook-addon-vis: node/defineStorybookVis](https://repobuddy.github.io/visual-testing/addon/reference/define-storybook-vis/): A helper function to configure the Storybook Visual Testing addon in `.storybook/main.ts`. Documents: defineStorybookVis.
42
+ - [storybook-addon-vis: node/defineStorybookVisOptions](https://repobuddy.github.io/visual-testing/addon/reference/define-storybook-vis-options/): A helper function to configure options for Storybook Visual Testing addon. Documents: defineStorybookVisOptions.
43
+ - [vitest-plugin-vis: auto snapshots/setAutoSnapshotOptions](https://repobuddy.github.io/visual-testing/plugin/reference/set-auto-snapshot-options/): A function to configure visual snapshot testing options for the current test or test suite. Documents: setAutoSnapshotOptions.
44
+ - [vitest-plugin-vis: client-api](https://repobuddy.github.io/visual-testing/plugin/reference/client-api/): The browser-side building blocks of vitest-plugin-vis, for tools that build on the plugin. Documents: AnimationsOptions, Awaitable, ComparisonMethod, FailureThresholdOptions, ImageSnapshotCompareOptions, ImageSnapshotComparisonInfo, ImageSnapshotKeyOptions, ImageSnapshotSubjectOptions, ImageSnapshotTimeoutOptions, MaskLocator, MaskOptions, MatchImageSnapshotOptions, MetaTask, PageImageSnapshotOptions, PixelComparisonOptions, PixelDiffOptions, ReviewImageOptions, SetupVisOptions, SnapshotTestMeta, SsimComparisonOptions, SsimDiffOptions, ToMatchImageSnapshotOptions, ToMatchPageImageSnapshotOptions.
45
+ - [vitest-plugin-vis: config/trimCommonFolder](https://repobuddy.github.io/visual-testing/plugin/reference/config/trim-common-folder/): The `trimCommonFolder` function is a utility that removes common folder prefixes from file paths to generate cleaner snapshot sub-paths. Documents: trimCommonFolder.
46
+
47
+ ## Visual testing concepts
48
+
49
+ - [What is visual testing](https://repobuddy.github.io/visual-testing/visual-testing/what-is-visual-testing/): What visual testing catches and misses, and the loop of writing, snapshotting, comparing, reviewing and updating.
50
+ - [How snapshots work](https://repobuddy.github.io/visual-testing/visual-testing/how-snapshots-work/): Baseline, result and diff images, the __vis__ folder layout, and what to commit and what to ignore.
51
+ - [Comparison and thresholds](https://repobuddy.github.io/visual-testing/visual-testing/comparison-and-thresholds/): How a result is compared with its baseline: pixel and SSIM methods, failure thresholds in pixels or percent, and how to choose.
52
+ - [Platforms and CI](https://repobuddy.github.io/visual-testing/visual-testing/platforms-and-ci/): Why baselines are kept per platform, how local runs differ from CI, and how to keep baselines current in CI.
53
+ - [Updating baselines](https://repobuddy.github.io/visual-testing/visual-testing/updating-baselines/): Create the first baselines and update them after an intended change, with createMissingBaseline, updateSnapshot and vitest -u.
54
+ - [Reviewing failures](https://repobuddy.github.io/visual-testing/visual-testing/reviewing-failures/): Read a failed image snapshot: the error message, the diff, the review image, the regions file, the Vis panel and git diff.
55
+ - [Variations](https://repobuddy.github.io/visual-testing/visual-testing/variations/): Take the same test in several themes, viewports and browsers, and when each one pays off.
56
+ - [Choosing a package](https://repobuddy.github.io/visual-testing/visual-testing/choosing-a-package/): Pick storybook-addon-vis for Storybook stories or vitest-plugin-vis for Vitest Browser Mode tests, and see how they relate.
35
57
 
36
58
  ## Entry points
37
59
 
38
- - [`storybook-addon-vis`](https://github.com/repobuddy/visual-testing/blob/main/packages/storybook-addon-vis/src/index.ts): default export; functions: defineAutoSnapshotParam, hasImageSnapshot, isSnapshotEnabled, setAutoSnapshotOptions; types: Awaitable, ComparisonMethod, FailureThresholdOptions, ImageSnapshotCompareOptions, ImageSnapshotComparisonInfo, ImageSnapshotKeyOptions, ImageSnapshotSubjectOptions, ImageSnapshotTimeoutOptions, MatchImageSnapshotOptions, MetaTask, PageImageSnapshotOptions, PixelComparisonOptions, PixelDiffOptions, ReviewImageOptions, SetupVisOptions, SnapshotTestMeta, SsimComparisonOptions, SsimDiffOptions, ToMatchImageSnapshotOptions, ToMatchPageImageSnapshotOptions; values: cdp, page, visAnnotations (28 exports, 6 with a documentation page).
60
+ - [`storybook-addon-vis`](https://github.com/repobuddy/visual-testing/blob/main/packages/storybook-addon-vis/src/index.ts): default export; functions: defineAutoSnapshotParam, hasImageSnapshot, isSnapshotEnabled, setAutoSnapshotOptions; types: AnimationsOptions, Awaitable, ComparisonMethod, FailureThresholdOptions, ImageSnapshotCompareOptions, ImageSnapshotComparisonInfo, ImageSnapshotKeyOptions, ImageSnapshotSubjectOptions, ImageSnapshotTimeoutOptions, MaskLocator, MaskOptions, MatchImageSnapshotOptions, MetaTask, PageImageSnapshotOptions, PixelComparisonOptions, PixelDiffOptions, ReviewImageOptions, SetupVisOptions, SnapshotTestMeta, SsimComparisonOptions, SsimDiffOptions, ToMatchImageSnapshotOptions, ToMatchPageImageSnapshotOptions; values: cdp, page, visAnnotations (31 exports, 31 with a documentation page).
39
61
  - [`storybook-addon-vis/manager`](https://github.com/repobuddy/visual-testing/blob/main/packages/storybook-addon-vis/src/exports/manager.tsx): no named exports; it is imported for its side effects.
40
62
  - [`storybook-addon-vis/matcher`](https://github.com/repobuddy/visual-testing/blob/main/packages/storybook-addon-vis/src/exports/matcher.ts): no named exports; it is imported for its side effects.
41
63
  - [`storybook-addon-vis/node`](https://github.com/repobuddy/visual-testing/blob/main/packages/storybook-addon-vis/src/exports/node.ts): functions: defineStorybookVis, defineStorybookVisOptions (2 exports, 2 with a documentation page).
42
- - [`storybook-addon-vis/preset`](https://github.com/repobuddy/visual-testing/blob/main/packages/storybook-addon-vis/src/exports/preset.ts): value: experimental_serverChannel (1 export, 0 with a documentation page).
64
+ - [`storybook-addon-vis/preset`](https://github.com/repobuddy/visual-testing/blob/main/packages/storybook-addon-vis/src/exports/preset.ts): value: experimental_serverChannel (1 export, 1 with a documentation page).
43
65
  - [`storybook-addon-vis/vitest-plugin`](https://github.com/repobuddy/visual-testing/blob/main/packages/storybook-addon-vis/src/exports/vitest-plugin.ts): functions: storybookVis, trimCommonFolder (2 exports, 2 with a documentation page).
44
66
  - [`storybook-addon-vis/vitest-setup`](https://github.com/repobuddy/visual-testing/blob/main/packages/storybook-addon-vis/src/exports/vitest-setup.ts): function: setAutoSnapshotOptions; values: vis, visAnnotations (3 exports, 3 with a documentation page).
45
67
 
@@ -48,4 +70,4 @@ Import from the entry points listed below, not from package internals. Documenta
48
70
  - [storybook-addon-vis: Changelog](https://repobuddy.github.io/visual-testing/releases/changelog-addon/): Release history of storybook-addon-vis.
49
71
  - [Generator](https://github.com/repobuddy/visual-testing/blob/main/packages/storybook-addon-vis/scripts/generate-llms-txt.mjs): Source of this file. Run it with `--gaps` to list the undocumented exports.
50
72
 
51
- Documentation coverage: 11 of 34 distinct exported declarations are named on a documentation page; 6 carry a doc comment.
73
+ Documentation coverage: 37 of 37 distinct exported declarations are named on a documentation page; 7 carry a doc comment.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storybook-addon-vis",
3
- "version": "4.3.5",
3
+ "version": "4.5.0",
4
4
  "description": "Storybook Vitest visual testing addon",
5
5
  "keywords": [
6
6
  "image-snapshot",
@@ -63,13 +63,14 @@
63
63
  "CHANGELOG.md"
64
64
  ],
65
65
  "dependencies": {
66
+ "@just-web/react-image-compare": "^0.1.1",
66
67
  "@storybook/icons": "^2.1.0",
67
- "glob": "^13.0.6",
68
+ "glob": "^14.0.2",
68
69
  "is-ci": "^4.1.0",
69
70
  "memoize": "^11.0.0",
70
71
  "pathe": "^2.0.3",
71
72
  "type-plus": "8.0.1",
72
- "vitest-plugin-vis": "^5.2.2"
73
+ "vitest-plugin-vis": "^5.4.0"
73
74
  },
74
75
  "devDependencies": {
75
76
  "@repobuddy/storybook": "^2.33.4",
package/readme.md CHANGED
@@ -151,16 +151,16 @@ The site-wide copy is at <https://repobuddy.github.io/visual-testing/llms.txt>.
151
151
 
152
152
  [@storybook/experimental-addon-test]: https://www.npmjs.com/package/@storybook/experimental-addon-test
153
153
  [docs]: https://repobuddy.github.io/visual-testing/
154
- [docs_agents]: https://repobuddy.github.io/visual-testing/guides/reviewing-failures-with-agents/
155
- [docs_auto]: https://repobuddy.github.io/visual-testing/addon/automatic-snapshots/
156
- [docs_define]: https://repobuddy.github.io/visual-testing/reference/addon/define-storybook-vis/
157
- [docs_define_options]: https://repobuddy.github.io/visual-testing/reference/addon/define-storybook-vis-options/
158
- [docs_install]: https://repobuddy.github.io/visual-testing/addon/install/
159
- [docs_manual]: https://repobuddy.github.io/visual-testing/addon/manual-snapshots/
154
+ [docs_agents]: https://repobuddy.github.io/visual-testing/visual-testing/reviewing-failures-with-agents/
155
+ [docs_auto]: https://repobuddy.github.io/visual-testing/addon/guides/automatic-snapshots/
156
+ [docs_define]: https://repobuddy.github.io/visual-testing/addon/reference/define-storybook-vis/
157
+ [docs_define_options]: https://repobuddy.github.io/visual-testing/addon/reference/define-storybook-vis-options/
158
+ [docs_install]: https://repobuddy.github.io/visual-testing/addon/get-started/
159
+ [docs_manual]: https://repobuddy.github.io/visual-testing/addon/guides/manual-snapshots/
160
160
  [docs_migrate_1]: https://repobuddy.github.io/visual-testing/releases/migrate-to-1/
161
161
  [docs_migrate_3]: https://repobuddy.github.io/visual-testing/releases/migrate-to-3/
162
- [docs_setup]: https://repobuddy.github.io/visual-testing/addon/setup/
163
- [docs_setup_10_3]: https://repobuddy.github.io/visual-testing/addon/setup/#storybook-103-and-vitest-project-annotations
162
+ [docs_setup]: https://repobuddy.github.io/visual-testing/addon/configuration/
163
+ [docs_setup_10_3]: https://repobuddy.github.io/visual-testing/addon/configuration/#storybook-103-and-vitest-project-annotations
164
164
  [docs_troubleshooting]: https://repobuddy.github.io/visual-testing/addon/troubleshooting/
165
165
  [downloads_image]: https://img.shields.io/npm/dm/storybook-addon-vis.svg?style=flat
166
166
  [github_action_url]: https://github.com/repobuddy/visual-testing/actions/workflows/release.yml
@@ -15,4 +15,4 @@ An agent loads it when a visual test fails with a `Snapshot ... mismatched` erro
15
15
 
16
16
  ## Install
17
17
 
18
- It ships as a plugin in both the `vitest-plugin-vis` and `storybook-addon-vis` npm packages (`plugin.json` and `skills/` in the package), identical in each. The measured token costs are on the [Reviewing Failures with Agents](https://repobuddy.github.io/visual-testing/guides/reviewing-failures-with-agents/) page.
18
+ It ships as a plugin in both the `vitest-plugin-vis` and `storybook-addon-vis` npm packages (`plugin.json` and `skills/` in the package), identical in each. The measured token costs are on the [Reviewing Failures with Agents](https://repobuddy.github.io/visual-testing/visual-testing/reviewing-failures-with-agents/) page.
@@ -27,7 +27,7 @@ Snapshots live under `__vis__/`: `__baselines__` is expected, `__results__` is t
27
27
  - Same content, only the edges of text or shapes differ: rendering drift (fonts, operating system, browser). Report it; do not update the baseline.
28
28
  - Anything else is a regression. Fix it or report it.
29
29
 
30
- Full explanation and measured token costs: the [Reviewing Failures with Agents](https://repobuddy.github.io/visual-testing/guides/reviewing-failures-with-agents/) page. The `llms.txt` in the package links it and names the copy in `node_modules` to read without network access.
30
+ Full explanation and measured token costs: the [Reviewing Failures with Agents](https://repobuddy.github.io/visual-testing/visual-testing/reviewing-failures-with-agents/) page. The `llms.txt` in the package links it and names the copy in `node_modules` to read without network access.
31
31
 
32
32
  ## Validate
33
33
 
@@ -1,3 +1,4 @@
1
+ import { ImageCompare, type ImageCompareMode } from '@just-web/react-image-compare'
1
2
  import { RefreshIcon } from '@storybook/icons'
2
3
  import React, { memo, useEffect, useState } from 'react'
3
4
  import { AddonPanel, Button, Placeholder, ScrollArea } from 'storybook/internal/components'
@@ -27,42 +28,52 @@ export const VisPanel = memo(function VisPanel({ active, getSnapshotResults, onR
27
28
  },
28
29
  {} as Record<string, ImageSnapshotResults[]>,
29
30
  )
31
+ // A result alone (no baseline, no diff) is a snapshot that has no baseline yet, so there is nothing to review.
32
+ const snapshots = Object.entries(groupedResults).filter(([, results]) =>
33
+ results.some((result) => result.type !== 'result'),
34
+ )
30
35
  return (
31
36
  <AddonPanel active={active}>
32
- {snapshotResults.length > 0 ? (
37
+ {snapshots.length > 0 ? (
33
38
  <ScrollArea vertical>
34
- {Object.entries(groupedResults).map(([key, results]) => (
35
- <div key={key}>
36
- {results.some((result) => result.type === 'diff') ? (
37
- <>
38
- <SnapshotRow failed>{key}</SnapshotRow>
39
- {results.map((result) => (
40
- <img key={result.filePath} src={`data:image/png;base64,${result.base64}`} alt={result.fileName} />
41
- ))}
42
- </>
43
- ) : (
44
- <>
45
- <SnapshotRow>
46
- <span>{key}</span>
47
- <Button
48
- aria-label="Reload snapshot"
49
- onClick={() => {
50
- onRefresh()
51
- getSnapshotResults().then(setSnapshotResults)
52
- }}
53
- >
54
- <RefreshIcon />
55
- </Button>
56
- </SnapshotRow>
57
- <img
58
- key={results[0].filePath}
59
- src={`data:image/png;base64,${results[0].base64}`}
60
- alt={results[0].fileName}
61
- />
62
- </>
63
- )}
64
- </div>
65
- ))}
39
+ {snapshots.map(([key, results]) => {
40
+ const baseline = results.find((result) => result.type === 'baseline')
41
+ const result = results.find((result) => result.type === 'result')
42
+ const diff = results.find((result) => result.type === 'diff')
43
+ return (
44
+ <div key={key}>
45
+ {diff ? (
46
+ <>
47
+ <SnapshotRow failed>{key}</SnapshotRow>
48
+ {baseline && result ? (
49
+ <SnapshotCompare baseline={baseline} result={result} diff={diff} />
50
+ ) : (
51
+ // No result to compare with (e.g. an old run): show each image as is.
52
+ results.map((result) => (
53
+ <img key={result.filePath} src={toDataUrl(result)} alt={result.fileName} />
54
+ ))
55
+ )}
56
+ </>
57
+ ) : (
58
+ <>
59
+ <SnapshotRow>
60
+ <span>{key}</span>
61
+ <Button
62
+ aria-label="Reload snapshot"
63
+ onClick={() => {
64
+ onRefresh()
65
+ getSnapshotResults().then(setSnapshotResults)
66
+ }}
67
+ >
68
+ <RefreshIcon />
69
+ </Button>
70
+ </SnapshotRow>
71
+ {baseline && <SnapshotImage image={baseline} />}
72
+ </>
73
+ )}
74
+ </div>
75
+ )
76
+ })}
66
77
  </ScrollArea>
67
78
  ) : (
68
79
  <Placeholder>There is no snapshots for this story</Placeholder>
@@ -71,6 +82,83 @@ export const VisPanel = memo(function VisPanel({ active, getSnapshotResults, onR
71
82
  )
72
83
  })
73
84
 
85
+ function toDataUrl(image: ImageSnapshotResults) {
86
+ return `data:image/png;base64,${image.base64}`
87
+ }
88
+
89
+ function SnapshotImage({ image }: { image: ImageSnapshotResults }) {
90
+ return <img src={toDataUrl(image)} alt={image.fileName} />
91
+ }
92
+
93
+ type CompareView = ImageCompareMode | 'diff'
94
+
95
+ const compareViews: Array<{ view: CompareView; label: string }> = [
96
+ { view: 'side-by-side', label: 'Side by side' },
97
+ { view: 'swipe', label: 'Swipe' },
98
+ { view: 'onion-skin', label: 'Onion skin' },
99
+ { view: 'diff', label: 'Diff' },
100
+ ]
101
+
102
+ interface SnapshotCompareProps {
103
+ baseline: ImageSnapshotResults
104
+ result: ImageSnapshotResults
105
+ diff: ImageSnapshotResults
106
+ }
107
+
108
+ /**
109
+ * Compares the baseline and the result of a failed snapshot like GitHub's image diff,
110
+ * plus the diff image that marks the changed pixels.
111
+ */
112
+ function SnapshotCompare({ baseline, result, diff }: SnapshotCompareProps) {
113
+ const [view, setView] = useState<CompareView>('side-by-side')
114
+ // The compare mode stays mounted while the diff shows, so the swipe position and the opacity are kept.
115
+ const [mode, setMode] = useState<ImageCompareMode>('side-by-side')
116
+ return (
117
+ <CompareContainer>
118
+ <ViewSwitcher role="group" aria-label="Comparison view">
119
+ {compareViews.map(({ view: v, label }) => (
120
+ <Button
121
+ key={v}
122
+ size="small"
123
+ variant="ghost"
124
+ active={v === view}
125
+ aria-pressed={v === view}
126
+ onClick={() => {
127
+ setView(v)
128
+ if (v !== 'diff') setMode(v)
129
+ }}
130
+ >
131
+ {label}
132
+ </Button>
133
+ ))}
134
+ </ViewSwitcher>
135
+ <ImageCompare
136
+ base={toDataUrl(baseline)}
137
+ compare={toDataUrl(result)}
138
+ baseLabel="Baseline"
139
+ compareLabel="Result"
140
+ mode={mode}
141
+ showModeSwitcher={false}
142
+ style={view === 'diff' ? { display: 'none' } : undefined}
143
+ />
144
+ {view === 'diff' && <SnapshotImage image={diff} />}
145
+ </CompareContainer>
146
+ )
147
+ }
148
+
149
+ const CompareContainer = styled.div({
150
+ display: 'flex',
151
+ flexDirection: 'column',
152
+ alignItems: 'flex-start',
153
+ gap: '0.5rem',
154
+ padding: '0.5rem',
155
+ })
156
+
157
+ const ViewSwitcher = styled.div({
158
+ display: 'flex',
159
+ gap: '0.25rem',
160
+ })
161
+
74
162
  const SnapshotRow = styled.div<{ failed?: boolean }>(
75
163
  ({ theme, failed }: { theme: any; failed?: boolean | undefined }) => ({
76
164
  display: 'flex',
package/src/index.ts CHANGED
@@ -4,7 +4,7 @@ import './shared/global_matcher_augment.ts'
4
4
  import { definePreviewAddon } from 'storybook/internal/csf'
5
5
  import { expect } from 'storybook/test'
6
6
  import type { SetupVisOptions } from 'vitest-plugin-vis'
7
- import { autoSnapshotMatcher, setAutoSnapshotOptions } from 'vitest-plugin-vis/client-api'
7
+ import { autoSnapshotMatcher, setAutoSnapshotOptions, toSuiteDefaults } from 'vitest-plugin-vis/client-api'
8
8
  import { toMatchImageSnapshot } from './client/expect/to_match_image_snapshot.ts'
9
9
  import { isVitestBrowser } from './client/is_vitest_browser.ts'
10
10
  import { cdp, commands, page, whenVitestProxyReady } from './client/vitest_proxy.ts'
@@ -32,10 +32,7 @@ export default (options: SetupVisOptions<{ tags: string[] }> = { auto: false })
32
32
  // follow read them synchronously, so wait for it here (#835).
33
33
  await whenVitestProxyReady()
34
34
  matcher = autoSnapshotMatcher(commands, expect)
35
- const suiteDefaults =
36
- options?.createMissingBaseline !== undefined
37
- ? { createMissingBaseline: options.createMissingBaseline }
38
- : undefined
35
+ const suiteDefaults = toSuiteDefaults(options)
39
36
  if (typeof options?.auto === 'function') {
40
37
  matcherFn = matcher.createMatcher(
41
38
  {
package/src/overview.mdx CHANGED
@@ -57,7 +57,7 @@ The basic setup will:
57
57
  - Baseline images are saved in the `<root>/__vis__/*/__baselines__` directory.
58
58
  - Image snapshots of the current test run are saved in the `<root>/__vis__/*/__results__` directory.
59
59
  - Diff images are saved in the `<root>/__vis__/*/__diffs__` directory.
60
- - You can review the baseline and diff images in addon `Vis` panel.
60
+ - You can review snapshots in the addon `Vis` panel. For a failed snapshot, compare the baseline with the result side by side, with a swipe divider, or as an onion skin, or view the diff image.
61
61
 
62
62
  This setup assumes that you are writing your stories in CSF 3.
63
63
  If you are writing your stories in CSF Next, check out [Basic Setup for CSF Next](#basic-setup-for-csf-next).
@@ -571,6 +571,20 @@ This is useful when you are performing some negative test.
571
571
 
572
572
 
573
573
 
574
+ ## Usage - CSF Next preview addon
575
+
576
+ The default export of `storybook-addon-vis`, `addonVis()`, is the preview addon for CSF Next.
577
+ Pass it to `definePreview({ addons: [addonVis({ auto: true })] })`.
578
+
579
+ ## Usage - tag helper
580
+
581
+ `isSnapshotEnabled(tags)` applies the tag rule: the last of `snapshot` and `!snapshot` wins, and no tag means no snapshot.
582
+
583
+ ## Usage - Vis panel server hook
584
+
585
+ `storybook-addon-vis/preset` exports `experimental_serverChannel`, which Storybook calls so that the Vis panel can read the snapshot images.
586
+ You do not call it yourself.
587
+
574
588
  ## Usage - Chrome DevTools Protocol
575
589
 
576
590
  `cdp` is a proxy of `cdp()` from `vitest/browser`.
@@ -8,11 +8,13 @@ import {
8
8
  BASELINE_DIR,
9
9
  DIFF_DIR,
10
10
  getSnapshotRootDir,
11
+ RESULT_DIR,
11
12
  REVIEW_IMAGE_SUFFIX,
12
13
  resolveSnapshotSubpathWithinLimits,
13
14
  SNAPSHOT_ROOT_DIR,
14
15
  trimCommonFolder,
15
16
  } from 'vitest-plugin-vis/server-utils'
17
+ import type { ImageSnapshotResults } from '../shared/events.ts'
16
18
  import type { StorybookVisOptions } from './types.ts'
17
19
 
18
20
  export function createStorybookVisServer(options: StorybookVisOptions) {
@@ -54,15 +56,18 @@ export function createStorybookVisServer(options: StorybookVisOptions) {
54
56
  const taskId = name.replace(/[^a-z0-9]/gi, '-').toLowerCase()
55
57
  const taskGlob = `${taskId}-*.png`
56
58
  const baselineGlob = resolve(snapshotRootDir, BASELINE_DIR, snapshotSubpath, taskGlob)
59
+ const resultGlob = resolve(snapshotRootDir, RESULT_DIR, snapshotSubpath, taskGlob)
57
60
  const diffGlob = resolve(snapshotRootDir, DIFF_DIR, snapshotSubpath, taskGlob)
58
61
 
59
62
  const taskIdRegex = new RegExp(`${taskId}-[^-]*.png$`)
60
63
  const isSnapshotFile = (filePath: string) =>
61
64
  taskIdRegex.test(filePath) && !filePath.endsWith(REVIEW_IMAGE_SUFFIX)
62
65
  const baselineFiles = globSync(baselineGlob).filter(isSnapshotFile)
66
+ const resultFiles = globSync(resultGlob).filter(isSnapshotFile)
63
67
  const diffFiles = globSync(diffGlob).filter(isSnapshotFile)
64
68
  return [
65
69
  ...baselineFiles.map((filePath) => mapFileToResult(filePath, snapshotRootDir, 'baseline')),
70
+ ...resultFiles.map((filePath) => mapFileToResult(filePath, snapshotRootDir, 'result')),
66
71
  ...diffFiles.map((filePath) => mapFileToResult(filePath, snapshotRootDir, 'diff')),
67
72
  ]
68
73
  })
@@ -70,7 +75,11 @@ export function createStorybookVisServer(options: StorybookVisOptions) {
70
75
  }
71
76
  }
72
77
 
73
- function mapFileToResult(filePath: string, snapshotRootDir: string, type: 'baseline' | 'diff') {
78
+ function mapFileToResult(
79
+ filePath: string,
80
+ snapshotRootDir: string,
81
+ type: ImageSnapshotResults['type'],
82
+ ): ImageSnapshotResults {
74
83
  return {
75
84
  filePath,
76
85
  fileName: basename(filePath),
@@ -1,9 +0,0 @@
1
- import * as storybook_internal_csf1 from "storybook/internal/csf";
2
-
3
- //#region src/preview/vis_annotation.d.ts
4
- declare const visAnnotations: {
5
- beforeEach(ctx: storybook_internal_csf1.StoryContext<any, storybook_internal_csf1.Args>): void;
6
- };
7
- //#endregion
8
- export { visAnnotations as t };
9
- //# sourceMappingURL=vis_annotation-N0xbuXis.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vis_annotation-N0xbuXis.d.mts","names":[],"sources":["../src/preview/vis_annotation.ts"],"sourcesContent":[],"mappings":";;;cAUa;kBAgBoC,uBAAA,CAAA,kBAAA,uBAAA,CAAA,IAAA"}