storybook-addon-vis 0.15.0 → 0.15.2

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.
@@ -0,0 +1,24 @@
1
+ // src/client/vitest_proxy.ts
2
+ var browserContext;
3
+ var vitestSuite;
4
+ if (globalThis.__vitest_browser__) {
5
+ import('@vitest/browser/context').then((m) => {
6
+ browserContext = m;
7
+ });
8
+ import('vitest/suite').then((m) => {
9
+ vitestSuite = m;
10
+ });
11
+ }
12
+ var commands = new Proxy({}, {
13
+ get(_target, prop) {
14
+ return browserContext?.commands?.[prop] ?? /* v8 ignore start : used in storybook, not in vitest */
15
+ (() => {
16
+ throw new Error(`Command '${String(prop)}' not found`);
17
+ })();
18
+ }
19
+ });
20
+ var getCurrentTest = () => vitestSuite?.getCurrentTest();
21
+
22
+ export { commands, getCurrentTest };
23
+ //# sourceMappingURL=chunk-GZMKOHHR.js.map
24
+ //# sourceMappingURL=chunk-GZMKOHHR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client/vitest_proxy.ts"],"names":[],"mappings":";AAgBA,IAAI,cAAA;AACJ,IAAI,WAAA;AAEJ,IAAK,WAAmB,kBAAoB,EAAA;AAC3C,EAAA,OAAO,yBAAyB,CAAA,CAAE,IAAK,CAAA,CAAC,CAAM,KAAA;AAC7C,IAAiB,cAAA,GAAA,CAAA;AAAA,GACjB,CAAA;AACD,EAAA,OAAO,cAAc,CAAA,CAAE,IAAK,CAAA,CAAC,CAAM,KAAA;AAClC,IAAc,WAAA,GAAA,CAAA;AAAA,GACd,CAAA;AACF;AAEO,IAAM,QAAW,GAAA,IAAI,KAAuB,CAAA,EAAW,EAAA;AAAA,EAC7D,GAAA,CAAI,SAAS,IAAM,EAAA;AAClB,IACE,OAAA,cAAA,EAAgB,WAAmB,IAAI,CAAA;AAAA,IAAA,CAEvC,MAAM;AACN,MAAA,MAAM,IAAI,KAAM,CAAA,CAAA,SAAA,EAAY,MAAO,CAAA,IAAI,CAAC,CAAa,WAAA,CAAA,CAAA;AAAA,KACnD,GAAA;AAAA;AAIN,CAAC;AAEY,IAAA,cAAA,GAAiB,MAAM,WAAA,EAAa,cAAe","file":"chunk-GZMKOHHR.js","sourcesContent":["import type { BrowserCommands } from '@vitest/browser/context'\nimport type {\n\tHasImageSnapshotCommand,\n\tImageSnapshotNextIndexCommand,\n\tMatchImageSnapshotCommand,\n\tSetupVisSuiteCommand,\n} from 'vitest-plugin-vis/commands'\n\ndeclare module '@vitest/browser/context' {\n\tinterface BrowserCommands\n\t\textends MatchImageSnapshotCommand,\n\t\t\tHasImageSnapshotCommand,\n\t\t\tImageSnapshotNextIndexCommand,\n\t\t\tSetupVisSuiteCommand {}\n}\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\tbrowserContext = m\n\t})\n\timport('vitest/suite').then((m) => {\n\t\tvitestSuite = m\n\t})\n}\n\nexport const commands = new Proxy<BrowserCommands>({} as any, {\n\tget(_target, prop) {\n\t\treturn (\n\t\t\t(browserContext?.commands as any)?.[prop] ??\n\t\t\t/* v8 ignore start : used in storybook, not in vitest */\n\t\t\t(() => {\n\t\t\t\tthrow new Error(`Command '${String(prop)}' not found`)\n\t\t\t})()\n\t\t\t/* v8 ignore end */\n\t\t)\n\t},\n})\n\nexport const getCurrentTest = () => vitestSuite?.getCurrentTest()\n"]}
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
- import { commands } from './chunk-ZABC5XSZ.js';
1
+ import { getCurrentTest, commands } from './chunk-GZMKOHHR.js';
2
2
  export * from 'vitest-plugin-vis';
3
3
  import { toTaskId } from 'vitest-plugin-vis/client';
4
- import { getCurrentTest } from 'vitest/suite';
5
4
 
6
5
  // src/client/storybook/param.ts
7
6
  function defineAutoSnapshotParam(snapshot) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client/storybook/param.ts","../src/client/has_image_snapshot.ts"],"names":[],"mappings":";;;;;;AAKO,SAAS,wBAAwB,QAAuC,EAAA;AAC9E,EAAA,OAAO,EAAE,QAAS,EAAA;AACnB;ACAA,eAAsB,iBAAiB,OAA8C,EAAA;AACpF,EAAA,MAAM,OAAO,cAAe,EAAA;AAC5B,EAAA,IAAI,CAAC,IAAM,EAAA;AACV,IAAO,OAAA,KAAA;AAAA;AAGR,EAAM,MAAA,MAAA,GAAS,SAAS,IAAI,CAAA;AAC5B,EAAA,IAAI,SAAS,mBAAqB,EAAA;AACjC,IAAA,OAAO,QACL,CAAA,sBAAA,CAAuB,MAAM,CAAA,CAC7B,KAAK,CAAC,KAAA,KAAU,QAAS,CAAA,gBAAA,CAAiB,QAAQ,OAAQ,CAAA,mBAAA,CAAqB,MAAQ,EAAA,KAAK,CAAC,CAAC,CAAA;AAAA;AAGjG,EAAO,OAAA,QAAA,CAAS,iBAAiB,MAAM,CAAA;AACxC","file":"index.js","sourcesContent":["import type { ToMatchImageSnapshotOptions } from 'vitest-plugin-vis/client'\n\n/**\n * Define snapshot parameter for auto snapshot.\n */\nexport function defineAutoSnapshotParam(snapshot: ToMatchImageSnapshotOptions) {\n\treturn { snapshot }\n}\n","import { type ImageSnapshotIdOptions, toTaskId } from 'vitest-plugin-vis/client'\nimport { getCurrentTest } from 'vitest/suite'\nimport { commands } from './commands_proxy.ts'\n\n/**\n * Check if the snapshot image exists.\n */\nexport async function hasImageSnapshot(options?: ImageSnapshotIdOptions | undefined) {\n\tconst test = getCurrentTest()\n\tif (!test) {\n\t\treturn false\n\t}\n\n\tconst taskId = toTaskId(test)\n\tif (options?.customizeSnapshotId) {\n\t\treturn commands\n\t\t\t.imageSnapshotNextIndex(taskId)\n\t\t\t.then((index) => commands.hasImageSnapshot(taskId, options.customizeSnapshotId!(taskId, index)))\n\t}\n\n\treturn commands.hasImageSnapshot(taskId)\n}\n"]}
1
+ {"version":3,"sources":["../src/client/storybook/param.ts","../src/client/has_image_snapshot.ts"],"names":[],"mappings":";;;;;AAKO,SAAS,wBAAwB,QAAuC,EAAA;AAC9E,EAAA,OAAO,EAAE,QAAS,EAAA;AACnB;ACDA,eAAsB,iBAAiB,OAA8C,EAAA;AACpF,EAAA,MAAM,OAAO,cAAe,EAAA;AAC5B,EAAA,IAAI,CAAC,IAAM,EAAA;AACV,IAAO,OAAA,KAAA;AAAA;AAGR,EAAM,MAAA,MAAA,GAAS,SAAS,IAAI,CAAA;AAC5B,EAAA,IAAI,SAAS,mBAAqB,EAAA;AACjC,IAAA,OAAO,QACL,CAAA,sBAAA,CAAuB,MAAM,CAAA,CAC7B,KAAK,CAAC,KAAA,KAAU,QAAS,CAAA,gBAAA,CAAiB,QAAQ,OAAQ,CAAA,mBAAA,CAAqB,MAAQ,EAAA,KAAK,CAAC,CAAC,CAAA;AAAA;AAGjG,EAAO,OAAA,QAAA,CAAS,iBAAiB,MAAM,CAAA;AACxC","file":"index.js","sourcesContent":["import type { ToMatchImageSnapshotOptions } from 'vitest-plugin-vis/client'\n\n/**\n * Define snapshot parameter for auto snapshot.\n */\nexport function defineAutoSnapshotParam(snapshot: ToMatchImageSnapshotOptions) {\n\treturn { snapshot }\n}\n","import { type ImageSnapshotIdOptions, toTaskId } from 'vitest-plugin-vis/client'\nimport { commands, getCurrentTest } from './vitest_proxy.ts'\n\n/**\n * Check if the snapshot image exists.\n */\nexport async function hasImageSnapshot(options?: ImageSnapshotIdOptions | undefined) {\n\tconst test = getCurrentTest()\n\tif (!test) {\n\t\treturn false\n\t}\n\n\tconst taskId = toTaskId(test)\n\tif (options?.customizeSnapshotId) {\n\t\treturn commands\n\t\t\t.imageSnapshotNextIndex(taskId)\n\t\t\t.then((index) => commands.hasImageSnapshot(taskId, options.customizeSnapshotId!(taskId, index)))\n\t}\n\n\treturn commands.hasImageSnapshot(taskId)\n}\n"]}