msw-storybook-addon
Advanced tools
Comparing version 2.0.2 to 2.0.3--canary.edc76c3.0
@@ -12,3 +12,6 @@ // src/initialize.browser.ts | ||
"__webpack_hmr", | ||
"sb-vite" | ||
"sb-vite", | ||
"/virtual:", | ||
".stories.", | ||
".mdx" | ||
]; | ||
@@ -54,6 +57,17 @@ var shouldFilterUrl = (url) => { | ||
const worker = setupWorker(...initialHandlers); | ||
worker.start(augmentInitializeOptions(options)); | ||
worker.context.activationPromise = worker.start( | ||
augmentInitializeOptions(options) | ||
); | ||
api = worker; | ||
return worker; | ||
} | ||
async function waitForMswReady() { | ||
const msw = getWorker(); | ||
if (!!msw.context?.isMockingEnabled) { | ||
return; | ||
} | ||
if (msw.context.activationPromise) { | ||
return await msw.context.activationPromise; | ||
} | ||
} | ||
function getWorker() { | ||
@@ -169,6 +183,4 @@ if (api === void 0) { | ||
var mswLoader = async (context) => { | ||
await waitForMswReady(); | ||
applyRequestHandlers(context.parameters.msw); | ||
if (typeof window !== "undefined" && "navigator" in window && navigator.serviceWorker?.controller) { | ||
await navigator.serviceWorker.ready; | ||
} | ||
return {}; | ||
@@ -175,0 +187,0 @@ }; |
@@ -12,3 +12,6 @@ // src/initialize.react-native.ts | ||
"__webpack_hmr", | ||
"sb-vite" | ||
"sb-vite", | ||
"/virtual:", | ||
".stories.", | ||
".mdx" | ||
]; | ||
@@ -58,2 +61,5 @@ var shouldFilterUrl = (url) => { | ||
} | ||
async function waitForMswReady() { | ||
getWorker(); | ||
} | ||
function getWorker() { | ||
@@ -169,6 +175,4 @@ if (api === void 0) { | ||
var mswLoader = async (context) => { | ||
await waitForMswReady(); | ||
applyRequestHandlers(context.parameters.msw); | ||
if (typeof window !== "undefined" && "navigator" in window && navigator.serviceWorker?.controller) { | ||
await navigator.serviceWorker.ready; | ||
} | ||
return {}; | ||
@@ -175,0 +179,0 @@ }; |
{ | ||
"name": "msw-storybook-addon", | ||
"version": "2.0.2", | ||
"version": "2.0.3--canary.edc76c3.0", | ||
"description": "Mock API requests in Storybook with Mock Service Worker.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21885
595
1