creevey 0.9.0-non-webpack.0 → 0.9.0-non-webpack.1
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.
- package/lib/cjs/client/addon/Manager.js +121 -275
- package/lib/cjs/client/addon/components/Addon.js +17 -38
- package/lib/cjs/client/addon/components/Icons.js +10 -6
- package/lib/cjs/client/addon/components/Panel.js +17 -13
- package/lib/cjs/client/addon/components/TestSelect.js +11 -9
- package/lib/cjs/client/addon/components/Tools.js +21 -40
- package/lib/cjs/client/addon/decorator.js +1 -1
- package/lib/cjs/client/addon/index.js +2 -2
- package/lib/cjs/client/addon/preset.js +11 -30
- package/lib/cjs/client/addon/register.js +45 -73
- package/lib/cjs/client/addon/utils.js +1 -1
- package/lib/cjs/client/addon/withCreevey.js +153 -360
- package/lib/cjs/client/shared/components/ImagesView/BlendView.js +23 -21
- package/lib/cjs/client/shared/components/ImagesView/ImagesView.js +21 -17
- package/lib/cjs/client/shared/components/ImagesView/SideBySideView.js +42 -64
- package/lib/cjs/client/shared/components/ImagesView/SlideView.js +35 -48
- package/lib/cjs/client/shared/components/ImagesView/SwapView.js +24 -43
- package/lib/cjs/client/shared/components/ImagesView/index.js +5 -5
- package/lib/cjs/client/shared/components/PageFooter/PageFooter.js +12 -8
- package/lib/cjs/client/shared/components/PageFooter/Paging.js +14 -18
- package/lib/cjs/client/shared/components/PageHeader/ImagePreview.js +22 -18
- package/lib/cjs/client/shared/components/PageHeader/PageHeader.js +42 -67
- package/lib/cjs/client/shared/components/ResultsPage.js +38 -68
- package/lib/cjs/client/shared/creeveyClientApi.js +55 -86
- package/lib/cjs/client/shared/helpers.js +123 -194
- package/lib/cjs/client/shared/viewMode.js +4 -4
- package/lib/cjs/shared/index.js +26 -14
- package/lib/cjs/shared/serializeRegExp.js +5 -4
- package/lib/esm/client/addon/Manager.js +121 -275
- package/lib/esm/client/addon/components/Addon.js +15 -34
- package/lib/esm/client/addon/components/Icons.js +10 -6
- package/lib/esm/client/addon/components/Panel.js +17 -13
- package/lib/esm/client/addon/components/TestSelect.js +11 -9
- package/lib/esm/client/addon/components/Tools.js +19 -36
- package/lib/esm/client/addon/decorator.js +1 -1
- package/lib/esm/client/addon/preset.js +9 -24
- package/lib/esm/client/addon/register.js +42 -70
- package/lib/esm/client/addon/utils.js +1 -1
- package/lib/esm/client/addon/withCreevey.js +148 -357
- package/lib/esm/client/shared/components/ImagesView/BlendView.js +21 -17
- package/lib/esm/client/shared/components/ImagesView/ImagesView.js +21 -17
- package/lib/esm/client/shared/components/ImagesView/SideBySideView.js +40 -60
- package/lib/esm/client/shared/components/ImagesView/SlideView.js +33 -44
- package/lib/esm/client/shared/components/ImagesView/SwapView.js +22 -39
- package/lib/esm/client/shared/components/PageFooter/PageFooter.js +12 -8
- package/lib/esm/client/shared/components/PageFooter/Paging.js +14 -18
- package/lib/esm/client/shared/components/PageHeader/ImagePreview.js +22 -18
- package/lib/esm/client/shared/components/PageHeader/PageHeader.js +37 -60
- package/lib/esm/client/shared/components/ResultsPage.js +36 -64
- package/lib/esm/client/shared/creeveyClientApi.js +57 -88
- package/lib/esm/client/shared/helpers.js +123 -194
- package/lib/esm/client/shared/viewMode.js +4 -4
- package/lib/esm/shared/index.js +26 -14
- package/lib/esm/shared/serializeRegExp.js +5 -4
- package/package.json +1 -1
- package/preset.js +1 -1
@@ -4,31 +4,35 @@ import { ResultsPage } from '../../shared/components/ResultsPage';
|
|
4
4
|
import { styled } from '@storybook/theming';
|
5
5
|
import { getTestPath } from '../../shared/helpers';
|
6
6
|
import TestSelect from './TestSelect';
|
7
|
-
|
8
|
-
|
7
|
+
const Wrapper = styled.div(_ref => {
|
8
|
+
let {
|
9
|
+
isRunning
|
10
|
+
} = _ref;
|
9
11
|
return {
|
10
12
|
opacity: isRunning ? 0.5 : 1,
|
11
13
|
height: '100%'
|
12
14
|
};
|
13
15
|
});
|
14
|
-
|
15
|
-
|
16
|
+
const TestSelectContainer = styled.div(_ref2 => {
|
17
|
+
let {
|
18
|
+
theme
|
19
|
+
} = _ref2;
|
16
20
|
return {
|
17
21
|
padding: '8px',
|
18
22
|
border: "1px solid ".concat(theme.appBorderColor)
|
19
23
|
};
|
20
24
|
});
|
21
|
-
export
|
25
|
+
export const Panel = _ref3 => {
|
22
26
|
var _result$results, _result$results$lengt, _result$results2;
|
23
27
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
let {
|
29
|
+
tests,
|
30
|
+
selectedTestId,
|
31
|
+
onChangeTest,
|
32
|
+
onImageApprove
|
33
|
+
} = _ref3;
|
34
|
+
const result = tests.find(x => x.id === selectedTestId);
|
35
|
+
const isRunning = (result === null || result === void 0 ? void 0 : result.status) === 'running';
|
32
36
|
return /*#__PURE__*/React.createElement("div", null, tests.length > 1 && /*#__PURE__*/React.createElement(TestSelectContainer, null, /*#__PURE__*/React.createElement(TestSelect, {
|
33
37
|
tests: tests,
|
34
38
|
selectedTestId: selectedTestId,
|
@@ -2,8 +2,10 @@ import { Button, Icons, TooltipLinkList, WithTooltip } from '@storybook/componen
|
|
2
2
|
import { styled } from '@storybook/theming';
|
3
3
|
import React from 'react';
|
4
4
|
import { getEmojiByTestStatus } from '../utils';
|
5
|
-
|
6
|
-
|
5
|
+
const LinkIconContainer = styled.span(_ref => {
|
6
|
+
let {
|
7
|
+
theme
|
8
|
+
} = _ref;
|
7
9
|
return {
|
8
10
|
display: 'inline-block',
|
9
11
|
width: '20px',
|
@@ -14,24 +16,24 @@ var LinkIconContainer = styled.span(function (_ref) {
|
|
14
16
|
export default function TestSelect(props) {
|
15
17
|
var _props$tests$find$tes, _props$tests$find;
|
16
18
|
|
17
|
-
|
18
|
-
return x.id === props.selectedTestId;
|
19
|
-
})) === null || _props$tests$find === void 0 ? void 0 : _props$tests$find.testName) !== null && _props$tests$find$tes !== void 0 ? _props$tests$find$tes : '';
|
19
|
+
const testName = (_props$tests$find$tes = (_props$tests$find = props.tests.find(x => x.id === props.selectedTestId)) === null || _props$tests$find === void 0 ? void 0 : _props$tests$find.testName) !== null && _props$tests$find$tes !== void 0 ? _props$tests$find$tes : '';
|
20
20
|
return /*#__PURE__*/React.createElement(WithTooltip, {
|
21
21
|
trigger: "click",
|
22
22
|
placement: "bottom",
|
23
23
|
closeOnClick: true,
|
24
|
-
tooltip:
|
25
|
-
|
24
|
+
tooltip: _ref2 => {
|
25
|
+
let {
|
26
|
+
onHide
|
27
|
+
} = _ref2;
|
26
28
|
return /*#__PURE__*/React.createElement(TooltipLinkList, {
|
27
|
-
links: props.tests.map(
|
29
|
+
links: props.tests.map(x => {
|
28
30
|
var _x$testName;
|
29
31
|
|
30
32
|
return {
|
31
33
|
id: x.id,
|
32
34
|
title: (_x$testName = x.testName) !== null && _x$testName !== void 0 ? _x$testName : '',
|
33
35
|
active: props.selectedTestId === x.id,
|
34
|
-
onClick:
|
36
|
+
onClick: () => {
|
35
37
|
props.onChangeTest(x.id);
|
36
38
|
onHide();
|
37
39
|
},
|
@@ -1,15 +1,3 @@
|
|
1
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
2
|
-
|
3
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
4
|
-
|
5
|
-
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); }
|
6
|
-
|
7
|
-
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; }
|
8
|
-
|
9
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
10
|
-
|
11
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
12
|
-
|
13
1
|
import React, { Fragment, useState, useEffect } from 'react';
|
14
2
|
import { IconButton, Icons, Separator } from '@storybook/components';
|
15
3
|
import { ForwardIcon, NextIcon } from './Icons';
|
@@ -17,7 +5,7 @@ import { stringify } from 'qs';
|
|
17
5
|
import { styled } from '@storybook/theming';
|
18
6
|
import { isDefined } from '../../../types';
|
19
7
|
import { getTestPath, useForceUpdate } from '../../shared/helpers';
|
20
|
-
|
8
|
+
const Button = styled(IconButton)({
|
21
9
|
'&:disabled': {
|
22
10
|
opacity: 0.5,
|
23
11
|
cursor: 'default'
|
@@ -26,30 +14,25 @@ var Button = styled(IconButton)({
|
|
26
14
|
color: 'inherit'
|
27
15
|
}
|
28
16
|
});
|
29
|
-
export
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
isRunning = _useState4[0],
|
40
|
-
setRunning = _useState4[1];
|
41
|
-
|
42
|
-
var forceUpdate = useForceUpdate();
|
43
|
-
var test = manager.getCurrentTest();
|
44
|
-
useEffect(function () {
|
45
|
-
var unsubscribe = manager.onChangeTest(function () {
|
17
|
+
export const Tools = _ref => {
|
18
|
+
let {
|
19
|
+
manager
|
20
|
+
} = _ref;
|
21
|
+
const [buttonClicked, setButtonClicked] = useState();
|
22
|
+
const [isRunning, setRunning] = useState(manager.status.isRunning);
|
23
|
+
const forceUpdate = useForceUpdate();
|
24
|
+
const test = manager.getCurrentTest();
|
25
|
+
useEffect(() => {
|
26
|
+
const unsubscribe = manager.onChangeTest(() => {
|
46
27
|
forceUpdate();
|
47
28
|
});
|
48
29
|
return unsubscribe;
|
49
30
|
}, [manager, forceUpdate]);
|
50
|
-
useEffect(
|
51
|
-
|
52
|
-
|
31
|
+
useEffect(() => {
|
32
|
+
const unsubscribe = manager.onUpdateStatus(_ref2 => {
|
33
|
+
let {
|
34
|
+
isRunning
|
35
|
+
} = _ref2;
|
53
36
|
if (isDefined(isRunning)) setRunning(isRunning);
|
54
37
|
});
|
55
38
|
return unsubscribe;
|
@@ -57,14 +40,14 @@ export var Tools = function Tools(_ref) {
|
|
57
40
|
if (!test) return null;
|
58
41
|
|
59
42
|
function renderButton(type, title, onClick, icon) {
|
60
|
-
|
43
|
+
const handleClick = () => {
|
61
44
|
setButtonClicked(type);
|
62
45
|
onClick();
|
63
46
|
};
|
64
47
|
|
65
|
-
|
48
|
+
const disabled = isRunning && buttonClicked != null && buttonClicked !== type;
|
66
49
|
return /*#__PURE__*/React.createElement(Button, {
|
67
|
-
onClick:
|
50
|
+
onClick: () => {
|
68
51
|
isRunning ? manager.onStop() : handleClick();
|
69
52
|
},
|
70
53
|
title: disabled ? '' : title,
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { withCreevey } from './withCreevey';
|
2
|
-
export
|
2
|
+
export const decorators = [withCreevey()];
|
@@ -1,33 +1,21 @@
|
|
1
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
2
|
-
|
3
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
4
|
-
|
5
|
-
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); }
|
6
|
-
|
7
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
8
|
-
|
9
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
10
|
-
|
11
|
-
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; }
|
12
|
-
|
13
1
|
import path from 'path';
|
14
2
|
import { exec } from 'shelljs';
|
15
3
|
import { DefinePlugin as FallbackDefinePlugin } from 'webpack';
|
16
4
|
import { isStorybookVersionLessThan, resolveFromStorybookCore, resolveFromStorybookCoreServer } from '../../server/storybook/helpers';
|
17
5
|
export function config() {
|
18
|
-
|
19
|
-
return [
|
6
|
+
let entry = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
7
|
+
return [...entry, require.resolve('./decorator')];
|
20
8
|
}
|
21
9
|
export function managerEntries() {
|
22
|
-
|
23
|
-
return [
|
10
|
+
let entry = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
11
|
+
return [...entry, require.resolve('./register')];
|
24
12
|
}
|
25
13
|
export function _managerWebpack(config, options) {
|
26
14
|
var _options$presets$appl, _options$presets;
|
27
15
|
|
28
16
|
// TODO How to execute with non-webpack bundlers
|
29
17
|
if (options.configType == 'PRODUCTION' && !isStorybookVersionLessThan(6, 2) && options.skipExtract != true) {
|
30
|
-
|
18
|
+
const args = [];
|
31
19
|
if (options.creeveyPreExtract) args.push("--require \"".concat(options.creeveyPreExtract, "\""));
|
32
20
|
args.push(path.join(__dirname, '../../cli'));
|
33
21
|
args.push("--extract \"".concat(options.outputDir, "\""));
|
@@ -37,15 +25,12 @@ export function _managerWebpack(config, options) {
|
|
37
25
|
});
|
38
26
|
}
|
39
27
|
|
40
|
-
return ((_options$presets$appl = (_options$presets = options.presets) === null || _options$presets === void 0 ? void 0 : _options$presets.apply('webpackInstance')) !== null && _options$presets$appl !== void 0 ? _options$presets$appl : Promise.resolve(undefined)).then(
|
41
|
-
return webpack !== null && webpack !== void 0 ? webpack : import(isStorybookVersionLessThan(6, 2) ? resolveFromStorybookCore('webpack') : resolveFromStorybookCoreServer('webpack'));
|
42
|
-
}).then(function (webpack) {
|
28
|
+
return ((_options$presets$appl = (_options$presets = options.presets) === null || _options$presets === void 0 ? void 0 : _options$presets.apply('webpackInstance')) !== null && _options$presets$appl !== void 0 ? _options$presets$appl : Promise.resolve(undefined)).then(webpack => webpack !== null && webpack !== void 0 ? webpack : import(isStorybookVersionLessThan(6, 2) ? resolveFromStorybookCore('webpack') : resolveFromStorybookCoreServer('webpack'))).then(webpack => {
|
43
29
|
var _config$plugins, _options$creeveyPort;
|
44
30
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
31
|
+
const {
|
32
|
+
DefinePlugin = FallbackDefinePlugin
|
33
|
+
} = webpack !== null && webpack !== void 0 ? webpack : {};
|
49
34
|
(_config$plugins = config.plugins) === null || _config$plugins === void 0 ? void 0 : _config$plugins.push(new DefinePlugin({
|
50
35
|
__CREEVEY_SERVER_HOST__: options.creeveyHost,
|
51
36
|
__CREEVEY_SERVER_PORT__: (_options$creeveyPort = options.creeveyPort) !== null && _options$creeveyPort !== void 0 ? _options$creeveyPort : 3000,
|
@@ -1,79 +1,51 @@
|
|
1
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
2
|
-
|
3
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
4
|
-
|
5
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
6
|
-
|
7
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
8
|
-
|
9
1
|
import { addons, types } from '@storybook/addons';
|
10
2
|
import React from 'react';
|
11
3
|
import { Addon } from './components/Addon';
|
12
4
|
import { Tools } from './components/Tools';
|
13
5
|
import { CreeveyManager } from './Manager';
|
14
|
-
export
|
15
|
-
addons.register(ADDON_ID,
|
6
|
+
export const ADDON_ID = 'creevey';
|
7
|
+
addons.register(ADDON_ID, api => {
|
16
8
|
void registerCreeveyPanels(api);
|
17
9
|
});
|
18
|
-
export function registerCreeveyPanels(
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
// NOTE key = PANEL_ID needs to correct render button in addons panel
|
57
|
-
// eslint-disable-next-line react/display-name
|
58
|
-
render: function render(_ref2) {
|
59
|
-
var active = _ref2.active,
|
60
|
-
key = _ref2.key;
|
61
|
-
return /*#__PURE__*/React.createElement(Addon, {
|
62
|
-
active: active,
|
63
|
-
key: key,
|
64
|
-
manager: manager,
|
65
|
-
browser: browser
|
66
|
-
});
|
67
|
-
}
|
68
|
-
});
|
69
|
-
});
|
70
|
-
|
71
|
-
case 6:
|
72
|
-
case "end":
|
73
|
-
return _context.stop();
|
74
|
-
}
|
10
|
+
export async function registerCreeveyPanels(storybookApi) {
|
11
|
+
const manager = new CreeveyManager(storybookApi);
|
12
|
+
addons.addPanel("".concat(ADDON_ID, "/panel/run"), {
|
13
|
+
title: "Creevey/Run",
|
14
|
+
match: _ref => {
|
15
|
+
let {
|
16
|
+
viewMode
|
17
|
+
} = _ref;
|
18
|
+
return !!(viewMode && /^story$/.exec(viewMode));
|
19
|
+
},
|
20
|
+
type: types.TOOL,
|
21
|
+
// eslint-disable-next-line react/display-name
|
22
|
+
render: () => /*#__PURE__*/React.createElement(Tools, {
|
23
|
+
manager
|
24
|
+
})
|
25
|
+
});
|
26
|
+
await manager.initAll();
|
27
|
+
const browsers = manager.getBrowsers();
|
28
|
+
browsers.forEach(browser => {
|
29
|
+
const panelId = "".concat(ADDON_ID, "/panel/").concat(browser);
|
30
|
+
const title = manager.getTabTitle(browser);
|
31
|
+
addons.addPanel(panelId, {
|
32
|
+
title,
|
33
|
+
type: types.PANEL,
|
34
|
+
paramKey: browser,
|
35
|
+
// NOTE key = PANEL_ID needs to correct render button in addons panel
|
36
|
+
// eslint-disable-next-line react/display-name
|
37
|
+
render: _ref2 => {
|
38
|
+
let {
|
39
|
+
active,
|
40
|
+
key
|
41
|
+
} = _ref2;
|
42
|
+
return /*#__PURE__*/React.createElement(Addon, {
|
43
|
+
active,
|
44
|
+
key,
|
45
|
+
manager,
|
46
|
+
browser
|
47
|
+
});
|
75
48
|
}
|
76
|
-
}
|
77
|
-
})
|
78
|
-
return _registerCreeveyPanels.apply(this, arguments);
|
49
|
+
});
|
50
|
+
});
|
79
51
|
}
|