storybook-addon-vis 4.6.0 → 4.8.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/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +1 -1
- package/CHANGELOG.md +48 -0
- package/dist/bin/storybook-addon-vis.mjs +13 -0
- package/dist/bin/storybook-addon-vis.mjs.map +1 -0
- package/dist/exports/constants-Dyl3Z-K5.mjs +5 -0
- package/dist/exports/constants-Dyl3Z-K5.mjs.map +1 -0
- package/dist/exports/matcher.d.mts +1 -1
- package/dist/exports/node.d.mts +4 -11
- package/dist/exports/node.d.mts.map +1 -1
- package/dist/exports/node.mjs +2 -4
- package/dist/exports/node.mjs.map +1 -1
- package/dist/exports/preset.d.mts +2 -6
- package/dist/exports/preset.d.mts.map +1 -1
- package/dist/exports/preset.mjs +8 -10
- package/dist/exports/preset.mjs.map +1 -1
- package/dist/exports/{types-CuNXsk6J.d.mts → types-DGIY4hWl.d.mts} +1 -3
- package/dist/exports/types-DGIY4hWl.d.mts.map +1 -0
- package/dist/exports/vitest-plugin.d.mts +2 -6
- package/dist/exports/vitest-plugin.d.mts.map +1 -1
- package/dist/exports/vitest-plugin.mjs +2 -3
- package/dist/exports/vitest-plugin.mjs.map +1 -1
- package/dist/exports/vitest-setup.d.mts +4 -8
- package/dist/exports/vitest-setup.d.mts.map +1 -1
- package/dist/exports/vitest-setup.mjs +2 -3
- package/dist/exports/vitest-setup.mjs.map +1 -1
- package/dist/{global_matcher_augment-B1plNA_9.d.mts → global_matcher_augment-CGDzrdCj.d.mts} +1 -4
- package/dist/global_matcher_augment-CGDzrdCj.d.mts.map +1 -0
- package/dist/index.d.mts +12 -26
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +6 -10
- package/dist/index.mjs.map +1 -1
- package/dist/manager.d.ts +1 -1
- package/dist/manager.js +13 -17
- package/dist/manager.js.map +1 -1
- package/dist/{vis_annotation-BHBO0X19.mjs → vis_annotation-CJD3p9Uh.mjs} +15 -21
- package/dist/vis_annotation-CJD3p9Uh.mjs.map +1 -0
- package/dist/vis_annotation-DJqDOBIl.d.mts +5 -0
- package/dist/vis_annotation-DJqDOBIl.d.mts.map +1 -0
- package/llms.txt +3 -3
- package/package.json +7 -4
- package/plugin.json +1 -1
- package/skills/remove-obsolete-image-snapshots/README.md +18 -0
- package/skills/remove-obsolete-image-snapshots/SKILL.md +39 -0
- package/skills/review-image-snapshot-failures/README.md +1 -1
- package/skills/review-image-snapshot-failures/SKILL.md +1 -1
- package/src/bin/storybook-addon-vis.ts +11 -0
- package/src/index.ts +1 -1
- package/src/overview.mdx +16 -0
- package/src/reviewing_failures_with_agents.mdx +17 -13
- package/dist/exports/constants-D_WcloLE.mjs +0 -7
- package/dist/exports/constants-D_WcloLE.mjs.map +0 -1
- package/dist/exports/types-CuNXsk6J.d.mts.map +0 -1
- package/dist/global_matcher_augment-B1plNA_9.d.mts.map +0 -1
- package/dist/vis_annotation-BHBO0X19.mjs.map +0 -1
- package/dist/vis_annotation-N0xbuXis.d.mts +0 -9
- package/dist/vis_annotation-N0xbuXis.d.mts.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "storybook-addon-vis",
|
|
3
3
|
"version": "4.3.2",
|
|
4
|
-
"description": "Review failed image snapshots from storybook-addon-vis cheaply: read the message, then the review image.",
|
|
4
|
+
"description": "Review failed image snapshots from storybook-addon-vis cheaply: read the message, then the review image. Remove obsolete baselines without losing the ones a gated test still needs.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Homa Wong",
|
|
7
7
|
"email": "homawong@gmail.com",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "storybook-addon-vis",
|
|
3
3
|
"version": "4.3.2",
|
|
4
|
-
"description": "Review failed image snapshots from storybook-addon-vis cheaply: read the message, then the review image.",
|
|
4
|
+
"description": "Review failed image snapshots from storybook-addon-vis cheaply: read the message, then the review image. Remove obsolete baselines without losing the ones a gated test still needs.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Homa Wong",
|
|
7
7
|
"email": "homawong@gmail.com",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "storybook-addon-vis",
|
|
3
3
|
"version": "4.3.2",
|
|
4
|
-
"description": "Review failed image snapshots from storybook-addon-vis cheaply: read the message, then the review image.",
|
|
4
|
+
"description": "Review failed image snapshots from storybook-addon-vis cheaply: read the message, then the review image. Remove obsolete baselines without losing the ones a gated test still needs.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Homa Wong",
|
|
7
7
|
"email": "homawong@gmail.com",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# CHANGE LOG
|
|
2
2
|
|
|
3
|
+
## 4.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1037](https://github.com/repobuddy/visual-testing/pull/1037) [`ec0f3c4`](https://github.com/repobuddy/visual-testing/commit/ec0f3c45ee1c830b936ea7b0f506c1a9b37eaa25) Thanks [@unional](https://github.com/unional)! - Add the `storybook-addon-vis prune [--dry-run]` command. It runs the `vitest-plugin-vis prune` command of the `vitest-plugin-vis` the addon depends on, so addon users can run it with their package manager without `npx` or `pnpm dlx` fetching a different version.
|
|
8
|
+
|
|
9
|
+
- [#1033](https://github.com/repobuddy/visual-testing/pull/1033) [`8660a45`](https://github.com/repobuddy/visual-testing/commit/8660a45a9da43df6bfdfe13e7894eb63026437da) Thanks [@unional](https://github.com/unional)! - Ship the `remove-obsolete-image-snapshots` agent skill. It tells a coding agent to run the full suite, read the obsolete image snapshot list, keep the baselines of tests that run only on some platforms or runs, and remove the rest with `-u` or `vitest-plugin-vis prune`.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`ec0f3c4`](https://github.com/repobuddy/visual-testing/commit/ec0f3c45ee1c830b936ea7b0f506c1a9b37eaa25), [`8660a45`](https://github.com/repobuddy/visual-testing/commit/8660a45a9da43df6bfdfe13e7894eb63026437da), [`b423380`](https://github.com/repobuddy/visual-testing/commit/b4233806626f3aceef39659365627cc7b001125b)]:
|
|
14
|
+
- vitest-plugin-vis@5.7.0
|
|
15
|
+
|
|
16
|
+
## 4.7.0
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- [#1028](https://github.com/repobuddy/visual-testing/pull/1028) [`03c1da1`](https://github.com/repobuddy/visual-testing/commit/03c1da151291802d61b93391da01c391af6b84fb) Thanks [@unional](https://github.com/unional)! - Write a whole-image review image when cropping does not help, and add `reviewImage: 'full'`.
|
|
21
|
+
|
|
22
|
+
When a failed snapshot's review image cannot be cropped to its changed regions
|
|
23
|
+
(the image size changed, more than 5 regions, the regions cover more than half of the image, or no region is found),
|
|
24
|
+
`<name>.review.png` now places the whole baseline, result, and diff side by side instead of being skipped.
|
|
25
|
+
The smaller image is padded to the larger size when the size changed.
|
|
26
|
+
The `Review:` line says `(baseline, result, diff of the whole image; not cropped, <reason>)`.
|
|
27
|
+
|
|
28
|
+
`reviewImage` also accepts `'full'` to always write the whole-image review, like the composite image of `jest-image-snapshot`.
|
|
29
|
+
In `storybook-addon-vis`, `storybookVis({ reviewImage: 'full' })` takes the same value.
|
|
30
|
+
|
|
31
|
+
- [#1029](https://github.com/repobuddy/visual-testing/pull/1029) [`5cb6da1`](https://github.com/repobuddy/visual-testing/commit/5cb6da1ee7fc2298aa620dfced2aabc31bf231b4) Thanks [@unional](https://github.com/unional)! - Report obsolete image snapshots at the end of each run, and delete them with `-u`.
|
|
32
|
+
|
|
33
|
+
The plugin records every baseline a run uses.
|
|
34
|
+
At the end of the run it lists the baselines in the run's snapshot folders that the run did not use,
|
|
35
|
+
like Vitest's `obsolete` count for text snapshots. With `-u`, it deletes them.
|
|
36
|
+
|
|
37
|
+
It keeps snapshots of skipped, todo, and failed tests, baselines of test files with errors or outside the run,
|
|
38
|
+
and snapshot folders the run did not use, such as other platforms and projects.
|
|
39
|
+
Baselines of test files that are gone are listed only when the run covered the snapshot folder in full.
|
|
40
|
+
|
|
41
|
+
Snapshots taken in Storybook through `storybook-addon-vis` are tracked the same way.
|
|
42
|
+
|
|
43
|
+
- [#824](https://github.com/repobuddy/visual-testing/pull/824) [`51f677c`](https://github.com/repobuddy/visual-testing/commit/51f677cd04ffc463f6404037d7bfa72587ae7deb) Thanks [@kohlmannj-nyt](https://github.com/kohlmannj-nyt)! - Re-export Vitest browser's `commands` export (https://vitest.dev/api/browser/commands.html)
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- [#572](https://github.com/repobuddy/visual-testing/pull/572) [`1bb4cb9`](https://github.com/repobuddy/visual-testing/commit/1bb4cb9675b305a754ed9353472d87072a5ed31d) Thanks [@renovate](https://github.com/apps/renovate)! - Build with `tsdown` 0.22. The emitted JavaScript and type declarations are equivalent; only formatting and import style change.
|
|
48
|
+
- Updated dependencies [[`03c1da1`](https://github.com/repobuddy/visual-testing/commit/03c1da151291802d61b93391da01c391af6b84fb), [`5cb6da1`](https://github.com/repobuddy/visual-testing/commit/5cb6da1ee7fc2298aa620dfced2aabc31bf231b4), [`1bb4cb9`](https://github.com/repobuddy/visual-testing/commit/1bb4cb9675b305a754ed9353472d87072a5ed31d)]:
|
|
49
|
+
- vitest-plugin-vis@5.6.0
|
|
50
|
+
|
|
3
51
|
## 4.6.0
|
|
4
52
|
|
|
5
53
|
### Minor Changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { runCli } from "vitest-plugin-vis/cli";
|
|
3
|
+
|
|
4
|
+
// src/bin/storybook-addon-vis.ts
|
|
5
|
+
process.exitCode = await runCli(process.argv.slice(2), {
|
|
6
|
+
cwd: process.cwd(),
|
|
7
|
+
name: "storybook-addon-vis",
|
|
8
|
+
log: (m) => process.stdout.write(`${m}\n`),
|
|
9
|
+
error: (m) => process.stderr.write(`${m}\n`)
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export { };
|
|
13
|
+
//# sourceMappingURL=storybook-addon-vis.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storybook-addon-vis.mjs","names":[],"sources":["../../src/bin/storybook-addon-vis.ts"],"sourcesContent":["#!/usr/bin/env node\n// Resolves `vitest-plugin-vis` from this package's own dependency,\n// so the command always matches the plugin version the addon runs with.\nimport { runCli } from 'vitest-plugin-vis/cli'\n\nprocess.exitCode = await runCli(process.argv.slice(2), {\n\tcwd: process.cwd(),\n\tname: 'storybook-addon-vis',\n\tlog: (m) => process.stdout.write(`${m}\\n`),\n\terror: (m) => process.stderr.write(`${m}\\n`),\n})\n"],"mappings":";;;;AAKA,QAAQ,WAAW,MAAM,OAAO,QAAQ,KAAK,MAAM,CAAC,GAAG;CACtD,KAAK,QAAQ,IAAI;CACjB,MAAM;CACN,MAAM,MAAM,QAAQ,OAAO,MAAM,GAAG,EAAE,GAAG;CACzC,QAAQ,MAAM,QAAQ,OAAO,MAAM,GAAG,EAAE,GAAG;AAC5C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants-Dyl3Z-K5.mjs","names":[],"sources":["../../src/shared/constants.ts"],"sourcesContent":["export const NAME = 'storybook-addon-vis'\nexport const VIS_PANEL_ID = `${NAME}/vis_panel`\n"],"mappings":";AAAA,MAAa,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import "../global_matcher_augment-
|
|
1
|
+
import "../global_matcher_augment-CGDzrdCj.mjs";
|
package/dist/exports/node.d.mts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { t as StorybookVisOptions } from "./types-
|
|
2
|
-
|
|
3
|
-
//#region src/node/define_storybook_vis.d.ts
|
|
4
|
-
|
|
1
|
+
import { t as StorybookVisOptions } from "./types-DGIY4hWl.mjs";
|
|
5
2
|
/**
|
|
6
3
|
* Defines the Storybook Visual Testing addon configuration.
|
|
7
4
|
*
|
|
@@ -30,7 +27,7 @@ import { t as StorybookVisOptions } from "./types-CuNXsk6J.mjs";
|
|
|
30
27
|
* // Returns: { name: string, options: StorybookVisOptions }
|
|
31
28
|
* ```
|
|
32
29
|
*/
|
|
33
|
-
declare function defineStorybookVis(): string;
|
|
30
|
+
export declare function defineStorybookVis(): string;
|
|
34
31
|
/**
|
|
35
32
|
* Defines the Storybook Visual Testing addon configuration with options.
|
|
36
33
|
*
|
|
@@ -62,16 +59,12 @@ declare function defineStorybookVis(): string;
|
|
|
62
59
|
* }
|
|
63
60
|
* ```
|
|
64
61
|
*/
|
|
65
|
-
declare function defineStorybookVis(options: StorybookVisOptions): {
|
|
62
|
+
export declare function defineStorybookVis(options: StorybookVisOptions): {
|
|
66
63
|
name: string;
|
|
67
64
|
options: StorybookVisOptions;
|
|
68
65
|
};
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region src/node/define_storybook_vis_options.d.ts
|
|
71
66
|
/**
|
|
72
67
|
* Define options for Storybook Visual Testing addon.
|
|
73
68
|
*/
|
|
74
|
-
declare function defineStorybookVisOptions(options: StorybookVisOptions): StorybookVisOptions;
|
|
75
|
-
//#endregion
|
|
76
|
-
export { defineStorybookVis, defineStorybookVisOptions };
|
|
69
|
+
export declare function defineStorybookVisOptions(options: StorybookVisOptions): StorybookVisOptions;
|
|
77
70
|
//# sourceMappingURL=node.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.mts","names":[],"sources":["../../src/node/define_storybook_vis.ts","../../src/node/define_storybook_vis_options.ts"],"
|
|
1
|
+
{"version":3,"file":"node.d.mts","names":[],"sources":["../../src/node/define_storybook_vis.ts","../../src/node/define_storybook_vis_options.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAgCgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAgCA,mBAAmB,SAAS;EAAwB;EAAc,SAAS;;;;;wBC3D3E,0BAA0B,SAAS,sBAAmB"}
|
package/dist/exports/node.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dirname } from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/node/define_storybook_vis.ts
|
|
5
5
|
function defineStorybookVis(options) {
|
|
6
6
|
const name = dirname(fileURLToPath(import.meta.resolve("storybook-addon-vis/package.json")));
|
|
7
7
|
return !options ? name : {
|
|
@@ -10,8 +10,7 @@ function defineStorybookVis(options) {
|
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
//#region src/node/define_storybook_vis_options.ts
|
|
13
|
+
// src/node/define_storybook_vis_options.ts
|
|
15
14
|
/**
|
|
16
15
|
* Define options for Storybook Visual Testing addon.
|
|
17
16
|
*/
|
|
@@ -19,6 +18,5 @@ function defineStorybookVisOptions(options) {
|
|
|
19
18
|
return options;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
//#endregion
|
|
23
21
|
export { defineStorybookVis, defineStorybookVisOptions };
|
|
24
22
|
//# sourceMappingURL=node.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.mjs","names":[],"sources":["../../src/node/define_storybook_vis.ts","../../src/node/define_storybook_vis_options.ts"],"sourcesContent":["import { dirname } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport type { StorybookVisOptions } from '../server/types.ts'\n\n/**\n * Defines the Storybook Visual Testing addon configuration.\n *\n * When called without options, returns the package directory name as a string.\n * When called with options, returns an object containing both the package name and the provided options.\n *\n * @returns When called without options, returns the package directory path as a filesystem path string (e.g., `/path/to/storybook-addon-vis`).\n *\n * @example\n * ```ts\n * // Without options - returns just the package directory path\n * const addonName = defineStorybookVis()\n * // Returns: string (absolute filesystem path to package directory)\n * ```\n *\n * @example\n * ```ts\n * // With options - returns object with name and options\n * const addonConfig = defineStorybookVis({\n * visProjects: [\n * {\n * snapshotRootDir: '__vis__/linux',\n * },\n * ],\n * })\n * // Returns: { name: string, options: StorybookVisOptions }\n * ```\n */\nexport function defineStorybookVis(): string\n/**\n * Defines the Storybook Visual Testing addon configuration with options.\n *\n * @param options - Configuration options for visual testing suites in Storybook.\n * @param options.visProjects - Array of visual testing project configurations.\n * @param options.visProjects[].snapshotRootDir - Root directory for storing snapshots. Can be a string path or a function that returns a path based on CI and platform context.\n * @param options.visProjects[].snapshotSubpath - Optional function to customize the snapshot subdirectory path.\n *\n * @returns An object containing the package name and the provided options.\n *\n * @example\n * ```ts\n * // In .storybook/main.ts\n * import { defineStorybookVis } from 'storybook-addon-vis/node'\n *\n * export default {\n * addons: [\n * defineStorybookVis({\n * visProjects: [\n * {\n * snapshotRootDir: '__vis__/linux',\n * },\n * {\n * snapshotRootDir: '__vis__/local',\n * },\n * ],\n * }),\n * ],\n * }\n * ```\n */\nexport function defineStorybookVis(options: StorybookVisOptions): { name: string; options: StorybookVisOptions }\nexport function defineStorybookVis(options?: StorybookVisOptions | undefined) {\n\tconst name = dirname(fileURLToPath(import.meta.resolve('storybook-addon-vis/package.json')))\n\treturn !options ? name : { name, options }\n}\n","import type { StorybookVisOptions } from '../server/types.ts'\n\n/**\n * Define options for Storybook Visual Testing addon.\n */\nexport function defineStorybookVisOptions(options: StorybookVisOptions) {\n\treturn options\n}\n"],"mappings":";;;;AAiEA,SAAgB,mBAAmB,SAA2C;CAC7E,MAAM,OAAO,QAAQ,cAAc,
|
|
1
|
+
{"version":3,"file":"node.mjs","names":[],"sources":["../../src/node/define_storybook_vis.ts","../../src/node/define_storybook_vis_options.ts"],"sourcesContent":["import { dirname } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport type { StorybookVisOptions } from '../server/types.ts'\n\n/**\n * Defines the Storybook Visual Testing addon configuration.\n *\n * When called without options, returns the package directory name as a string.\n * When called with options, returns an object containing both the package name and the provided options.\n *\n * @returns When called without options, returns the package directory path as a filesystem path string (e.g., `/path/to/storybook-addon-vis`).\n *\n * @example\n * ```ts\n * // Without options - returns just the package directory path\n * const addonName = defineStorybookVis()\n * // Returns: string (absolute filesystem path to package directory)\n * ```\n *\n * @example\n * ```ts\n * // With options - returns object with name and options\n * const addonConfig = defineStorybookVis({\n * visProjects: [\n * {\n * snapshotRootDir: '__vis__/linux',\n * },\n * ],\n * })\n * // Returns: { name: string, options: StorybookVisOptions }\n * ```\n */\nexport function defineStorybookVis(): string\n/**\n * Defines the Storybook Visual Testing addon configuration with options.\n *\n * @param options - Configuration options for visual testing suites in Storybook.\n * @param options.visProjects - Array of visual testing project configurations.\n * @param options.visProjects[].snapshotRootDir - Root directory for storing snapshots. Can be a string path or a function that returns a path based on CI and platform context.\n * @param options.visProjects[].snapshotSubpath - Optional function to customize the snapshot subdirectory path.\n *\n * @returns An object containing the package name and the provided options.\n *\n * @example\n * ```ts\n * // In .storybook/main.ts\n * import { defineStorybookVis } from 'storybook-addon-vis/node'\n *\n * export default {\n * addons: [\n * defineStorybookVis({\n * visProjects: [\n * {\n * snapshotRootDir: '__vis__/linux',\n * },\n * {\n * snapshotRootDir: '__vis__/local',\n * },\n * ],\n * }),\n * ],\n * }\n * ```\n */\nexport function defineStorybookVis(options: StorybookVisOptions): { name: string; options: StorybookVisOptions }\nexport function defineStorybookVis(options?: StorybookVisOptions | undefined) {\n\tconst name = dirname(fileURLToPath(import.meta.resolve('storybook-addon-vis/package.json')))\n\treturn !options ? name : { name, options }\n}\n","import type { StorybookVisOptions } from '../server/types.ts'\n\n/**\n * Define options for Storybook Visual Testing addon.\n */\nexport function defineStorybookVisOptions(options: StorybookVisOptions) {\n\treturn options\n}\n"],"mappings":";;;;AAiEA,SAAgB,mBAAmB,SAA2C;CAC7E,MAAM,OAAO,QAAQ,cAAc,YAAY,QAAQ,kCAAkC,CAAC,CAAC;CAC3F,OAAO,CAAC,UAAU,OAAO;EAAE;EAAM;CAAQ;AAC1C;;;;;;AC/DA,SAAgB,0BAA0B,SAA8B;CACvE,OAAO;AACR"}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { t as StorybookVisOptions } from "./types-
|
|
1
|
+
import { t as StorybookVisOptions } from "./types-DGIY4hWl.mjs";
|
|
2
2
|
import { Channel } from "storybook/internal/channels";
|
|
3
|
-
|
|
4
|
-
//#region src/exports/preset.d.ts
|
|
5
|
-
declare const experimental_serverChannel: (channel: Channel, options: StorybookVisOptions) => Promise<Channel>;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { experimental_serverChannel };
|
|
3
|
+
export declare const experimental_serverChannel: (channel: Channel, options: StorybookVisOptions) => Promise<Channel>;
|
|
8
4
|
//# sourceMappingURL=preset.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preset.d.mts","names":[],"sources":["../../src/exports/preset.ts"],"
|
|
1
|
+
{"version":3,"file":"preset.d.mts","names":[],"sources":["../../src/exports/preset.ts"],"mappings":";;qBAMa,6BAAoC,SAAS,SAAS,SAAS,wBAAmB,QAAA"}
|
package/dist/exports/preset.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as NAME } from "./constants-
|
|
1
|
+
import { t as NAME } from "./constants-Dyl3Z-K5.mjs";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { platform } from "node:process";
|
|
4
4
|
import { globSync } from "glob";
|
|
@@ -7,7 +7,7 @@ import memoize from "memoize";
|
|
|
7
7
|
import { basename, resolve } from "pathe";
|
|
8
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
|
+
// src/server/create_storybook_vis_server.ts
|
|
11
11
|
function createStorybookVisServer(options) {
|
|
12
12
|
const visSuites = options.visProjects ?? [{}];
|
|
13
13
|
return {
|
|
@@ -19,10 +19,11 @@ function createStorybookVisServer(options) {
|
|
|
19
19
|
platform
|
|
20
20
|
}) : memoize(getSnapshotRootDir)(SNAPSHOT_ROOT_DIR);
|
|
21
21
|
const snapshotSubpathRaw = (typeof suite.snapshotSubpath === "function" ? memoize(suite.snapshotSubpath) : memoize(({ subpath }) => trimCommonFolder(subpath.startsWith("./") ? subpath.slice(2) : subpath)))({ subpath: importPath });
|
|
22
|
+
const snapshotBaselineRootAbs = resolve(snapshotRootDir, BASELINE_DIR);
|
|
22
23
|
return {
|
|
23
24
|
snapshotRootDir,
|
|
24
25
|
snapshotSubpath: resolveSnapshotSubpathWithinLimits({
|
|
25
|
-
snapshotBaselineRootAbs
|
|
26
|
+
snapshotBaselineRootAbs,
|
|
26
27
|
rawSnapshotSubpath: snapshotSubpathRaw,
|
|
27
28
|
shortenLongSnapshotPaths: suite.shortenLongSnapshotPaths === true
|
|
28
29
|
})
|
|
@@ -33,7 +34,7 @@ function createStorybookVisServer(options) {
|
|
|
33
34
|
const baselineGlob = resolve(snapshotRootDir, BASELINE_DIR, snapshotSubpath, taskGlob);
|
|
34
35
|
const resultGlob = resolve(snapshotRootDir, RESULT_DIR, snapshotSubpath, taskGlob);
|
|
35
36
|
const diffGlob = resolve(snapshotRootDir, DIFF_DIR, snapshotSubpath, taskGlob);
|
|
36
|
-
const taskIdRegex =
|
|
37
|
+
const taskIdRegex = new RegExp(`${taskId}-[^-]*.png$`);
|
|
37
38
|
const isSnapshotFile = (filePath) => taskIdRegex.test(filePath) && !filePath.endsWith(REVIEW_IMAGE_SUFFIX);
|
|
38
39
|
const baselineFiles = globSync(baselineGlob).filter(isSnapshotFile);
|
|
39
40
|
const resultFiles = globSync(resultGlob).filter(isSnapshotFile);
|
|
@@ -57,17 +58,15 @@ function mapFileToResult(filePath, snapshotRootDir, type) {
|
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
|
|
61
|
-
//#region src/shared/events.ts
|
|
61
|
+
// src/shared/events.ts
|
|
62
62
|
const IMAGE_SNAPSHOT_RESULTS_REQUEST = "IMAGE_SNAPSHOT_RESULTS_REQUEST";
|
|
63
63
|
const IMAGE_SNAPSHOT_RESULTS_RESPONSE = "IMAGE_SNAPSHOT_RESULTS_RESPONSE";
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
//#region src/exports/preset.ts
|
|
65
|
+
// src/exports/preset.ts
|
|
67
66
|
const experimental_serverChannel = async (channel, options) => {
|
|
68
67
|
const server = createStorybookVisServer(options);
|
|
69
68
|
channel.on(NAME, async (event) => {
|
|
70
|
-
if (event.type === IMAGE_SNAPSHOT_RESULTS_REQUEST) {
|
|
69
|
+
if (event.type === "IMAGE_SNAPSHOT_RESULTS_REQUEST") {
|
|
71
70
|
const results = await server.getImageSnapshotResults(event.name, event.importPath);
|
|
72
71
|
channel.emit(NAME, {
|
|
73
72
|
type: IMAGE_SNAPSHOT_RESULTS_RESPONSE,
|
|
@@ -80,6 +79,5 @@ const experimental_serverChannel = async (channel, options) => {
|
|
|
80
79
|
return channel;
|
|
81
80
|
};
|
|
82
81
|
|
|
83
|
-
//#endregion
|
|
84
82
|
export { experimental_serverChannel };
|
|
85
83
|
//# sourceMappingURL=preset.mjs.map
|
|
@@ -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\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,
|
|
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,CAAC,CAAC;CAC5C,OAAO;EACN;EACA,MAAM,wBAAwB,MAAc,YAAoB;GAC/D,OAAO,UACL,KAAK,UAAU;IACf,MAAM,kBACL,OAAO,MAAM,oBAAoB,WAC9B,MAAM,kBACN,OAAO,MAAM,oBAAoB,aAChC,QAAQ,MAAM,eAAe,CAAC,CAAC;KAC/B;KACA;IACD,CAAC,IACA,QAAQ,kBAAkB,CAAC,CAAC,iBAAiB;IAQlD,MAAM,sBALL,OAAO,MAAM,oBAAoB,aAC9B,QAAQ,MAAM,eAAe,IAC7B,SAAS,EAAE,cACX,iBAAiB,QAAQ,WAAW,IAAI,IAAI,QAAQ,MAAM,CAAC,IAAI,OAAO,CACvE,EACyC,CAAC,EAAE,SAAS,WAAW,CAAC;IACpE,MAAM,0BAA0B,QAAQ,iBAAiB,YAAY;IAMrE,OAAO;KACN;KACA,iBAPuB,mCAAmC;MAC1D;MACA,oBAAoB;MACpB,0BAA0B,MAAM,6BAA6B;KAC9D,CAGe;IACf;GACD,CAAC,CAAC,CACD,SAAS,EAAE,iBAAiB,sBAAsB;IAClD,MAAM,SAAS,KAAK,QAAQ,eAAe,GAAG,CAAC,CAAC,YAAY;IAC5D,MAAM,WAAW,GAAG,OAAO;IAC3B,MAAM,eAAe,QAAQ,iBAAiB,cAAc,iBAAiB,QAAQ;IACrF,MAAM,aAAa,QAAQ,iBAAiB,YAAY,iBAAiB,QAAQ;IACjF,MAAM,WAAW,QAAQ,iBAAiB,UAAU,iBAAiB,QAAQ;IAE7E,MAAM,cAAc,IAAI,OAAO,GAAG,OAAO,YAAY;IACrD,MAAM,kBAAkB,aACvB,YAAY,KAAK,QAAQ,KAAK,CAAC,SAAS,SAAS,mBAAmB;IACrE,MAAM,gBAAgB,SAAS,YAAY,CAAC,CAAC,OAAO,cAAc;IAClE,MAAM,cAAc,SAAS,UAAU,CAAC,CAAC,OAAO,cAAc;IAC9D,MAAM,YAAY,SAAS,QAAQ,CAAC,CAAC,OAAO,cAAc;IAC1D,OAAO;KACN,GAAG,cAAc,KAAK,aAAa,gBAAgB,UAAU,iBAAiB,UAAU,CAAC;KACzF,GAAG,YAAY,KAAK,aAAa,gBAAgB,UAAU,iBAAiB,QAAQ,CAAC;KACrF,GAAG,UAAU,KAAK,aAAa,gBAAgB,UAAU,iBAAiB,MAAM,CAAC;IAClF;GACD,CAAC;EACH;CACD;AACD;AAEA,SAAS,gBACR,UACA,iBACA,MACuB;CACvB,OAAO;EACN;EACA,UAAU,SAAS,QAAQ;EAC3B;EACA;EACA,QAAQ,aAAa,UAAU,QAAQ;CACxC;AACD;;;ACvFA,MAAa,iCAAiC;AAC9C,MAAa,kCAAkC;;;ACG/C,MAAa,6BAA6B,OAAO,SAAkB,YAAiC;CACnG,MAAM,SAAS,yBAAyB,OAAO;CAE/C,QAAQ,GAAG,MAAM,OAAO,UAAoB;EAC3C,IAAI,MAAM,2CAAyC;GAClD,MAAM,UAAU,MAAM,OAAO,wBAAwB,MAAM,MAAM,MAAM,UAAU;GACjF,QAAQ,KAAK,MAAM;IAClB,MAAM;IACN,MAAM,MAAM;IACZ,YAAY,MAAM;IAClB;GACD,CAAC;EACF;CACD,CAAC;CAED,OAAO;AACR"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/server/types.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Configuration options for visual testing suites in Storybook.
|
|
4
3
|
*
|
|
@@ -24,6 +23,5 @@ type StorybookVisOptions = {
|
|
|
24
23
|
shortenLongSnapshotPaths?: boolean | undefined;
|
|
25
24
|
}>;
|
|
26
25
|
};
|
|
27
|
-
//#endregion
|
|
28
26
|
export { StorybookVisOptions as t };
|
|
29
|
-
//# sourceMappingURL=types-
|
|
27
|
+
//# sourceMappingURL=types-DGIY4hWl.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-DGIY4hWl.d.mts","names":[],"sources":["../../src/server/types.ts"],"mappings":";;;;;;;KAOY;EACX,aAAa;IACZ,4BAA4B;MAAW;MAAa;;IACpD,oBAAoB;MAAW;;;;;;;;IAO/B"}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { ComparisonMethod, VisOptions, trimCommonFolder } from "vitest-plugin-vis/config";
|
|
2
2
|
import { ObjectPlus } from "type-plus";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
declare function storybookVis<M extends ComparisonMethod>(options?: ObjectPlus.Omit<VisOptions<M>, 'preset'> | undefined): any;
|
|
7
|
-
//#endregion
|
|
8
|
-
export { storybookVis, trimCommonFolder };
|
|
3
|
+
export declare function storybookVis<M extends ComparisonMethod>(options?: ObjectPlus.Omit<VisOptions<M>, 'preset'> | undefined): any;
|
|
4
|
+
export { trimCommonFolder };
|
|
9
5
|
//# sourceMappingURL=vitest-plugin.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest-plugin.d.mts","names":[],"sources":["../../src/vitest-plugin/storybook_vis.ts"],"
|
|
1
|
+
{"version":3,"file":"vitest-plugin.d.mts","names":[],"sources":["../../src/vitest-plugin/storybook_vis.ts"],"mappings":";;wBAOgB,aAAa,UAAU,kBACtC,UAAU,WAAW,KAAK,WAAW"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as NAME } from "./constants-
|
|
1
|
+
import { t as NAME } from "./constants-Dyl3Z-K5.mjs";
|
|
2
2
|
import { trimCommonFolder, vis } from "vitest-plugin-vis/config";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/vitest-plugin/storybook_vis.ts
|
|
5
5
|
function storybookVis(options) {
|
|
6
6
|
return {
|
|
7
7
|
...vis({
|
|
@@ -12,6 +12,5 @@ function storybookVis(options) {
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
//#endregion
|
|
16
15
|
export { storybookVis, trimCommonFolder };
|
|
17
16
|
//# sourceMappingURL=vitest-plugin.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest-plugin.mjs","names":[],"sources":["../../src/vitest-plugin/storybook_vis.ts"],"sourcesContent":["/**\n * Return type is `any` to support different Vitest and Vite versions.\n */\nimport type { ObjectPlus } from 'type-plus'\nimport { type ComparisonMethod, type VisOptions, vis } from 'vitest-plugin-vis/config'\nimport { NAME } from '../shared/constants.ts'\n\nexport function storybookVis<M extends ComparisonMethod>(\n\toptions?: ObjectPlus.Omit<VisOptions<M>, 'preset'> | undefined,\n): any {\n\treturn {\n\t\t...vis({\n\t\t\t...options,\n\t\t\tpreset: 'custom',\n\t\t}),\n\t\tname: NAME,\n\t}\n}\n"],"mappings":";;;;AAOA,SAAgB,aACf,SACM;
|
|
1
|
+
{"version":3,"file":"vitest-plugin.mjs","names":[],"sources":["../../src/vitest-plugin/storybook_vis.ts"],"sourcesContent":["/**\n * Return type is `any` to support different Vitest and Vite versions.\n */\nimport type { ObjectPlus } from 'type-plus'\nimport { type ComparisonMethod, type VisOptions, vis } from 'vitest-plugin-vis/config'\nimport { NAME } from '../shared/constants.ts'\n\nexport function storybookVis<M extends ComparisonMethod>(\n\toptions?: ObjectPlus.Omit<VisOptions<M>, 'preset'> | undefined,\n): any {\n\treturn {\n\t\t...vis({\n\t\t\t...options,\n\t\t\tpreset: 'custom',\n\t\t}),\n\t\tname: NAME,\n\t}\n}\n"],"mappings":";;;;AAOA,SAAgB,aACf,SACM;CACN,OAAO;EACN,GAAG,IAAI;GACN,GAAG;GACH,QAAQ;EACT,CAAC;EACD,MAAM;CACP;AACD"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import "../global_matcher_augment-
|
|
2
|
-
import { t as visAnnotations } from "../vis_annotation-
|
|
1
|
+
import "../global_matcher_augment-CGDzrdCj.mjs";
|
|
2
|
+
import { t as visAnnotations } from "../vis_annotation-DJqDOBIl.mjs";
|
|
3
3
|
import { setAutoSnapshotOptions } from "vitest-plugin-vis";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
//#region src/exports/vitest-setup.d.ts
|
|
7
|
-
declare const vis: vitest_plugin_vis_setup_api0.VisClientConfigurator<{
|
|
4
|
+
export declare const vis: import("vitest-plugin-vis/setup-api").VisClientConfigurator<{
|
|
8
5
|
tags: string[];
|
|
9
6
|
}>;
|
|
10
|
-
|
|
11
|
-
export { setAutoSnapshotOptions, vis, visAnnotations };
|
|
7
|
+
export { setAutoSnapshotOptions, visAnnotations };
|
|
12
8
|
//# sourceMappingURL=vitest-setup.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest-setup.d.mts","names":[],"sources":["../../src/exports/vitest-setup.ts"],"
|
|
1
|
+
{"version":3,"file":"vitest-setup.d.mts","names":[],"sources":["../../src/exports/vitest-setup.ts"],"mappings":";;;qBAMa,2CAAG;EAAqB"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { a as commands, t as visAnnotations } from "../vis_annotation-
|
|
1
|
+
import { a as commands, t as visAnnotations } from "../vis_annotation-CJD3p9Uh.mjs";
|
|
2
2
|
import { setAutoSnapshotOptions } from "vitest-plugin-vis";
|
|
3
3
|
import { createVis } from "vitest-plugin-vis/setup-api";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/exports/vitest-setup.ts
|
|
6
6
|
const vis = createVis(commands);
|
|
7
7
|
|
|
8
|
-
//#endregion
|
|
9
8
|
export { setAutoSnapshotOptions, vis, visAnnotations };
|
|
10
9
|
//# sourceMappingURL=vitest-setup.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest-setup.mjs","names":[],"sources":["../../src/exports/vitest-setup.ts"],"sourcesContent":["// `storybook-addon-vis/vitest-setup` provides code needed in `vitest.setup.ts`.\nimport '../shared/global_matcher_augment.ts'\n\nimport { createVis } from 'vitest-plugin-vis/setup-api'\nimport { commands } from '../client/vitest_proxy.ts'\n\nexport const vis = createVis<{ tags: string[] }>(commands)\nexport { setAutoSnapshotOptions } from 'vitest-plugin-vis'\nexport { visAnnotations } from '../preview/vis_annotation.ts'\n"],"mappings":";;;;;AAMA,MAAa,MAAM,UAA8B,
|
|
1
|
+
{"version":3,"file":"vitest-setup.mjs","names":[],"sources":["../../src/exports/vitest-setup.ts"],"sourcesContent":["// `storybook-addon-vis/vitest-setup` provides code needed in `vitest.setup.ts`.\nimport '../shared/global_matcher_augment.ts'\n\nimport { createVis } from 'vitest-plugin-vis/setup-api'\nimport { commands } from '../client/vitest_proxy.ts'\n\nexport const vis = createVis<{ tags: string[] }>(commands)\nexport { setAutoSnapshotOptions } from 'vitest-plugin-vis'\nexport { visAnnotations } from '../preview/vis_annotation.ts'\n"],"mappings":";;;;;AAMA,MAAa,MAAM,UAA8B,QAAQ"}
|
package/dist/{global_matcher_augment-B1plNA_9.d.mts → global_matcher_augment-CGDzrdCj.d.mts}
RENAMED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { ImageSnapshotMatcher } from "vitest-plugin-vis/client-api";
|
|
2
|
-
|
|
3
|
-
//#region src/shared/global_matcher_augment.d.ts
|
|
4
2
|
declare global {
|
|
5
3
|
namespace jest {
|
|
6
4
|
interface Matchers<R, T> extends ImageSnapshotMatcher {}
|
|
7
5
|
}
|
|
8
6
|
}
|
|
9
|
-
//# sourceMappingURL=global_matcher_augment.d.
|
|
10
|
-
//# sourceMappingURL=global_matcher_augment-B1plNA_9.d.mts.map
|
|
7
|
+
//# sourceMappingURL=global_matcher_augment-CGDzrdCj.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global_matcher_augment-CGDzrdCj.d.mts","names":[],"sources":["../src/shared/global_matcher_augment.ts"],"mappings":";QAIQ;YACG;cACC,SAAS,GAAG,WAAW"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,44 +1,30 @@
|
|
|
1
|
-
import "./global_matcher_augment-
|
|
2
|
-
import { t as visAnnotations } from "./vis_annotation-
|
|
3
|
-
import * as storybook_internal_csf0 from "storybook/internal/csf";
|
|
1
|
+
import "./global_matcher_augment-CGDzrdCj.mjs";
|
|
2
|
+
import { t as visAnnotations } from "./vis_annotation-DJqDOBIl.mjs";
|
|
4
3
|
import { ComparisonMethod, FailureThresholdOptions, ImageSnapshotCompareOptions, ImageSnapshotKeyOptions, ImageSnapshotKeyOptions as ImageSnapshotKeyOptions$1, ImageSnapshotSubjectOptions, ImageSnapshotTimeoutOptions, PageImageSnapshotOptions, PixelComparisonOptions, SsimComparisonOptions, ToMatchImageSnapshotOptions } from "vitest-plugin-vis/client-api";
|
|
5
|
-
import * as vitest_plugin_vis0 from "vitest-plugin-vis";
|
|
6
4
|
import { SetupVisOptions } from "vitest-plugin-vis";
|
|
7
|
-
import "vitest";
|
|
8
|
-
import { BrowserPage, CDPSession } from "vitest/browser";
|
|
5
|
+
import { BrowserCommands, BrowserPage, CDPSession } from "vitest/browser";
|
|
9
6
|
export * from "vitest-plugin-vis";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
declare const page: BrowserPage;
|
|
14
|
-
declare const cdp: () => CDPSession;
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/client/has_image_snapshot.d.ts
|
|
7
|
+
export declare const page: BrowserPage;
|
|
8
|
+
export declare const commands: BrowserCommands;
|
|
9
|
+
export declare const cdp: () => CDPSession;
|
|
17
10
|
/**
|
|
18
11
|
* Check if the snapshot image exists.
|
|
19
12
|
*/
|
|
20
|
-
declare function hasImageSnapshot(options?: ImageSnapshotKeyOptions$1 | undefined): false | Promise<boolean>;
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/client/storybook/param.d.ts
|
|
13
|
+
export declare function hasImageSnapshot(options?: ImageSnapshotKeyOptions$1 | undefined): false | Promise<boolean>;
|
|
23
14
|
/**
|
|
24
15
|
* Define snapshot parameter for auto snapshot.
|
|
25
16
|
*
|
|
26
17
|
* Set `fullPage: true` to snapshot the whole page instead of the subject.
|
|
27
18
|
*/
|
|
28
|
-
declare function defineAutoSnapshotParam<M extends ComparisonMethod>(snapshot: ToMatchImageSnapshotOptions<M> & ImageSnapshotSubjectOptions & PageImageSnapshotOptions): {
|
|
29
|
-
snapshot: ImageSnapshotTimeoutOptions & ImageSnapshotKeyOptions & (M extends "ssim" ? SsimComparisonOptions<M> : PixelComparisonOptions<M>) & FailureThresholdOptions &
|
|
19
|
+
export declare function defineAutoSnapshotParam<M extends ComparisonMethod>(snapshot: ToMatchImageSnapshotOptions<M> & ImageSnapshotSubjectOptions & PageImageSnapshotOptions): {
|
|
20
|
+
snapshot: ImageSnapshotTimeoutOptions & ImageSnapshotKeyOptions & (M extends "ssim" ? SsimComparisonOptions<M> : PixelComparisonOptions<M>) & FailureThresholdOptions & import("vitest-plugin-vis").ReviewImageOptions & import("vitest-plugin-vis").AnimationsOptions & import("vitest-plugin-vis").MaskOptions & {
|
|
30
21
|
expectToFail?: boolean | undefined;
|
|
31
22
|
createMissingBaseline?: boolean | undefined;
|
|
32
23
|
} & ImageSnapshotSubjectOptions & PageImageSnapshotOptions;
|
|
33
24
|
};
|
|
34
|
-
|
|
35
|
-
//#region src/client/storybook/tags.d.ts
|
|
36
|
-
declare function isSnapshotEnabled(tags: string[]): boolean;
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/index.d.ts
|
|
25
|
+
export declare function isSnapshotEnabled(tags: string[]): boolean;
|
|
39
26
|
declare const _default: (options?: SetupVisOptions<{
|
|
40
27
|
tags: string[];
|
|
41
|
-
}>) =>
|
|
42
|
-
|
|
43
|
-
export { type ComparisonMethod, type FailureThresholdOptions, type ImageSnapshotCompareOptions, type ImageSnapshotKeyOptions, type ImageSnapshotSubjectOptions, type ImageSnapshotTimeoutOptions, type PageImageSnapshotOptions, type PixelComparisonOptions, type SsimComparisonOptions, type ToMatchImageSnapshotOptions, cdp, _default as default, defineAutoSnapshotParam, hasImageSnapshot, isSnapshotEnabled, page, visAnnotations };
|
|
28
|
+
}>) => import("storybook/internal/csf").PreviewAddon<import("storybook/internal/csf").AddonTypes>;
|
|
29
|
+
export { type ComparisonMethod, type FailureThresholdOptions, type ImageSnapshotCompareOptions, type ImageSnapshotKeyOptions, type ImageSnapshotSubjectOptions, type ImageSnapshotTimeoutOptions, type PageImageSnapshotOptions, type PixelComparisonOptions, type SsimComparisonOptions, type ToMatchImageSnapshotOptions, _default as default, visAnnotations };
|
|
44
30
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/client/vitest_proxy.ts","../src/client/has_image_snapshot.ts","../src/client/storybook/param.ts","../src/client/storybook/tags.ts","../src/index.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["ImageSnapshotKeyOptions"],"sources":["../src/client/vitest_proxy.ts","../src/client/has_image_snapshot.ts","../src/client/storybook/param.ts","../src/client/storybook/tags.ts","../src/index.ts"],"mappings":";;;;;;qBAyGa,MAAI;qBACJ,UAAQ;qBACR,WAhCI;;;;wBCpED,iBAAiB,UAAUA,gDAAmC;;;;;;wBCyB9D,wBAAwB,UAAU,kBACjD,UAAU,4BAA4B,KAAK,8BAA8B;;;;;;wBCjC1D,kBAAkB;cCuBlB,WAAA,UAAS;EAAkB;wCAAmC,8CAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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-
|
|
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-CJD3p9Uh.mjs";
|
|
2
2
|
import { definePreviewAddon } from "storybook/internal/csf";
|
|
3
3
|
import { expect } from "storybook/test";
|
|
4
4
|
import { autoSnapshotMatcher, hasImageSnapshotAction, setAutoSnapshotOptions, toSuiteDefaults, toTaskId } from "vitest-plugin-vis/client-api";
|
|
5
5
|
|
|
6
6
|
export * from "vitest-plugin-vis"
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// src/client/ctx.ts
|
|
9
9
|
const ctx = {
|
|
10
10
|
getCurrentTest,
|
|
11
11
|
__test__reset() {
|
|
@@ -13,8 +13,7 @@ const ctx = {
|
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
//#region src/client/has_image_snapshot.ts
|
|
16
|
+
// src/client/has_image_snapshot.ts
|
|
18
17
|
/**
|
|
19
18
|
* Check if the snapshot image exists.
|
|
20
19
|
*/
|
|
@@ -24,8 +23,7 @@ function hasImageSnapshot(options) {
|
|
|
24
23
|
return hasImageSnapshotAction(commands, toTaskId(test), options);
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
//#region src/client/storybook/param.ts
|
|
26
|
+
// src/client/storybook/param.ts
|
|
29
27
|
/**
|
|
30
28
|
* Define snapshot parameter for auto snapshot.
|
|
31
29
|
*
|
|
@@ -35,8 +33,7 @@ function defineAutoSnapshotParam(snapshot) {
|
|
|
35
33
|
return { snapshot };
|
|
36
34
|
}
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
//#region src/index.ts
|
|
36
|
+
// src/index.ts
|
|
40
37
|
expect.extend({ toMatchImageSnapshot });
|
|
41
38
|
var src_default = (options = { auto: false }) => {
|
|
42
39
|
let matcher;
|
|
@@ -61,6 +58,5 @@ var src_default = (options = { auto: false }) => {
|
|
|
61
58
|
});
|
|
62
59
|
};
|
|
63
60
|
|
|
64
|
-
|
|
65
|
-
export { cdp, src_default as default, defineAutoSnapshotParam, hasImageSnapshot, isSnapshotEnabled, page, visAnnotations };
|
|
61
|
+
export { cdp, commands, src_default as default, defineAutoSnapshotParam, hasImageSnapshot, isSnapshotEnabled, page, visAnnotations };
|
|
66
62
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -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\tPageImageSnapshotOptions,\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\tPageImageSnapshotOptions,\n\tPixelComparisonOptions,\n\tSsimComparisonOptions,\n\tToMatchImageSnapshotOptions,\n}\n\n/**\n * Define snapshot parameter for auto snapshot.\n *\n * Set `fullPage: true` to snapshot the whole page instead of the subject.\n */\nexport function defineAutoSnapshotParam<M extends ComparisonMethod>(\n\tsnapshot: ToMatchImageSnapshotOptions<M> & ImageSnapshotSubjectOptions & PageImageSnapshotOptions,\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;
|
|
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\tPageImageSnapshotOptions,\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\tPageImageSnapshotOptions,\n\tPixelComparisonOptions,\n\tSsimComparisonOptions,\n\tToMatchImageSnapshotOptions,\n}\n\n/**\n * Define snapshot parameter for auto snapshot.\n *\n * Set `fullPage: true` to snapshot the whole page instead of the subject.\n */\nexport function defineAutoSnapshotParam<M extends ComparisonMethod>(\n\tsnapshot: ToMatchImageSnapshotOptions<M> & ImageSnapshotSubjectOptions & PageImageSnapshotOptions,\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, commands, 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;EACf,IAAI,iBAAiB;CACtB;AACD;;;;;;ACAA,SAAgB,iBAAiB,SAA+C;CAC/E,MAAM,OAAO,IAAI,eAAe;CAChC,IAAI,CAAC,MAAM,OAAO;CAElB,OAAO,uBAAuB,UAAU,SAAS,IAAI,GAAG,OAAO;AAChE;;;;;;;;ACoBA,SAAgB,wBACf,UACC;CACD,OAAO,EAAE,SAAS;AACnB;;;ACtBA,OAAO,OAAO,EAAE,qBAAqB,CAAC;AAStC,mBAAgB,UAA+C,EAAE,MAAM,MAAM,MAAM;CAClF,IAAI;CACJ,IAAI;CACJ,OAAO,mBAAmB;EACzB,MAAM,QAAQ,SAAS,OAAO,CAAC,UAAU,IAAI,CAAC;EAC9C,MAAM,YAAY;GACjB,IAAI,CAAC,gBAAgB,GAAG;GAGxB,MAAM,qBAAqB;GAC3B,UAAU,oBAAoB,UAAU,MAAM;GAC9C,MAAM,gBAAgB,gBAAgB,OAAO;GAC7C,IAAI,OAAO,SAAS,SAAS,YAC5B,YAAY,QAAQ,cACnB,EACC,MAAM,QAAQ,KACf,GACA,aACD;QACM,IAAI,OAAO,SAAS,SAAS,UACnC,YAAY,QAAQ,cAAc,QAAQ,MAAM,aAAa;QACvD,YAAY,QAAQ,cAAc,EAAE,MAAM,OAAO,CAAC,EAAE,GAAG,aAAa;GAE3E,MAAM,QAAQ,MAAM;GACpB,MAAM,uBAAuB,IAAI;EAClC;EACA,YAAY;GACX,IAAI,WACH,OAAO,UAAU;EAEnB;EACA,GAAG;CACJ,CAAC;AACF"}
|
package/dist/manager.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|