storybook-addon-vis 2.1.2 → 2.1.4
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/dist/chunk-HQDMSJMI.cjs.map +1 -1
- package/dist/chunk-UOITZV6D.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/manager.js +1 -1
- package/dist/manager.js.map +1 -1
- package/dist/preset.cjs.map +1 -1
- package/dist/vitest-plugin.js.map +1 -1
- package/dist/vitest-setup.cjs.map +1 -1
- package/dist/vitest-setup.js.map +1 -1
- package/package.json +31 -29
- package/src/manager.tsx +7 -2
- package/src/server/vis_options.ts +1 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client/page/to_match_image_snapshot.ts","../src/client/vitest_proxy.ts","../src/client/expect/to_match_image_snapshot.ts","../src/client/storybook/expect_extend.ts","../src/client/storybook/tags.ts"],"names":["matchPageImageSnapshotAction","toTaskId","toMatchImageSnapshot","success","matchImageSnapshotAction","expect"],"mappings":";;;;;;AAQO,SAAS,qBACf,
|
|
1
|
+
{"version":3,"sources":["../src/client/page/to_match_image_snapshot.ts","../src/client/vitest_proxy.ts","../src/client/expect/to_match_image_snapshot.ts","../src/client/storybook/expect_extend.ts","../src/client/storybook/tags.ts"],"names":["matchPageImageSnapshotAction","toTaskId","toMatchImageSnapshot","success","matchImageSnapshotAction","expect"],"mappings":";;;;;;AAQO,SAAS,qBACf,OAAA,EACC;AACD,EAAA,MAAM,OAAO,cAAA,EAAe;AAG5B,EAAA,IAAI,CAAC,IAAA,EAAM,OAAO,OAAA,CAAQ,OAAA,EAAQ;AAGlC,EAAA,OAAOA,sCAAA,CAA6B,QAAA,EAAUC,kBAAA,CAAS,IAAI,GAAG,OAAO,CAAA;AACtE;;;ACdA,IAAI,cAAA;AACJ,IAAI,WAAA;AAEJ,IAAK,WAAmB,kBAAA,EAAoB;AAC3C,EAAA,OAAO,yBAAyB,CAAA,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,SAAS,kBAAkB,IAAA,EAAgB;AACjD,EAAA,OAAO,KAAK,WAAA,CAAY,WAAW,CAAA,GAAI,IAAA,CAAK,YAAY,UAAU,CAAA;AACnE","file":"chunk-HQDMSJMI.cjs","sourcesContent":["import {\n\ttype ComparisonMethod,\n\ttype ToMatchPageImageSnapshotOptions,\n\tmatchPageImageSnapshotAction,\n\ttoTaskId,\n} from 'vitest-plugin-vis/client-api'\nimport { commands, getCurrentTest } from '../vitest_proxy.ts'\n\nexport function toMatchImageSnapshot<M extends ComparisonMethod = 'pixel'>(\n\toptions?: ToMatchPageImageSnapshotOptions<M> | undefined,\n) {\n\tconst test = getCurrentTest()\n\n\t/* v8 ignore start: stub as success when not in a test (e.g. in a story) */\n\tif (!test) return Promise.resolve()\n\t/* v8 ignore end */\n\n\treturn matchPageImageSnapshotAction(commands, toTaskId(test), options)\n}\n","import type { BrowserCommands, BrowserPage } from '@vitest/browser/context'\nimport type { SnapshotTestMeta } from 'vitest-plugin-vis/client-api'\nimport { toMatchImageSnapshot } from './page/to_match_image_snapshot.ts'\n\nlet browserContext: Awaited<typeof import('@vitest/browser/context')>\nlet vitestSuite: Awaited<typeof import('vitest/suite')>\n\nif ((globalThis as any).__vitest_browser__) {\n\timport('@vitest/browser/context').then((m) => {\n\t\tm.page.extend({ toMatchImageSnapshot })\n\t\tbrowserContext = m\n\t})\n\timport('vitest/suite').then((m) => {\n\t\tvitestSuite = m\n\t})\n}\n\nexport const page = new Proxy<BrowserPage>({} as any, {\n\tget(_target, prop) {\n\t\tconst r = (browserContext?.page as any)?.[prop]\n\t\tif (prop === 'toMatchImageSnapshot' && r === undefined) {\n\t\t\treturn () => {}\n\t\t}\n\t\treturn r\n\t},\n})\n\nexport const commands = new Proxy<BrowserCommands>({} as any, {\n\tget(_target, prop) {\n\t\treturn (browserContext?.commands as any)?.[prop]\n\t},\n})\n\nexport const getCurrentTest = () =>\n\tvitestSuite?.getCurrentTest() as (ReturnType<typeof vitestSuite.getCurrentTest> & SnapshotTestMeta) | undefined\n","import type { AsyncExpectationResult } from '@vitest/expect'\nimport {\n\ttype ComparisonMethod,\n\ttype ToMatchImageSnapshotOptions,\n\tmatchImageSnapshotAction,\n\tsuccess,\n\ttoTaskId,\n} from 'vitest-plugin-vis/client-api'\nimport { commands, getCurrentTest } from '../vitest_proxy.ts'\n\nexport function toMatchImageSnapshot<M extends ComparisonMethod>(\n\t/**\n\t * The element or locator to take the snapshot of,\n\t * or the base64 value of the image to compare against.\n\t */\n\tsubject: any,\n\toptions?: ToMatchImageSnapshotOptions<M> | undefined,\n): AsyncExpectationResult {\n\tconst test = getCurrentTest()\n\n\t/* v8 ignore start: stub as success when not in a test (e.g. in a story) */\n\tif (!test) return Promise.resolve(success)\n\t/* v8 ignore end */\n\n\treturn matchImageSnapshotAction(commands, toTaskId(test), subject, options).then(() => success)\n}\n","import { expect } from 'storybook/test'\nimport { toMatchImageSnapshot } from '../expect/to_match_image_snapshot.ts'\n\nexpect.extend({ toMatchImageSnapshot })\n","export function isSnapshotEnabled(tags: string[]) {\n\treturn tags.lastIndexOf('!snapshot') < tags.lastIndexOf('snapshot')\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client/page/to_match_image_snapshot.ts","../src/client/vitest_proxy.ts","../src/client/expect/to_match_image_snapshot.ts","../src/client/storybook/expect_extend.ts","../src/client/storybook/tags.ts"],"names":["toMatchImageSnapshot","toTaskId"],"mappings":";;;;AAQO,SAAS,qBACf,
|
|
1
|
+
{"version":3,"sources":["../src/client/page/to_match_image_snapshot.ts","../src/client/vitest_proxy.ts","../src/client/expect/to_match_image_snapshot.ts","../src/client/storybook/expect_extend.ts","../src/client/storybook/tags.ts"],"names":["toMatchImageSnapshot","toTaskId"],"mappings":";;;;AAQO,SAAS,qBACf,OAAA,EACC;AACD,EAAA,MAAM,OAAO,cAAA,EAAe;AAG5B,EAAA,IAAI,CAAC,IAAA,EAAM,OAAO,OAAA,CAAQ,OAAA,EAAQ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QAAA,EAAUC,QAAAA,CAAS,IAAI,CAAA,EAAG,SAAS,OAAO,CAAA,CAAE,IAAA,CAAK,MAAM,OAAO,CAAA;AAC/F;;;ACtBA,MAAA,CAAO,MAAA,CAAO,EAAE,oBAAA,EAAAD,qBAAAA,EAAsB,CAAA;;;ACH/B,SAAS,kBAAkB,IAAA,EAAgB;AACjD,EAAA,OAAO,KAAK,WAAA,CAAY,WAAW,CAAA,GAAI,IAAA,CAAK,YAAY,UAAU,CAAA;AACnE","file":"chunk-UOITZV6D.js","sourcesContent":["import {\n\ttype ComparisonMethod,\n\ttype ToMatchPageImageSnapshotOptions,\n\tmatchPageImageSnapshotAction,\n\ttoTaskId,\n} from 'vitest-plugin-vis/client-api'\nimport { commands, getCurrentTest } from '../vitest_proxy.ts'\n\nexport function toMatchImageSnapshot<M extends ComparisonMethod = 'pixel'>(\n\toptions?: ToMatchPageImageSnapshotOptions<M> | undefined,\n) {\n\tconst test = getCurrentTest()\n\n\t/* v8 ignore start: stub as success when not in a test (e.g. in a story) */\n\tif (!test) return Promise.resolve()\n\t/* v8 ignore end */\n\n\treturn matchPageImageSnapshotAction(commands, toTaskId(test), options)\n}\n","import type { BrowserCommands, BrowserPage } from '@vitest/browser/context'\nimport type { SnapshotTestMeta } from 'vitest-plugin-vis/client-api'\nimport { toMatchImageSnapshot } from './page/to_match_image_snapshot.ts'\n\nlet browserContext: Awaited<typeof import('@vitest/browser/context')>\nlet vitestSuite: Awaited<typeof import('vitest/suite')>\n\nif ((globalThis as any).__vitest_browser__) {\n\timport('@vitest/browser/context').then((m) => {\n\t\tm.page.extend({ toMatchImageSnapshot })\n\t\tbrowserContext = m\n\t})\n\timport('vitest/suite').then((m) => {\n\t\tvitestSuite = m\n\t})\n}\n\nexport const page = new Proxy<BrowserPage>({} as any, {\n\tget(_target, prop) {\n\t\tconst r = (browserContext?.page as any)?.[prop]\n\t\tif (prop === 'toMatchImageSnapshot' && r === undefined) {\n\t\t\treturn () => {}\n\t\t}\n\t\treturn r\n\t},\n})\n\nexport const commands = new Proxy<BrowserCommands>({} as any, {\n\tget(_target, prop) {\n\t\treturn (browserContext?.commands as any)?.[prop]\n\t},\n})\n\nexport const getCurrentTest = () =>\n\tvitestSuite?.getCurrentTest() as (ReturnType<typeof vitestSuite.getCurrentTest> & SnapshotTestMeta) | undefined\n","import type { AsyncExpectationResult } from '@vitest/expect'\nimport {\n\ttype ComparisonMethod,\n\ttype ToMatchImageSnapshotOptions,\n\tmatchImageSnapshotAction,\n\tsuccess,\n\ttoTaskId,\n} from 'vitest-plugin-vis/client-api'\nimport { commands, getCurrentTest } from '../vitest_proxy.ts'\n\nexport function toMatchImageSnapshot<M extends ComparisonMethod>(\n\t/**\n\t * The element or locator to take the snapshot of,\n\t * or the base64 value of the image to compare against.\n\t */\n\tsubject: any,\n\toptions?: ToMatchImageSnapshotOptions<M> | undefined,\n): AsyncExpectationResult {\n\tconst test = getCurrentTest()\n\n\t/* v8 ignore start: stub as success when not in a test (e.g. in a story) */\n\tif (!test) return Promise.resolve(success)\n\t/* v8 ignore end */\n\n\treturn matchImageSnapshotAction(commands, toTaskId(test), subject, options).then(() => success)\n}\n","import { expect } from 'storybook/test'\nimport { toMatchImageSnapshot } from '../expect/to_match_image_snapshot.ts'\n\nexpect.extend({ toMatchImageSnapshot })\n","export function isSnapshotEnabled(tags: string[]) {\n\treturn tags.lastIndexOf('!snapshot') < tags.lastIndexOf('snapshot')\n}\n"]}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client/ctx.ts","../src/client/has_image_snapshot.ts","../src/client/storybook/param.ts","../src/server/vis_options.ts"],"names":["getCurrentTest","hasImageSnapshotAction","commands","toTaskId"],"mappings":";;;;;;;AAEO,IAAM,GAAM
|
|
1
|
+
{"version":3,"sources":["../src/client/ctx.ts","../src/client/has_image_snapshot.ts","../src/client/storybook/param.ts","../src/server/vis_options.ts"],"names":["getCurrentTest","hasImageSnapshotAction","commands","toTaskId"],"mappings":";;;;;;;AAEO,IAAM,GAAA,GAAM;AAAA,kBAClBA,gCAAA;AAAA,EACA,aAAA,GAAgB;AACf,IAAA,GAAA,CAAI,cAAA,GAAiBA,gCAAA;AAAA,EACtB;AACD,CAAA;;;ACAO,SAAS,iBAAiB,OAAA,EAA+C;AAC/E,EAAA,MAAM,IAAA,GAAO,IAAI,cAAA,EAAe;AAChC,EAAA,IAAI,CAAC,MAAM,OAAO,KAAA;AAElB,EAAA,OAAOC,gCAAA,CAAuBC,0BAAA,EAAUC,kBAAA,CAAS,IAAI,GAAG,OAAO,CAAA;AAChE;;;ACgBO,SAAS,wBACf,QAAA,EACC;AACD,EAAA,OAAO,EAAE,QAAA,EAAS;AACnB;;;ACfO,SAAS,0BAA0B,OAAA,EAA8B;AACvE,EAAA,OAAO,OAAA;AACR","file":"index.cjs","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, toTaskId, type ImageSnapshotKeyOptions } 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","/**\n * Configuration options for visual testing suites in Storybook.\n *\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 */\nexport type StorybookVisOptions = {\n\tvisProjects: Array<{\n\t\tsnapshotRootDir: string | ((context: { ci: boolean; platform: string }) => string) | undefined\n\t\tsnapshotSubpath?: ((options: { subpath: string }) => string) | undefined\n\t}>\n}\n\n/**\n * Define options for Storybook Visual Testing addon.\n */\nexport function defineStorybookVisOptions(options: StorybookVisOptions) {\n\treturn options\n}\n"]}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client/ctx.ts","../src/client/has_image_snapshot.ts","../src/client/storybook/param.ts","../src/server/vis_options.ts"],"names":[],"mappings":";;;;;;AAEO,IAAM,GAAM
|
|
1
|
+
{"version":3,"sources":["../src/client/ctx.ts","../src/client/has_image_snapshot.ts","../src/client/storybook/param.ts","../src/server/vis_options.ts"],"names":[],"mappings":";;;;;;AAEO,IAAM,GAAA,GAAM;AAAA,EAClB,cAAA;AAAA,EACA,aAAA,GAAgB;AACf,IAAA,GAAA,CAAI,cAAA,GAAiB,cAAA;AAAA,EACtB;AACD,CAAA;;;ACAO,SAAS,iBAAiB,OAAA,EAA+C;AAC/E,EAAA,MAAM,IAAA,GAAO,IAAI,cAAA,EAAe;AAChC,EAAA,IAAI,CAAC,MAAM,OAAO,KAAA;AAElB,EAAA,OAAO,sBAAA,CAAuB,QAAA,EAAU,QAAA,CAAS,IAAI,GAAG,OAAO,CAAA;AAChE;;;ACgBO,SAAS,wBACf,QAAA,EACC;AACD,EAAA,OAAO,EAAE,QAAA,EAAS;AACnB;;;ACfO,SAAS,0BAA0B,OAAA,EAA8B;AACvE,EAAA,OAAO,OAAA;AACR","file":"index.js","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, toTaskId, type ImageSnapshotKeyOptions } 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","/**\n * Configuration options for visual testing suites in Storybook.\n *\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 */\nexport type StorybookVisOptions = {\n\tvisProjects: Array<{\n\t\tsnapshotRootDir: string | ((context: { ci: boolean; platform: string }) => string) | undefined\n\t\tsnapshotSubpath?: ((options: { subpath: string }) => string) | undefined\n\t}>\n}\n\n/**\n * Define options for Storybook Visual Testing addon.\n */\nexport function defineStorybookVisOptions(options: StorybookVisOptions) {\n\treturn options\n}\n"]}
|
package/dist/manager.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {memo,useState,useEffect}from'react';import {addons,types}from'storybook/internal/manager-api';import {RefreshIcon}from'@storybook/icons';import {AddonPanel,ScrollArea,IconButton,Placeholder}from'storybook/internal/components';import {styled}from'storybook/internal/theming';import {SNAPSHOT_ROOT_DIR}from'vitest-plugin-vis/client-api';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var E=memo(function({active:s,snapshotResults:r=[],onRefresh:S}){let n=r.reduce((a,e)=>{let R=`(${e.snapshotRootDir.slice(SNAPSHOT_ROOT_DIR.length+1)}) ${e.fileName}`;return a[R]=[...a[R]??[],e],a},{});return jsx(AddonPanel,{active:s,children:r.length>0?jsx(ScrollArea,{vertical:true,children:Object.entries(n).map(([a,e])=>jsx("div",{children:e.some(i=>i.type==="diff")?jsxs(Fragment,{children:[jsx(g,{failed:true,children:a}),e.map(i=>jsx("img",{src:`data:image/png;base64,${i.base64}`,alt:i.fileName},i.filePath))]}):jsxs(Fragment,{children:[jsxs(g,{children:[jsx("span",{children:a}),jsx(IconButton,{onClick:()=>S(),children:jsx(RefreshIcon,{})})]}),jsx("img",{src:`data:image/png;base64,${e[0].base64}`,alt:e[0].fileName},e[0].filePath)]})},a))}):jsx(Placeholder,{children:"There is no snapshots for this story"})})}),g=styled.div(({theme:t,failed:s})=>({display:"flex",alignItems:"center",gap:"0.5rem",paddingBlock:"0.5rem",paddingInline:"0.2rem",backgroundColor:s?t.background.negative:t.background.positive,color:t.barTextColor}));var p="storybook-addon-vis",h=`${p}/vis_panel`;var O="IMAGE_SNAPSHOT_RESULTS_REQUEST",d="IMAGE_SNAPSHOT_RESULTS_RESPONSE";function l({name:t,importPath:s}){return {type:O,name:t,importPath:s}}addons.register(p,t=>{globalThis.CONFIG_TYPE==="DEVELOPMENT"&&addons.add(h,{type:types.PANEL,title:"Vis",match:({tabId:s,viewMode:r})=>!s&&r==="story",render({active:s}){
|
|
1
|
+
import {memo,useState,useEffect}from'react';import {addons,types}from'storybook/internal/manager-api';import {RefreshIcon}from'@storybook/icons';import {AddonPanel,ScrollArea,IconButton,Placeholder}from'storybook/internal/components';import {styled}from'storybook/internal/theming';import {SNAPSHOT_ROOT_DIR}from'vitest-plugin-vis/client-api';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var E=memo(function({active:s,snapshotResults:r=[],onRefresh:S}){let n=r.reduce((a,e)=>{let R=`(${e.snapshotRootDir.slice(SNAPSHOT_ROOT_DIR.length+1)}) ${e.fileName}`;return a[R]=[...a[R]??[],e],a},{});return jsx(AddonPanel,{active:s,children:r.length>0?jsx(ScrollArea,{vertical:true,children:Object.entries(n).map(([a,e])=>jsx("div",{children:e.some(i=>i.type==="diff")?jsxs(Fragment,{children:[jsx(g,{failed:true,children:a}),e.map(i=>jsx("img",{src:`data:image/png;base64,${i.base64}`,alt:i.fileName},i.filePath))]}):jsxs(Fragment,{children:[jsxs(g,{children:[jsx("span",{children:a}),jsx(IconButton,{onClick:()=>S(),children:jsx(RefreshIcon,{})})]}),jsx("img",{src:`data:image/png;base64,${e[0].base64}`,alt:e[0].fileName},e[0].filePath)]})},a))}):jsx(Placeholder,{children:"There is no snapshots for this story"})})}),g=styled.div(({theme:t,failed:s})=>({display:"flex",alignItems:"center",gap:"0.5rem",paddingBlock:"0.5rem",paddingInline:"0.2rem",backgroundColor:s?t.background.negative:t.background.positive,color:t.barTextColor}));var p="storybook-addon-vis",h=`${p}/vis_panel`;var O="IMAGE_SNAPSHOT_RESULTS_REQUEST",d="IMAGE_SNAPSHOT_RESULTS_RESPONSE";function l({name:t,importPath:s}){return {type:O,name:t,importPath:s}}addons.register(p,t=>{globalThis.CONFIG_TYPE==="DEVELOPMENT"&&addons.add(h,{type:types.PANEL,title:"Vis",match:({tabId:s,viewMode:r})=>!s&&r==="story",render({active:s}){let[r,S]=useState([]),n=t.getCurrentStoryData();return useEffect(()=>{let a=[t.on(p,e=>{e.name===n.name&&e.importPath===n.importPath&&e.type===d&&S(e.results);})];return t.emit(p,l(n)),()=>a.forEach(e=>{e();})},[n]),s?jsx(E,{active:s,snapshotResults:r,onRefresh:()=>{t.emit(p,l(n));}}):null}});});//# sourceMappingURL=manager.js.map
|
|
2
2
|
//# sourceMappingURL=manager.js.map
|
package/dist/manager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/vis_panel.tsx","../src/shared/contants.ts","../src/shared/events.ts","../src/manager.tsx"],"names":["VisPanel","memo","active","snapshotResults","onRefresh","groupedResults","acc","result","key","SNAPSHOT_ROOT_DIR","jsx","AddonPanel","ScrollArea","results","jsxs","Fragment","SnapshotRow","IconButton","RefreshIcon","Placeholder","styled","theme","failed","NAME","VIS_PANEL_ID","IMAGE_SNAPSHOT_RESULTS_REQUEST","IMAGE_SNAPSHOT_RESULTS_RESPONSE","requestImageSnapshotResults","name","importPath","addons","api","types","tabId","viewMode","setSnapshotResults","useState","storyData","useEffect","disposes","event","dispose"],"mappings":"yYAaO,IAAMA,CAAAA,CAAWC,
|
|
1
|
+
{"version":3,"sources":["../src/components/vis_panel.tsx","../src/shared/contants.ts","../src/shared/events.ts","../src/manager.tsx"],"names":["VisPanel","memo","active","snapshotResults","onRefresh","groupedResults","acc","result","key","SNAPSHOT_ROOT_DIR","jsx","AddonPanel","ScrollArea","results","jsxs","Fragment","SnapshotRow","IconButton","RefreshIcon","Placeholder","styled","theme","failed","NAME","VIS_PANEL_ID","IMAGE_SNAPSHOT_RESULTS_REQUEST","IMAGE_SNAPSHOT_RESULTS_RESPONSE","requestImageSnapshotResults","name","importPath","addons","api","types","tabId","viewMode","setSnapshotResults","useState","storyData","useEffect","disposes","event","dispose"],"mappings":"yYAaO,IAAMA,CAAAA,CAAWC,IAAAA,CAAK,SAAkB,CAAE,MAAA,CAAAC,EAAQ,eAAA,CAAAC,CAAAA,CAAkB,EAAC,CAAG,SAAA,CAAAC,CAAU,CAAA,CAAe,CACvG,IAAMC,CAAAA,CAAiBF,CAAAA,CAAgB,MAAA,CACtC,CAACG,CAAAA,CAAKC,CAAAA,GAAW,CAEhB,IAAMC,CAAAA,CAAM,IADMD,CAAAA,CAAO,eAAA,CAAgB,KAAA,CAAME,iBAAAA,CAAkB,MAAA,CAAS,CAAC,CAClD,CAAA,EAAA,EAAKF,CAAAA,CAAO,QAAQ,CAAA,CAAA,CAC7C,OAAAD,EAAIE,CAAG,CAAA,CAAI,CAAC,GAAIF,CAAAA,CAAIE,CAAG,GAAK,EAAC,CAAID,CAAM,CAAA,CAChCD,CACR,EACA,EACD,CAAA,CACA,OACCI,GAAAA,CAACC,UAAAA,CAAA,CAAW,MAAA,CAAQT,CAAAA,CAClB,SAAAC,CAAAA,CAAgB,MAAA,CAAS,EACzBO,GAAAA,CAACE,UAAAA,CAAA,CAAW,QAAA,CAAQ,IAAA,CAClB,QAAA,CAAA,MAAA,CAAO,QAAQP,CAAc,CAAA,CAAE,IAAI,CAAC,CAACG,EAAKK,CAAO,CAAA,GACjDH,GAAAA,CAAC,KAAA,CAAA,CACC,QAAA,CAAAG,CAAAA,CAAQ,KAAMN,CAAAA,EAAWA,CAAAA,CAAO,OAAS,MAAM,CAAA,CAC/CO,KAAAC,QAAAA,CAAA,CACC,QAAA,CAAA,CAAAL,GAAAA,CAACM,CAAAA,CAAA,CAAY,OAAM,IAAA,CAAE,QAAA,CAAAR,EAAI,CAAA,CACxBK,CAAA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AC,CACH,CAAA,CAAG,CAACJ,CAAS,CAAC,EAETnC,CAAAA,CAGJQ,GAAAA,CAACV,EAAA,CACA,MAAA,CAAQE,EACR,eAAA,CAAiBC,CAAAA,CACjB,SAAA,CAAW,IAAM,CAChB4B,CAAAA,CAAI,KAAKR,CAAAA,CAAMI,CAAAA,CAA4BU,CAAS,CAAC,EACtD,CAAA,CACD,EATmB,IAWrB,CACD,CAAC,EAEH,CAAC,CAAA","file":"manager.js","sourcesContent":["import { RefreshIcon } from '@storybook/icons'\nimport { memo } from 'react'\nimport { AddonPanel, IconButton, Placeholder, ScrollArea } from 'storybook/internal/components'\nimport { styled } from 'storybook/internal/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\tsnapshotResults: ImageSnapshotResults[]\n\tonRefresh: () => void\n}\n\nexport const VisPanel = memo(function VisPanel({ active, snapshotResults = [], onRefresh }: PanelProps) {\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<IconButton onClick={() => onRefresh()}>\n\t\t\t\t\t\t\t\t\t\t\t<RefreshIcon />\n\t\t\t\t\t\t\t\t\t\t</IconButton>\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 }>(({ theme, failed }) => ({\n\tdisplay: 'flex',\n\talignItems: 'center',\n\tgap: '0.5rem',\n\tpaddingBlock: '0.5rem',\n\tpaddingInline: '0.2rem',\n\tbackgroundColor: failed ? theme.background.negative : theme.background.positive,\n\tcolor: theme.barTextColor,\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 { useEffect, useState } from 'react'\nimport { addons, types } from 'storybook/internal/manager-api'\nimport { VisPanel } from './components/vis_panel.tsx'\nimport { NAME, VIS_PANEL_ID } from './shared/contants.ts'\nimport {\n\tIMAGE_SNAPSHOT_RESULTS_RESPONSE,\n\trequestImageSnapshotResults,\n\ttype ImageSnapshotResults,\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\tconst [snapshotResults, setSnapshotResults] = useState<ImageSnapshotResults[]>([])\n\n\t\t\t\tconst storyData = api.getCurrentStoryData()\n\n\t\t\t\tuseEffect(() => {\n\t\t\t\t\tconst disposes = [\n\t\t\t\t\t\tapi.on(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\n\t\t\t\t\t\t\tif (event.type === IMAGE_SNAPSHOT_RESULTS_RESPONSE) {\n\t\t\t\t\t\t\t\tsetSnapshotResults(event.results)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t// api.on('UNIVERSAL_STORE:storybook/test', (event) => {\n\t\t\t\t\t\t// \tconsole.log('storybook/test', event)\n\t\t\t\t\t\t// }),\n\t\t\t\t\t]\n\t\t\t\t\tapi.emit(NAME, requestImageSnapshotResults(storyData))\n\t\t\t\t\treturn () =>\n\t\t\t\t\t\tdisposes.forEach((dispose) => {\n\t\t\t\t\t\t\tdispose()\n\t\t\t\t\t\t})\n\t\t\t\t}, [storyData])\n\n\t\t\t\tif (!active) return null\n\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\tsnapshotResults={snapshotResults}\n\t\t\t\t\t\tonRefresh={() => {\n\t\t\t\t\t\t\tapi.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"]}
|
package/dist/preset.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server/create_storybook_vis_server.ts","../src/shared/contants.ts","../src/shared/events.ts","../src/preset.ts"],"names":["createStorybookVisServer","options","visSuites","name","importPath","suite","snapshotRootDir","memoize","ci","platform","getSnapshotRootDir","SNAPSHOT_ROOT_DIR","snapshotSubpath","subpath","trimCommonFolder","taskId","taskGlob","baselineGlob","resolve","BASELINE_DIR","diffGlob","DIFF_DIR","taskIdRegex","baselineFiles","globSync","filePath","diffFiles","mapFileToResult","type","basename","readFileSync","NAME","IMAGE_SNAPSHOT_RESULTS_REQUEST","IMAGE_SNAPSHOT_RESULTS_RESPONSE","experimental_serverChannel","channel","server","event","results"],"mappings":"sWAeO,SAASA,CAAAA,CAAyBC,CAA8B,
|
|
1
|
+
{"version":3,"sources":["../src/server/create_storybook_vis_server.ts","../src/shared/contants.ts","../src/shared/events.ts","../src/preset.ts"],"names":["createStorybookVisServer","options","visSuites","name","importPath","suite","snapshotRootDir","memoize","ci","platform","getSnapshotRootDir","SNAPSHOT_ROOT_DIR","snapshotSubpath","subpath","trimCommonFolder","taskId","taskGlob","baselineGlob","resolve","BASELINE_DIR","diffGlob","DIFF_DIR","taskIdRegex","baselineFiles","globSync","filePath","diffFiles","mapFileToResult","type","basename","readFileSync","NAME","IMAGE_SNAPSHOT_RESULTS_REQUEST","IMAGE_SNAPSHOT_RESULTS_RESPONSE","experimental_serverChannel","channel","server","event","results"],"mappings":"sWAeO,SAASA,CAAAA,CAAyBC,CAAAA,CAA8B,CACtE,IAAMC,CAAAA,CAAYD,CAAAA,CAAQ,WAAA,EAAe,CAAC,EAAE,CAAA,CAC5C,OAAO,CACN,QAAAA,CAAAA,CACA,MAAM,uBAAA,CAAwBE,CAAAA,CAAcC,EAAoB,CAC/D,OAAOF,CAAAA,CACL,GAAA,CAAKG,GAAU,CACf,IAAMC,CAAAA,CACL,OAAOD,EAAM,eAAA,EAAoB,QAAA,CAC9BA,CAAAA,CAAM,eAAA,CACN,OAAOA,CAAAA,CAAM,eAAA,EAAoB,UAAA,CAChCE,kBAAAA,CAAQF,EAAM,eAAe,CAAA,CAAE,CAC/B,EAAA,CAAAG,kBAAAA,CACA,QAAA,CAAAC,gBACD,CAAC,EACAF,kBAAAA,CAAQG,8BAAkB,CAAA,CAAEC,6BAAiB,EAQ5CC,CAAAA,CAAAA,CALL,OAAOP,CAAAA,CAAM,eAAA,EAAoB,WAC9BE,kBAAAA,CAAQF,CAAAA,CAAM,eAAe,CAAA,CAC7BE,mBAAQ,CAAC,CAAE,OAAA,CAAAM,CAAQ,IACnBC,4BAAAA,CAAiBD,CAAAA,CAAQ,UAAA,CAAW,IAAI,EAAIA,CAAAA,CAAQ,KAAA,CAAM,CAAC,CAAA,CAAIA,CAAO,CACvE,CAAA,EACuC,CAAE,OAAA,CAAST,CAAW,CAAC,CAAA,CACjE,OAAO,CACN,gBAAAE,CAAAA,CACA,eAAA,CAAAM,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A,CAAaL,CAAAA,CAAU,QAAQ,CACxC,CACD,CCtEO,IAAMM,CAAAA,CAAO,qBAAA,CCEb,IAAMC,EAAiC,gCAAA,CACjCC,CAAAA,CAAkC,iCAAA,CCGxC,IAAMC,EAA6B,MAAOC,CAAAA,CAAkBlC,CAAAA,GAAiC,CACnG,IAAMmC,CAAAA,CAASpC,CAAAA,CAAyBC,CAAO,CAAA,CAE/C,OAAAkC,CAAAA,CAAQ,EAAA,CAAGJ,CAAAA,CAAM,MAAOM,GAAoB,CAC3C,GAAIA,CAAAA,CAAM,IAAA,GAASL,EAAgC,CAClD,IAAMM,CAAAA,CAAU,MAAMF,EAAO,uBAAA,CAAwBC,CAAAA,CAAM,IAAA,CAAMA,CAAAA,CAAM,UAAU,CAAA,CACjFF,CAAAA,CAAQ,IAAA,CAAKJ,CAAAA,CAAM,CAClB,IAAA,CAAME,CAAAA,CACN,IAAA,CAAMI,CAAAA,CAAM,KACZ,UAAA,CAAYA,CAAAA,CAAM,UAAA,CAClB,OAAA,CAAAC,CACD,CAAC,EACF,CACD,CAAC,EAEMH,CACR","file":"preset.cjs","sourcesContent":["import { globSync } from 'glob'\nimport ci from 'is-ci'\nimport memoize from 'memoize'\nimport { readFileSync } from 'node:fs'\nimport { platform } from 'node:process'\nimport { basename, resolve } from 'pathe'\nimport {\n\tBASELINE_DIR,\n\tDIFF_DIR,\n\tgetSnapshotRootDir,\n\tSNAPSHOT_ROOT_DIR,\n\ttrimCommonFolder,\n} from 'vitest-plugin-vis/server-utils'\nimport type { StorybookVisOptions } from './vis_options.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 snapshotSubpath = snapshotSubpathFn({ subpath: importPath })\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 baselineFiles = globSync(baselineGlob).filter((filePath) => taskIdRegex.test(filePath))\n\t\t\t\t\tconst diffFiles = globSync(diffGlob).filter((filePath) => taskIdRegex.test(filePath))\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 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 type { Channel } from 'storybook/internal/channels'\nimport { createStorybookVisServer } from './server/create_storybook_vis_server.ts'\nimport type { StorybookVisOptions } from './server/vis_options.ts'\nimport { NAME } from './shared/contants.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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/shared/contants.ts","../src/vitest-plugin/storybook_vis.ts"],"names":[],"mappings":";;;;;;AAAO,IAAM,
|
|
1
|
+
{"version":3,"sources":["../src/shared/contants.ts","../src/vitest-plugin/storybook_vis.ts"],"names":[],"mappings":";;;;;;AAAO,IAAM,IAAA,GAAO,qBAAA;;;ACOb,SAAS,aAAyC,OAAA,EAA0D;AAClH,EAAA,OAAO;AAAA,IACN,GAAG,GAAA,CAAI;AAAA,MACN,GAAG,OAAA;AAAA,MACH,MAAA,EAAQ;AAAA,KACR,CAAA;AAAA,IACD,IAAA,EAAM;AAAA,GACP;AACD","file":"vitest-plugin.js","sourcesContent":["export const NAME = 'storybook-addon-vis'\nexport const VIS_PANEL_ID = `${NAME}/vis_panel`\n","/**\n * Return type is `any` to support different Vitest and Vite versions.\n */\nimport type { Omit } from 'type-plus'\nimport { type ComparisonMethod, type VisOptions, vis } from 'vitest-plugin-vis/config'\nimport { NAME } from '../shared/contants.ts'\n\nexport function storybookVis<M extends ComparisonMethod>(options?: Omit<VisOptions<M>, 'preset'> | undefined): any {\n\treturn {\n\t\t...vis({\n\t\t\t...options,\n\t\t\tpreset: 'none',\n\t\t}),\n\t\tname: NAME,\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/preview/vis_annotation.ts","../src/vitest-setup.ts"],"names":["getCurrentTest","setAutoSnapshotOptions","isSnapshotEnabled","createVis","commands"],"mappings":";;;;;;AAKO,IAAM,
|
|
1
|
+
{"version":3,"sources":["../src/preview/vis_annotation.ts","../src/vitest-setup.ts"],"names":["getCurrentTest","setAutoSnapshotOptions","isSnapshotEnabled","createVis","commands"],"mappings":";;;;;;AAKO,IAAM,cAAA,GAAiB;AAAA,EAC7B,WAAW,GAAA,EAAmB;AAE7B,IAAA,MAAM,OAAOA,gCAAA,EAAe;AAC5B,IAAAC,sCAAA,CAAuB;AAAA,MACtB,MAAA,EAAQC,mCAAA,CAAkB,GAAA,CAAI,IAAI,CAAA;AAAA,MAClC,GAAG,IAAI,UAAA,EAAY,QAAA;AAAA,MACnB,MAAM,GAAA,CAAI,IAAA;AAAA,MACV,GAAG,MAAM,IAAA,CAAK;AAAA,KACd,CAAA;AAAA,EACF;AACD;;;ACRO,IAAM,GAAA,GAAMC,gBAA8BC,0BAAQ","file":"vitest-setup.cjs","sourcesContent":["import type { ProjectAnnotations, Renderer, StoryContext } from 'storybook/internal/types'\nimport { setAutoSnapshotOptions } from 'vitest-plugin-vis'\nimport { isSnapshotEnabled } from '../client/storybook/tags.ts'\nimport { getCurrentTest } from '../client/vitest_proxy.ts'\n\nexport const visAnnotations = {\n\tbeforeEach(ctx: StoryContext) {\n\t\t// console.debug('storbook-addon-vis.preview.beforeEach starts...')\n\t\tconst test = getCurrentTest()\n\t\tsetAutoSnapshotOptions({\n\t\t\tenable: isSnapshotEnabled(ctx.tags),\n\t\t\t...ctx.parameters?.snapshot,\n\t\t\ttags: ctx.tags,\n\t\t\t...test?.meta.vis,\n\t\t})\n\t},\n} satisfies ProjectAnnotations<Renderer>\n","// `storybook-addon-vis/vitest-setup` provides code needed in `vitest.setup.ts`.\nimport './client/storybook/expect_extend.ts'\nimport './shared/global_matcher_augment.ts'\n\nimport 'vitest-plugin-vis/setup' // for Vitest extends\nimport { createVis } from 'vitest-plugin-vis/setup'\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"]}
|
package/dist/vitest-setup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/preview/vis_annotation.ts","../src/vitest-setup.ts"],"names":[],"mappings":";;;;;AAKO,IAAM,
|
|
1
|
+
{"version":3,"sources":["../src/preview/vis_annotation.ts","../src/vitest-setup.ts"],"names":[],"mappings":";;;;;AAKO,IAAM,cAAA,GAAiB;AAAA,EAC7B,WAAW,GAAA,EAAmB;AAE7B,IAAA,MAAM,OAAO,cAAA,EAAe;AAC5B,IAAA,sBAAA,CAAuB;AAAA,MACtB,MAAA,EAAQ,iBAAA,CAAkB,GAAA,CAAI,IAAI,CAAA;AAAA,MAClC,GAAG,IAAI,UAAA,EAAY,QAAA;AAAA,MACnB,MAAM,GAAA,CAAI,IAAA;AAAA,MACV,GAAG,MAAM,IAAA,CAAK;AAAA,KACd,CAAA;AAAA,EACF;AACD;;;ACRO,IAAM,GAAA,GAAM,UAA8B,QAAQ","file":"vitest-setup.js","sourcesContent":["import type { ProjectAnnotations, Renderer, StoryContext } from 'storybook/internal/types'\nimport { setAutoSnapshotOptions } from 'vitest-plugin-vis'\nimport { isSnapshotEnabled } from '../client/storybook/tags.ts'\nimport { getCurrentTest } from '../client/vitest_proxy.ts'\n\nexport const visAnnotations = {\n\tbeforeEach(ctx: StoryContext) {\n\t\t// console.debug('storbook-addon-vis.preview.beforeEach starts...')\n\t\tconst test = getCurrentTest()\n\t\tsetAutoSnapshotOptions({\n\t\t\tenable: isSnapshotEnabled(ctx.tags),\n\t\t\t...ctx.parameters?.snapshot,\n\t\t\ttags: ctx.tags,\n\t\t\t...test?.meta.vis,\n\t\t})\n\t},\n} satisfies ProjectAnnotations<Renderer>\n","// `storybook-addon-vis/vitest-setup` provides code needed in `vitest.setup.ts`.\nimport './client/storybook/expect_extend.ts'\nimport './shared/global_matcher_augment.ts'\n\nimport 'vitest-plugin-vis/setup' // for Vitest extends\nimport { createVis } from 'vitest-plugin-vis/setup'\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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "storybook-addon-vis",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"description": "Storybook Vitest visual testing addon",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"image-snapshot",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"require": "./dist/vitest-setup.cjs"
|
|
46
46
|
},
|
|
47
47
|
"./vitest-plugin": {
|
|
48
|
-
"types": "./vitest-plugin.d.ts",
|
|
48
|
+
"types": "./dist/vitest-plugin.d.ts",
|
|
49
49
|
"import": "./dist/vitest-plugin.js"
|
|
50
50
|
},
|
|
51
51
|
"./package.json": "./package.json"
|
|
@@ -59,51 +59,51 @@
|
|
|
59
59
|
"!**/*.{spec,test,unit,accept,integrate,system,perf,stress,stories,study}.*"
|
|
60
60
|
],
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@storybook/icons": "^
|
|
63
|
-
"glob": "^11.0.
|
|
62
|
+
"@storybook/icons": "^2.0.0",
|
|
63
|
+
"glob": "^11.0.3",
|
|
64
64
|
"is-ci": "^4.1.0",
|
|
65
65
|
"memoize": "^10.1.0",
|
|
66
66
|
"pathe": "^2.0.3",
|
|
67
67
|
"type-plus": "8.0.0-beta.7",
|
|
68
|
-
"vitest-plugin-vis": "^3.
|
|
68
|
+
"vitest-plugin-vis": "^3.5.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@repobuddy/storybook": "^1.0.
|
|
72
|
-
"@storybook/
|
|
73
|
-
"@storybook/addon-
|
|
74
|
-
"@storybook/
|
|
71
|
+
"@repobuddy/storybook": "^1.0.1",
|
|
72
|
+
"@storybook-community/storybook-dark-mode": "^6.0.8",
|
|
73
|
+
"@storybook/addon-docs": "^10.0.6",
|
|
74
|
+
"@storybook/addon-vitest": "9.1.16",
|
|
75
|
+
"@storybook/react-vite": "^9.1.15",
|
|
75
76
|
"@tailwindcss/cli": "^4.1.7",
|
|
76
|
-
"@tailwindcss/vite": "^4.1.
|
|
77
|
+
"@tailwindcss/vite": "^4.1.14",
|
|
77
78
|
"@testing-library/react": "^16.0.1",
|
|
78
|
-
"@types/react": "^
|
|
79
|
-
"@types/react-dom": "^
|
|
80
|
-
"@vitejs/plugin-react": "^
|
|
81
|
-
"@vitest/browser": "^3.
|
|
82
|
-
"@vitest/coverage-istanbul": "^
|
|
83
|
-
"@vitest/expect": "^
|
|
79
|
+
"@types/react": "^19.2.2",
|
|
80
|
+
"@types/react-dom": "^19.2.1",
|
|
81
|
+
"@vitejs/plugin-react": "^5.0.0",
|
|
82
|
+
"@vitest/browser": "^3.2.4",
|
|
83
|
+
"@vitest/coverage-istanbul": "^4.0.3",
|
|
84
|
+
"@vitest/expect": "^4.0.6",
|
|
84
85
|
"boxen": "^8.0.1",
|
|
85
|
-
"cross-env": "^
|
|
86
|
+
"cross-env": "^10.0.0",
|
|
86
87
|
"dedent": "^1.5.1",
|
|
87
88
|
"npm-run-all2": "^8.0.0",
|
|
88
89
|
"playwright": "latest",
|
|
89
|
-
"react": "^
|
|
90
|
-
"react-dom": "^
|
|
91
|
-
"storybook": "^9.
|
|
92
|
-
"storybook-addon-tag-badges": "^
|
|
93
|
-
"
|
|
94
|
-
"tailwindcss": "^4.1.7",
|
|
90
|
+
"react": "^19.0.0",
|
|
91
|
+
"react-dom": "^19.0.0",
|
|
92
|
+
"storybook": "^9.1.10",
|
|
93
|
+
"storybook-addon-tag-badges": "^3.0.0",
|
|
94
|
+
"tailwindcss": "^4.1.14",
|
|
95
95
|
"tsup": "^8.3.5",
|
|
96
|
-
"typescript": "^5.
|
|
97
|
-
"vite": "^
|
|
98
|
-
"vitest": "^3.
|
|
99
|
-
"vitest-browser-react": "^0.
|
|
96
|
+
"typescript": "^5.9.3",
|
|
97
|
+
"vite": "^7.1.12",
|
|
98
|
+
"vitest": "^3.2.4",
|
|
99
|
+
"vitest-browser-react": "^1.0.0",
|
|
100
100
|
"webdriverio": "latest",
|
|
101
101
|
"zx": "^8.0.0"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
|
+
"@storybook/addon-vitest": "^9.1.10",
|
|
104
105
|
"@vitest/browser": "^2 || ^3",
|
|
105
|
-
"
|
|
106
|
-
"storybook": "^9.0.0",
|
|
106
|
+
"storybook": "^9.1.10",
|
|
107
107
|
"vitest": "^2 || ^3"
|
|
108
108
|
},
|
|
109
109
|
"publishConfig": {
|
|
@@ -144,6 +144,7 @@
|
|
|
144
144
|
"clean:vis:local": "rimraf __vis__/local",
|
|
145
145
|
"cov": "vitest run --coverage",
|
|
146
146
|
"coverage": "vitest run --coverage",
|
|
147
|
+
"coverage:u": "vitest run --coverage -u",
|
|
147
148
|
"dev": "run-p build:watch w",
|
|
148
149
|
"nuke": "rimraf node_modules",
|
|
149
150
|
"prerelease": "zx scripts/prepublish-checks.js",
|
|
@@ -155,6 +156,7 @@
|
|
|
155
156
|
"test:node": "vitest run -c vitest.config.node.ts",
|
|
156
157
|
"test:pw": "vitest run -c vitest.config.playwright.ts",
|
|
157
158
|
"test:type": "tsc --noEmit",
|
|
159
|
+
"test:u": "vitest run -u",
|
|
158
160
|
"v": "run-p build cov",
|
|
159
161
|
"w": "vitest",
|
|
160
162
|
"w:cov": "vitest --coverage",
|
package/src/manager.tsx
CHANGED
|
@@ -18,7 +18,6 @@ addons.register(NAME, (api) => {
|
|
|
18
18
|
title: 'Vis',
|
|
19
19
|
match: ({ tabId, viewMode }) => !tabId && viewMode === 'story',
|
|
20
20
|
render({ active }) {
|
|
21
|
-
if (!active) return null
|
|
22
21
|
const [snapshotResults, setSnapshotResults] = useState<ImageSnapshotResults[]>([])
|
|
23
22
|
|
|
24
23
|
const storyData = api.getCurrentStoryData()
|
|
@@ -38,8 +37,14 @@ addons.register(NAME, (api) => {
|
|
|
38
37
|
// }),
|
|
39
38
|
]
|
|
40
39
|
api.emit(NAME, requestImageSnapshotResults(storyData))
|
|
41
|
-
return () =>
|
|
40
|
+
return () =>
|
|
41
|
+
disposes.forEach((dispose) => {
|
|
42
|
+
dispose()
|
|
43
|
+
})
|
|
42
44
|
}, [storyData])
|
|
45
|
+
|
|
46
|
+
if (!active) return null
|
|
47
|
+
|
|
43
48
|
return (
|
|
44
49
|
<VisPanel
|
|
45
50
|
active={active}
|
|
@@ -7,13 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export type StorybookVisOptions = {
|
|
9
9
|
visProjects: Array<{
|
|
10
|
-
snapshotRootDir:
|
|
11
|
-
| string
|
|
12
|
-
| ((context: {
|
|
13
|
-
ci: boolean
|
|
14
|
-
platform: string
|
|
15
|
-
}) => string)
|
|
16
|
-
| undefined
|
|
10
|
+
snapshotRootDir: string | ((context: { ci: boolean; platform: string }) => string) | undefined
|
|
17
11
|
snapshotSubpath?: ((options: { subpath: string }) => string) | undefined
|
|
18
12
|
}>
|
|
19
13
|
}
|