Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

msw-storybook-addon

Package Overview
Dependencies
Maintainers
2
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

msw-storybook-addon - npm Package Compare versions

Comparing version 1.10.1--canary.134.6ef71b8.0 to 1.10.1--canary.134.966f069.0

dist/index.browser.d.ts

79

dist/index.browser.js

@@ -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": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc