msw-storybook-addon
Advanced tools
Comparing version 1.10.1--canary.134.6ef71b8.0 to 1.10.1--canary.134.966f069.0
@@ -20,5 +20,6 @@ "use strict"; | ||
// src/index.new.ts | ||
var index_new_exports = {}; | ||
__export(index_new_exports, { | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
getWorker: () => getWorker, | ||
initialize: () => initialize, | ||
@@ -28,3 +29,3 @@ mswDecorator: () => mswDecorator, | ||
}); | ||
module.exports = __toCommonJS(index_new_exports); | ||
module.exports = __toCommonJS(src_exports); | ||
@@ -40,24 +41,35 @@ // src/initialize.browser.ts | ||
} | ||
function getWorker() { | ||
if (api === void 0) { | ||
throw new Error( | ||
`[MSW] Failed to retrieve the worker: no active worker found. Did you forget to call "initialize"?` | ||
); | ||
} | ||
return api; | ||
} | ||
// src/applyRequestHandlers.ts | ||
function applyRequestHandlers(handlersListOrObject) { | ||
if (handlersListOrObject == null) { | ||
return; | ||
} | ||
if (Array.isArray(handlersListOrObject) && handlersListOrObject.length > 0) { | ||
api.use(...handlersListOrObject); | ||
return; | ||
} | ||
if ("handlers" in handlersListOrObject && handlersListOrObject.handlers) { | ||
const handlers = Object.values(handlersListOrObject.handlers).filter(Boolean).reduce( | ||
(handlers2, handlersList) => handlers2.concat(handlersList), | ||
[] | ||
); | ||
if (handlers.length > 0) { | ||
api.use(...handlers); | ||
} | ||
return; | ||
} | ||
} | ||
// src/decorator.ts | ||
var mswDecorator = (storyFn, context) => { | ||
const { | ||
parameters: { msw } | ||
} = context; | ||
if (api) { | ||
api.resetHandlers(); | ||
if (msw) { | ||
if (Array.isArray(msw) && msw.length > 0) { | ||
api.use(...msw); | ||
} else if ("handlers" in msw && msw.handlers) { | ||
const handlers = Object.values(msw.handlers).filter(Boolean).reduce( | ||
(handlers2, handlersList) => handlers2.concat(handlersList), | ||
[] | ||
); | ||
if (handlers.length > 0) { | ||
api.use(...handlers); | ||
} | ||
} | ||
} | ||
} | ||
applyRequestHandlers(context.parameters.msw); | ||
return storyFn(); | ||
@@ -68,21 +80,3 @@ }; | ||
var mswLoader = async (context) => { | ||
const { | ||
parameters: { msw } | ||
} = context; | ||
if (api) { | ||
api.resetHandlers(); | ||
if (msw) { | ||
if (Array.isArray(msw) && msw.length > 0) { | ||
api.use(...msw); | ||
} else if ("handlers" in msw && msw.handlers) { | ||
const handlers = Object.values(msw.handlers).filter(Boolean).reduce( | ||
(handlers2, handlersList) => handlers2.concat(handlersList), | ||
[] | ||
); | ||
if (handlers.length > 0) { | ||
api.use(...handlers); | ||
} | ||
} | ||
} | ||
} | ||
applyRequestHandlers(context.parameters.msw); | ||
if (typeof window !== "undefined" && "navigator" in window && navigator.serviceWorker.controller) { | ||
@@ -95,2 +89,3 @@ await navigator.serviceWorker.ready; | ||
0 && (module.exports = { | ||
getWorker, | ||
initialize, | ||
@@ -97,0 +92,0 @@ mswDecorator, |
@@ -20,5 +20,6 @@ "use strict"; | ||
// src/index.new.ts | ||
var index_new_exports = {}; | ||
__export(index_new_exports, { | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
getWorker: () => getWorker, | ||
initialize: () => initialize, | ||
@@ -28,3 +29,3 @@ mswDecorator: () => mswDecorator, | ||
}); | ||
module.exports = __toCommonJS(index_new_exports); | ||
module.exports = __toCommonJS(src_exports); | ||
@@ -40,24 +41,35 @@ // src/initialize.node.ts | ||
} | ||
function getWorker() { | ||
if (api === void 0) { | ||
throw new Error( | ||
`[MSW] Failed to retrieve the worker: no active worker found. Did you forget to call "initialize"?` | ||
); | ||
} | ||
return api; | ||
} | ||
// src/applyRequestHandlers.ts | ||
function applyRequestHandlers(handlersListOrObject) { | ||
if (handlersListOrObject == null) { | ||
return; | ||
} | ||
if (Array.isArray(handlersListOrObject) && handlersListOrObject.length > 0) { | ||
api.use(...handlersListOrObject); | ||
return; | ||
} | ||
if ("handlers" in handlersListOrObject && handlersListOrObject.handlers) { | ||
const handlers = Object.values(handlersListOrObject.handlers).filter(Boolean).reduce( | ||
(handlers2, handlersList) => handlers2.concat(handlersList), | ||
[] | ||
); | ||
if (handlers.length > 0) { | ||
api.use(...handlers); | ||
} | ||
return; | ||
} | ||
} | ||
// src/decorator.ts | ||
var mswDecorator = (storyFn, context) => { | ||
const { | ||
parameters: { msw } | ||
} = context; | ||
if (api) { | ||
api.resetHandlers(); | ||
if (msw) { | ||
if (Array.isArray(msw) && msw.length > 0) { | ||
api.use(...msw); | ||
} else if ("handlers" in msw && msw.handlers) { | ||
const handlers = Object.values(msw.handlers).filter(Boolean).reduce( | ||
(handlers2, handlersList) => handlers2.concat(handlersList), | ||
[] | ||
); | ||
if (handlers.length > 0) { | ||
api.use(...handlers); | ||
} | ||
} | ||
} | ||
} | ||
applyRequestHandlers(context.parameters.msw); | ||
return storyFn(); | ||
@@ -68,21 +80,3 @@ }; | ||
var mswLoader = async (context) => { | ||
const { | ||
parameters: { msw } | ||
} = context; | ||
if (api) { | ||
api.resetHandlers(); | ||
if (msw) { | ||
if (Array.isArray(msw) && msw.length > 0) { | ||
api.use(...msw); | ||
} else if ("handlers" in msw && msw.handlers) { | ||
const handlers = Object.values(msw.handlers).filter(Boolean).reduce( | ||
(handlers2, handlersList) => handlers2.concat(handlersList), | ||
[] | ||
); | ||
if (handlers.length > 0) { | ||
api.use(...handlers); | ||
} | ||
} | ||
} | ||
} | ||
applyRequestHandlers(context.parameters.msw); | ||
if (typeof window !== "undefined" && "navigator" in window && navigator.serviceWorker.controller) { | ||
@@ -95,2 +89,3 @@ await navigator.serviceWorker.ready; | ||
0 && (module.exports = { | ||
getWorker, | ||
initialize, | ||
@@ -97,0 +92,0 @@ mswDecorator, |
@@ -20,5 +20,6 @@ "use strict"; | ||
// src/index.new.ts | ||
var index_new_exports = {}; | ||
__export(index_new_exports, { | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
getWorker: () => getWorker, | ||
initialize: () => initialize, | ||
@@ -28,3 +29,3 @@ mswDecorator: () => mswDecorator, | ||
}); | ||
module.exports = __toCommonJS(index_new_exports); | ||
module.exports = __toCommonJS(src_exports); | ||
@@ -40,24 +41,35 @@ // src/initialize.react-native.ts | ||
} | ||
function getWorker() { | ||
if (api === void 0) { | ||
throw new Error( | ||
`[MSW] Failed to retrieve the worker: no active worker found. Did you forget to call "initialize"?` | ||
); | ||
} | ||
return api; | ||
} | ||
// src/applyRequestHandlers.ts | ||
function applyRequestHandlers(handlersListOrObject) { | ||
if (handlersListOrObject == null) { | ||
return; | ||
} | ||
if (Array.isArray(handlersListOrObject) && handlersListOrObject.length > 0) { | ||
api.use(...handlersListOrObject); | ||
return; | ||
} | ||
if ("handlers" in handlersListOrObject && handlersListOrObject.handlers) { | ||
const handlers = Object.values(handlersListOrObject.handlers).filter(Boolean).reduce( | ||
(handlers2, handlersList) => handlers2.concat(handlersList), | ||
[] | ||
); | ||
if (handlers.length > 0) { | ||
api.use(...handlers); | ||
} | ||
return; | ||
} | ||
} | ||
// src/decorator.ts | ||
var mswDecorator = (storyFn, context) => { | ||
const { | ||
parameters: { msw } | ||
} = context; | ||
if (api) { | ||
api.resetHandlers(); | ||
if (msw) { | ||
if (Array.isArray(msw) && msw.length > 0) { | ||
api.use(...msw); | ||
} else if ("handlers" in msw && msw.handlers) { | ||
const handlers = Object.values(msw.handlers).filter(Boolean).reduce( | ||
(handlers2, handlersList) => handlers2.concat(handlersList), | ||
[] | ||
); | ||
if (handlers.length > 0) { | ||
api.use(...handlers); | ||
} | ||
} | ||
} | ||
} | ||
applyRequestHandlers(context.parameters.msw); | ||
return storyFn(); | ||
@@ -68,21 +80,3 @@ }; | ||
var mswLoader = async (context) => { | ||
const { | ||
parameters: { msw } | ||
} = context; | ||
if (api) { | ||
api.resetHandlers(); | ||
if (msw) { | ||
if (Array.isArray(msw) && msw.length > 0) { | ||
api.use(...msw); | ||
} else if ("handlers" in msw && msw.handlers) { | ||
const handlers = Object.values(msw.handlers).filter(Boolean).reduce( | ||
(handlers2, handlersList) => handlers2.concat(handlersList), | ||
[] | ||
); | ||
if (handlers.length > 0) { | ||
api.use(...handlers); | ||
} | ||
} | ||
} | ||
} | ||
applyRequestHandlers(context.parameters.msw); | ||
if (typeof window !== "undefined" && "navigator" in window && navigator.serviceWorker.controller) { | ||
@@ -95,2 +89,3 @@ await navigator.serviceWorker.ready; | ||
0 && (module.exports = { | ||
getWorker, | ||
initialize, | ||
@@ -97,0 +92,0 @@ mswDecorator, |
{ | ||
"name": "msw-storybook-addon", | ||
"description": "Mock API requests in Storybook with Mock Service Worker.", | ||
"version": "1.10.1--canary.134.6ef71b8.0", | ||
"version": "1.10.1--canary.134.966f069.0", | ||
"main": "./dist/index.browser.js", | ||
"types": "./dist/index.browser.d.ts", | ||
"exports": { | ||
"browser": "./dist/index.browser.js", | ||
"react-native": "./dist/index.react-native.js", | ||
"node": "./dist/index.node.js" | ||
"browser": { | ||
"types": "./dist/index.browser.d.ts", | ||
"default": "./dist/index.browser.js" | ||
}, | ||
"react-native": { | ||
"types": "./dist/index.react-native.d.ts", | ||
"default": "./dist/index.react-native.js" | ||
}, | ||
"node": { | ||
"types": "./dist/index.node.d.ts", | ||
"default": "./dist/index.node.js" | ||
} | ||
}, | ||
@@ -11,0 +21,0 @@ "scripts": { |
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12144
7
300
0