@itcase/storybook-config 1.3.4 → 1.3.5

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,3 @@
1
+ import type { StartOptions } from 'msw/browser';
2
+ declare function getMswWorkerStartOptions(): StartOptions;
3
+ export { getMswWorkerStartOptions };
@@ -0,0 +1,14 @@
1
+ import { getStorybookPublicPath } from './getStorybookPublicPath.js';
2
+ function getMswWorkerStartOptions() {
3
+ const storybookPublicPath = getStorybookPublicPath();
4
+ return {
5
+ serviceWorker: {
6
+ url: `${storybookPublicPath}mockServiceWorker.js`,
7
+ options: {
8
+ scope: storybookPublicPath,
9
+ },
10
+ },
11
+ onUnhandledRequest: 'bypass',
12
+ };
13
+ }
14
+ export { getMswWorkerStartOptions };
@@ -0,0 +1,2 @@
1
+ declare function getStorybookPublicPath(): string;
2
+ export { getStorybookPublicPath };
@@ -0,0 +1,8 @@
1
+ function getStorybookPublicPath() {
2
+ const { pathname } = window.location;
3
+ if (pathname.endsWith('/iframe.html')) {
4
+ return pathname.slice(0, -'iframe.html'.length) || '/';
5
+ }
6
+ return pathname.endsWith('/') ? pathname : `${pathname}/`;
7
+ }
8
+ export { getStorybookPublicPath };
@@ -1,7 +1,9 @@
1
1
  import { getFigmaSourceLink } from './getFigmaSourceLink.js';
2
+ import { getMswWorkerStartOptions } from './getMswWorkerStartOptions.js';
3
+ import { getStorybookPublicPath } from './getStorybookPublicPath.js';
2
4
  import { getStoryInfoBlocks } from './getStoryInfoBlocks.js';
3
5
  import { handleMSWParameters } from './handleMSWParameters.js';
4
6
  import { hasFormParameters } from './hasFormParameters.js';
5
7
  import { isVitestEnvironment } from './isVitestEnvironment.js';
6
8
  import { mapErrorsToFinalForm } from './storybookServerErrorOnSubmit.js';
7
- export { getFigmaSourceLink, getStoryInfoBlocks, handleMSWParameters, hasFormParameters, isVitestEnvironment, mapErrorsToFinalForm, };
9
+ export { getFigmaSourceLink, getMswWorkerStartOptions, getStorybookPublicPath, getStoryInfoBlocks, handleMSWParameters, hasFormParameters, isVitestEnvironment, mapErrorsToFinalForm, };
@@ -1,10 +1,12 @@
1
1
  import { getFigmaSourceLink } from './getFigmaSourceLink.js';
2
+ import { getMswWorkerStartOptions } from './getMswWorkerStartOptions.js';
3
+ import { getStorybookPublicPath } from './getStorybookPublicPath.js';
2
4
  import { getStoryInfoBlocks } from './getStoryInfoBlocks.js';
3
5
  import { handleMSWParameters } from './handleMSWParameters.js';
4
6
  import { hasFormParameters } from './hasFormParameters.js';
5
7
  import { isVitestEnvironment } from './isVitestEnvironment.js';
6
8
  import { mapErrorsToFinalForm } from './storybookServerErrorOnSubmit.js';
7
9
  // import { storybookFormMockFactory } from './storybookFormMockFactory.js'
8
- export { getFigmaSourceLink, getStoryInfoBlocks, handleMSWParameters, hasFormParameters, isVitestEnvironment, mapErrorsToFinalForm,
10
+ export { getFigmaSourceLink, getMswWorkerStartOptions, getStorybookPublicPath, getStoryInfoBlocks, handleMSWParameters, hasFormParameters, isVitestEnvironment, mapErrorsToFinalForm,
9
11
  // storybookFormMockFactory,
10
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itcase/storybook-config",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "author": "ITCase",
5
5
  "description": "Storybook configuration package",
6
6
  "engines": {