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

happo-plugin-storybook

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

happo-plugin-storybook - npm Package Compare versions

Comparing version 2.11.2 to 3.0.0

.ackrc

2

package.json
{
"name": "happo-plugin-storybook",
"version": "2.11.2",
"version": "3.0.0",
"description": "A happo.io plugin for projects using Storybook",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,3 +0,1 @@

import storybookClient from '@storybook/core/client';
const time = window.happoTime || {

@@ -43,80 +41,33 @@ originalDateNow: Date.now,

const storyStore = window.__STORYBOOK_CLIENT_API__._storyStore;
if (storyStore.extract) {
if (storyStore.cacheAllCSFFiles) {
await storyStore.cacheAllCSFFiles();
}
return Object.values(storyStore.extract())
.map(({ id, kind, story, parameters }) => {
if (parameters.happo === false) {
return;
}
let delay = defaultDelay;
let waitForContent;
let waitFor;
let beforeScreenshot;
let afterScreenshot;
let targets;
if (typeof parameters.happo === 'object' && parameters.happo !== null) {
delay = parameters.happo.delay || defaultDelay;
waitForContent = parameters.happo.waitForContent;
waitFor = parameters.happo.waitFor;
beforeScreenshot = parameters.happo.beforeScreenshot;
afterScreenshot = parameters.happo.afterScreenshot;
targets = parameters.happo.targets;
}
return {
component: kind,
variant: story,
storyId: id,
delay,
waitForContent,
waitFor,
beforeScreenshot,
afterScreenshot,
targets,
};
})
.filter(Boolean);
if (!storyStore.extract) {
throw new Error('Missing Storybook Client API');
}
const result = [];
for (let story of window.__STORYBOOK_CLIENT_API__.getStorybook()) {
const component = story.kind;
for (let example of story.stories) {
const { name: variant } = example;
if (storyStore.cacheAllCSFFiles) {
await storyStore.cacheAllCSFFiles();
}
return Object.values(storyStore.extract())
.map(({ id, kind, story, parameters }) => {
if (parameters.happo === false) {
return;
}
let delay = defaultDelay;
let waitForContent;
let waitFor;
let targets;
let beforeScreenshot;
let afterScreenshot;
if (storyStore.getStoryAndParameters) {
const { parameters } = storyStore.getStoryAndParameters(
story.kind,
variant,
);
if (parameters.happo === false) {
continue;
}
if (typeof parameters.happo === 'object' && parameters.happo !== null) {
delay = parameters.happo.delay || defaultDelay;
waitForContent = parameters.happo.waitForContent;
waitFor = parameters.happo.waitFor;
beforeScreenshot = parameters.happo.beforeScreenshot;
afterScreenshot = parameters.happo.afterScreenshot;
targets = parameters.happo.targets;
}
let targets;
if (typeof parameters.happo === 'object' && parameters.happo !== null) {
delay = parameters.happo.delay || defaultDelay;
waitForContent = parameters.happo.waitForContent;
waitFor = parameters.happo.waitFor;
beforeScreenshot = parameters.happo.beforeScreenshot;
afterScreenshot = parameters.happo.afterScreenshot;
targets = parameters.happo.targets;
}
const storyId = (storybookClient.toId || (() => undefined))(
story.kind,
variant,
);
result.push({
component,
variant,
return {
component: kind,
variant: story,
storyId: id,
delay,
storyId,
waitForContent,

@@ -127,6 +78,5 @@ waitFor,

targets,
});
}
}
return result;
};
})
.filter(Boolean);
}

@@ -136,5 +86,3 @@

if (initConfig.chunk) {
const examplesPerChunk = Math.ceil(
all.length / initConfig.chunk.total,
);
const examplesPerChunk = Math.ceil(all.length / initConfig.chunk.total);
const startIndex = initConfig.chunk.index * examplesPerChunk;

@@ -160,3 +108,3 @@ const endIndex = startIndex + examplesPerChunk;

window.happo.init = (config) => {
window.happo.init = config => {
initConfig = config;

@@ -163,0 +111,0 @@ };

@@ -16,10 +16,2 @@ "use strict";

var _client = _interopRequireDefault(require("@storybook/core/client"));
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
var time = window.happoTime || {

@@ -120,4 +112,3 @@ originalDateNow: Date.now,

_getExamples = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
var storyStore, result, _iterator, _step, story, component, _iterator2, _step2, example, variant, delay, waitForContent, waitFor, targets, beforeScreenshot, afterScreenshot, _storyStore$getStoryA, parameters, storyId;
var storyStore;
return _regenerator.default.wrap(function _callee4$(_context4) {

@@ -129,16 +120,19 @@ while (1) {

if (!storyStore.extract) {
_context4.next = 6;
if (storyStore.extract) {
_context4.next = 3;
break;
}
throw new Error('Missing Storybook Client API');
case 3:
if (!storyStore.cacheAllCSFFiles) {
_context4.next = 5;
_context4.next = 6;
break;
}
_context4.next = 5;
_context4.next = 6;
return storyStore.cacheAllCSFFiles();
case 5:
case 6:
return _context4.abrupt("return", Object.values(storyStore.extract()).map(function (_ref3) {

@@ -183,124 +177,3 @@ var id = _ref3.id,

case 6:
result = [];
_iterator = _createForOfIteratorHelper(window.__STORYBOOK_CLIENT_API__.getStorybook());
_context4.prev = 8;
_iterator.s();
case 10:
if ((_step = _iterator.n()).done) {
_context4.next = 44;
break;
}
story = _step.value;
component = story.kind;
_iterator2 = _createForOfIteratorHelper(story.stories);
_context4.prev = 14;
_iterator2.s();
case 16:
if ((_step2 = _iterator2.n()).done) {
_context4.next = 34;
break;
}
example = _step2.value;
variant = example.name;
delay = defaultDelay;
waitForContent = void 0;
waitFor = void 0;
targets = void 0;
beforeScreenshot = void 0;
afterScreenshot = void 0;
if (!storyStore.getStoryAndParameters) {
_context4.next = 30;
break;
}
_storyStore$getStoryA = storyStore.getStoryAndParameters(story.kind, variant), parameters = _storyStore$getStoryA.parameters;
if (!(parameters.happo === false)) {
_context4.next = 29;
break;
}
return _context4.abrupt("continue", 32);
case 29:
if ((0, _typeof2.default)(parameters.happo) === 'object' && parameters.happo !== null) {
delay = parameters.happo.delay || defaultDelay;
waitForContent = parameters.happo.waitForContent;
waitFor = parameters.happo.waitFor;
beforeScreenshot = parameters.happo.beforeScreenshot;
afterScreenshot = parameters.happo.afterScreenshot;
targets = parameters.happo.targets;
}
case 30:
storyId = (_client.default.toId || function () {
return undefined;
})(story.kind, variant);
result.push({
component: component,
variant: variant,
delay: delay,
storyId: storyId,
waitForContent: waitForContent,
waitFor: waitFor,
beforeScreenshot: beforeScreenshot,
afterScreenshot: afterScreenshot,
targets: targets
});
case 32:
_context4.next = 16;
break;
case 34:
_context4.next = 39;
break;
case 36:
_context4.prev = 36;
_context4.t0 = _context4["catch"](14);
_iterator2.e(_context4.t0);
case 39:
_context4.prev = 39;
_iterator2.f();
return _context4.finish(39);
case 42:
_context4.next = 10;
break;
case 44:
_context4.next = 49;
break;
case 46:
_context4.prev = 46;
_context4.t1 = _context4["catch"](8);
_iterator.e(_context4.t1);
case 49:
_context4.prev = 49;
_iterator.f();
return _context4.finish(49);
case 52:
return _context4.abrupt("return", result);
case 53:
case 7:
case "end":

@@ -310,3 +183,3 @@ return _context4.stop();

}
}, _callee4, null, [[8, 46, 49, 52], [14, 36, 39, 42]]);
}, _callee4);
}));

@@ -313,0 +186,0 @@ return _getExamples.apply(this, arguments);

Sorry, the diff of this file is not supported yet

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